:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --text: #111827;
    --muted: #5b6472;
    --line: #d7dce3;
    --accent: #0f766e;
    --accent-dark: #115e59;
    --danger: #b42318;
    --danger-bg: #fff1ef;
    --ok: #1f7a3b;
    --ok-bg: #e8f7ed;
    --wait: #8a5a00;
    --wait-bg: #fff7db;
    --system-bg: #fff4df;
    --system-line: #e6b96f;
    --llm-bg: #e8f4ff;
    --llm-line: #8cc4ef;
    --shadow: 0 10px 28px rgb(15 23 42 / 7%);
}

* {
    box-sizing: border-box;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family:
        Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
    line-height: 1.5;
    margin: 0;
    overflow-x: hidden;
}

a {
    color: var(--accent-dark);
}

.topbar {
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 56px;
    padding: 8px clamp(14px, 4vw, 28px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-main {
    align-items: center;
    display: flex;
    gap: 14px;
    min-height: 40px;
    width: 100%;
}

.brand {
    color: var(--text);
    font-size: 18px;
    font-weight: 750;
    text-decoration: none;
}

.topbar-status-box {
    align-items: center;
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.topbar-status-box[hidden] {
    display: none;
}

.session-page-tabs {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    width: 100%;
}

.session-page-tabs[hidden] {
    display: none;
}

.session-page-tabs-track {
    display: flex;
    gap: 8px;
    min-width: max-content;
    padding: 2px 0 5px;
}

.session-page-tab {
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    display: inline-flex;
    font-size: 14px;
    font-weight: 700;
    height: 36px;
    justify-content: center;
    min-width: 40px;
    padding: 0 11px;
    width: auto;
}

.session-page-tab:hover:not(:disabled) {
    background: #ecfdf5;
    border-color: var(--accent);
}

.session-page-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.session-page-tab:disabled {
    background: #f1f3f5;
    border-color: #e1e5ea;
    color: #9aa2ad;
    cursor: not-allowed;
}

.status-chip {
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 999px;
    display: inline-flex;
    gap: 5px;
    max-width: 100%;
    min-width: 0;
    padding: 4px 9px;
}

.status-chip span {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.status-chip strong {
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-shell {
    margin: 0 auto;
    max-width: 1040px;
    padding: clamp(14px, 3vw, 28px);
    width: 100%;
}

.panel,
.step-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin: 0 0 16px;
    padding: clamp(16px, 2.6vw, 24px);
    width: 100%;
}

.step-card.system,
.card.system {
    background: var(--system-bg);
    border-color: var(--system-line);
}

.step-card.llm,
.card.llm {
    background: var(--llm-bg);
    border-color: var(--llm-line);
}

.hero-panel {
    align-items: flex-start;
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
}

.kicker {
    color: var(--accent-dark);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    margin: 0 0 8px;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    letter-spacing: 0;
    margin: 0;
}

h1 {
    font-size: clamp(25px, 4vw, 34px);
    line-height: 1.18;
}

h2 {
    font-size: 20px;
    line-height: 1.25;
}

h3 {
    font-size: 16px;
}

.lead {
    color: var(--muted);
    margin: 10px 0 0;
    max-width: 760px;
}

.status-box {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.status-box[hidden] {
    display: none;
}

.status-row {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin: 4px 0;
}

.status-row span:first-child {
    color: var(--muted);
}

.single-action {
    align-items: flex-start;
    display: flex;
}

.panel-head {
    align-items: flex-start;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 14px;
}

.form-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid .wide,
.wide {
    grid-column: 1 / -1;
}

label {
    color: var(--muted);
    display: grid;
    font-size: 13px;
    gap: 6px;
}

label span {
    color: var(--text);
}

input,
select,
textarea {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 38px;
    padding: 8px 10px;
    width: 100%;
}

input[readonly] {
    background: #f8fafc;
    color: #334155;
}

input::placeholder,
textarea::placeholder {
    color: #a7afb9;
    opacity: 1;
}

input:hover::placeholder,
textarea:hover::placeholder,
input:focus::placeholder,
textarea:focus::placeholder {
    opacity: 0;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

button,
.button-link {
    align-items: center;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 650;
    justify-content: center;
    min-height: 38px;
    padding: 8px 12px;
    text-decoration: none;
}

button:hover,
.button-link:hover {
    background: var(--accent-dark);
}

button:disabled,
button:disabled:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
    color: #6b7280;
    cursor: not-allowed;
}

.ghost-button {
    background: #ffffff;
    border-color: var(--line);
    color: var(--text);
}

.ghost-button:hover {
    background: #f8fafc;
}

.danger-button {
    background: var(--danger);
    border-color: var(--danger);
}

.saved-indicator {
    align-items: center;
    color: var(--muted);
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 12px;
    gap: 6px;
    justify-content: flex-end;
    min-height: 24px;
}

.saved-indicator input {
    min-height: auto;
    width: auto;
}

.content-box {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 14px;
    padding: 14px 16px;
}

.content-box h3 {
    margin-bottom: 10px;
}

.content-box p,
.content-box ol {
    margin-bottom: 10px;
    margin-top: 0;
}

.emotion-list {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin: 12px 0;
}

.emotion-list label {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    padding: 12px;
}

.question-list {
    display: grid;
    gap: 12px;
    margin: 12px 0;
}

.question-item {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    padding: 12px;
}

.question-group {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 12px;
}

.question-group legend {
    color: var(--text);
    font-weight: 700;
    padding: 0 6px;
}

.option-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding-left: 20px;
}

.option-list li {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}

.option-list p {
    margin-bottom: 0;
}

.inline-details,
.debug-details {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 14px 0;
    padding: 12px;
}

.debug-details {
    margin-top: 22px;
}

.inline-details summary,
.debug-details summary {
    cursor: pointer;
    font-weight: 650;
}

.notice {
    border-radius: 8px;
    margin: 10px 0 12px;
    padding: 10px 12px;
}

.notice.ok {
    background: var(--ok-bg);
    color: var(--ok);
}

.notice.error {
    background: var(--danger-bg);
    color: var(--danger);
}

.notice.wait {
    background: var(--wait-bg);
    color: var(--wait);
}

.table-like {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 12px 0;
    overflow: hidden;
}

.table-row {
    display: grid;
    gap: 10px;
    grid-template-columns: 180px minmax(0, 1fr);
    padding: 10px 12px;
}

.table-row:nth-child(odd) {
    background: #f8fafc;
}

.json-block,
.event-log {
    background: #0f172a;
    border-radius: 8px;
    color: #e2e8f0;
    overflow: auto;
    padding: 12px;
    white-space: pre-wrap;
}

.event-log {
    min-height: 120px;
}

.session-list {
    display: grid;
    gap: 12px;
}

.session-row {
    align-items: stretch;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
}

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

.text-report {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 14px;
    padding-top: 14px;
}

.report-section {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.report-section h4,
.report-section h5 {
    margin: 0 0 8px;
}

.report-subsection {
    margin-top: 10px;
}

.report-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding-left: 20px;
}

.report-list li {
    padding-left: 2px;
}

.small {
    color: var(--muted);
    font-size: 13px;
}

.hidden {
    display: none;
}

@media (max-width: 760px) {
    .topbar {
        gap: 8px;
        min-height: 52px;
    }

    .topbar-main {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .topbar-status-box {
        width: 100%;
    }

    .status-chip {
        max-width: 100%;
    }

    .hero-panel,
    .form-grid,
    .emotion-list {
        grid-template-columns: 1fr;
    }

    .panel-head,
    .session-row-head,
    .session-row {
        align-items: stretch;
        flex-direction: column;
    }

    .button-row,
    .single-action {
        align-items: stretch;
        flex-direction: column;
    }

    button,
    .button-link {
        width: 100%;
    }

    .session-page-tab {
        width: auto;
    }

    .table-row {
        grid-template-columns: 1fr;
    }
}
