/* Light theme, mobile first. The phone layout IS the layout; desktop just centers it. */

:root {
    color-scheme: light;

    --ink: #17202a;
    --ink-soft: #4a5665;
    --ink-faint: #6b7787;
    --page: #f4f6f9;
    --surface: #ffffff;
    --line: #d8dee7;
    --line-soft: #e8edf3;

    --brand: #1d4ed8;
    --brand-dark: #1a43b8;
    --brand-tint: #eef3ff;
    --go: #15803d;
    --go-dark: #126832;
    --warn: #b45309;
    --fail: #b91c1c;

    --radius: 12px;
    --tap: 44px;

    /* MikesTools theming hooks. */
    --mt-bg: var(--surface);
    --mt-fg: var(--ink);
    --mt-border: var(--line);
    --mt-accent: var(--brand);
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

/* ---- Chrome ---------------------------------------------------------- */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.app-title {
    font-size: 1.05rem;
    font-weight: 650;
    color: var(--ink);
    text-decoration: none;
}

.header-form {
    margin: 0;
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 44rem;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.app-footer {
    padding: 16px;
    text-align: center;
    color: var(--ink-faint);
    font-size: 0.85rem;
}

/* ---- Cards ----------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 16px;
}

.card-tight {
    padding: 14px 16px;
}

h1 {
    font-size: 1.4rem;
    line-height: 1.3;
    margin: 0 0 12px;
}

h2 {
    font-size: 1.1rem;
    margin: 0 0 10px;
}

.lede {
    color: var(--ink-soft);
    margin: 0 0 18px;
}

/* ---- Buttons: solid, vibrant, never hollow --------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    padding: 0 20px;
    border: none;
    border-radius: 10px;
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    touch-action: manipulation;
}

.btn:hover {
    background: var(--brand-dark);
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
}

.btn-go {
    background: var(--go);
}

.btn-go:hover {
    background: var(--go-dark);
}

/* Gray is reserved for cancel and disabled, never for a live action. */
.btn-quiet {
    background: #e2e8f0;
    color: var(--ink);
}

.btn-quiet:hover {
    background: #cfd8e3;
}

.btn:disabled,
.btn[aria-disabled="true"] {
    background: #cbd5e1;
    color: #6b7787;
    cursor: not-allowed;
}

.btn-block {
    width: 100%;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* ---- Forms ----------------------------------------------------------- */

label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

.field {
    margin-bottom: 16px;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    min-height: var(--tap);
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    /* 16px minimum stops iOS Safari zooming the viewport on focus. */
    font-size: 16px;
}

textarea {
    min-height: 8.5rem;
    resize: vertical;
    line-height: 1.5;
}

input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 0;
    border-color: var(--brand);
}

.hint {
    color: var(--ink-faint);
    font-size: 0.85rem;
    margin-top: 6px;
}

/* ---- Messages -------------------------------------------------------- */

.alert {
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid;
}

.alert-error {
    background: #fef2f2;
    border-color: #fca5a5;
    color: var(--fail);
}

.alert-notice {
    background: var(--brand-tint);
    border-color: #b9ccff;
    color: var(--brand-dark);
}

/* ---- Interview ------------------------------------------------------- */

.progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    color: var(--ink-faint);
    font-size: 0.85rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    background: var(--line-soft);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--brand);
    border-radius: 999px;
}

.question {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 0 0 14px;
}

.qa-log {
    margin-top: 28px;
}

.qa-log summary {
    cursor: pointer;
    font-weight: 600;
    min-height: var(--tap);
    display: flex;
    align-items: center;
}

.qa-item {
    border-top: 1px solid var(--line-soft);
    padding: 14px 0;
}

.qa-item:first-of-type {
    border-top: none;
}

.qa-q {
    font-weight: 600;
    margin: 0 0 6px;
}

.qa-a {
    margin: 0;
    color: var(--ink-soft);
    white-space: pre-wrap;
}

.state-line {
    color: var(--ink-soft);
}

/* ---- Research progress ----------------------------------------------- */

.topic-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.topic {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--line-soft);
}

.topic:first-child {
    border-top: none;
}

.topic-name {
    font-weight: 600;
}

.topic-state {
    flex-shrink: 0;
    font-size: 0.85rem;
    color: var(--ink-faint);
}

.topic-running .topic-state {
    color: var(--brand);
    font-weight: 600;
}

.topic-done .topic-state {
    color: var(--go);
    font-weight: 600;
}

/* Red is reserved for genuine failure. */
.topic-failed .topic-state {
    color: var(--fail);
    font-weight: 600;
}

/* ---- Plan ------------------------------------------------------------ */

.plan-body {
    line-height: 1.65;
    overflow-wrap: break-word;
}

.plan-body table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}

.plan-stream {
    white-space: pre-wrap;
    font-family: inherit;
    margin: 0;
}

@media (min-width: 700px) {
    .app-main {
        padding: 28px 16px;
    }

    h1 {
        font-size: 1.6rem;
    }
}
