/* Global Styles & Reset - Geminicode Theme */
:root {
color-scheme: dark;
--bg-main: #0d1117;
--bg-secondary: #161b22;
--bg-hover: #21262d;
--border-color: #30363d;
--border-dark: #8b949e;
--text-main: #c9d1d9;
--text-muted: #8b949e;
--text-light: #484f58;
--primary: #10b981;
--primary-hover: #059669;
--primary-light: rgba(16, 185, 129, 0.1);
--success: #10b981;
--success-light: rgba(16, 185, 129, 0.15);
--warning: #f59e0b;
--warning-light: rgba(245, 158, 11, 0.15);
--danger: #f87171;
--danger-light: rgba(248, 113, 113, 0.15);
--radius-sm: 2px;
--radius-md: 2px;
--radius-lg: 4px;
--shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
--shadow-md: 0 4px 6px -1px rgba(0,0,0,0.5);
--shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.6);
--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
--font-mono: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

::-webkit-scrollbar {
width: 8px;
height: 8px;
}

::-webkit-scrollbar-track {
background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
background: var(--border-color);
border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
background: var(--border-dark);
}

* {
scrollbar-width: thin;
scrollbar-color: var(--border-color) var(--bg-main);
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
background-color: var(--bg-main);
color: var(--text-main);
font-family: var(--font-sans);
line-height: 1.5;
height: 100vh;
overflow: hidden;
}

.app-container {
display: flex;
flex-direction: column;
height: 100vh;
}

/* Header */
.app-header {
height: 56px;
background-color: var(--bg-secondary);
border-bottom: 1px solid var(--border-color);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 16px;
z-index: 10;
gap: 12px;
}

.header-left {
display: flex;
align-items: center;
gap: 16px;
flex-shrink: 0;
white-space: nowrap;
}

.logo {
display: flex;
align-items: center;
gap: 8px;
font-weight: 700;
font-size: 1rem;
font-family: var(--font-mono);
color: var(--text-main);
white-space: nowrap;
}

.logo i {
color: var(--primary);
}

.status-badge {
display: flex;
align-items: center;
gap: 6px;
padding: 3px 8px;
background-color: var(--bg-main);
border: 1px solid var(--border-color);
border-radius: 12px;
font-size: 0.75rem;
color: var(--text-muted);
white-space: nowrap;
}

.status-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background-color: var(--text-light);
}

.status-badge.running .status-dot {
background-color: var(--primary);
box-shadow: 0 0 6px var(--primary);
animation: pulse 1.5s infinite;
}

@keyframes pulse {
0% { opacity: 1; }
50% { opacity: 0.3; }
100% { opacity: 1; }
}

.header-right {
display: flex;
align-items: center;
gap: 12px;
flex-shrink: 0;
white-space: nowrap;
}

.control-group {
display: flex;
align-items: center;
gap: 6px;
font-size: 0.8rem;
color: var(--text-muted);
white-space: nowrap;
}

.styled-select, .styled-input {
padding: 5px 10px;
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
background-color: var(--bg-main);
color: var(--text-main);
font-size: 0.8rem;
outline: none;
transition: border-color 0.2s;
white-space: nowrap;
}

.styled-input {
width: 140px;
font-family: var(--font-mono);
}

.btn {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 12px;
border-radius: var(--radius-sm);
font-size: 0.82rem;
font-weight: 500;
cursor: pointer;
border: 1px solid transparent;
transition: all 0.2s;
white-space: nowrap;
flex-shrink: 0;
}

.btn-primary {
background-color: var(--primary);
color: #ffffff;
}

.btn-primary:hover {
background-color: var(--primary-hover);
}

.btn-secondary {
background-color: var(--bg-main);
border-color: var(--border-color);
color: var(--text-main);
}

.btn-secondary:hover {
background-color: var(--bg-hover);
}

.btn-success {
background-color: var(--success);
color: #ffffff;
}

.btn-danger {
background-color: var(--danger);
color: #ffffff;
}

.icon-btn {
background: transparent;
border: none;
color: var(--text-muted);
cursor: pointer;
padding: 4px;
border-radius: var(--radius-sm);
display: flex;
align-items: center;
justify-content: center;
}

.icon-btn:hover {
color: var(--text-main);
background-color: var(--bg-hover);
}

/* Main Layout */
.main-layout {
display: flex;
flex: 1;
height: calc(100vh - 56px);
overflow: hidden;
}

/* Resizer */
.resizer {
width: 5px;
background-color: var(--border-color);
cursor: col-resize;
transition: background-color 0.2s;
flex-shrink: 0;
z-index: 5;
}

.resizer:hover, .resizer.resizing {
background-color: var(--primary);
}

body.is-resizing {
cursor: col-resize !important;
user-select: none !important;
}

body.is-resizing iframe {
pointer-events: none !important;
}

/* Browser Panel Right */
.browser-panel {
width: 450px;
min-width: 200px;
max-width: 80vw;
background-color: var(--bg-secondary);
border-left: 1px solid var(--border-color);
display: flex;
flex-direction: column;
overflow: hidden;
flex-shrink: 0;
}

.browser-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 8px 12px;
background-color: var(--bg-main);
border-bottom: 1px solid var(--border-color);
}

.browser-controls-left {
display: flex;
align-items: center;
gap: 6px;
font-size: 0.8rem;
font-weight: 600;
color: var(--text-muted);
white-space: nowrap;
}

.browser-nav-buttons {
display: flex;
align-items: center;
gap: 6px;
}

.btn-xs {
padding: 4px 8px;
font-size: 0.75rem;
gap: 4px;
border-radius: var(--radius-sm);
}

.browser-body {
flex: 1;
position: relative;
background-color: #ffffff;
overflow: hidden;
}

.browser-iframe {
width: 100%;
height: 100%;
border: none;
background-color: #ffffff;
}

/* ===== AI疑似マウス操作オーバーレイ ===== */
.ai-interact-overlay {
position: absolute;
inset: 0;
pointer-events: none;
z-index: 50;
overflow: visible;
}

.ai-fake-cursor {
position: absolute;
left: 0;
top: 0;
transform: translate(-4px, -4px);
display: flex;
align-items: center;
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
transition: left 0.1s linear, top 0.1s linear;
will-change: left, top;
z-index: 51;
}

.ai-fake-cursor.hidden {
display: none;
}

.ai-fake-cursor svg {
transition: transform 0.12s ease;
}

.ai-fake-cursor.is-pressing svg {
transform: scale(0.78);
}

.ai-cursor-label {
margin-left: 2px;
margin-top: 14px;
background: #6d5bff;
color: #fff;
font-size: 10px;
font-weight: 700;
line-height: 1;
padding: 2px 5px;
border-radius: 4px;
white-space: nowrap;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.ai-fake-cursor.is-pressing::after {
content: "";
position: absolute;
left: -2px;
top: -2px;
width: 16px;
height: 16px;
border-radius: 50%;
background: rgba(109, 91, 255, 0.45);
animation: ai-press-ripple 0.18s ease-out;
pointer-events: none;
}

@keyframes ai-press-ripple {
from { transform: scale(0.4); opacity: 0.9; }
to { transform: scale(2.2); opacity: 0; }
}

.ai-typing-indicator {
position: absolute;
left: 0;
top: 0;
transform: translate(-50%, -100%);
display: flex;
align-items: center;
gap: 4px;
background: #161b22;
color: #fff;
font-size: 11px;
font-weight: 600;
padding: 4px 8px;
border-radius: 6px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
z-index: 52;
white-space: nowrap;
}

.ai-typing-indicator.hidden {
display: none;
}

.ai-typing-indicator i {
width: 13px;
height: 13px;
}

.ai-typing-dots {
display: inline-block;
animation: ai-typing-blink 1s steps(4, end) infinite;
overflow: hidden;
width: 14px;
vertical-align: bottom;
}

@keyframes ai-typing-blink {
0% { width: 0; }
100% { width: 14px; }
}

.browser-search-results {
width: 100%;
height: 100%;
overflow-y: auto;
background-color: #ffffff;
color: #202124;
padding: 16px;
font-family: arial, sans-serif;
}

.browser-placeholder {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
color: var(--text-muted);
background-color: var(--bg-main);
text-align: center;
padding: 20px;
}

.browser-placeholder i {
width: 48px;
height: 48px;
margin-bottom: 12px;
opacity: 0.5;
}

/* Google Search Style Mock */
.google-search-header {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 16px;
padding-bottom: 12px;
border-bottom: 1px solid #dfe1e5;
}

.google-logo {
font-family: 'Product Sans', Arial, sans-serif;
font-size: 1.4rem;
font-weight: bold;
color: #4285f4;
}

.google-search-box-mock {
flex: 1;
padding: 6px 12px;
border: 1px solid #dfe1e5;
border-radius: 24px;
font-size: 0.85rem;
color: #202124;
background: #fff;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.google-search-results-list {
display: flex;
flex-direction: column;
gap: 16px;
}

.google-search-item {
font-size: 0.85rem;
line-height: 1.4;
}

.google-search-cite {
font-size: 0.75rem;
color: #202124;
margin-bottom: 2px;
word-break: break-all;
}

.google-search-title {
font-size: 1rem;
color: #1a0dab;
text-decoration: none;
font-weight: 400;
display: block;
margin-bottom: 3px;
}

.google-search-title:hover {
text-decoration: underline;
}

.google-search-snippet {
color: #4d5156;
font-size: 0.82rem;
word-break: break-word;
}

/* Sidebar */
.sidebar {
width: 260px;
background-color: var(--bg-secondary);
border-right: 1px solid var(--border-color);
display: flex;
flex-direction: column;
overflow: hidden;
flex-shrink: 0;
}

.sidebar-section {
flex: 1;
display: flex;
flex-direction: column;
border-bottom: 1px solid var(--border-color);
overflow: hidden;
}

.sidebar-section.memory-section {
flex: 1;
}

.sidebar-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 12px;
border-bottom: 1px solid var(--border-color);
background-color: var(--bg-main);
}

.sidebar-header h3 {
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.5px;
color: var(--text-muted);
display: flex;
align-items: center;
gap: 6px;
font-family: var(--font-mono);
}

.file-tree, .memory-list {
padding: 8px;
overflow-y: auto;
flex: 1;
font-size: 0.8rem;
font-family: var(--font-mono);
}

.empty-msg {
color: var(--text-light);
font-style: italic;
font-size: 0.75rem;
text-align: center;
margin-top: 16px;
}

.file-item {
display: flex;
align-items: center;
gap: 6px;
padding: 4px 6px;
border-radius: 3px;
cursor: pointer;
color: var(--text-main);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.file-item:hover {
background-color: var(--bg-hover);
}

.file-item.directory {
font-weight: 600;
color: #58a6ff;
}

.memory-item {
background: var(--bg-main);
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
padding: 6px 8px;
margin-bottom: 6px;
font-size: 0.75rem;
}

.memory-key {
font-weight: 600;
color: var(--primary);
margin-bottom: 2px;
}

.memory-item .memory-val {
color: var(--text-main);
word-break: break-word;
}

/* Chat Viewport */
.chat-viewport {
flex: 1;
display: flex;
flex-direction: column;
background-color: var(--bg-main);
position: relative;
overflow: hidden;
}

/* Status Card */
.status-card {
margin: 12px 16px 0;
padding: 8px 12px;
background-color: var(--bg-secondary);
border: 1px solid var(--primary);
border-radius: var(--radius-md);
transition: all 0.3s ease;
}

.status-details-toggle {
width: 100%;
}

.status-summary-bar {
display: flex;
align-items: center;
gap: 8px;
cursor: pointer;
list-style: none;
user-select: none;
}

.status-summary-bar::-webkit-details-marker {
display: none;
}

.status-summary-bar .toggle-icon {
margin-left: auto;
width: 16px;
height: 16px;
color: var(--text-muted);
transition: transform 0.2s;
}

.status-details-toggle[open] .toggle-icon {
transform: rotate(180deg);
}

.current-action-label {
font-size: 0.82rem;
font-weight: 600;
font-family: var(--font-mono);
color: #58a6ff;
max-width: 220px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.thought-header {
font-size: 0.78rem;
font-weight: 600;
color: var(--text-muted);
margin-bottom: 4px;
display: flex;
align-items: center;
gap: 4px;
}

.spinner {
width: 14px;
height: 14px;
border: 2px solid var(--border-color);
border-top-color: var(--primary);
border-radius: 50%;
animation: spin 0.8s linear infinite;
}

@keyframes spin {
to { transform: rotate(360deg); }
}

.status-title {
font-weight: 600;
font-size: 0.8rem;
color: var(--primary);
font-family: var(--font-mono);
}

.thought-process-container {
margin-top: 6px;
font-size: 0.78rem;
color: var(--text-muted);
}

.thought-text {
margin-top: 6px;
padding: 8px 10px;
background: var(--bg-main);
border-radius: var(--radius-sm);
border: 1px solid var(--border-color);
white-space: pre-wrap;
font-family: var(--font-mono);
max-height: 150px;
overflow-y: auto;
color: #79c0ff;
}

/* Timeline */
.chat-timeline {
flex: 1;
padding: 16px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 12px;
}

.welcome-card {
max-width: 600px;
margin: 30px auto;
padding: 24px;
border: 1px solid var(--border-color);
border-radius: var(--radius-lg);
background: var(--bg-secondary);
text-align: left;
}

.welcome-card h2 {
font-size: 1.2rem;
margin-bottom: 8px;
color: var(--text-main);
font-family: var(--font-mono);
}

.welcome-card p {
color: var(--text-muted);
font-size: 0.85rem;
margin-bottom: 14px;
}

.welcome-card ul {
list-style: none;
display: flex;
flex-direction: column;
gap: 8px;
font-size: 0.82rem;
}

.welcome-card li {
display: flex;
align-items: flex-start;
gap: 8px;
}

.welcome-card li i {
color: var(--primary);
margin-top: 2px;
}

/* Timeline Items */
.timeline-item {
display: flex;
flex-direction: column;
gap: 4px;
max-width: 88%;
}

.timeline-item.user {
align-self: flex-end;
}

.timeline-item.agent, .timeline-item.tool {
align-self: flex-start;
}

.bubble {
padding: 10px 14px;
border-radius: var(--radius-md);
font-size: 0.85rem;
box-shadow: var(--shadow-sm);
word-break: break-word;
}

/* Markdown Specific Styles inside Bubbles */
.bubble p {
margin-bottom: 0.5em;
}

.bubble p:last-child {
margin-bottom: 0;
}

.bubble h1, .bubble h2, .bubble h3, .bubble h4, .bubble h5, .bubble h6 {
margin-top: 0.6em;
margin-bottom: 0.4em;
font-weight: 600;
line-height: 1.25;
}

.bubble h1 { font-size: 1.3em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3em; }
.bubble h2 { font-size: 1.15em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.2em; }
.bubble h3 { font-size: 1em; }

.bubble ul, .bubble ol {
margin-left: 1.4em;
margin-bottom: 0.5em;
}

.bubble li {
margin-bottom: 0.2em;
}

.bubble a {
color: #58a6ff;
text-decoration: none;
}

.bubble a:hover {
text-decoration: underline;
}

.bubble pre {
background-color: var(--bg-main);
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
padding: 8px 12px;
overflow-x: auto;
margin: 8px 0;
}

.bubble code {
font-family: var(--font-mono);
font-size: 0.85em;
background-color: rgba(110, 118, 129, 0.2);
padding: 0.2em 0.4em;
border-radius: 4px;
}

.bubble pre code {
background-color: transparent;
padding: 0;
}

.bubble blockquote {
border-left: 3px solid var(--border-dark);
padding-left: 10px;
color: var(--text-muted);
margin: 6px 0;
}

.bubble table {
border-collapse: collapse;
width: 100%;
margin: 8px 0;
}

.bubble th, .bubble td {
border: 1px solid var(--border-color);
padding: 6px 8px;
text-align: left;
}

.bubble th {
background-color: var(--bg-secondary);
}

.bubble.user {
background-color: #1f6feb;
color: #ffffff;
border-bottom-right-radius: 2px;
}

.bubble.agent {
background-color: var(--bg-hover);
border: 1px solid var(--border-dark);
color: #ffffff;
border-bottom-left-radius: 2px;
box-shadow: var(--shadow-md);
}

.bubble.agent-log {
background-color: var(--bg-secondary);
border-left: 3px solid var(--primary);
color: var(--text-main);
font-size: 0.82rem;
display: flex;
align-items: flex-start;
gap: 8px;
}

.bubble.agent-log .markdown-body {
flex: 1;
}

.bubble.agent-log i {
margin-top: 3px;
flex-shrink: 0;
}

.bubble.tool-result {
background-color: var(--bg-main);
border: 1px solid var(--border-color);
font-family: var(--font-mono);
font-size: 0.78rem;
color: #a5d6ff;
white-space: pre-wrap;
}

/* Action Log Style */
.action-log-toggle {
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
padding: 6px 10px;
font-size: 0.8rem;
color: var(--text-main);
}

.action-log-summary {
cursor: pointer;
display: flex;
align-items: center;
gap: 6px;
user-select: none;
color: #58a6ff;
font-family: var(--font-mono);
}

.action-log-toggle.completed .action-log-summary {
color: var(--text-muted);
}

.action-log-body {
margin-top: 8px;
padding: 8px;
background: var(--bg-main);
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
font-family: var(--font-mono);
font-size: 0.75rem;
color: #a5d6ff;
white-space: pre-wrap;
max-height: 200px;
overflow-y: auto;
}

/* Collapsed Logs Details */
.collapsed-logs-details {
background: var(--bg-secondary);
border: 1px dashed var(--border-color);
border-radius: var(--radius-md);
padding: 8px 12px;
margin: 8px 0;
}

.collapsed-logs-summary {
cursor: pointer;
font-size: 0.8rem;
font-weight: 600;
color: var(--text-muted);
user-select: none;
}

.collapsed-logs-content {
margin-top: 8px;
display: flex;
flex-direction: column;
gap: 8px;
}

.spin-icon {
animation: spin 1.5s linear infinite;
width: 14px;
height: 14px;
}

.tool-call-badge {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 4px 10px;
background-color: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
font-family: var(--font-mono);
font-size: 0.75rem;
color: #d2a8ff;
}

/* Approval Dock */
.approval-dock {
padding: 12px 16px;
background-color: var(--bg-secondary);
border-top: 1px solid var(--warning);
border-bottom: 1px solid var(--warning);
}

.approval-card {
display: flex;
flex-direction: column;
gap: 10px;
}

.approval-header {
display: flex;
align-items: flex-start;
gap: 10px;
}

.warning-icon {
color: var(--warning);
margin-top: 2px;
}

.approval-header h4 {
font-size: 0.88rem;
color: var(--warning);
}

.approval-header p {
font-size: 0.8rem;
color: var(--text-muted);
}

.approval-details {
background-color: var(--bg-main);
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
padding: 8px 10px;
font-family: var(--font-mono);
font-size: 0.78rem;
color: var(--text-main);
max-height: 120px;
overflow-y: auto;
}

.approval-actions {
display: flex;
justify-content: flex-end;
gap: 8px;
}

/* Input Dock */
.input-dock {
padding: 12px 16px;
background-color: var(--bg-main);
border-top: 1px solid var(--border-color);
}

.input-wrapper {
display: flex;
flex-direction: column;
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
background-color: var(--bg-secondary);
box-shadow: var(--shadow-sm);
transition: border-color 0.2s;
}

.input-wrapper:focus-within {
border-color: var(--primary);
}

textarea#goal-input {
width: 100%;
padding: 10px 12px;
border: none;
outline: none;
resize: none;
font-family: inherit;
font-size: 0.85rem;
background: transparent;
color: var(--text-main);
}

.input-actions {
display: flex;
justify-content: space-between;
align-items: center;
padding: 6px 10px;
border-top: 1px solid var(--border-color);
background-color: var(--bg-main);
border-bottom-left-radius: var(--radius-md);
border-bottom-right-radius: var(--radius-md);
gap: 12px;
}

.input-controls-left {
display: flex;
align-items: center;
gap: 12px;
}

.input-controls-right {
display: flex;
align-items: center;
gap: 8px;
}

.toggle-label {
display: flex;
align-items: center;
gap: 6px;
font-size: 0.8rem;
color: var(--text-muted);
cursor: pointer;
user-select: none;
}

.toggle-label input[type="checkbox"] {
cursor: pointer;
accent-color: var(--primary);
}

.toggle-label span {
display: flex;
align-items: center;
gap: 4px;
}

/* Thinking Log Style */
.thinking-item {
    width: 100%;
    max-width: 100%;
    margin: 2px 0;
}

.thinking-details {
    width: 100%;
    background: transparent;
    border: none;
    border-left: 2px solid var(--border-color);
    border-radius: 0;
    padding: 2px 0 2px 14px;
    margin-bottom: 8px;
    color: var(--text-muted);
    transition: border-color 0.2s ease;
}

.thinking-details[open] {
    border-left-color: var(--primary);
}

.thinking-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    cursor: pointer;
    list-style: none;
    user-select: none;

    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;

    padding: 5px 0;
    transition: color 0.2s ease;
}

.thinking-summary::-webkit-details-marker {
    display: none;
}

.thinking-summary:hover,
.thinking-details[open] .thinking-summary {
    color: var(--text-main);
}

.thinking-summary > svg:first-child {
    width: 14px;
    height: 14px;
    opacity: 0.75;
}

.thinking-summary::after {
    content: "";
    width: 6px;
    height: 6px;
    margin-left: 4px;

    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;

    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.thinking-details[open] .thinking-summary::after {
    transform: rotate(225deg);
}

.thinking-details {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.thinking-body {
    margin-top: 5px;
    padding: 4px 12px 8px 0;

    background: transparent;
    border: none;
    border-radius: 0;

    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.75;
    color: var(--text-muted);

    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    max-height: 320px;
    overflow-y: auto;
    overflow-x: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.thinking-body pre {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.thinking-body pre {
    margin: 0;
    padding: 0;

    background: transparent;
    border: none;

    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    color: inherit;

    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.timeline-item.agent-final {
    width: 100%;
    max-width: 88%;
    align-self: flex-start;
}

.final-streaming {
    position: relative;
}

.final-streaming-text {
    display: inline;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.7;
}

.final-streaming-cursor {
    display: inline-block;

    width: 2px;
    height: 1em;

    margin-left: 2px;

    background: var(--primary);

    vertical-align: -0.15em;

    animation: finalCursorBlink 0.7s step-end infinite;
}

@keyframes finalCursorBlink {
    0%, 49% {
        opacity: 1;
    }

    50%, 100% {
        opacity: 0;
    }
}

/* 実行履歴収納UI */

.collapsed-logs-details {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 4px 0;
    margin: 6px 0;
}

.collapsed-logs-summary {
    display: flex;
    align-items: center;
    gap: 7px;

    width: fit-content;
    cursor: pointer;
    user-select: none;
    list-style: none;

    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;

    transition: color 0.15s ease;
}

.collapsed-logs-summary::-webkit-details-marker {
    display: none;
}

.collapsed-logs-summary:hover {
    color: var(--text-main);
}

.collapsed-logs-summary svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;

    transition: transform 0.15s ease;
}

.collapsed-logs-details[open]
.collapsed-logs-summary svg {
    transform: rotate(90deg);
}

.collapsed-logs-content {
    display: flex;
    flex-direction: column;
    gap: 8px;

    min-height: 0;
    margin-top: 8px;

    overflow: hidden;
}

.hidden {
display: none !important;
}
/* ===================== Chat Sessions Sidebar ===================== */
.chat-sidebar {
width: 260px;
background-color: var(--bg-secondary);
border-right: 1px solid var(--border-color);
display: flex;
flex-direction: column;
overflow: hidden;
flex-shrink: 0;
}

.chat-sidebar-header {
padding: 10px 12px;
border-bottom: 1px solid var(--border-color);
background-color: var(--bg-main);
}

.btn-block {
width: 100%;
justify-content: center;
}

.chat-sidebar-list {
flex: 1;
overflow-y: auto;
padding: 8px;
font-size: 0.8rem;
}

.chat-session-item {
display: flex;
align-items: center;
gap: 6px;
padding: 7px 8px;
border-radius: var(--radius-sm);
cursor: pointer;
color: var(--text-muted);
font-size: 0.82rem;
margin-bottom: 2px;
position: relative;
border: 1px solid transparent;
transition: all 0.15s;
}

.chat-session-item:hover {
background-color: var(--bg-hover);
color: var(--text-main);
}

.chat-session-item.active {
background-color: var(--primary-light);
border-color: var(--primary);
color: var(--text-main);
font-weight: 500;
}

.chat-session-item .session-title {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.chat-session-item .session-title[contenteditable="true"] {
outline: 1px solid var(--primary);
background: var(--bg-main);
border-radius: var(--radius-sm);
padding: 0 2px;
white-space: normal;
color: var(--text-main);
}

.chat-session-item .session-actions {
display: none;
gap: 2px;
flex-shrink: 0;
}

.chat-session-item:hover .session-actions {
display: flex;
}

.chat-session-item .session-actions button {
background: transparent;
border: none;
color: var(--text-muted);
cursor: pointer;
padding: 3px;
border-radius: var(--radius-sm);
display: flex;
align-items: center;
justify-content: center;
}

.chat-session-item .session-actions button:hover {
color: var(--text-main);
background-color: var(--bg-hover);
}

.chat-session-item .session-actions button svg,
.chat-session-item .session-actions button i {
width: 13px;
height: 13px;
}

.chat-session-item.compressed-flag .session-title::after {
content: " (圧縮済み)";
font-size: 10px;
opacity: 0.6;
}

.chat-sidebar-footer {
padding: 8px;
border-top: 1px solid var(--border-color);
background-color: var(--bg-main);
}

/* Trash (ゴミ箱) Panel */
.trash-panel {
position: fixed;
inset: 0;
background: rgba(0,0,0,0.55);
z-index: 100;
display: flex;
align-items: center;
justify-content: center;
}

.trash-panel.hidden { display: none; }

.trash-panel-inner {
background: var(--bg-secondary);
width: 440px;
max-width: 90vw;
max-height: 80vh;
border-radius: var(--radius-lg);
border: 1px solid var(--border-color);
display: flex;
flex-direction: column;
overflow: hidden;
box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.trash-panel-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 14px;
border-bottom: 1px solid var(--border-color);
background-color: var(--bg-main);
}

.trash-panel-header h3 {
font-size: 0.8rem;
text-transform: uppercase;
letter-spacing: 0.5px;
color: var(--text-muted);
display: flex;
align-items: center;
gap: 6px;
font-family: var(--font-mono);
}

.trash-panel-list {
overflow-y: auto;
padding: 8px;
}

.trash-session-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 10px;
border-radius: var(--radius-sm);
font-size: 0.82rem;
gap: 8px;
}

.trash-session-item:hover {
background-color: var(--bg-hover);
}

.trash-session-item .ttl {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1;
color: var(--text-main);
}

.trash-session-item .ttl-sub {
font-size: 0.7rem;
color: var(--text-light);
font-family: var(--font-mono);
}

.trash-session-item .trash-actions {
display: flex;
gap: 2px;
flex-shrink: 0;
}

.trash-session-item .trash-actions button {
background: transparent;
border: none;
color: var(--text-muted);
cursor: pointer;
padding: 4px;
border-radius: var(--radius-sm);
display: flex;
align-items: center;
justify-content: center;
}

.trash-session-item .trash-actions button:hover {
background-color: var(--bg-hover);
color: var(--text-main);
}

.trash-session-item .btn-purge:hover {
color: var(--danger);
background-color: var(--danger-light);
}

/* ===================== Mobile / Responsive ===================== */
html {
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
}

body {
-webkit-tap-highlight-color: transparent;
}

@supports (height: 100dvh) {
body,
.app-container {
height: 100dvh;
}
.main-layout {
height: calc(100dvh - 56px);
}
}

.main-layout {
min-height: 0;
}

.chat-viewport {
min-width: 0;
}

.mobile-only {
display: none;
}

.mobile-backdrop {
display: none;
position: absolute;
inset: 0;
background: rgba(0, 0, 0, 0.55);
z-index: 40;
}

.mobile-backdrop.show {
display: block;
}

/* ---- Tablet / Phone (<= 900px) ---- */
@media (max-width: 900px) {
.mobile-only {
display: inline-flex;
}

/* Header: 2 rows (title row + scrollable tool row) */
.app-header {
height: auto;
flex-wrap: wrap;
gap: 6px;
padding: calc(6px + env(safe-area-inset-top, 0px)) calc(8px + env(safe-area-inset-right, 0px)) 6px calc(8px + env(safe-area-inset-left, 0px));
}

.header-left {
flex: 1 1 100%;
min-width: 0;
gap: 8px;
}

.header-left .icon-btn {
border: 1px solid var(--border-color);
background-color: var(--bg-main);
color: var(--text-main);
}

.status-badge {
margin-left: auto;
min-width: 0;
}

.header-right {
flex: 1 1 100%;
min-width: 0;
gap: 8px;
overflow-x: auto;
overflow-y: hidden;
padding-bottom: 2px;
-webkit-overflow-scrolling: touch;
}

.header-right > * {
flex-shrink: 0;
}

.label-text,
.btn-label {
display: none;
}

#btn-select-folder {
max-width: 52vw;
}

#folder-name-display {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 40vw;
}

/* Touch targets */
.btn {
min-height: 36px;
}

.icon-btn {
min-width: 36px;
min-height: 36px;
}

.btn-xs {
min-height: 32px;
}

/* iOS zooms into inputs smaller than 16px */
select,
textarea,
input {
font-size: 16px !important;
}

.styled-select {
padding: 6px 8px;
min-height: 36px;
}

/* Layout: single column, side panels become drawers */
.main-layout {
position: relative;
height: auto;
flex: 1;
min-height: 0;
}

.chat-viewport {
width: 100%;
flex: 1 1 auto;
}

.chat-sidebar,
.sidebar {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: min(84vw, 340px);
z-index: 50;
transform: translateX(-100%);
visibility: hidden;
transition: transform 0.2s ease, visibility 0s linear 0.2s;
}

.chat-sidebar.open,
.sidebar.open {
transform: translateX(0);
visibility: visible;
transition: transform 0.2s ease, visibility 0s linear 0s;
box-shadow: 4px 0 16px rgba(0, 0, 0, 0.5);
}

/* Browser panel becomes a full-screen overlay */
.resizer {
display: none;
}

#browser-panel {
display: none !important;
position: absolute;
inset: 0;
width: 100% !important;
min-width: 0 !important;
max-width: none !important;
z-index: 60;
border-left: none;
}

#browser-panel.mobile-open {
display: flex !important;
}

.browser-header {
flex-wrap: wrap;
gap: 6px;
}

.browser-nav-buttons {
flex-wrap: wrap;
flex: 1 1 auto;
}

#btn-toggle-browser {
position: relative;
}

#btn-toggle-browser.has-update::after {
content: "";
position: absolute;
top: 3px;
right: 3px;
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--primary);
box-shadow: 0 0 6px var(--primary);
}

/* Status card */
.status-card {
margin: 8px 8px 0;
}

.current-action-label {
flex: 1;
min-width: 0;
max-width: none;
}

.thought-text {
max-height: 30vh;
}

/* Timeline */
.chat-timeline {
padding: 10px 8px;
gap: 10px;
overscroll-behavior: contain;
-webkit-overflow-scrolling: touch;
}

.welcome-card {
margin: 12px auto;
padding: 16px;
}

.timeline-item {
max-width: 96%;
}

.bubble {
padding: 9px 12px;
font-size: 0.9rem;
overflow-wrap: anywhere;
}

.bubble img {
max-width: 100%;
height: auto;
}

.bubble table {
display: block;
overflow-x: auto;
max-width: 100%;
}

.bubble pre {
max-width: 100%;
}

.bubble.tool-result,
.action-log-body,
.thinking-body {
overflow-x: auto;
overflow-wrap: anywhere;
}

/* Approval dock */
.approval-dock {
padding: 10px 12px;
max-height: 50dvh;
overflow-y: auto;
}

.approval-details {
max-height: 22vh;
}

.approval-actions {
gap: 8px;
}

.approval-actions .btn {
flex: 1;
justify-content: center;
min-height: 42px;
}

/* Input dock */
.input-dock {
padding: 8px calc(10px + env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) calc(10px + env(safe-area-inset-left, 0px));
}

textarea#goal-input {
max-height: 28vh;
}

.input-actions {
gap: 8px;
}

.input-controls-left {
flex: 1 1 auto;
min-width: 0;
flex-wrap: wrap;
gap: 8px;
}

.input-controls-left .control-group {
min-width: 0;
}

#chat-model-select {
max-width: 46vw;
text-overflow: ellipsis;
}

.input-controls-right {
flex-shrink: 0;
}

#btn-submit,
#btn-stop {
min-height: 40px;
}

/* Session list: no hover on touch, so keep actions visible */
.chat-session-item {
padding: 10px 8px;
}

.chat-session-item .session-actions {
display: flex;
}

.chat-session-item .session-actions button {
padding: 6px;
}

.chat-session-item .session-actions button svg,
.chat-session-item .session-actions button i {
width: 16px;
height: 16px;
}

/* Trash dialog */
.trash-panel-inner {
width: 94vw;
max-width: 94vw;
max-height: 85dvh;
}

.trash-panel-header {
flex-wrap: wrap;
gap: 6px;
}

.trash-session-item {
padding: 10px;
}
}

/* ---- Small phones ---- */
@media (max-width: 480px) {
.logo {
font-size: 0.95rem;
}

.status-badge {
font-size: 0.7rem;
padding: 2px 6px;
}

.welcome-card h2 {
font-size: 1.05rem;
}

.timeline-item {
max-width: 100%;
}
}

/* ---- Landscape phones (short height) ---- */
@media (max-width: 900px) and (max-height: 500px) {
.welcome-card {
margin: 6px auto;
padding: 10px 12px;
}

.welcome-card ul {
display: none;
}

textarea#goal-input {
max-height: 22vh;
}

.approval-dock {
max-height: 60dvh;
}
}

@media (prefers-reduced-motion: reduce) {
.chat-sidebar,
.sidebar {
transition: none;
}
}

/* ===== Cohesive developer-workbench UI ===== */
:root {
  --radius-sm: 2px;
  --radius-md: 2px;
  --radius-lg: 4px;
  --workbench-line: #303c49;
  --workbench-accent-soft: rgba(16, 185, 129, 0.09);
}

.app-header {
  background: linear-gradient(180deg, #171e27 0%, #121820 100%);
  border-bottom-color: var(--workbench-line);
}

.sidebar,
.chat-sidebar,
.browser-panel {
  background: #111821;
  border-color: var(--workbench-line);
}

.sidebar-header,
.chat-sidebar-header,
.chat-sidebar-footer,
.browser-header {
  background: #0f151c;
  border-color: var(--workbench-line);
}

.btn,
.icon-btn,
.styled-select,
.styled-input,
.toggle-label span,
.chat-session-item,
.status-badge,
.welcome-card,
.approval-card,
.input-wrapper,
.thought-text,
.action-log-toggle,
.tool-call-badge,
.collapsed-logs-details,
.trash-session-item {
  border-radius: var(--radius-md);
}

.btn {
  border-color: #34414e;
  background-image: linear-gradient(180deg, rgba(255,255,255,0.025), transparent);
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, color 140ms ease, transform 140ms ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  border-color: #159a75;
  background-color: #0f9f76;
  box-shadow: inset 0 1px rgba(255,255,255,0.12), 0 0 0 1px rgba(16,185,129,0.08);
}

.btn-primary:hover {
  background-color: #0db183;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.1);
}

.btn-secondary {
  background-color: #151d27;
  border-color: #34414e;
}

.btn-secondary:hover,
.icon-btn:hover {
  background-color: #202b37;
  border-color: #526171;
}

.icon-btn {
  border: 1px solid transparent;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.styled-select,
.styled-input {
  background-color: #0c1218;
  border-color: #34414e;
}

.styled-select:focus,
.styled-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(16,185,129,0.10);
}

.status-badge {
  background: #10171f;
  border-color: #34414e;
  border-radius: 5px;
}

.status-badge.running {
  border-color: rgba(16,185,129,0.55);
  background: rgba(16,185,129,0.07);
}

.chat-session-item {
  border-radius: 3px;
}

.chat-session-item.active {
  background: var(--workbench-accent-soft);
  border-color: #2d6759;
  box-shadow: inset 2px 0 var(--primary);
}

.input-dock {
  background: #0e141b;
  border-top-color: var(--workbench-line);
}

.input-wrapper {
  background: #111922;
  border-color: #34414e;
  box-shadow: 0 8px 24px rgba(0,0,0,0.16);
}

.input-wrapper:focus-within {
  border-color: #168d6c;
  box-shadow: 0 0 0 1px rgba(16,185,129,0.16), 0 8px 26px rgba(0,0,0,0.2);
}

.input-actions {
  background: #0d141b;
  border-top-color: #273442;
}

textarea#goal-input::placeholder {
  color: #718092;
}

.bubble {
  border-radius: 5px;
  box-shadow: none;
}

.bubble.user {
  background: #172d42;
  border: 1px solid #2b4b68;
  border-bottom-right-radius: 2px;
  color: #e4edf7;
}

.bubble.agent {
  background: linear-gradient(135deg, #171f29 0%, #141b24 100%);
  border: 1px solid #354251;
  border-left: 2px solid #21896d;
  border-bottom-left-radius: 2px;
  box-shadow: 0 5px 18px rgba(0,0,0,0.14);
  color: #dce5ee;
}

.bubble.agent-log {
  background: #111922;
  border-color: #1e765e;
  color: #c5d0dc;
}

.bubble.tool-result,
.action-log-body,
.thought-text {
  background: #0c1218;
  border-color: #2b3947;
}

.action-log-toggle {
  background: #111922;
  border-color: #2e3d4c;
  border-left: 2px solid #3b5367;
}

.action-log-toggle:not(.completed) {
  border-left-color: var(--primary);
  box-shadow: inset 0 0 24px rgba(16,185,129,0.025);
}

.thinking-details {
  border-left-color: #334556;
}

.thinking-details[open] {
  border-left-color: var(--primary);
}

.status-card {
  background: linear-gradient(135deg, #151e28, #101720);
  border-color: #2b765f;
  border-radius: 5px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

.welcome-card {
  background: linear-gradient(135deg, #151e28, #101720);
  border-color: #334150;
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.15);
}

/* Streaming state: a restrained leading activity marker rather than an extra empty text line. */
.streaming-leading-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 9px;
  color: #7d9b92;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.streaming-leading-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: #39d5a1;
  box-shadow: 0 0 9px rgba(57,213,161,0.6);
  animation: streamingDotPulse 1.1s ease-in-out infinite;
}

@keyframes streamingDotPulse {
  0%, 100% { opacity: 0.45; transform: scale(0.82); }
  50% { opacity: 1; transform: scale(1); }
}

.final-streaming {
  min-height: 0;
}

.final-streaming-text {
  display: inline;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.7;
}

.final-streaming-text p:last-child {
  margin-bottom: 0;
}

.timeline-item.agent-final .bubble {
  min-height: 0;
}

/* Copy controls are quiet and appear as part of the developer-tool chrome. */
.message-actions {
  display: flex;
  align-items: center;
  min-height: 20px;
  padding: 0 2px;
  margin-top: 0;
}

.timeline-item.user .message-actions {
  justify-content: flex-end;
}

.timeline-item.agent-final .message-actions {
  justify-content: flex-start;
}

.copy-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 24px;
  padding: 3px 7px;
  color: #8393a3;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  font: 500 0.7rem/1.2 var(--font-sans);
  cursor: pointer;
  opacity: 0.78;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

.copy-control svg,
.copy-control i {
  width: 13px;
  height: 13px;
}

.copy-control:hover,
.copy-control:focus-visible {
  color: #cbd7e3;
  background: #1b2631;
  border-color: #344656;
  opacity: 1;
  outline: none;
}

.copy-control.is-copied {
  color: #52d6a6;
  border-color: rgba(16,185,129,0.22);
  background: rgba(16,185,129,0.06);
  opacity: 1;
}

.code-block-shell {
  margin: 9px 0;
  overflow: hidden;
  border: 1px solid #344251;
  border-radius: 4px;
  background: #0c1218;
}

.code-block-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 32px;
  padding: 3px 6px 3px 11px;
  background: #131c26;
  border-bottom: 1px solid #293746;
}

.code-block-language {
  overflow: hidden;
  color: #8ea0b1;
  font: 600 0.65rem/1.3 var(--font-mono);
  letter-spacing: 0.09em;
  text-overflow: ellipsis;
}

.code-block-copy {
  min-height: 23px;
  padding: 3px 6px;
  color: #9aaaba;
}

.bubble .code-block-shell pre {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #0c1218;
  padding: 11px 12px;
  max-width: 100%;
}

.bubble .code-block-shell pre code {
  color: #c7d4e2;
  line-height: 1.65;
  tab-size: 2;
}

.bubble .code-block-shell + p,
.bubble .code-block-shell + ul,
.bubble .code-block-shell + ol {
  margin-top: 0.6em;
}

@media (prefers-reduced-motion: reduce) {
  .streaming-leading-dot {
    animation: none;
  }
  .btn,
  .icon-btn,
  .copy-control {
    transition: none;
  }
}

:root {
  --radius-sm: 2px !important;
  --radius-md: 2px !important;
  --radius-lg: 3px !important;
}

.status-badge {
  border-radius: 3px !important;
}

.status-card {
  border-radius: 3px !important;
}

.bubble.agent-log {
  border-radius: 2px !important;
}

.action-log-toggle {
  border-radius: 2px !important;
}

.bubble.agent {
  border-radius: 2px !important;
  border-bottom-left-radius: 2px !important;
}

.bubble,
.bubble.user,
.input-wrapper,
.code-block-shell,
.btn,
.styled-select {
  border-radius: 2px !important;
}

/* =====================================================================
   Geminicode UI refresh — polished developer workspace
   Existing DOM hooks and component class names are intentionally retained.
   ===================================================================== */
:root {
  color-scheme: dark;
  --bg-main: #0a1018;
  --bg-secondary: #101925;
  --bg-hover: #1a2939;
  --border-color: #263648;
  --border-dark: #40566d;
  --text-main: #e4edf6;
  --text-muted: #94a6b9;
  --text-light: #64778b;
  --primary: #42d6b0;
  --primary-hover: #65e6c3;
  --primary-light: rgba(66, 214, 176, 0.11);
  --success: #2fc99a;
  --success-light: rgba(47, 201, 154, 0.14);
  --warning: #f4bb62;
  --warning-light: rgba(244, 187, 98, 0.14);
  --danger: #f07882;
  --danger-light: rgba(240, 120, 130, 0.14);
  --radius-sm: 7px !important;
  --radius-md: 11px !important;
  --radius-lg: 16px !important;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.16);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.22);
  --shadow-lg: 0 22px 60px rgba(0, 0, 0, 0.34);
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic UI", "Meiryo", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --workbench-line: #263648;
  --workbench-accent-soft: rgba(66, 214, 176, 0.09);
  --header-height: 68px;
}

html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  min-height: 100%;
  background:
    radial-gradient(ellipse at 48% -18%, rgba(31, 91, 92, 0.18), transparent 48%),
    var(--bg-main);
  color: var(--text-main);
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
select,
textarea,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

::selection {
  color: #061912;
  background: rgba(66, 214, 176, 0.72);
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: rgba(7, 13, 21, 0.45);
}

::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: #34475a;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: #50677e;
  background-clip: padding-box;
}

:focus-visible {
  outline: 2px solid var(--primary) !important;
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

/* Top bar */
.app-header {
  position: relative;
  height: var(--header-height);
  min-height: var(--header-height);
  padding: 0 20px;
  gap: 18px;
  background: rgba(15, 24, 36, 0.94);
  border-bottom: 1px solid #26384a;
  box-shadow: 0 5px 24px rgba(0, 0, 0, 0.13);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.header-left,
.header-right {
  min-width: 0;
  gap: 10px;
}

.header-left {
  gap: 15px;
}

.logo {
  gap: 10px;
  color: #f0f6fc;
  font-size: 1.02rem;
  font-weight: 760;
  letter-spacing: -0.045em;
}

.logo i,
.logo svg {
  width: 21px;
  height: 21px;
  color: #071b18;
  padding: 4px;
  box-sizing: content-box;
  border-radius: 9px;
  background: linear-gradient(145deg, #6ce8c5, #24b993);
  filter: drop-shadow(0 3px 9px rgba(47, 201, 154, 0.2));
}

.status-badge {
  gap: 7px;
  padding: 5px 10px;
  color: #a6b6c7;
  background: #121f2c;
  border: 1px solid #2b4052;
  border-radius: 999px !important;
  font-size: 0.72rem;
  font-weight: 600;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: #72869a;
  box-shadow: 0 0 0 3px rgba(114, 134, 154, 0.11);
}

.status-badge.running {
  color: #8ce8ca;
  border-color: rgba(66, 214, 176, 0.34);
  background: rgba(37, 129, 105, 0.13);
}

.status-badge.running .status-dot {
  background: #49dbb5;
  box-shadow: 0 0 0 3px rgba(66, 214, 176, 0.13), 0 0 12px rgba(66, 214, 176, 0.35);
}

.header-right {
  gap: 8px;
}

.header-right .control-group {
  padding: 0 7px 0 10px;
  min-height: 36px;
  border: 1px solid #293b4d;
  border-radius: 10px;
  background: rgba(8, 15, 24, 0.55);
}

.header-right .control-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.header-right .control-group label svg {
  width: 15px;
  height: 15px;
  color: #8ca2b7;
}

.btn {
  min-height: 36px;
  padding: 8px 12px;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px !important;
  font-size: 0.79rem;
  font-weight: 640;
  letter-spacing: 0.005em;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.btn svg,
.btn i {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.btn:active {
  transform: translateY(1px) scale(0.985);
}

.btn-primary {
  color: #062018;
  background: linear-gradient(135deg, #59e2bd, #2fc49c);
  border-color: rgba(115, 255, 216, 0.32);
  box-shadow: 0 5px 16px rgba(37, 190, 148, 0.17), inset 0 1px rgba(255, 255, 255, 0.32);
}

.btn-primary:hover {
  color: #041b14;
  background: linear-gradient(135deg, #75efd0, #42d4ac);
  box-shadow: 0 7px 20px rgba(37, 190, 148, 0.24), inset 0 1px rgba(255, 255, 255, 0.38);
}

.btn-secondary {
  color: #c2cfdd;
  background: linear-gradient(180deg, #172434, #131f2d);
  border-color: #304458;
}

.btn-secondary:hover {
  color: #f0f6fc;
  background: #203247;
  border-color: #49627a;
}

.btn-success {
  color: #062018;
  background: linear-gradient(135deg, #59e2bd, #2fc49c);
  border-color: transparent;
}

.btn-danger {
  color: #fff7f7;
  background: linear-gradient(135deg, #e97983, #cf5667);
  border-color: rgba(255, 255, 255, 0.09);
}

.btn-danger:hover {
  background: #e66b78;
}

.btn-xs {
  min-height: 30px;
  padding: 5px 9px;
  gap: 6px;
  border-radius: 8px !important;
  font-size: 0.72rem;
}

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  color: #93a6ba;
  border: 1px solid transparent;
  border-radius: 9px !important;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}

.icon-btn svg,
.icon-btn i {
  width: 16px;
  height: 16px;
}

.icon-btn:hover {
  color: #eff6fd;
  background: #203247;
  border-color: #344b61;
}

.styled-select,
.styled-input {
  min-height: 32px;
  padding: 6px 10px;
  color: #dce7f2;
  background: #0b1420;
  border: 1px solid #304458;
  border-radius: 8px !important;
  font-size: 0.78rem;
}

.styled-select:hover,
.styled-input:hover {
  border-color: #49627a;
}

.styled-select:focus,
.styled-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(66, 214, 176, 0.12);
}

/* Three working areas */
.main-layout {
  height: calc(100dvh - var(--header-height));
  min-height: 0;
  background: var(--bg-main);
}

.chat-sidebar,
.sidebar,
.browser-panel {
  background: #0e1824;
  border-color: #26384a;
}

.chat-sidebar {
  width: 268px;
  min-width: 228px;
  border-right: 1px solid #26384a;
}

.sidebar {
  width: 278px;
  min-width: 228px;
  border-right: 1px solid #26384a;
}

.chat-sidebar-header,
.chat-sidebar-footer,
.sidebar-header,
.browser-header {
  background: #111d2a;
  border-color: #26384a;
}

.chat-sidebar-header {
  padding: 15px 14px 13px;
}

.chat-sidebar-header .btn {
  min-height: 42px;
  justify-content: center;
  color: #bdf7e5;
  background: linear-gradient(135deg, rgba(48, 151, 123, 0.2), rgba(26, 91, 80, 0.15));
  border: 1px solid rgba(66, 214, 176, 0.27);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
}

.chat-sidebar-header .btn:hover {
  color: #eafff8;
  background: rgba(48, 151, 123, 0.27);
  border-color: rgba(66, 214, 176, 0.5);
}

.chat-sidebar-list {
  padding: 10px;
}

.chat-session-item {
  min-height: 39px;
  margin-bottom: 4px;
  padding: 8px 10px;
  gap: 8px;
  color: #a6b6c7;
  border: 1px solid transparent;
  border-radius: 9px !important;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.chat-session-item:hover {
  color: #e2edf7;
  background: #192838;
  border-color: #2b4053;
}

.chat-session-item.active {
  color: #e7fff7;
  background: linear-gradient(100deg, rgba(46, 164, 130, 0.2), rgba(31, 93, 85, 0.1));
  border-color: rgba(66, 214, 176, 0.25);
  box-shadow: inset 3px 0 #42d6b0;
}

.chat-session-item .session-title {
  font-size: 0.79rem;
  line-height: 1.45;
}

.chat-session-item .session-actions {
  gap: 3px;
}

.chat-session-item .session-actions button {
  width: 25px;
  height: 25px;
  padding: 4px;
  border-radius: 6px;
}

.chat-sidebar-footer {
  padding: 10px 12px;
}

.chat-sidebar-footer .btn {
  color: #91a2b5;
  background: transparent;
  border-color: #2c3d50;
}

.chat-sidebar-footer .btn:hover {
  color: #f1a0a7;
  background: rgba(240, 120, 130, 0.08);
  border-color: rgba(240, 120, 130, 0.25);
}

.sidebar-section {
  min-height: 0;
  border-color: #26384a;
}

.sidebar-header {
  min-height: 48px;
  padding: 11px 14px;
}

.sidebar-header h3,
.trash-panel-header h3 {
  color: #b5c4d3;
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.045em;
  text-transform: none;
}

.sidebar-header h3 svg {
  width: 15px;
  height: 15px;
  color: #7fdcc2;
}

.file-tree,
.memory-list {
  padding: 12px;
  color: #b9c7d5;
  font-family: var(--font-sans);
  font-size: 0.78rem;
}

.empty-msg {
  margin: 20px 10px;
  color: #708399;
  font-size: 0.76rem;
  line-height: 1.65;
}

.file-item {
  min-height: 30px;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 7px;
  color: #b8c7d6;
  font-size: 0.77rem;
}

.file-item:hover {
  color: #f0f6fc;
  background: #1a2b3d;
}

.file-item.directory {
  color: #86bfff;
  font-weight: 650;
}

.memory-item {
  margin-bottom: 8px;
  padding: 10px 11px;
  color: #b9c8d7;
  background: linear-gradient(145deg, #142233, #101b29);
  border: 1px solid #2a3e52;
  border-radius: 9px !important;
  font-size: 0.75rem;
}

.memory-key {
  margin-bottom: 4px;
  color: #67dabb;
  font-size: 0.72rem;
}

/* Main conversation */
.chat-viewport {
  min-width: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(27, 67, 75, 0.09), transparent 52%),
    #0b121c;
}

.chat-timeline {
  width: 100%;
  padding: 26px clamp(20px, 3.2vw, 52px) 22px;
  gap: 19px;
  overscroll-behavior: contain;
}

.timeline-item {
  max-width: min(88%, 900px);
  gap: 7px;
}

.timeline-item.agent-final {
  width: 100%;
  max-width: min(100%, 920px);
}

.bubble {
  padding: 15px 18px;
  border-radius: 14px !important;
  font-size: 0.9rem;
  line-height: 1.75;
  box-shadow: none;
}

.bubble.user {
  color: #eaf3ff;
  background: linear-gradient(145deg, #1a3651, #172c43);
  border: 1px solid #31516f;
  border-bottom-right-radius: 5px !important;
}

.bubble.agent {
  color: #dce7f1;
  background: linear-gradient(145deg, rgba(22, 34, 48, 0.98), rgba(17, 27, 40, 0.98));
  border: 1px solid #2b3f53;
  border-left: 3px solid rgba(66, 214, 176, 0.75);
  border-bottom-left-radius: 5px !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.bubble.agent-log {
  padding: 11px 14px;
  color: #c5d3df;
  background: rgba(17, 31, 43, 0.9);
  border: 1px solid #2a6658;
  border-left: 3px solid #36bd98;
  border-radius: 10px !important;
  font-size: 0.81rem;
}

.bubble.tool-result {
  padding: 12px 14px;
  color: #b8d8ec;
  background: #0a1420;
  border: 1px solid #2b3d50;
  border-radius: 10px !important;
  font-size: 0.78rem;
}

.bubble p {
  margin-bottom: 0.72em;
}

.bubble h1,
.bubble h2,
.bubble h3,
.bubble h4,
.bubble h5,
.bubble h6 {
  color: #f0f6fc;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.bubble h1,
.bubble h2 {
  border-color: #31465a;
}

.bubble a {
  color: #7fc7ff;
  text-decoration: underline;
  text-decoration-color: rgba(127, 199, 255, 0.3);
  text-underline-offset: 3px;
}

.bubble a:hover {
  color: #b1ddff;
  text-decoration-color: currentColor;
}

.bubble pre {
  padding: 13px 15px;
  background: #08111b;
  border: 1px solid #2a3c4e;
  border-radius: 10px;
}

.bubble code {
  color: #aee7d7;
  background: rgba(81, 139, 128, 0.15);
  border-radius: 5px;
}

.bubble pre code {
  color: #d0deeb;
}

.bubble blockquote {
  padding: 7px 0 7px 14px;
  color: #9bafc1;
  border-left: 3px solid #3d806f;
}

.bubble table {
  border-color: #30465a;
}

.bubble th,
.bubble td {
  padding: 8px 10px;
  border-color: #30465a;
}

.bubble th {
  color: #dce8f3;
  background: #182839;
}

.welcome-card {
  width: min(100%, 700px);
  margin: clamp(24px, 8vh, 88px) auto 30px;
  padding: clamp(25px, 4vw, 38px);
  color: #dce7f1;
  text-align: left;
  background:
    radial-gradient(circle at 100% 0%, rgba(55, 181, 149, 0.12), transparent 36%),
    linear-gradient(145deg, #172637, #111d2b 70%);
  border: 1px solid #30465a;
  border-radius: 20px !important;
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.2), inset 0 1px rgba(255, 255, 255, 0.035);
}

.welcome-card h2 {
  margin-bottom: 10px;
  color: #f3f8fc;
  font-size: clamp(1.18rem, 2vw, 1.5rem);
  letter-spacing: -0.035em;
}

.welcome-card p {
  color: #a4b6c8;
  font-size: 0.88rem;
  line-height: 1.75;
}

.welcome-card ul {
  gap: 11px;
  color: #c4d2df;
  font-size: 0.83rem;
}

.welcome-card li {
  gap: 10px;
}

.welcome-card li svg,
.welcome-card li i {
  color: #65ddbc;
}

/* Status / progress */
.status-card {
  margin: 14px clamp(16px, 3vw, 42px) 0;
  padding: 11px 15px;
  background: linear-gradient(135deg, #142b31, #111f2b);
  border: 1px solid rgba(66, 214, 176, 0.38);
  border-radius: 12px !important;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
}

.status-summary-bar {
  min-height: 22px;
  gap: 10px;
}

.status-title {
  color: #72ddbf;
  font-family: var(--font-sans);
  font-size: 0.76rem;
}

.current-action-label {
  color: #b7e8dc;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 650;
}

.spinner {
  width: 15px;
  height: 15px;
  border-width: 2px;
  border-top-color: #55dfb9;
}

.thought-process-container {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(116, 174, 164, 0.18);
}

.thought-header {
  color: #9db4c5;
}

.thought-text {
  padding: 11px 13px;
  color: #b7d5e7;
  background: #0a1420;
  border: 1px solid #2a4053;
  border-radius: 9px !important;
  line-height: 1.65;
}

/* Execution logs and thinking details */
.action-log-toggle {
  padding: 8px 11px;
  color: #c2d1df;
  background: #142232;
  border: 1px solid #30455a;
  border-left: 3px solid #466078;
  border-radius: 9px !important;
}

.action-log-toggle:not(.completed) {
  border-left-color: #42d6b0;
  box-shadow: inset 0 0 25px rgba(66, 214, 176, 0.035);
}

.action-log-summary {
  color: #a9c9df;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 650;
}

.action-log-body {
  padding: 11px 13px;
  color: #b9d5e8;
  background: #09131f;
  border: 1px solid #2a3d50;
  border-radius: 8px;
  line-height: 1.65;
}

.collapsed-logs-details {
  padding: 7px 0;
  border: 0;
}

.collapsed-logs-summary {
  color: #91a6ba;
  font-size: 0.76rem;
}

.collapsed-logs-summary:hover {
  color: #d5e2ed;
}

.tool-call-badge {
  padding: 5px 9px;
  color: #d2c3ff;
  background: rgba(114, 86, 180, 0.13);
  border: 1px solid rgba(154, 127, 218, 0.24);
  border-radius: 8px !important;
}

.thinking-details {
  padding-left: 13px;
  border-left-color: #34485b;
}

.thinking-details[open] {
  border-left-color: #4ad5b0;
}

.thinking-summary {
  color: #9eafc1;
  font-size: 0.78rem;
}

.thinking-summary:hover,
.thinking-details[open] .thinking-summary {
  color: #d8e6f2;
}

.thinking-body {
  color: #a8bbcd;
  font-size: 0.81rem;
  line-height: 1.8;
}

/* Composer */
.input-dock {
  padding: 14px clamp(16px, 3vw, 42px) max(16px, env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(11, 18, 28, 0.78), #0d1722 35%);
  border-top: 1px solid rgba(43, 62, 82, 0.78);
}

.input-wrapper {
  width: min(100%, 980px);
  margin: 0 auto;
  overflow: hidden;
  background: linear-gradient(145deg, #142131, #101b28);
  border: 1px solid #354b60;
  border-radius: 16px !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22), inset 0 1px rgba(255, 255, 255, 0.025);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.input-wrapper:focus-within {
  background: #142333;
  border-color: rgba(66, 214, 176, 0.76);
  box-shadow: 0 0 0 3px rgba(66, 214, 176, 0.1), 0 14px 34px rgba(0, 0, 0, 0.24);
}

textarea#goal-input {
  min-height: 82px;
  max-height: 34vh;
  padding: 17px 18px 13px;
  color: #e6eff7;
  font-size: 0.91rem;
  line-height: 1.65;
  caret-color: #65e4c0;
}

textarea#goal-input::placeholder {
  color: #8296aa;
  opacity: 0.88;
}

.input-actions {
  min-height: 49px;
  padding: 7px 10px 7px 15px;
  background: rgba(8, 16, 26, 0.58);
  border-top: 1px solid #2b3e51;
}

.input-controls-left,
.input-controls-right {
  gap: 10px;
}

.input-controls-left .control-group {
  gap: 7px;
}

.input-controls-left .control-group label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.input-controls-left .control-group label svg {
  width: 14px;
  height: 14px;
  color: #8aa2b8;
}

.toggle-label {
  color: #a9b9c9;
  font-size: 0.77rem;
}

.toggle-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #43d5b0;
}

.toggle-label span {
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: 8px !important;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}

.toggle-label:hover span {
  color: #e3f3ef;
  background: #1c3040;
  border-color: #344a5f;
}

.toggle-label span svg {
  width: 15px;
  height: 15px;
  color: #9dadd0;
}

#btn-submit {
  width: 42px;
  height: 42px;
  min-height: 42px;
  justify-content: center;
  padding: 0;
  border-radius: 12px !important;
}

#btn-submit svg {
  width: 17px;
  height: 17px;
}

#btn-stop {
  min-height: 38px;
}

/* Approval request */
.approval-dock {
  padding: 13px clamp(16px, 3vw, 42px);
  background: rgba(53, 40, 24, 0.28);
  border-top: 1px solid rgba(244, 187, 98, 0.45);
  border-bottom: 1px solid rgba(244, 187, 98, 0.28);
}

.approval-card {
  max-width: 980px;
  margin: 0 auto;
  padding: 15px 17px;
  gap: 13px;
  background: linear-gradient(145deg, #29271f, #1c2024);
  border: 1px solid rgba(244, 187, 98, 0.4);
  border-radius: 13px !important;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.17);
}

.approval-header h4 {
  color: #f2c47d;
  font-size: 0.88rem;
}

.approval-header p {
  margin-top: 3px;
  color: #c6b99f;
  font-size: 0.79rem;
}

.approval-details {
  padding: 11px 13px;
  color: #e4d6bd;
  background: rgba(10, 15, 19, 0.55);
  border: 1px solid rgba(192, 158, 104, 0.24);
  border-radius: 9px !important;
  line-height: 1.6;
}

/* Browser panel */
.browser-panel {
  width: clamp(330px, 29vw, 480px);
  min-width: 290px;
  max-width: 48vw;
  background: #101a27;
  border-left: 1px solid #2b3e52;
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.12);
}

.resizer {
  width: 6px;
  background: #152333;
  border-left: 1px solid #223549;
  border-right: 1px solid #223549;
}

.resizer:hover,
.resizer.resizing {
  background: #3bcba6;
  border-color: #3bcba6;
  box-shadow: 0 0 12px rgba(66, 214, 176, 0.3);
}

.browser-header {
  min-height: 52px;
  padding: 8px 12px;
  gap: 8px;
  border-bottom: 1px solid #2b3e52;
}

.browser-controls-left {
  color: #d1deea;
  font-size: 0.8rem;
  font-weight: 700;
}

.browser-controls-left svg {
  width: 16px;
  height: 16px;
  color: #72dabc;
}

.browser-nav-buttons {
  gap: 4px;
}

.browser-nav-buttons .icon-btn {
  width: 31px;
  height: 31px;
}

.browser-body {
  background: #f8fafc;
}

.browser-search-results {
  padding: 18px;
  background: #fff;
}

.browser-placeholder {
  color: #8ea0b4;
  background: #101a27;
}

.browser-placeholder svg {
  color: #5b8f88;
}

/* Trash dialog */
.trash-panel {
  padding: 20px;
  background: rgba(3, 8, 14, 0.72);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.trash-panel-inner {
  width: min(520px, 92vw);
  max-height: min(82vh, 760px);
  background: #111e2c;
  border: 1px solid #3a4f64;
  border-radius: 17px !important;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

.trash-panel-header {
  min-height: 54px;
  padding: 13px 16px;
  background: #152334;
  border-color: #2e4358;
}

.trash-panel-list {
  padding: 12px;
}

.trash-session-item {
  padding: 10px 12px;
  color: #c2d0de;
  background: #162537;
  border: 1px solid #2b4055;
  border-radius: 9px !important;
}

/* Dynamically generated utility elements */
.message-actions {
  min-height: 26px;
  margin-top: 1px;
}

.copy-control {
  min-height: 26px;
  padding: 4px 8px;
  color: #90a4b8;
  border-radius: 7px;
}

.copy-control:hover,
.copy-control:focus-visible {
  color: #e2edf6;
  background: #1a2a3b;
  border-color: #344b60;
}

.copy-control.is-copied {
  color: #6be0bd;
  background: rgba(66, 214, 176, 0.08);
  border-color: rgba(66, 214, 176, 0.24);
}

.code-block-shell {
  margin: 12px 0;
  background: #09131f;
  border: 1px solid #304458;
  border-radius: 11px !important;
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.12);
}

.code-block-toolbar {
  min-height: 36px;
  padding: 5px 8px 5px 13px;
  background: #152436;
  border-bottom-color: #2b4054;
}

.code-block-language {
  color: #9bb0c4;
  font-size: 0.67rem;
}

.bubble .code-block-shell pre {
  padding: 14px 15px;
  background: #09131f;
}

.bubble .code-block-shell pre code {
  color: #d0deeb;
  line-height: 1.75;
}

.streaming-leading-indicator {
  color: #89b8aa;
  font-size: 0.67rem;
  letter-spacing: 0.09em;
}

.streaming-leading-dot {
  background: #55dfb9;
  box-shadow: 0 0 10px rgba(85, 223, 185, 0.5);
}

/* Tablet: retain all three areas while preventing the header from compressing. */
@media (min-width: 901px) and (max-width: 1220px) {
  .app-header {
    height: auto;
    min-height: 68px;
    flex-wrap: wrap;
    padding: 9px 14px;
    gap: 8px 14px;
  }

  .header-left {
    flex: 1 1 100%;
  }

  .header-right {
    flex: 1 1 100%;
    min-height: 38px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .header-right::-webkit-scrollbar {
    display: none;
  }

  .main-layout {
    height: auto;
    flex: 1 1 auto;
  }

  .chat-sidebar {
    width: 226px;
    min-width: 205px;
  }

  .sidebar {
    width: 232px;
    min-width: 210px;
  }

  .browser-panel {
    width: 320px;
    min-width: 270px;
  }

  .label-text,
  .btn-label {
    display: none;
  }
}

/* Mobile drawers and browser overlay */
@media (max-width: 900px) {
  :root {
    --header-height: auto;
  }

  html {
    scrollbar-gutter: auto;
  }

  .app-header {
    height: auto;
    min-height: 0;
    flex-wrap: wrap;
    gap: 7px;
    padding: calc(9px + env(safe-area-inset-top, 0px)) calc(10px + env(safe-area-inset-right, 0px)) 8px calc(10px + env(safe-area-inset-left, 0px));
    background: rgba(15, 24, 36, 0.97);
  }

  .header-left {
    flex: 1 1 100%;
    min-height: 38px;
    gap: 7px;
  }

  .header-left .icon-btn {
    width: 38px;
    height: 38px;
    color: #dce7f2;
    background: #172536;
    border: 1px solid #30465c;
  }

  .header-right {
    flex: 1 1 100%;
    min-width: 0;
    gap: 7px;
    padding: 1px 0 3px;
  }

  .header-right .control-group {
    min-height: 36px;
  }

  .header-right .btn {
    min-height: 36px;
  }

  .main-layout {
    position: relative;
    height: auto;
    flex: 1 1 auto;
    min-height: 0;
  }

  .chat-sidebar,
  .sidebar {
    width: min(86vw, 350px);
    max-width: 350px;
    background: #101c2a;
    border-right: 1px solid #3a5065;
    box-shadow: 14px 0 35px rgba(0, 0, 0, 0.25);
  }

  .chat-sidebar.open,
  .sidebar.open {
    box-shadow: 14px 0 45px rgba(0, 0, 0, 0.42);
  }

  .mobile-backdrop.show {
    background: rgba(2, 8, 14, 0.66);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
  }

  .chat-viewport {
    width: 100%;
    min-width: 0;
  }

  .chat-timeline {
    padding: 17px 13px 14px;
    gap: 15px;
  }

  .timeline-item,
  .timeline-item.agent-final {
    max-width: 94%;
  }

  .bubble {
    padding: 13px 14px;
    font-size: 0.88rem;
    line-height: 1.72;
  }

  .welcome-card {
    margin: 22px auto;
    padding: 22px 19px;
    border-radius: 16px !important;
  }

  .status-card {
    margin: 9px 12px 0;
    padding: 9px 11px;
  }

  .input-dock {
    padding: 9px 11px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .input-wrapper {
    border-radius: 14px !important;
  }

  textarea#goal-input {
    min-height: 70px;
    max-height: 28vh;
    padding: 13px 14px 10px;
    font-size: 16px !important;
  }

  .input-actions {
    padding: 6px 8px 6px 10px;
    gap: 7px;
  }

  .input-controls-left {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
    gap: 5px 8px;
  }

  .input-controls-left .control-group {
    min-width: 0;
  }

  #chat-model-select {
    max-width: min(45vw, 210px);
    text-overflow: ellipsis;
  }

  .toggle-label {
    font-size: 0.74rem;
  }

  .input-controls-right {
    flex-shrink: 0;
    gap: 6px;
  }

  #btn-submit {
    width: 40px;
    height: 40px;
    min-height: 40px;
  }

  #btn-stop {
    min-height: 40px;
  }

  .approval-dock {
    padding: 9px 11px;
    max-height: 50dvh;
    overflow-y: auto;
  }

  .approval-card {
    padding: 12px;
  }

  .approval-details {
    max-height: 22vh;
  }

  .approval-actions {
    gap: 8px;
  }

  .approval-actions .btn {
    flex: 1;
    justify-content: center;
    min-height: 42px;
  }

  .browser-panel#browser-panel {
    position: absolute;
    inset: 0;
    z-index: 60;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .browser-header {
    min-height: 55px;
    padding: 8px 10px;
  }

  .browser-nav-buttons {
    flex-wrap: wrap;
    gap: 3px;
  }

  #btn-browser-copy-text {
    max-width: 44vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-session-item {
    min-height: 42px;
    padding: 10px 9px;
  }

  .chat-session-item .session-actions {
    display: flex;
  }

  .chat-session-item .session-actions button {
    width: 30px;
    height: 30px;
  }

  .trash-panel {
    padding: 12px;
  }

  .trash-panel-inner {
    width: 94vw;
    max-width: 94vw;
    max-height: 86dvh;
  }

  .trash-panel-header {
    flex-wrap: wrap;
    gap: 7px;
  }

  .trash-session-item {
    padding: 10px;
  }
}

@media (max-width: 480px) {
  .logo {
    font-size: 0.97rem;
  }

  .status-badge {
    padding: 4px 8px;
    font-size: 0.68rem;
  }

  .header-right .control-group {
    padding: 0 5px 0 8px;
  }

  #btn-select-folder {
    max-width: 45vw;
  }

  #folder-name-display {
    max-width: 32vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-timeline {
    padding-right: 10px;
    padding-left: 10px;
  }

  .timeline-item,
  .timeline-item.agent-final {
    max-width: 100%;
  }

  .bubble {
    padding: 12px 13px;
    font-size: 0.86rem;
  }

  .welcome-card {
    margin: 17px auto;
    padding: 20px 16px;
  }

  .welcome-card ul {
    gap: 8px;
  }

  .input-actions {
    align-items: flex-end;
  }

  .input-controls-left {
    gap: 4px 6px;
  }

  .input-controls-left .control-group {
    gap: 4px;
    font-size: 0.73rem;
  }

  #chat-model-select {
    max-width: 43vw;
  }

  .toggle-label span {
    padding: 5px 6px;
  }
}

@media (max-width: 360px) {
  .header-left {
    gap: 5px;
  }

  .header-left .icon-btn {
    width: 34px;
    height: 34px;
  }

  .logo {
    gap: 7px;
    font-size: 0.9rem;
  }

  .status-badge {
    font-size: 0.64rem;
  }

  .input-controls-left .control-group label .label-text {
    display: none;
  }

  .toggle-label span {
    font-size: 0.69rem;
  }
}

@media (max-width: 900px) and (max-height: 500px) {
  .welcome-card {
    margin: 7px auto;
    padding: 13px 15px;
  }

  .welcome-card ul {
    display: none;
  }

  textarea#goal-input {
    max-height: 22vh;
  }

  .approval-dock {
    max-height: 60dvh;
  }
}

@media (hover: none) {
  .chat-session-item .session-actions {
    display: flex;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Message variants also override the legacy compact-radius safety rules. */
.bubble.user {
  border-radius: 14px !important;
  border-bottom-right-radius: 5px !important;
}

.bubble.agent {
  border-radius: 14px !important;
  border-bottom-left-radius: 5px !important;
}

/* ===== AI operation surface, explorer and result views ===== */
.ai-interact-overlay.ai-input-lock {
  pointer-events: auto;
  cursor: default;
  touch-action: none;
  user-select: none;
}
.ai-interact-overlay.ai-input-lock .ai-fake-cursor,
.ai-interact-overlay.ai-input-lock .ai-typing-indicator {
  pointer-events: none !important;
}
.ai-fake-cursor {
  pointer-events: none;
  z-index: 51;
}
.ai-tool-status-bar {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 24px);
  padding: 6px 10px;
  border: 1px solid rgba(36, 49, 65, .22);
  border-radius: 7px;
  background: rgba(248, 250, 252, .94);
  color: #263445;
  box-shadow: 0 2px 8px rgba(20, 30, 45, .16);
  font: 600 11px/1.3 var(--font-sans);
  pointer-events: none;
  backdrop-filter: blur(8px);
}
.ai-tool-status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: #d99a25;
  box-shadow: 0 0 0 3px rgba(217, 154, 37, .14);
}
.ai-tool-status-bar[data-state="done"] .ai-tool-status-dot { background: #14966b; box-shadow: 0 0 0 3px rgba(20, 150, 107, .14); }
.ai-tool-status-bar[data-state="error"] .ai-tool-status-dot { background: #dc4545; box-shadow: 0 0 0 3px rgba(220, 69, 69, .14); }
.ai-tool-lock-label {
  padding-left: 7px;
  border-left: 1px solid #d7dee7;
  color: #667487;
  white-space: nowrap;
}
.ai-tool-screen {
  min-height: 100%;
  padding: 52px 20px 28px;
  background: #f5f7fa;
  color: #1f2937;
  font-family: var(--font-sans);
}
.ai-tool-screen-heading,
.ai-explorer-heading,
.ai-twitter-heading {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}
.ai-tool-kicker {
  color: #69788b;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.ai-tool-screen h2,
.ai-explorer-heading h2,
.ai-twitter-heading h2 {
  color: #1c2735;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
}
.ai-tool-state {
  align-self: flex-start;
  border: 1px solid #e6c77d;
  border-radius: 999px;
  padding: 3px 9px;
  background: #fff8e7;
  color: #936718;
  font-size: 11px;
  font-weight: 700;
}
.ai-tool-state.is-done { border-color: #a8dbc8; background: #edf9f4; color: #137653; }
.ai-tool-state.is-error { border-color: #efb7b7; background: #fff0f0; color: #b72d2d; }
.ai-tool-operation-card,
.ai-result-card,
.ai-subagent-card {
  overflow: hidden;
  border: 1px solid #dce3eb;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(24, 39, 58, .06);
}
.ai-tool-operation-top,
.ai-result-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid #e7ecf2;
  color: #596a7f;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
}
.ai-tool-operation-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e1a332;
  animation: ai-tool-pulse 1.1s ease-in-out infinite;
}
@keyframes ai-tool-pulse { 50% { opacity: .35; transform: scale(.8); } }
.ai-tool-operation-card pre,
.ai-result-output {
  margin: 0;
  padding: 14px;
  overflow: auto;
  color: #29384a;
  font: 12px/1.65 var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ai-tool-focus {
  margin: 0 14px 14px;
  padding: 10px 12px;
  border: 1px dashed #a9b7c7;
  border-radius: 7px;
  background: #f6f9fc;
  color: #52657b;
  font-size: 12px;
}
.ai-result-card-title { justify-content: flex-start; }
.ai-result-output { max-height: 58vh; }
.ai-tool-subtitle { color: #65758a; font-size: 11px; overflow-wrap: anywhere; }
.ai-explorer-screen { padding-top: 52px; }
.ai-explorer-heading { margin-bottom: 14px; }
.ai-explorer-address {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #dce3eb;
  border-radius: 8px;
  background: #fff;
  color: #718096;
  font-size: 11px;
}
.ai-explorer-address strong { color: #2d3d51; font: 600 12px var(--font-mono); overflow-wrap: anywhere; }
.ai-explorer-list {
  overflow: hidden;
  border: 1px solid #dce3eb;
  border-radius: 9px;
  background: #fff;
}
.ai-explorer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 43px;
  padding: 8px 12px;
  border-bottom: 1px solid #edf0f4;
  color: #2b394b;
  font-size: 12px;
  transition: background .18s, box-shadow .18s;
}
.ai-explorer-row:last-child { border-bottom: 0; }
.ai-explorer-row.is-opening,
.ai-explorer-row.is-selected { background: #eaf3ff; box-shadow: inset 3px 0 #4285d4; }
.ai-explorer-icon { width: 20px; text-align: center; font-size: 16px; }
.ai-explorer-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.ai-explorer-kind { color: #8793a2; font-size: 10px; }
.ai-explorer-empty,
.ai-twitter-empty { padding: 24px; color: #7c8796; text-align: center; font-size: 12px; }
.ai-explorer-footer { padding: 9px 2px; color: #7b8796; text-align: right; font-size: 10px; }
.ai-file-document { padding-top: 52px; }
.ai-file-document-header { margin-bottom: 13px; }
.ai-file-document-header h2 { margin: 5px 0; }
.ai-file-path { color: #748398; font: 11px var(--font-mono); overflow-wrap: anywhere; }
.ai-file-document-meta { margin: 10px 0; color: #7b8796; font-size: 10px; }
.ai-file-content {
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding: 15px;
  border: 1px solid #dce3eb;
  border-radius: 9px;
  background: #fff;
  color: #29384a;
  font: 11px/1.65 var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ai-file-operation-screen { padding-top: 52px; }
.ai-fs-operation-flow { display: grid; grid-template-columns: minmax(0,1fr) 24px minmax(0,1fr); align-items: center; gap: 8px; }
.ai-fs-operation-pane { min-width: 0; }
.ai-fs-pane-label { display: block; margin-bottom: 7px; color: #7b8796; font-size: 10px; font-weight: 700; }
.ai-fs-operation-entry {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 88px;
  padding: 12px;
  border: 1px solid #dce3eb;
  border-radius: 8px;
  background: #fff;
  color: #334256;
  overflow-wrap: anywhere;
}
.ai-fs-operation-entry > span { font-size: 18px; }
.ai-fs-operation-entry strong { font-size: 12px; }
.ai-fs-operation-entry small { color: #8290a0; font: 10px var(--font-mono); }
.ai-fs-operation-arrow { color: #6e8298; text-align: center; font-size: 17px; }
.ai-fs-delete-action { width: 100%; min-height: 88px; border: 1px solid #e6bcbc; border-radius: 8px; background: #fff5f5; color: #b33d3d; font-weight: 700; }
.ai-fs-rename-preview { display: flex; gap: 10px; align-items: center; margin: 12px 0; color: #738197; font-size: 11px; }
.ai-fs-rename-input { flex: 1; min-width: 0; padding: 8px; border: 1px solid #dce3eb; border-radius: 6px; background: #fff; color: #29384a; }
.ai-file-operation-complete { margin-top: 13px; padding: 10px; border-radius: 7px; background: #eaf8f1; color: #197451; font-size: 12px; font-weight: 700; text-align: center; }
.ai-key-animation { position: sticky; bottom: 12px; width: max-content; margin: 16px auto 0; padding: 9px 15px; border: 1px solid #c8d2df; border-radius: 7px; background: #202b3a; color: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.18); font: 700 13px var(--font-mono); opacity: 0; transform: translateY(7px); transition: opacity .12s, transform .12s; }
.ai-key-animation.is-visible { opacity: 1; transform: translateY(0); }
.ai-twitter-screen { padding-top: 52px; background: #f7f9fc; }
.ai-twitter-heading { margin-bottom: 14px; }
.ai-twitter-query { color: #64748b; font-size: 11px; }
.ai-twitter-results { display: flex; flex-direction: column; gap: 10px; }
.ai-twitter-post { padding: 14px; border: 1px solid #dce3eb; border-radius: 10px; background: #fff; box-shadow: 0 2px 6px rgba(24,39,58,.04); }
.ai-twitter-user { display: flex; align-items: center; gap: 9px; }
.ai-twitter-avatar { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%; object-fit: cover; background: #e5eaf0; }
.ai-twitter-avatar-empty { display: grid; place-items: center; color: #4c5c70; font-weight: 800; }
.ai-twitter-user-meta { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.ai-twitter-user-meta strong { color: #202b39; font-size: 12px; }
.ai-twitter-user-meta span { color: #8792a0; font-size: 10px; overflow-wrap: anywhere; }
.ai-twitter-badge { margin-left: 4px; }
.ai-twitter-text { margin: 12px 0; color: #263446; font-size: 13px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-twitter-media { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; margin: 8px 0; }
.ai-twitter-media img { width: 100%; max-height: 220px; border-radius: 7px; object-fit: cover; }
.ai-twitter-stats { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 0 7px; color: #7b8795; font-size: 10px; }
.ai-twitter-open-link { display: inline-block; color: #1769aa; font-size: 11px; font-weight: 700; text-decoration: none; }
.ai-twitter-open-link:hover { text-decoration: underline; }
.ai-twitter-empty pre { margin-top: 12px; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-network-table-wrap { overflow: auto; border: 1px solid #dce3eb; border-radius: 9px; background: #fff; }
.ai-network-table { width: 100%; border-collapse: collapse; color: #344357; font-size: 11px; }
.ai-network-table th, .ai-network-table td { padding: 9px 11px; border-bottom: 1px solid #e9edf2; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.ai-network-table th { background: #f0f4f8; color: #65748a; font-size: 10px; }
.ai-subagent-card { display: flex; flex-direction: column; gap: 12px; padding: 15px; }
.ai-subagent-card > div:first-child,
.ai-subagent-card > div:nth-child(2) { display: flex; flex-direction: column; gap: 3px; }
.ai-subagent-card small { color: #8090a2; font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.ai-subagent-card strong { color: #2a394b; font-size: 12px; }
.ai-subagent-prompt { padding: 12px; border-radius: 7px; background: #f5f8fb; color: #45566b; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.google-search-submit-mock { display: grid; width: 28px; height: 28px; place-items: center; flex: 0 0 28px; border-radius: 50%; background: #f0f4f9; color: #64748b; font-size: 19px; }
@media (max-width: 600px) {
  .ai-tool-screen { padding: 48px 12px 20px; }
  .ai-fs-operation-flow { grid-template-columns: minmax(0,1fr) 18px minmax(0,1fr); gap: 5px; }
  .ai-fs-operation-entry { padding: 9px; }
  .ai-tool-status-bar { right: 7px; top: 7px; }
}


/* =====================================================================
   GEMINICODE 2026 — layout hardening + midnight workspace polish
   The application shell is a fixed-height flex layout. Only content panes
   scroll; headers, toolbars and the composer never participate in scrolling.
   ===================================================================== */
:root {
  color-scheme: dark;
  --bg-main: #070b11;
  --bg-secondary: #0d141d;
  --bg-hover: #172330;
  --border-color: #202d3b;
  --border-dark: #40566a;
  --text-main: #e7edf4;
  --text-muted: #91a1b3;
  --text-light: #607185;
  --primary: #42d6b0;
  --primary-hover: #69e7c5;
  --primary-light: rgba(66, 214, 176, .12);
  --success: #3bc99a;
  --warning: #f1b95f;
  --danger: #f07882;
  --workbench-line: #202d3b;
  --workbench-accent-soft: rgba(66, 214, 176, .10);
  --header-height: 68px;
}

html,
body {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  background: #070b11;
}

.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
}

/* Solid, non-shrinking chrome: no chat content can appear through it. */
.app-header {
  position: relative;
  z-index: 100;
  flex: 0 0 auto;
  min-width: 0;
  background: #080d14 !important;
  border-bottom: 1px solid #263342;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .34);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  isolation: isolate;
}

.main-layout {
  position: relative;
  display: flex;
  flex: 1 1 0%;
  width: 100%;
  height: auto !important;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #070b11;
}

.chat-sidebar,
.sidebar,
.chat-viewport,
.browser-panel {
  min-height: 0;
}

.chat-viewport {
  position: relative;
  display: flex;
  flex: 1 1 0%;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 52% -12%, rgba(27, 91, 82, .10), transparent 48%),
    #080e15;
}

.status-card {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  min-width: 0;
  max-height: min(38dvh, 300px);
  overflow: auto;
  background: #101b23;
}

.chat-timeline {
  position: relative;
  display: flex;
  flex: 1 1 0%;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: auto;
  scrollbar-gutter: stable;
  padding-bottom: 24px;
}

.timeline-item {
  flex: 0 0 auto;
  min-width: 0;
}

.timeline-item.user {
  align-self: flex-end;
}

.timeline-item.agent,
.timeline-item.tool,
.timeline-item.agent-log,
.timeline-item.thinking-item,
.timeline-item.action-detail-item {
  align-self: flex-start;
}

.timeline-item.agent-final {
  align-self: flex-start;
  width: min(100%, 920px);
  max-width: min(100%, 920px);
}

.bubble,
.bubble * {
  min-width: 0;
}

.bubble {
  overflow-wrap: anywhere;
  word-break: normal;
}

/* Composer stays in its own opaque bottom rail. */
.input-dock {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  min-width: 0;
  padding-top: 12px;
  background: #080d14 !important;
  border-top: 1px solid #243241;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .18);
  isolation: isolate;
}

.input-wrapper {
  width: min(100%, 1040px);
  min-width: 0;
  margin-inline: auto;
  background: #101923;
  border-color: #2b3a49;
}

.input-actions {
  background: #0b121a;
  border-top-color: #253443;
}

.approval-dock {
  position: relative;
  z-index: 4;
  flex: 0 0 auto;
  min-width: 0;
  max-height: min(52dvh, 480px);
  overflow-y: auto;
  background: #15140f;
}

/* The AI workspace has a fixed toolbar and a separately scrolling viewport. */
.browser-panel {
  display: flex;
  flex: 0 1 clamp(320px, 31vw, 500px);
  flex-direction: column;
  min-width: 290px;
  min-height: 0;
  overflow: hidden;
  background: #0b121a;
}

.browser-header {
  position: relative;
  z-index: 3;
  display: flex;
  flex: 0 0 auto;
  min-height: 52px;
  background: #0a1017;
  border-bottom: 1px solid #263645;
}

.browser-body {
  position: relative;
  flex: 1 1 0%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #080e15;
}

.browser-iframe,
.browser-search-results {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.browser-search-results {
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Keep all toolbar controls visible even when the AI output is very long. */
.browser-nav-buttons {
  min-width: 0;
  flex: 0 1 auto;
}

.browser-nav-buttons > * {
  flex: 0 0 auto;
}

/* Slightly deeper surfaces, restrained teal highlights and clearer hierarchy. */
.sidebar,
.chat-sidebar {
  background: #0b121a;
  border-color: #202d3b;
}

.sidebar-header,
.chat-sidebar-header,
.chat-sidebar-footer {
  background: #090f16;
  border-color: #202d3b;
}

.chat-session-item {
  border-color: transparent;
  background: transparent;
}

.chat-session-item:hover {
  background: #141f2b;
}

.chat-session-item.active {
  background: rgba(50, 177, 145, .11);
  border-color: rgba(66, 214, 176, .22);
  box-shadow: inset 3px 0 #42d6b0;
}

.status-badge,
.styled-select,
.styled-input {
  background-color: #0a1119;
  border-color: #2a3948;
}

.btn-secondary {
  color: #c5d2df;
  background: linear-gradient(180deg, #151f2b, #101923);
  border-color: #2c3b4a;
}

.btn-secondary:hover,
.icon-btn:hover {
  background: #1b2a38;
  border-color: #43586c;
}

.bubble.agent {
  background: linear-gradient(145deg, #111b25, #0e1720);
  border-color: #273747;
  border-left-color: #34bd98;
}

.bubble.user {
  background: linear-gradient(145deg, #172c40, #122438);
  border-color: #29455e;
}

.welcome-card {
  background:
    radial-gradient(circle at 100% 0%, rgba(55, 181, 149, .09), transparent 38%),
    linear-gradient(145deg, #121e29, #0c151e 72%);
  border-color: #293b4b;
}

.code-block-shell,
.bubble pre {
  background: #070d13;
  border-color: #263746;
}

/* Tablet / compact laptop: header may wrap, main area consumes the remainder. */
@media (min-width: 901px) and (max-width: 1220px) {
  .app-header {
    flex: 0 0 auto;
  }
  .main-layout {
    flex: 1 1 0%;
    height: auto !important;
  }
}

/* Mobile: header is a solid two-row rail; content never scrolls behind it. */
@media (max-width: 900px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body,
  .app-container {
    height: 100dvh !important;
    min-height: 0;
  }

  .app-header {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    width: 100%;
    gap: 7px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) calc(10px + env(safe-area-inset-right, 0px)) 8px calc(10px + env(safe-area-inset-left, 0px));
    background: #080d14 !important;
    border-bottom: 1px solid #263545;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .38);
  }

  .header-left {
    display: flex;
    flex: 1 0 100%;
    min-width: 0;
    min-height: 38px;
    gap: 7px;
  }

  .header-left .icon-btn {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    color: #e0eaf4;
    background: #14202c;
    border: 1px solid #2c3e4f;
  }

  .logo {
    min-width: 0;
  }

  .status-badge {
    flex: 0 1 auto;
    min-width: 0;
    margin-left: auto;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-right {
    display: flex;
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 7px;
    padding: 2px 0 4px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .header-right::-webkit-scrollbar {
    display: none;
  }

  .header-right > * {
    flex: 0 0 auto;
  }

  .main-layout {
    position: relative;
    display: flex;
    flex: 1 1 0%;
    width: 100%;
    height: auto !important;
    min-height: 0;
    overflow: hidden;
  }

  .chat-viewport {
    display: flex;
    flex: 1 1 0%;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }

  .chat-timeline {
    flex: 1 1 0%;
    min-height: 0;
    padding: 15px 12px 18px;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-behavior: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .status-card {
    flex: 0 0 auto;
    max-height: 32dvh;
    margin: 8px 10px 0;
    overflow: auto;
  }

  .input-dock {
    flex: 0 0 auto;
    padding: 8px calc(10px + env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) calc(10px + env(safe-area-inset-left, 0px));
    background: #080d14 !important;
    border-top: 1px solid #263545;
  }

  .input-wrapper {
    width: 100%;
    border-radius: 15px !important;
  }

  textarea#goal-input {
    min-height: 64px;
    max-height: min(26dvh, 220px);
    font-size: 16px !important;
  }

  .input-actions {
    flex-wrap: nowrap;
    min-width: 0;
    align-items: center;
  }

  .input-controls-left {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
  }

  .input-controls-right {
    flex: 0 0 auto;
  }

  #btn-submit,
  #btn-stop {
    flex: 0 0 auto;
    min-height: 42px;
  }

  .approval-dock {
    flex: 0 0 auto;
    max-height: 45dvh;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
  }

  .chat-sidebar,
  .sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    width: min(86vw, 350px);
    max-width: 350px;
    min-height: 0;
    background: #0b131d;
    border-right: 1px solid #34485b;
    box-shadow: 18px 0 48px rgba(0, 0, 0, .55);
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 220ms cubic-bezier(.2, .7, .2, 1), visibility 0s linear 220ms;
  }

  .chat-sidebar.open,
  .sidebar.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 220ms cubic-bezier(.2, .7, .2, 1), visibility 0s;
  }

  .mobile-backdrop {
    position: absolute;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, .68);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  #browser-panel {
    display: none !important;
    position: absolute;
    inset: 0;
    z-index: 80;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  #browser-panel.mobile-open {
    display: flex !important;
  }

  .browser-header {
    flex: 0 0 auto;
    min-height: 54px;
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 6px;
    background: #090f16;
    border-bottom: 1px solid #273746;
  }

  .browser-nav-buttons {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    min-width: 0;
  }

  .browser-body {
    flex: 1 1 0%;
    min-height: 0;
  }

  .browser-search-results {
    min-height: 0;
  }

  #btn-browser-copy-text {
    max-width: 44vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .trash-panel-inner {
    max-height: 86dvh;
  }
}

@media (max-width: 480px) {
  .app-header {
    gap: 6px;
  }
  .header-left {
    gap: 5px;
  }
  .header-left .icon-btn {
    flex-basis: 36px;
    width: 36px;
    height: 36px;
  }
  .logo {
    gap: 7px;
    font-size: .94rem;
  }
  .status-badge {
    max-width: 35vw;
    padding: 4px 7px;
    font-size: .66rem;
  }
  .chat-timeline {
    padding-right: 10px;
    padding-left: 10px;
  }
  .bubble {
    padding: 12px 13px;
    font-size: .86rem;
  }
  .input-actions {
    gap: 5px;
  }
  #chat-model-select {
    max-width: 42vw;
  }
}

@media (max-width: 360px) {
  .header-left .icon-btn {
    flex-basis: 33px;
    width: 33px;
    height: 33px;
  }
  .logo {
    font-size: .88rem;
  }
  .status-badge {
    max-width: 31vw;
    font-size: .62rem;
  }
}

@media (max-width: 900px) and (max-height: 500px) {
  textarea#goal-input {
    min-height: 48px;
    max-height: 20dvh;
  }
  .status-card {
    max-height: 25dvh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-sidebar,
  .sidebar {
    transition: none !important;
  }
}
