/* ── Reset & Root ── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body { display: flex; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #24283b; color: #a9b1d6; }

/* ── Shared button styles ── */
.btn-primary { background: #3d59a1; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; }
.btn-primary:hover { background: #2e4478; }
.btn-primary:disabled { background: #414868; cursor: not-allowed; }
.btn-primary.sm { font-size: 11px; border-radius: 4px; }
.btn-cancel { background: #292e42; color: #c0caf5; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; }
.btn-cancel:hover { background: #3b4261; }

/* ── Sidebar ── */
#sidebar { width: 220px; background: #1f2335; border-right: 1px solid #3b4261; display: flex; flex-direction: column; flex-shrink: 0; transition: width 0.2s ease, border-right-color 0.2s ease; overflow: hidden; }
#sidebar.collapsed { width: 0; border-right-color: transparent; }
.cwd-wrapper { position: relative; }
.cwd-wrapper input { padding: 7px 28px 7px 8px; background: #24283b; color: #a9b1d6; border: 1px solid #3b4261; border-radius: 5px; font-size: 12px; font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; width: 100%; }
.cwd-wrapper input::placeholder { color: #565f89; }
.cwd-wrapper input:focus { outline: none; border-color: #7aa2f7; }
.cwd-dropdown-btn { position: absolute; right: 1px; top: 1px; bottom: 1px; width: 24px; background: none; border: none; color: #565f89; cursor: pointer; font-size: 12px; border-radius: 0 4px 4px 0; }
.cwd-dropdown-btn:hover { background: #3b4261; color: #a9b1d6; }
.cwd-dropdown { display: none; position: absolute; top: 100%; left: 0; right: 0; background: #1a1b26; border: 1px solid #3b4261; border-radius: 5px; margin-top: 2px; max-height: 200px; overflow-y: auto; z-index: 250; }
.cwd-dropdown.open { display: block; }
.cwd-dropdown .cwd-option { padding: 6px 8px; font-size: 12px; font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; color: #a9b1d6; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cwd-dropdown .cwd-option:hover { background: #292e42; }
.sched-field .cwd-wrapper input { padding-right: 28px; }
#sidebar-tools { display: flex; flex-direction: column; gap: 4px; margin: 16px 10px; }
.sidebar-tool-btn { padding: 8px 0; background: #24283b; color: #c0caf5; border: 1px solid #3b4261; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; text-align: center; }
.sidebar-tool-btn:hover { background: #3b4261; color: #a9b1d6; }
.sidebar-tool-btn.active { background: #3b4261; color: #7aa2f7; border-color: #7aa2f7; }

/* ── Files browser dropdown ── */
#files-browser-tool { display: flex; margin: 0 10px 16px; }
#files-cwd-select { width: 100%; padding: 8px 8px; background: #24283b; color: #c0caf5; border: 1px solid #3b4261; border-radius: 6px; font-size: 12px; font-weight: 600; font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; cursor: pointer; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23565f89'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; padding-right: 24px; }
#files-cwd-select:hover { background-color: #3b4261; border-color: #7aa2f7; }
#files-cwd-select:focus { outline: none; border-color: #7aa2f7; }
#files-cwd-select option { background: #1a1b26; color: #a9b1d6; padding: 4px 8px; }

/* ── Session History ── */
.history-header { padding: 8px 10px; font-size: 11px; color: #565f89; cursor: pointer; display: flex; align-items: center; gap: 6px; border-top: 1px solid #3b4261; margin-top: 16px; user-select: none; flex-shrink: 0; }
.history-header:hover { color: #a9b1d6; }
.history-header .arrow { font-size: 9px; transition: transform 0.15s; display: inline-block; }
.history-header .arrow.open { transform: rotate(90deg); }
.history-count { font-size: 10px; color: #414868; margin-left: auto; }
.history-list { display: none; overflow-y: auto; padding: 0 6px 6px; max-height: 40vh; flex-shrink: 0; }
.history-list.open { display: block; }
.history-item { padding: 6px 10px; margin-bottom: 2px; border-radius: 5px; cursor: pointer; font-size: 11px; color: #565f89; display: flex; flex-direction: column; gap: 2px; }
.history-item:hover { background: #292e42; color: #a9b1d6; }
.history-top { display: flex; align-items: center; gap: 6px; }
.history-meta { font-size: 10px; color: #414868; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-badge { display: inline-block; padding: 1px 5px; background: #292e42; border-radius: 3px; font-size: 9px; color: #7aa2f7; margin-left: 2px; }
.tag-badge.analyzing { color: #565f89; animation: tag-pulse 1.5s ease-in-out infinite; }
@keyframes tag-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

/* ── Dialog common ── */
.dialog-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 200; align-items: center; justify-content: center; }
.dialog-overlay.open { display: flex; }
.dialog-box { background: #1f2335; border: 1px solid #3b4261; border-radius: 12px; width: 90%; padding: 20px; box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.dialog-box h3 { font-size: 14px; color: #7aa2f7; margin-bottom: 12px; }

/* ── Dialog individual max-widths ── */
#cwd-picker-dialog { max-width: 480px; }
#cwd-picker-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.cwd-picker-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #24283b; border: 1px solid #3b4261; border-radius: 6px; cursor: pointer; font-size: 13px; color: #c0caf5; font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; transition: all 0.15s; }
.cwd-picker-item:hover { background: #292e42; border-color: #7aa2f7; }
.cwd-picker-item .cwd-picker-icon { color: #7aa2f7; font-size: 14px; flex-shrink: 0; }
.cwd-picker-item .cwd-picker-path { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#session-meta-dialog { max-width: 400px; }
#sm-delete { padding: 8px 18px; background: none; border: 1px solid #f7768e; color: #f7768e; border-radius: 6px; cursor: pointer; font-size: 13px; }
#sm-delete:hover { background: #f7768e; color: #fff; }

/* ── Main layout ── */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

/* ── Status bar (in sidebar) ── */
#status-bar { padding: 10px 12px 8px; font-size: 11px; border-bottom: 1px solid #3b4261; flex-shrink: 0; }
#status-text { white-space: nowrap; }
#status-bar.ok #status-text { color: #9ece6a; }
#status-bar.err #status-text { color: #f7768e; }
#status-bar.warn #status-text { color: #e0af68; }

/* ── Panel container ── */
#panel-container { flex: 1; min-height: 0; position: relative; }
.panel { position: absolute; inset: 0; display: none; overflow: hidden; }
.panel.active { display: flex; }

/* ── Terminal panel ── */
#terminal-panel { flex-direction: column; }
#placeholder { flex: 1; display: flex; align-items: center; justify-content: center; color: #565f89; font-size: 15px; }
#term-wrap { position: absolute; inset: 0; display: none; flex-direction: row; flex-wrap: wrap; gap: 0; overflow: hidden; }
#term-wrap.visible { display: flex; }
/* Terminal pane — sized dynamically by applyPaneZoom() */
.term-pane { flex-shrink: 0; position: relative; border: 2px solid #3b4261; box-sizing: border-box; overflow: hidden; }
.term-pane iframe { border: none; }

/* ── Files panel ── */
#files-panel.layout-h { flex-direction: row; }
#files-panel.layout-v { flex-direction: column; }

/* File tree */
.file-tree { background: #1f2335; overflow-y: auto; font-size: 13px; flex-shrink: 0; }
#files-panel.layout-h .file-tree { width: 250px; min-width: 150px; border-right: 1px solid #3b4261; }
#files-panel.layout-v .file-tree { height: 250px; min-height: 100px; border-bottom: 1px solid #3b4261; width: 100%; }
.tree-header { padding: 8px 12px; font-size: 11px; text-transform: uppercase; color: #565f89; font-weight: 600; letter-spacing: 0.5px; border-bottom: 1px solid #3b4261; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.tree-filter-wrap { padding: 6px 8px; border-bottom: 1px solid #3b4261; flex-shrink: 0; }
#tree-filter { width: 100%; padding: 5px 8px; background: #24283b; color: #a9b1d6; border: 1px solid #3b4261; border-radius: 4px; font-size: 12px; font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; box-sizing: border-box; }
#tree-filter::placeholder { color: #565f89; }
#tree-filter:focus { outline: none; border-color: #7aa2f7; }
.tree-search-item { padding: 4px 8px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; color: #c0caf5; font-size: 12px; }
.tree-search-item:hover { background: #292e42; }
.tree-search-item .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-search-item .search-path { font-size: 10px; color: #565f89; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.refresh-btn { background: none; border: none; color: #565f89; cursor: pointer; padding: 2px 6px; font-size: 14px; border-radius: 3px; }
.refresh-btn:hover { background: #3b4261; color: #c0caf5; }
.refresh-btn.loading { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.tree-item { padding: 4px 8px; cursor: pointer; display: flex; align-items: center; gap: 4px; color: #c0caf5; white-space: nowrap; font-size: 12px; }
.tree-item:hover { background: #292e42; }
.tree-item.selected { background: #3b4261; }
.tree-item .icon { width: 16px; text-align: center; flex-shrink: 0; font-size: 10px; color: #565f89; }
.tree-item .name { overflow: hidden; text-overflow: ellipsis; }
.tree-children { display: none; }
.tree-children.expanded { display: block; }
.tree-item.directory > .icon::before { content: '>'; display: inline-block; transition: transform 0.1s; font-size: 10px; }
.tree-item.directory.expanded > .icon::before { transform: rotate(90deg); }
.tree-loading { padding: 4px 8px; color: #565f89; font-size: 11px; font-style: italic; }

/* File viewer */
.file-viewer { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.file-header { padding: 6px 10px; background: #1f2335; border-bottom: 1px solid #3b4261; font-size: 12px; display: none; align-items: center; gap: 8px; flex-shrink: 0; }
.file-header-info { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; overflow: hidden; }
.file-header-info #file-name { font-weight: 600; color: #c0caf5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 1; min-width: 0; }
.file-header-info .file-path { color: #565f89; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 10; min-width: 0; }
.file-header-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.file-action-btn { padding: 4px 10px; font-size: 11px; border: 1px solid #3b4261; background: #24283b; color: #c0caf5; border-radius: 4px; cursor: pointer; font-weight: 600; white-space: nowrap; min-height: 28px; }
.file-action-btn:hover { background: #3b4261; }
.file-action-btn.active { background: #7aa2f7; color: #fff; border-color: #7aa2f7; }
.file-action-btn.primary { background: #3d59a1; color: #fff; border-color: #3d59a1; }
.file-action-btn.primary:hover { background: #2e4478; }
.file-action-btn.danger { border-color: #f7768e; color: #f7768e; }
.file-action-btn.danger:hover { background: #f7768e; color: #fff; }
.file-content { flex: 1; overflow: auto; background: #24283b; }
.file-content pre { margin: 0; padding: 12px; font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.5; color: #a9b1d6; white-space: pre-wrap; word-break: break-all; }
.file-content .shiki { margin: 0; padding: 12px; font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-all; overflow: auto; height: 100%; }
.file-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: #565f89; font-size: 14px; }
.file-error { color: #f7768e; padding: 20px; }
.file-preview-iframe { width: 100%; height: 100%; border: none; background: #fff; }
.file-image-preview { max-width: 100%; max-height: 100%; object-fit: contain; display: block; margin: 0 auto; padding: 16px; box-sizing: border-box; }

/* ── Markdown ── */
.md-body { padding: 16px 24px; color: #c0caf5; font-size: 14px; line-height: 1.7; overflow-wrap: break-word; background: #1e2130; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { color: #e0e4f7; margin: 1.2em 0 0.5em; font-weight: 600; }
.md-body h1 { font-size: 1.6em; border-bottom: 1px solid #3b4261; padding-bottom: 0.3em; }
.md-body h2 { font-size: 1.3em; border-bottom: 1px solid #3b4261; padding-bottom: 0.2em; }
.md-body p { margin: 0.6em 0; }
.md-body ul, .md-body ol { padding-left: 1.5em; margin: 0.5em 0; }
.md-body li { margin: 0.2em 0; }
.md-body strong { color: #e0e4f7; }
.md-body code { background: #414868; color: #c8d3f5; padding: 2px 5px; border-radius: 3px; font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; font-size: 0.9em; }
.md-body pre { background: #1a1b26; padding: 12px; border-radius: 6px; overflow-x: auto; margin: 0.8em 0; }
.md-body pre code { background: none; padding: 0; color: #a9b1d6; }
.md-body blockquote { border-left: 3px solid #7aa2f7; padding-left: 12px; color: #9aa5ce; margin: 0.8em 0; }
.md-body a { color: #7aa2f7; }
.md-body table { border-collapse: collapse; margin: 0.8em 0; }
.md-body th, .md-body td { border: 1px solid #3b4261; padding: 6px 12px; }
.md-body th { background: #292e42; color: #c0caf5; }
.md-body img { max-width: 100%; }

/* ── Resizer ── */
.resizer { background: #3b4261; flex-shrink: 0; transition: background 0.15s; }
.resizer:hover, .resizer.dragging { background: #7aa2f7; }
.resizer.horizontal { width: 4px; cursor: col-resize; }
.resizer.vertical { height: 4px; cursor: row-resize; }

/* ── Input Pad dialog ── */
#pad-dialog { max-width: 560px; }
#pad-dialog h3 { display: flex; align-items: center; gap: 8px; }
#pad-textarea { width: 100%; height: 120px; background: #24283b; color: #a9b1d6; border: 1px solid #3b4261; border-radius: 6px; padding: 10px; font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; resize: vertical; }
#pad-textarea:focus { outline: none; border-color: #7aa2f7; }
#pad-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }
#pad-actions button { padding: 8px 18px; }

/* ── Schedule panel ── */
#schedule-panel { flex-direction: column; overflow-y: auto; padding: 16px 20px; gap: 16px; }
.sched-toolbar { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.sched-toolbar button { padding: 8px 16px; }
/* Schedule cards */
#sched-list { display: flex; flex-direction: column; gap: 10px; }
.sched-card { background: #1f2335; border: 1px solid #3b4261; border-radius: 8px; padding: 12px 14px; }
.sched-card:hover { border-color: #565f89; }
.sched-card.running { border-color: #9ece6a; animation: pulse-border 1.2s ease-in-out infinite; }
@keyframes pulse-border { 0%, 100% { border-color: #9ece6a; box-shadow: 0 0 0 0 rgba(158,206,106,0); } 50% { border-color: #9ece6a; box-shadow: 0 0 0 3px rgba(158,206,106,0.2); } }
.sched-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sched-card-header .sched-card-name { flex: 1; font-size: 14px; font-weight: 600; color: #c0caf5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-card-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: #565f89; margin-bottom: 10px; }
.sched-card-meta .sched-time { font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; font-size: 13px; color: #e0af68; }
.sched-card-meta .sched-status { font-size: 12px; }
.sched-card-meta .sched-status.running { color: #9ece6a; }
.sched-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.sched-actions button { padding: 5px 10px; font-size: 11px; border: 1px solid #3b4261; background: #24283b; color: #c0caf5; border-radius: 4px; cursor: pointer; }
.sched-actions button:hover { background: #3b4261; }
.sched-actions button.danger { border-color: #f7768e; color: #f7768e; }
.sched-actions button.danger:hover { background: #f7768e; color: #fff; }
.sched-toggle { width: 36px; height: 20px; border-radius: 10px; border: none; cursor: pointer; position: relative; transition: background 0.2s; }
.sched-toggle.on { background: #9ece6a; }
.sched-toggle.off { background: #414868; }
.sched-toggle::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 2px; transition: left 0.2s; }
.sched-toggle.on::after { left: 18px; }
.sched-toggle.off::after { left: 2px; }
.sched-time { font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; font-size: 14px; color: #e0af68; }
.sched-status { font-size: 11px; }
.sched-status.running { color: #9ece6a; }

/* Schedule form dialog */
#sched-form-dialog { max-width: 560px; }
.sched-field { margin-bottom: 10px; }
.sched-field label { display: block; font-size: 11px; color: #565f89; margin-bottom: 4px; text-transform: uppercase; }
.sched-field input, .sched-field textarea { width: 100%; padding: 8px; background: #24283b; color: #a9b1d6; border: 1px solid #3b4261; border-radius: 5px; font-size: 13px; font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; }
.sched-field input:focus, .sched-field textarea:focus { outline: none; border-color: #7aa2f7; }
.sched-field textarea { height: 80px; resize: vertical; }
.sched-time-row { display: flex; gap: 8px; align-items: center; }
.sched-time-row input { width: 70px; text-align: center; }
.sched-time-row span { color: #565f89; font-size: 16px; }
.sched-form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.sched-form-actions button { padding: 8px 18px; }

/* Schedule log dialog */
#sched-log-dialog { max-width: 700px; max-height: 80vh; display: flex; flex-direction: column; }
#sched-log-dialog h3 { flex-shrink: 0; }
#sched-log-content { flex: 1; overflow: auto; background: #24283b; border-radius: 6px; padding: 12px; font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; color: #a9b1d6; min-height: 200px; }
#sched-log-close { margin-top: 12px; align-self: flex-end; padding: 8px 18px; }

/* ── Code editor (shared by file viewer) ── */
.memo-codemirror { flex: 1; display: none; flex-direction: column; overflow: hidden; background: #24283b; }
.memo-codemirror .cm-editor { flex: 1; height: 100%; }
.memo-codemirror .cm-scroller { flex: 1; overflow: auto; }

/* ── Sessions (launcher) section ── */
#launchers-section { margin: 0 10px 16px; }
.launchers-header { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: #565f89; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; padding: 0 2px; }
.launchers-header button { background: none; border: 1px solid #3b4261; color: #a9b1d6; border-radius: 4px; cursor: pointer; font-size: 13px; padding: 1px 7px; line-height: 1.2; }
.launchers-header button:hover { background: #3b4261; }
#launchers-list { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.launcher-btn { display: flex; align-items: center; gap: 3px; padding: 8px 6px; background: linear-gradient(135deg, #1a1e30 0%, #24283b 100%); border: 1px solid #3b4261; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; color: #c0caf5; text-align: left; transition: all 0.15s; position: relative; }
.launcher-btn:hover { background: linear-gradient(135deg, #1e2340 0%, #292e42 100%); border-color: #7aa2f7; box-shadow: 0 0 8px rgba(122, 162, 247, 0.15); }
.launcher-btn:active { transform: scale(0.98); }
.launcher-btn .launcher-icon { display: flex; align-items: center; justify-content: center; width: 14px; height: 14px; font-size: 9px; color: #7aa2f7; flex-shrink: 0; }
.launcher-btn .launcher-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; font-size: 11px; }

/* Launcher form dialog */
#launcher-form-dialog { max-width: 480px; }
#lf-shell { width: 100%; padding: 8px; background: #24283b; color: #a9b1d6; border: 1px solid #3b4261; border-radius: 5px; font-size: 13px; font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; }
#lf-shell:focus { outline: none; border-color: #7aa2f7; }

/* Launcher context menu */
#launcher-context-menu { display: none; position: fixed; z-index: 300; background: #1f2335; border: 1px solid #3b4261; border-radius: 8px; padding: 4px 0; min-width: 150px; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
#launcher-context-menu.open { display: block; }
#launcher-context-menu button { display: block; width: 100%; padding: 8px 14px; background: none; border: none; color: #c0caf5; cursor: pointer; font-size: 12px; text-align: left; }
#launcher-context-menu button:hover { background: #292e42; }
#launcher-context-menu button.danger { color: #f7768e; }
#launcher-context-menu button.danger:hover { background: #f7768e; color: #fff; }

#session-context-menu { display: none; position: fixed; z-index: 300; background: #1f2335; border: 1px solid #3b4261; border-radius: 8px; padding: 4px 0; min-width: 150px; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
#session-context-menu.open { display: block; }
#session-context-menu button { display: block; width: 100%; padding: 8px 14px; background: none; border: none; color: #c0caf5; cursor: pointer; font-size: 12px; text-align: left; }
#session-context-menu button:hover { background: #292e42; }
#session-context-menu button.danger { color: #f7768e; }
#session-context-menu button.danger:hover { background: #f7768e; color: #fff; }

/* ── Active session list ── */
#session-list { overflow-y: auto; padding: 6px 10px; flex: 1; min-height: 0; }
.session-item { padding: 8px 10px; margin-bottom: 3px; border-radius: 5px; cursor: pointer; font-size: 12px; display: flex; align-items: center; gap: 7px; border-left: 3px solid transparent; background: #1e2233; color: #565f89; }
.session-item:hover { background: #292e42; }
.session-item.active { background: #3b4261; color: #c0caf5; }
.session-icon { width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; font-size: 10px; flex-shrink: 0; border-radius: 3px; font-weight: 700; font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; }
.session-item.type-terminal .session-icon { background: #292e42; color: #7aa2f7; }
.session-item.type-files .session-icon { background: #292e42; color: #e0af68; }
.session-item.active .session-icon { background: #414868; }
.session-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; }
.session-fork-btn { flex-shrink: 0; padding: 1px 5px; font-size: 13px; line-height: 1; background: transparent; border: 1px solid transparent; border-radius: 3px; cursor: pointer; color: #565f89; opacity: 0; transition: opacity .15s, color .15s, border-color .15s; }
.session-item:hover .session-fork-btn { opacity: 1; }
.session-fork-btn:hover { color: #7aa2f7; border-color: #7aa2f7; }

/* ── Commands section ── */
#commands-section { margin: 16px 10px 16px; }
.commands-header { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: #565f89; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; padding: 0 2px; }
.commands-header button { background: none; border: 1px solid #3b4261; color: #a9b1d6; border-radius: 4px; cursor: pointer; font-size: 13px; padding: 1px 7px; line-height: 1.2; }
.commands-header button:hover { background: #3b4261; }
.commands-header .sidebar-tool-btn { background: none; padding: 1px 6px; font-size: 13px; font-weight: normal; border-color: #3b4261; text-transform: none; letter-spacing: 0; }
.commands-header .sidebar-tool-btn:hover { background: #3b4261; }
.commands-header .sidebar-tool-btn.active { background: #3b4261; color: #7aa2f7; border-color: #7aa2f7; }
#commands-list { display: flex; flex-direction: column; gap: 3px; max-height: 180px; overflow-y: auto; }
.os-windows #commands-list::-webkit-scrollbar { width: 6px; }
.os-windows #commands-list::-webkit-scrollbar-track { background: #1a1b26; }
.os-windows #commands-list::-webkit-scrollbar-thumb { background: #3b4261; border-radius: 3px; }
.os-windows #commands-list::-webkit-scrollbar-thumb:hover { background: #565f89; }
.cmd-btn { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: linear-gradient(135deg, #1a1e30 0%, #24283b 100%); border: 1px solid #3b4261; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; color: #c0caf5; text-align: left; transition: all 0.15s; position: relative; }
.cmd-btn:hover { background: linear-gradient(135deg, #1e2340 0%, #292e42 100%); border-color: #7aa2f7; box-shadow: 0 0 8px rgba(122, 162, 247, 0.15); }
.cmd-btn:active { transform: scale(0.98); }
.cmd-btn .cmd-indicator { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cmd-btn .cmd-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-btn.running .cmd-indicator { animation: pulse-dot 1s ease-in-out infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 0.35; transform: scale(0.85); } 50% { opacity: 1; transform: scale(1.15); } }
.cmd-btn.done-fail { border-color: #f7768e; }

/* Command form dialog */
#cmd-form-dialog { max-width: 480px; }
#cf-color { width: 60px; height: 32px; padding: 2px; cursor: pointer; }
.cmd-sched-row { display: flex; align-items: center; gap: 6px; }
.cmd-sched-row input[type="number"] { width: 56px; }
.toggle-label-inline { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #c0caf5; cursor: pointer; white-space: nowrap; }
.toggle-label-inline input[type="checkbox"] { accent-color: #7aa2f7; }
.cmd-sched-badge { font-size: 10px; color: #7aa2f7; margin-left: auto; flex-shrink: 0; opacity: 0.8; }

/* Command context menu */
#cmd-context-menu { display: none; position: fixed; z-index: 300; background: #1f2335; border: 1px solid #3b4261; border-radius: 8px; padding: 4px 0; min-width: 150px; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
#cmd-context-menu.open { display: block; }
#cmd-context-menu button { display: block; width: 100%; padding: 8px 14px; background: none; border: none; color: #c0caf5; cursor: pointer; font-size: 12px; text-align: left; }
#cmd-context-menu button:hover { background: #292e42; }
#cmd-context-menu button.danger { color: #f7768e; }
#cmd-context-menu button.danger:hover { background: #f7768e; color: #fff; }

/* Schedule form selects */
.sched-field select { width: 100%; padding: 8px; background: #24283b; color: #a9b1d6; border: 1px solid #3b4261; border-radius: 5px; font-size: 13px; font-family: "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace; }
.sched-field select:focus { outline: none; border-color: #7aa2f7; }

/* ── Mobile list toggle ── */
.mobile-list-toggle { display: none; align-items: center; justify-content: center; gap: 6px; padding: 0; height: 28px; background: #292e42; border-bottom: 1px solid #3b4261; cursor: pointer; user-select: none; font-size: 11px; color: #7aa2f7; flex-shrink: 0; -webkit-tap-highlight-color: transparent; }
.mobile-list-toggle:active { background: #3b4261; }
.mobile-list-toggle .toggle-arrow { font-size: 8px; transition: transform 0.2s; display: inline-block; line-height: 1; }
.mobile-list-toggle .toggle-arrow.open { transform: none; }
.mobile-list-toggle .toggle-label { font-weight: 600; letter-spacing: 0.3px; }

/* ── Header (always visible) ── */
#mobile-header {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px;
  background: #1a1b26; border-bottom: 1px solid #3b4261;
  flex-shrink: 0;
}
#mobile-menu-btn {
  background: none; border: none; color: #a9b1d6; font-size: 20px;
  cursor: pointer; padding: 4px 6px; line-height: 1;
}
#mobile-menu-btn:hover { color: #7aa2f7; }
#mobile-menu-btn:active { color: #7aa2f7; }
#mobile-title { color: #565f89; font-size: 12px; font-weight: 600; letter-spacing: 0.5px; flex: 1; }
#mobile-pad-btn {
  background: none; border: none; color: #a9b1d6; font-size: 18px;
  cursor: pointer; padding: 4px 6px; line-height: 1;
}
#mobile-pad-btn:active { color: #7aa2f7; }
#sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; }

/* ── Mobile overlay sidebar ── */
@media (max-width: 768px) {
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 100;
    transform: translateX(-100%); transition: transform 0.2s ease;
  }
  #sidebar.collapsed { width: 280px; border-right-color: #3b4261; }
  #sidebar.open { transform: translateX(0); }
  #sidebar-backdrop.open { display: block; }
  .session-item { padding: 11px 10px; }
}
@media (max-width: 768px) {
  #files-panel.layout-h, #files-panel.layout-v { flex-direction: column; }
  .file-tree { width: 100% !important; height: 75% !important; min-width: unset !important; min-height: unset !important; border-right: none !important; border-bottom: 1px solid #3b4261 !important; }
  .resizer { display: none; }
  #layout-toggle-btn { display: none; }
  .file-tree { transition: height 0.2s ease; }
  .file-tree.collapsed { height: 0 !important; min-height: 0 !important; border-bottom: none !important; overflow: hidden; }
  .mobile-list-toggle { display: flex !important; }
  .file-header { flex-wrap: wrap; padding: 6px 8px; gap: 4px; }
  .file-header-info { flex-basis: 100%; order: 1; }
  .file-header-actions { order: 2; margin-left: auto; }
  .file-action-btn { min-height: 32px; padding: 6px 12px; font-size: 12px; }
}
