/* Web App layout — PWA / remote web UI shell */

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    font-family: var(--font-family);
    font-size: var(--font-size);
}

/* ── Offline banner ────────────────────────────────────────────────────── */

#ab-offline {
    display: none;
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    background: var(--error);
    color: #fff;
    text-align: center;
    padding: 4px 8px;
    font-size: .85em;
    z-index: 200;
}

#ab-offline.visible {
    display: block;
}

/* ── Header ────────────────────────────────────────────────────────────── */

#ab-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--fg-a16);
    background: var(--bg);
    min-height: 36px;
}

#ab-title {
    font-weight: 600;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#ab-model {
    font-size: .82em;
    color: var(--fg-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

#ab-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--fg-a16);
    flex: 0 0 8px;
    transition: background .3s;
}

#ab-status.connected {
    background: var(--kind-execute);
}

#ab-status.running {
    background: var(--agent);
    animation: ab-pulse 1.5s infinite;
}

@keyframes ab-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: .35;
    }
}

/* ── Chat area ─────────────────────────────────────────────────────────── */

#ab-chat {
    flex: 1;
    height: 100%;
    overflow: hidden;
    position: relative;
}

chat-container {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px 8px;
    box-sizing: border-box;
}

/* ── Footer / input ────────────────────────────────────────────────────── */

#ab-footer {
    flex: 0 0 auto;
    border-top: 1px solid var(--fg-a16);
    display: flex;
    align-items: flex-end;
    background: var(--bg);
}

#ab-input {
    flex: 1;
    border: 0;
    background: var(--fg-a05);
    color: var(--fg);
    padding: 6px 8px;
    font: inherit;
    resize: none;
    min-height: 36px;
    max-height: 160px;
    overflow-y: auto;
    outline: none;
}

#ab-send {
    border: none;
    padding: 6px 10px;
    cursor: pointer;
    font: inherit;
    background: var(--user-a12);
    color: var(--user);
    font-size: .88em;
    white-space: nowrap;
    height: 100%;
    display: flex;
    align-items: center;
}

#ab-send:hover {
    background: var(--user-a16);
}

#ab-nudge {
    border: none;
    border-radius: var(--r-md);
    padding: 6px 10px;
    cursor: pointer;
    font: inherit;
    background: var(--tool-a08);
    color: var(--tool);
    font-size: .88em;
    white-space: nowrap;
}

#ab-nudge:hover {
    background: var(--tool-a16);
}

#ab-send:disabled,
#ab-nudge:disabled {
    opacity: .38;
    cursor: default;
}

/* Disable tool chip clicks in web context */
tool-chip {
    pointer-events: none;
}

tool-chip .chip-expand {
    display: none;
}

/* ── Settings pane ──────────────────────────────────────────────────────── */

.ab-settings-scroll {
    overflow-y: auto;
    height: 100%;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
}

#ab-connect-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: min(360px, 90vw);
    max-height: 600px;
}

.ab-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--fg-a16);
    border-radius: 10px;
    padding: 16px;
}

.ab-card-header {
    font-weight: 600;
    font-size: 1em;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ab-card-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ab-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ab-status-label {
    font-size: .85em;
    color: var(--fg-muted);
    min-width: 60px;
}

.ab-status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.ab-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--fg-a16);
    flex: 0 0 10px;
    transition: background .3s;
}

.ab-status-dot.connected {
    background: var(--kind-execute);
}

.ab-status-dot.running {
    background: var(--agent);
    animation: ab-pulse 1.5s infinite;
}

#ab-mcp-text {
    font-size: .9em;
    color: var(--fg);
}

.ab-card-stop-btn {
    border: none;
    background: transparent;
    color: var(--error, #e06c75);
    cursor: pointer;
    font-size: .95em;
    padding: 4px 8px;
    border-radius: 4px;
    flex: 0 0 auto;
}

.ab-card-stop-btn:hover {
    background: var(--fg-a08);
}

#ab-connect-profile {
    background: var(--fg-a05);
    color: var(--fg);
    border: 1px solid var(--fg-a16);
    border-radius: 6px;
    padding: 7px 10px;
    font: inherit;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}

#ab-connect-profile:focus {
    outline: 1px solid var(--user);
}

#ab-connect-btn {
    border: none;
    border-radius: 6px;
    padding: 9px 16px;
    background: var(--user-a12);
    color: var(--user);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    font-size: .95em;
    width: 100%;
}

#ab-connect-btn:hover {
    background: var(--user-a16);
}

#ab-connect-btn:disabled {
    opacity: .4;
    cursor: default;
}

#ab-connect-status {
    font-size: .85em;
    color: var(--fg-muted);
    min-height: 1.2em;
}

#ab-connect-status.error {
    color: var(--error);
}

.ab-settings-select {
    width: 100%;
    background: var(--fg-a05);
    color: var(--fg);
    border: 1px solid var(--fg-a16);
    border-radius: 6px;
    padding: 7px 10px;
    font: inherit;
    cursor: pointer;
    box-sizing: border-box;
}

.ab-settings-select:focus {
    outline: 1px solid var(--user);
}

.ab-settings-hint {
    font-size: .82em;
    color: var(--fg-muted);
    min-height: 1.2em;
}

.ab-settings-actions {
    gap: 8px;
}

.ab-btn-danger {
    display: block;
    width: 100%;
    border: none;
    border-radius: 6px;
    padding: 9px 16px;
    background: transparent;
    color: var(--error, #e06c75);
    cursor: pointer;
    font: inherit;
    font-size: .9em;
    text-align: left;
}

.ab-btn-danger:hover {
    background: var(--fg-a08);
}

.ab-btn-secondary {
    display: block;
    width: 100%;
    border: none;
    border-radius: 6px;
    padding: 9px 16px;
    background: var(--fg-a05);
    color: var(--fg);
    cursor: pointer;
    font: inherit;
    font-size: .9em;
    text-align: center;
}

.ab-btn-secondary:hover {
    background: var(--fg-a08);
}

/* ── Scroll-to-bottom FAB ───────────────────────────────────────────────── */

#ab-scroll-fab {
    position: absolute;
    bottom: 10px;
    right: 14px;
    z-index: 20;
    border: none;
    border-radius: 20px;
    background: var(--user-a12);
    color: var(--user);
    padding: 5px 12px;
    cursor: pointer;
    font: inherit;
    font-size: .88em;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
    transition: opacity .15s, background .15s;
}

#ab-scroll-fab:hover {
    background: var(--user-a16);
}

/* ── Empty-state placeholder ────────────────────────────────────────────── */

#messages:empty::after {
    content: 'Ask Copilot something…';
    display: block;
    text-align: center;
    color: var(--fg-muted);
    font-size: .95em;
    margin-top: 40px;
    pointer-events: none;
}

/* ── Pane Swiper ────────────────────────────────────────────────────────── */

pane-swiper {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ── Tab bar ── */

.ps-tab-bar {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    background: var(--bg-secondary, transparent);
    z-index: 10;
    flex-shrink: 0;
}

.ps-tab-bar::-webkit-scrollbar {
    display: none;
}

.ps-tab {
    all: unset;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--fg-muted, rgba(255, 255, 255, 0.5));
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.ps-tab:hover {
    color: var(--fg, #e6edf3);
}

.ps-tab.active {
    color: var(--user, #79c0ff);
    border-bottom-color: var(--user, #79c0ff);
}

/* ── Track & panes ── */

.ps-track {
    display: flex;
    flex: 1;
    min-height: 0;
    will-change: transform;
}

.ps-pane {
    height: 100%;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

/* ── Dot indicator ── */

.ps-dots {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 10;
    pointer-events: auto;
}

.ps-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--fg-a16);
    cursor: pointer;
    transition: background .2s;
}

.ps-dot.active {
    background: var(--user, #79c0ff);
}

/* ── File Viewer ───────────────────────────────────────────────────────── */

file-viewer {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.fv-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.fv-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-bottom: 1px solid var(--fg-a08);
    min-height: 28px;
    font-size: .82em;
    color: var(--fg-muted);
}

.fv-path {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

.fv-copy-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: .9em;
    padding: 2px 4px;
    border-radius: 3px;
    color: var(--fg-muted);
}

.fv-copy-btn:hover {
    background: var(--fg-a08);
}

.fv-content-area {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.fv-content {
    position: absolute;
    inset: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg);
}

.fv-fab {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--accent, #0d6efd);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: transform .12s ease, box-shadow .12s ease;
}

.fv-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .45);
}

.fv-fab:active {
    transform: scale(.96);
}

.fv-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--fg-muted);
    padding: 24px;
}

.fv-empty-icon {
    font-size: 2.4em;
    opacity: .5;
}

.fv-empty-title {
    font-size: 1.05em;
    font-weight: 600;
}

.fv-empty-hint {
    font-size: .85em;
    text-align: center;
    max-width: 260px;
}

.fv-recent-list {
    margin-top: 12px;
    width: 100%;
    max-width: 300px;
}

.fv-recent-title {
    font-size: .78em;
    color: var(--fg-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.fv-recent-item {
    display: flex;
    flex-direction: column;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    gap: 1px;
}

.fv-recent-item:hover {
    background: var(--fg-a08);
}

.fv-recent-name {
    font-size: .88em;
    color: var(--fg);
}

.fv-recent-path {
    font-size: .75em;
    color: var(--fg-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Code display ──────────────────────────────────────────────────────── */

.fv-code-wrap {
    display: flex;
    min-height: 100%;
}

.fv-gutter {
    flex: 0 0 auto;
    padding: 8px 8px 8px 12px;
    text-align: right;
    color: var(--fg-muted);
    opacity: .5;
    user-select: none;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: .82em;
    line-height: 1.55;
    margin: 0;
    border-right: 1px solid var(--fg-a08);
}

.fv-code {
    flex: 1;
    padding: 8px 12px;
    margin: 0;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: .82em;
    line-height: 1.55;
    overflow-x: auto;
    tab-size: 4;
}

.fv-code code {
    font: inherit;
}

.fv-line-highlight {
    position: absolute;
    left: 0;
    right: 0;
    background: var(--user-a12);
    pointer-events: none;
    animation: fv-highlight-fade 2s forwards;
}

@keyframes fv-highlight-fade {
    0% {
        opacity: 1;
    }
    70% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* ── Markdown display ──────────────────────────────────────────────────── */

.fv-markdown {
    padding: 12px 16px;
    line-height: 1.6;
}

.fv-markdown h1,
.fv-markdown h2,
.fv-markdown h3 {
    margin-top: 1.2em;
    margin-bottom: .5em;
}

.fv-markdown pre {
    background: var(--fg-a05);
    border-radius: 6px;
    padding: 10px 12px;
    overflow-x: auto;
}

.fv-markdown code {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: .88em;
}

.fv-markdown blockquote {
    border-left: 3px solid var(--fg-a16);
    margin: .8em 0;
    padding: .4em .8em;
    color: var(--fg-muted);
}

/* ── File Nav ──────────────────────────────────────────────────────────── */

file-nav {
    display: block;
    position: relative;
}

.fn-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--fg-a08);
    min-height: 32px;
}

.fn-toggle {
    border: none;
    background: transparent;
    color: var(--fg-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
}

.fn-toggle:hover {
    background: var(--fg-a08);
    color: var(--fg);
}

.fn-breadcrumb {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: .82em;
    color: var(--fg-muted);
    display: flex;
    align-items: center;
    gap: 2px;
}

.fn-sep {
    color: var(--fg-a16);
    margin: 0 1px;
}

.fn-crumb {
    color: var(--fg-muted);
}

.fn-clickable {
    cursor: pointer;
    color: var(--user, #79c0ff);
}

.fn-clickable:hover {
    text-decoration: underline;
}

.fn-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 50;
    background: var(--bg);
    border-bottom: 1px solid var(--fg-a16);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
    max-height: 60vh;
    display: none;
    flex-direction: column;
}

.fn-dropdown.fn-open {
    display: flex;
}

.fn-search-row {
    padding: 6px 8px;
    border-bottom: 1px solid var(--fg-a08);
}

.fn-search {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--fg-a16);
    background: var(--fg-a05);
    color: var(--fg);
    padding: 4px 8px;
    border-radius: 4px;
    font: inherit;
    font-size: .85em;
    outline: none;
}

.fn-search:focus {
    border-color: var(--user, #79c0ff);
}

.fn-list {
    overflow-y: auto;
    flex: 1;
    padding: 4px 0;
}

.fn-entry {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    cursor: pointer;
    font-size: .88em;
}

.fn-entry:hover {
    background: var(--fg-a08);
}

.fn-icon {
    flex: 0 0 auto;
    font-size: .9em;
}

.fn-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fn-dir .fn-name {
    color: var(--fg);
    font-weight: 500;
}

.fn-file .fn-name {
    color: var(--fg-muted);
}

.fn-loading, .fn-error {
    padding: 12px;
    text-align: center;
    font-size: .85em;
    color: var(--fg-muted);
}

.fn-error {
    color: var(--error, #e06c75);
}

/* ── Syntax highlighting theme ─────────────────────────────────────────── */

.sh-kw {
    color: var(--sh-keyword, #c678dd);
}

.sh-str {
    color: var(--sh-string, #98c379);
}

.sh-cmt {
    color: var(--sh-comment, #5c6370);
    font-style: italic;
}

.sh-num {
    color: var(--sh-number, #d19a66);
}

.sh-pun {
    color: var(--fg-muted);
}

.sh-tag {
    color: var(--sh-tag, #e06c75);
}

.sh-attr {
    color: var(--sh-attr, #d19a66);
}

.sh-key {
    color: var(--sh-key, #e06c75);
}

.sh-prop {
    color: var(--sh-prop, #61afef);
}

.light .sh-kw {
    color: var(--sh-keyword, #a626a4);
}

.light .sh-str {
    color: var(--sh-string, #50a14f);
}

.light .sh-cmt {
    color: var(--sh-comment, #a0a1a7);
    font-style: italic;
}

.light .sh-num {
    color: var(--sh-number, #986801);
}

.light .sh-tag {
    color: var(--sh-tag, #e45649);
}

.light .sh-attr {
    color: var(--sh-attr, #986801);
}

.light .sh-key {
    color: var(--sh-key, #e45649);
}

.light .sh-prop {
    color: var(--sh-prop, #4078f2);
}

/* ── Narrow-screen header ───────────────────────────────────────────────── */

@media (max-width: 480px) {
    #ab-model {
        display: none;
    }
}

/* ── Review View ───────────────────────────────────────── */
.rv-container {
    padding: 12px;
    height: 100%;
    overflow-y: auto;
}

.rv-empty {
    color: var(--muted);
    text-align: center;
    padding: 40px 16px;
}

.rv-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.rv-status {
    font-weight: bold;
    width: 16px;
    text-align: center;
}

.rv-added .rv-status {
    color: var(--green, #2ea043);
}

.rv-modified .rv-status {
    color: var(--blue, #388bfd);
}

.rv-deleted .rv-status {
    color: var(--muted);
}

.rv-path {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rv-dir {
    color: var(--muted);
}

.rv-diff {
    display: flex;
    gap: 6px;
    font-size: 12px;
    font-family: monospace;
}

.rv-add {
    color: var(--green, #2ea043);
}

.rv-rem {
    color: var(--red, #f85149);
}

.rv-check {
    color: var(--green, #2ea043);
    font-weight: bold;
}

.rv-approved {
    opacity: 0.7;
}

/* ── Todo View ─────────────────────────────────────────── */
.tv-container {
    padding: 12px;
    height: 100%;
    overflow-y: auto;
}

.tv-empty {
    color: var(--muted);
    text-align: center;
    padding: 40px 16px;
}

.tv-content {
    line-height: 1.5;
}

.tv-content h1, .tv-content h2, .tv-content h3 {
    margin: 16px 0 8px;
}

.tv-content h1 {
    font-size: 20px;
}

.tv-content h2 {
    font-size: 17px;
}

.tv-content h3 {
    font-size: 15px;
}

.tv-content pre {
    background: var(--input-bg, #161b22);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 13px;
    margin: 8px 0;
}

.tv-content code {
    font-size: 13px;
}

.tv-content p {
    margin: 4px 0;
}

.tv-check {
    padding: 2px 0;
}

.tv-done {
    color: var(--muted);
    text-decoration: line-through;
}

.tv-pending {
    /* no special styling — present for JS class-toggling */
    display: block;
}

.tv-li {
    padding: 2px 0 2px 8px;
}

.tv-section {
    margin-bottom: 18px;
}

.tv-section h2 {
    font-size: 14px;
    margin: 0 0 8px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tv-db-summary {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 8px;
}

.tv-db-item {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) 24px;
    gap: 8px;
    align-items: start;
    padding: 8px;
    border: 1px solid var(--border, #30363d);
    border-radius: 8px;
    background: var(--input-bg, #161b22);
    margin-bottom: 6px;
}

.tv-status-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-weight: bold;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    color: var(--muted);
    border-radius: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tv-status-btn:hover {
    background: var(--hover-bg, rgba(255, 255, 255, .08));
}

.tv-db-item.in_progress .tv-status-btn {
    color: var(--blue, #388bfd);
}

.tv-db-item.done .tv-status-btn {
    color: var(--green, #2ea043);
}

.tv-db-item.blocked .tv-status-btn {
    color: var(--red, #f85149);
}

.tv-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 12px;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.tv-db-item:hover .tv-delete-btn {
    opacity: 1;
}

.tv-delete-btn:hover {
    color: var(--red, #f85149);
    background: var(--hover-bg, rgba(255, 255, 255, .08));
}

.tv-db-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.tv-db-header h2 {
    margin: 0;
}

.tv-add-btn {
    background: none;
    border: 1px solid var(--border, #30363d);
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tv-add-btn:hover {
    color: var(--fg);
    border-color: var(--fg);
}

.tv-add-form {
    background: var(--input-bg, #161b22);
    border: 1px solid var(--border, #30363d);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tv-hidden {
    display: none !important;
}

.tv-input {
    background: var(--bg, #0d1117);
    border: 1px solid var(--border, #30363d);
    border-radius: 6px;
    color: var(--fg);
    padding: 5px 8px;
    font-size: 13px;
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
}

.tv-input:focus {
    outline: none;
    border-color: var(--blue, #388bfd);
}

.tv-form-actions {
    display: flex;
    gap: 6px;
}

.tv-btn {
    background: var(--input-bg, #161b22);
    border: 1px solid var(--border, #30363d);
    color: var(--fg);
    border-radius: 6px;
    padding: 4px 12px;
    font-size: 13px;
    cursor: pointer;
}

.tv-btn-primary {
    background: var(--blue, #2563eb);
    border-color: var(--blue, #2563eb);
    color: #fff;
}

.tv-btn:hover {
    opacity: 0.85;
}

.tv-db-main {
    min-width: 0;
}

.tv-db-title {
    display: block;
    overflow-wrap: anywhere;
}

.tv-db-desc {
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
    overflow-wrap: anywhere;
}

.tv-db-id {
    color: var(--muted);
    font-size: 11px;
    font-style: italic;
}

/* ── Tool Calls View ───────────────────────────────────── */
.tcv-container,
.pv-container {
    padding: var(--sp-8, 16px);
    box-sizing: border-box;
    height: 100%;
    overflow-y: auto;
}

.tcv-empty,
.pv-empty {
    color: var(--muted);
    text-align: center;
    padding: 40px 16px;
}

.tcv-item {
    /* Uses turn-chip/tool/kind-* CSS classes for color scheme (see chat.css).
       Override to full-width flex row matching chat chip height. */
    display: flex !important;
    width: 100%;
    box-sizing: border-box;
    white-space: normal;
    border-radius: var(--r-sm, 3px);
    margin-bottom: var(--sp-2, 4px);
    cursor: pointer;
    flex-wrap: wrap;
}

.tcv-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--font-size, 11pt);
}

.tcv-time {
    color: var(--muted);
    font-size: 0.78em;
    margin-top: 3px;
}

.tcv-time-sep {
    text-align: center;
    font-size: 0.72em;
    color: var(--muted);
    opacity: 0.5;
    margin: 4px 0 2px;
    letter-spacing: 0.05em;
    user-select: none;
}

.tcv-load-more {
    text-align: center;
    font-size: 0.78em;
    color: var(--link);
    cursor: pointer;
    padding: 6px 0;
    user-select: none;
    opacity: 0.8;
}
.tcv-load-more:hover { opacity: 1; text-decoration: underline; }
.tcv-load-more[hidden] { display: none; }

.tcv-detail {
    flex-basis: 100%;
    margin-top: var(--sp-4, 8px);
}

/* ── Metadata summary row shown at the top of every expanded chip ── */

.tcv-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-bottom: var(--sp-4, 8px);
    font-size: 0.8em;
}

.tcv-meta-item {
    color: var(--muted);
}

.tcv-meta-item strong {
    color: var(--fg, #c9d1d9);
}

.tcv-meta-ts {
    opacity: 0.6;
}

.tcv-label {
    color: var(--muted);
    font-size: 0.78em;
    font-weight: 700;
    margin: var(--sp-4, 8px) 0 var(--sp-2, 4px);
    text-transform: uppercase;
}

.tcv-diff-btn {
    background: none;
    border: 1px solid var(--muted);
    border-radius: 3px;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.75em;
    padding: 1px 5px;
    vertical-align: middle;
}

.tcv-diff-btn:hover {
    border-color: var(--fg);
    color: var(--fg);
}

.tcv-detail pre {
    max-height: 160px;
    overflow: auto;
    background: var(--bg, #0d1117);
    color: var(--fg, #c9d1d9);
    border-radius: 6px;
    padding: var(--sp-4, 8px);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: var(--code-font, monospace);
    font-size: var(--code-font-size, 11pt);
}

.tcv-detail pre code {
    font: inherit;
}

.tcv-duration {
    color: currentColor;
    font-size: 0.82em;
    opacity: 0.65;
    white-space: nowrap;
}

.tcv-expanded {
    border-color: var(--accent, #58a6ff);
}

/* ── Pipeline visualization ─────────────────────────── */

.tcv-pipeline {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 8px 0;
    overflow-x: auto;
    flex-wrap: wrap;
    row-gap: 4px;
}

.tcv-pipe-node {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.78em;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border, #30363d);
    background: var(--input-bg, #161b22);
    white-space: nowrap;
    transition: border-color 0.15s, background 0.15s;
}

.tcv-pipe-node:hover {
    border-color: var(--accent, #58a6ff);
}

.tcv-pipe-selected {
    border-color: var(--accent, #58a6ff);
    background: color-mix(in srgb, var(--accent, #58a6ff) 15%, transparent);
}

.tcv-pipe-connector {
    color: var(--muted);
    font-size: 0.85em;
    padding: 0 4px;
    user-select: none;
}

.tcv-pipe-success .tcv-pipe-label {
    color: var(--green, #2ea043);
}

.tcv-pipe-warning .tcv-pipe-label {
    color: var(--tool-edit, #cd9b5f);
}

.tcv-pipe-error .tcv-pipe-label {
    color: var(--red, #f85149);
}

.tcv-pipe-neutral .tcv-pipe-label {
    color: var(--fg, #c9d1d9);
}

.tcv-pipe-running .tcv-pipe-label {
    color: var(--accent, #58a6ff);
}

/* ── Stage detail panel ─────────────────────────────── */

.tcv-stage-detail {
    margin-top: 8px;
    border: 1px solid var(--border, #30363d);
    border-radius: 6px;
    padding: 8px;
    background: var(--bg, #0d1117);
}

.tcv-stage-meta {
    display: flex;
    gap: 16px;
    font-size: 0.85em;
    color: var(--muted);
    margin: 4px 0;
}

.tcv-stage-meta strong {
    color: var(--fg, #c9d1d9);
}

.tcv-stage-detail pre {
    max-height: 160px;
    overflow: auto;
    background: var(--input-bg, #161b22);
    color: var(--fg, #c9d1d9);
    border-radius: 6px;
    padding: var(--sp-4, 8px);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: var(--code-font, monospace);
    font-size: var(--code-font-size, 11pt);
}

.tcv-stage-detail pre code {
    font: inherit;
}

/* ── I/O sections in detail view ───────────────────── */

.tcv-io {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

@media (max-width: 600px) {
    .tcv-io {
        grid-template-columns: 1fr;
    }
}

/* ── JSON syntax highlighting in tool call detail panels ── */
.tcv-detail .sh-key, .tcv-stage-detail .sh-key {
    color: var(--tool-read, #64b9b9);
}

.tcv-detail .sh-str, .tcv-stage-detail .sh-str {
    color: var(--tool-execute, #82be82);
}

.tcv-detail .sh-num, .tcv-stage-detail .sh-num {
    color: var(--link, #58a6ff);
}

.tcv-detail .sh-kw, .tcv-stage-detail .sh-kw {
    color: var(--tool-edit, #cd9b5f);
}

.tcv-detail .sh-cmt, .tcv-stage-detail .sh-cmt {
    color: var(--muted, #8b949e);
}

.tcv-detail .sh-attr, .tcv-stage-detail .sh-attr {
    color: var(--tool-edit, #cd9b5f);
}

.tcv-detail .sh-tag, .tcv-stage-detail .sh-tag {
    color: var(--tool-read, #64b9b9);
}

.tcv-detail .sh-pun, .tcv-stage-detail .sh-pun {
    color: var(--muted, #8b949e);
}

/* ── Prompt Search View ────────────────────────────────── */
.pv-search {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border, #30363d);
    border-radius: 8px;
    background: var(--input-bg, #161b22);
    color: var(--fg, #e6edf3);
    padding: 8px 10px;
    margin-bottom: 10px;
}

.pv-item {
    all: unset;
    box-sizing: border-box;
    display: block;
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
}

.pv-item:hover {
    background: var(--input-bg, #161b22);
    border-color: var(--border, #30363d);
}

.pv-time {
    display: block;
    color: var(--muted);
    font-size: 11px;
    margin-bottom: 3px;
}

.pv-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

/* ── Session View ──────────────────────────────────────── */
.sv-container {
    padding: 12px;
    height: 100%;
    overflow-y: auto;
}

.sv-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sv-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--input-bg, #161b22);
    border-radius: 8px;
}

.sv-dot {
    font-size: 16px;
}

.sv-label {
    font-weight: 600;
}

.sv-key {
    color: var(--muted);
    min-width: 80px;
}

.sv-val {
    /* inherits default text color — present for JS class-toggling */
    display: inline;
}

.sv-offline {
    opacity: 0.6;
}
