:root {
    color-scheme: light;
    --ink: #182026;
    --muted: #64727d;
    --line: #dce4e8;
    --brand: #16232e;
    --accent: #2f8f6b;
    --danger: #b42318;
    --surface: #ffffff;
    --page: #f4f7f8;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--page);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
    width: min(980px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.logo {
    width: min(360px, 70vw);
    height: auto;
    display: block;
}

.logout,
.mainnav a {
    color: var(--brand);
    font-weight: 700;
    text-decoration: none;
}

.mainnav {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.login-panel,
.chat-panel,
.result,
.progress-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
}

.login-panel {
    max-width: 460px;
    margin: 48px auto 0;
}

h1,
h2,
p {
    margin-top: 0;
}

p {
    color: var(--muted);
}

label {
    display: grid;
    gap: 8px;
    font-weight: 700;
    margin-bottom: 18px;
}

label.field-muted {
    color: var(--muted);
    opacity: .55;
}

label.field-muted input,
label.field-muted select,
label.field-muted textarea {
    background: #f3f6f7;
    color: var(--muted);
    border-color: #d8e0e4;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #b8c4ca;
    border-radius: 6px;
    padding: 12px 13px;
    font: inherit;
    background: white;
    color: var(--ink);
}

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

button {
    border: 0;
    border-radius: 6px;
    background: var(--brand);
    color: white;
    font: inherit;
    font-weight: 800;
    padding: 13px 18px;
    cursor: pointer;
}

button:disabled {
    opacity: .65;
    cursor: wait;
}

.secondary-button,
.retry-button {
    background: #eef3f5;
    color: var(--brand);
    border: 1px solid var(--line);
}

.heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.status-dot {
    flex: 0 0 auto;
    background: #dff7e8;
    color: #126b39;
    border-radius: 999px;
    padding: 7px 11px;
    font-weight: 800;
}

.form-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(220px, .8fr);
    gap: 18px;
    align-items: end;
}

.form-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.feature-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 22px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
}

.feature-tab {
    border: 1px solid var(--line);
    background: #fbfcfc;
    color: var(--brand);
    padding: 10px 12px;
    font-weight: 800;
}

.feature-tab.active {
    background: var(--brand);
    color: white;
    border-color: var(--brand);
}

.feature-panel {
    display: none;
}

.feature-panel.active {
    display: block;
}

.tool-intro {
    margin-bottom: 16px;
}

.tool-intro h2 {
    margin-bottom: 6px;
}

.sample-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: -2px 0 14px;
}

.sample-button {
    background: #eef3f5;
    color: var(--brand);
    border: 1px solid var(--line);
    padding: 9px 11px;
    font-weight: 800;
}

.queue-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 16px 0 20px;
}

.collapsible-section {
    margin-top: 22px;
}

.collapsible-section > summary {
    cursor: pointer;
    color: var(--brand);
    font-size: 1.25rem;
    font-weight: 900;
    margin-bottom: 12px;
}

.collapsible-section[open] > summary {
    margin-bottom: 14px;
}

.queue-panel {
    display: none;
}

.queue-panel.active {
    display: block;
}

.archive-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.archive-pager {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.archive-pager span {
    color: var(--muted);
    font-weight: 800;
}

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

.queue-job {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfc;
    padding: 0;
}

.queue-job summary {
    cursor: pointer;
    padding: 15px 16px;
    list-style-position: inside;
}

.queue-job summary span {
    display: inline-grid;
    gap: 4px;
    vertical-align: top;
    max-width: calc(100% - 32px);
}

.queue-job small,
.queue-job em {
    color: var(--muted);
    font-style: normal;
}

.queue-job details > h3,
.queue-job details > pre,
.queue-job details > .answer-content,
.queue-job details > .alert,
.queue-job details > .retry-button,
.queue-job details > details {
    margin-left: 16px;
    margin-right: 16px;
}

.queue-job pre,
.answer-meta pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.queue-job .answer-content {
    white-space: pre-wrap;
    background: white;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 14px;
}

.status-pending {
    border-left: 5px solid #d4a72c;
}

.status-processing {
    border-left: 5px solid #2f80ed;
}

.status-done {
    border-left: 5px solid var(--accent);
}

.status-error {
    border-left: 5px solid var(--danger);
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
}

.checkbox-line input {
    width: 20px;
    height: 20px;
}

.progress-wrap {
    margin-top: 18px;
}

.progress-label {
    font-weight: 800;
    margin-bottom: 10px;
}

.progress-bar {
    height: 13px;
    overflow: hidden;
    border-radius: 999px;
    background: #e5ecef;
}

.progress-bar span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), #62b6a0);
    transition: width .5s ease;
}

.result {
    margin-top: 18px;
}

.answer-content {
    line-height: 1.6;
}

.answer-content h3,
.answer-content h4,
.answer-content h5 {
    margin: 22px 0 8px;
    color: var(--brand);
    line-height: 1.25;
}

.answer-content h3 {
    font-size: 21px;
}

.answer-content h4,
.answer-content h5 {
    font-size: 18px;
}

.answer-content p {
    margin: 0 0 12px;
    color: var(--ink);
}

.answer-content ul {
    margin: 0 0 16px 22px;
    padding: 0;
}

.answer-content li {
    margin-bottom: 7px;
}

.answer-meta {
    border-top: 1px solid var(--line);
    margin-top: 22px;
    padding-top: 12px;
}

.answer-meta details {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fbfcfc;
    margin-top: 10px;
    overflow: hidden;
}

.answer-meta summary {
    cursor: pointer;
    font-weight: 900;
    padding: 12px 14px;
    color: var(--brand);
}

.answer-meta pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: 0;
    padding: 0 14px 14px;
    color: var(--ink);
    font-family: inherit;
    line-height: 1.45;
}

.alert {
    border: 1px solid #f2b8b5;
    background: #fff0ee;
    color: var(--danger);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 16px;
    font-weight: 700;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-top: 18px;
}

.footer-links a {
    color: var(--brand);
    font-weight: 800;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin: 14px 0 18px;
}

.metric {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fbfcfc;
}

.metric span {
    display: block;
    color: var(--muted);
    font-weight: 800;
    margin-bottom: 4px;
    font-size: 12px;
}

.metric strong {
    display: block;
    font-size: 18px;
    line-height: 1.2;
}

.metric small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
    font-size: 12px;
}

.metric-highlight {
    border-color: #b9decf;
    background: #f3fbf7;
}

.metric-wide {
    grid-column: span 2;
}

.good {
    color: #126b39;
    font-weight: 900;
}

.bad {
    color: var(--danger);
    font-weight: 900;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 18px;
}

th,
td {
    border-bottom: 1px solid #e7ecef;
    padding: 9px;
    text-align: left;
    vertical-align: top;
}

.secondary-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #eef3f5;
    color: var(--brand);
    font-weight: 800;
    padding: 10px 12px;
    text-decoration: none;
}

.queue-summary-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 15px 16px;
}

.queue-summary-row span {
    display: grid;
    gap: 4px;
}

.queue-summary-row small,
.queue-summary-row em {
    color: var(--muted);
    font-style: normal;
}

.queue-open-link {
    flex: 0 0 auto;
}

.queue-ticket,
.queue-minimal {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.queue-ticket {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
}

.queue-minimal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
}

.queue-minimal strong,
.queue-ticket-main strong {
    display: block;
    color: var(--ink);
    font-size: 18px;
    line-height: 1.25;
}

.queue-ticket-main span,
.queue-ticket-main small {
    display: block;
    color: var(--muted);
    margin-top: 5px;
    font-weight: 700;
}

.queue-avatar {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: #f5f9fb;
    color: #718294;
    font-weight: 900;
}

.queue-ticket-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.ticket-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 86px;
    border-radius: 999px;
    padding: 8px 13px;
    font-weight: 900;
    text-decoration: none;
}

.ticket-status-done {
    background: #dff7e8;
    color: #126b39;
}

.ticket-status-pending {
    background: #fff4ce;
    color: #876500;
}

.ticket-status-processing {
    background: #e0efff;
    color: #155a9f;
}

.ticket-status-error {
    background: #fde2df;
    color: var(--danger);
}

.queue-log-panel {
    margin-top: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfc;
    padding: 12px 14px;
}

.queue-log-panel summary {
    cursor: pointer;
    font-weight: 900;
}

.queue-log-list {
    display: grid;
    gap: 10px;
    list-style: none;
    padding: 0;
    margin: 14px 0 0;
}

.queue-log-list li {
    border-left: 4px solid var(--line);
    padding: 8px 10px;
    background: white;
}

.queue-log-list li.status-processing {
    border-left-color: #2f80ed;
}

.queue-log-list li.status-done {
    border-left-color: var(--accent);
}

.queue-log-list li.status-error {
    border-left-color: var(--danger);
}

.queue-log-list span,
.queue-log-list em,
.queue-log-list small {
    display: block;
    color: var(--muted);
    font-style: normal;
    margin-top: 2px;
}

.detail-page .heading-row {
    align-items: center;
}

.detail-page h1 {
    overflow-wrap: anywhere;
}

.detail-back-link {
    margin-bottom: 18px;
}

.detail-section {
    border-top: 1px solid var(--line);
    padding-top: 18px;
    margin-top: 18px;
}

.detail-section pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
    overflow-x: hidden;
    background: #fbfcfc;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 14px;
}

.request-summary {
    font-family: inherit;
    line-height: 1.45;
}

.detail-collapse {
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.detail-collapse summary {
    cursor: pointer;
    color: var(--brand);
    font-size: 24px;
    font-weight: 900;
}

.detail-answer {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 16px;
}

.detail-answer h3,
.detail-answer h4,
.detail-answer h5 {
    margin: 26px 0 10px;
    color: var(--brand);
    line-height: 1.25;
}

.detail-answer h3:first-child,
.detail-answer h4:first-child,
.detail-answer h5:first-child {
    margin-top: 0;
}

.detail-answer p {
    color: var(--ink);
    margin: 0 0 12px;
}

.detail-answer ul {
    margin: 0 0 16px 22px;
    padding: 0;
}

.detail-answer li {
    margin-bottom: 8px;
}

@media (max-width: 720px) {
    .form-grid,
    .form-grid.two,
    .form-grid.three,
    .heading-row {
        grid-template-columns: 1fr;
        display: grid;
    }

    .login-panel,
    .chat-panel,
    .result,
    .progress-wrap {
        padding: 18px;
    }
}
