/* 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: 4px;
--radius-md: 6px;
--radius-lg: 10px;
--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;
}

.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-details {
background: var(--bg-secondary);
border: 1px solid #3b82f6;
border-radius: var(--radius-sm);
padding: 6px 10px;
font-size: 0.8rem;
color: var(--text-main);
margin-bottom: 8px;
}

.thinking-summary {
cursor: pointer;
display: flex;
align-items: center;
gap: 6px;
user-select: none;
color: #60a5fa;
font-family: var(--font-mono);
font-weight: 600;
}

.thinking-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.78rem;
color: #93c5fd;
white-space: pre-wrap;
max-height: 250px;
overflow-y: auto;
}

.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;
}
}
