:root {
    --bg: #f5ead9;
    --bg-deep: #ead7bf;
    --paper: rgba(255, 249, 240, 0.86);
    --paper-strong: #fffaf3;
    --ink: #2b241d;
    --muted: #6f6256;
    --line: rgba(120, 92, 67, 0.22);
    --accent: #186b63;
    --accent-warm: #cb6b3f;
    --accent-deep: #8d3f2a;
    --danger: #b23a2f;
    --shadow: 0 24px 60px rgba(73, 45, 23, 0.14);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 18px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Noto Sans TC", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(203, 107, 63, 0.2), transparent 32%),
        radial-gradient(circle at 85% 10%, rgba(24, 107, 99, 0.16), transparent 24%),
        linear-gradient(180deg, #f8efe3 0%, #f3e1cb 100%);
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(16px);
    opacity: 0.55;
    pointer-events: none;
    z-index: 0;
}

.orb-a {
    width: 220px;
    height: 220px;
    top: -72px;
    right: -60px;
    background: rgba(203, 107, 63, 0.24);
}

.orb-b {
    width: 180px;
    height: 180px;
    left: -48px;
    bottom: 18%;
    background: rgba(24, 107, 99, 0.16);
}

.app-shell {
    position: relative;
    z-index: 1;
    width: min(100%, 760px);
    margin: 0 auto;
    padding: 20px 16px 48px;
}

.hero,
.panel,
.mode-switch {
    background: var(--paper);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow);
}

.hero {
    border-radius: 32px;
    padding: 22px 20px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
}

.back-link:hover,
.back-link:focus-visible {
    text-decoration: underline;
}

.eyebrow,
.panel-kicker {
    margin: 0;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 900;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.hero h1,
.panel h2 {
    margin: 8px 0 0;
    font-family: "Noto Serif TC", serif;
    line-height: 1.15;
}

.hero h1 {
    font-size: clamp(2.1rem, 9vw, 3.3rem);
}

.hero-copy {
    margin: 14px 0 0;
    color: var(--muted);
    line-height: 1.7;
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 22px;
}

.stat-card {
    padding: 16px 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.6);
    text-align: center;
}

.stat-card strong {
    display: block;
    font-size: 1.7rem;
    font-weight: 900;
    color: var(--accent-deep);
}

.stat-card span {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.92rem;
}

.app-notice {
    margin: 14px 0 0;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(24, 107, 99, 0.18);
    background: rgba(255, 251, 245, 0.92);
    color: var(--ink);
    line-height: 1.5;
}

.app-notice[data-tone="success"] {
    border-color: rgba(24, 107, 99, 0.3);
    color: var(--accent);
}

.app-notice[data-tone="warning"] {
    border-color: rgba(178, 58, 47, 0.3);
    color: var(--danger);
}

.mode-switch {
    position: sticky;
    top: 12px;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 18px 0 0;
    padding: 8px;
    border-radius: 22px;
}

.mode-btn,
.toggle-btn {
    border: 0;
    border-radius: 16px;
    padding: 13px 14px;
    background: transparent;
    color: var(--ink);
    font-weight: 900;
}

.mode-btn.is-active,
.toggle-btn.is-active {
    background: var(--ink);
    color: #fff;
}

.main-content {
    margin-top: 18px;
}

.view {
    display: none;
    gap: 18px;
}

.view.is-active {
    display: grid;
}

.panel {
    border-radius: var(--radius-xl);
    padding: 20px;
}

.panel-head {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.panel-head p:last-child {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
}

.field {
    display: grid;
    gap: 8px;
}

.field span {
    font-weight: 800;
}

textarea,
input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.92);
    color: var(--ink);
    padding: 14px 16px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

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

textarea:focus,
input:focus,
.btn:focus-visible,
.mode-btn:focus-visible,
.toggle-btn:focus-visible {
    border-color: rgba(24, 107, 99, 0.48);
    box-shadow: 0 0 0 4px rgba(24, 107, 99, 0.12);
}

.button-row,
.button-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.button-row {
    margin-top: 16px;
}

.button-stack {
    flex-direction: column;
}

.btn {
    border: 0;
    border-radius: 17px;
    padding: 14px 18px;
    font-weight: 900;
    transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
}

.btn:hover:not(:disabled),
.btn:focus-visible:not(:disabled) {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink);
    border: 1px solid var(--line);
}

.btn-accent {
    background: var(--accent-warm);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--ink);
    border: 1px dashed rgba(111, 98, 86, 0.36);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.hint,
.exam-meta,
.item-sub {
    margin: 12px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    margin: 16px 0 0;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(24, 107, 99, 0.12);
    color: var(--accent);
    font-weight: 800;
}

.record-preview {
    margin-top: 14px;
}

.record-preview audio {
    width: 100%;
}

.empty-state {
    padding: 18px;
    border: 1px dashed rgba(111, 98, 86, 0.35);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.45);
    color: var(--muted);
    line-height: 1.7;
}

.item-list,
.result-list {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.item-card,
.result-item {
    border-radius: 20px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    padding: 16px;
}

.item-top,
.result-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.item-title,
.result-title {
    margin: 8px 0 0;
    font-family: "Noto Serif TC", serif;
    font-size: 1.2rem;
    line-height: 1.35;
}

.item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.82rem;
    font-weight: 800;
}

.badge-tts {
    background: rgba(24, 107, 99, 0.14);
    color: var(--accent);
}

.badge-recording {
    background: rgba(203, 107, 63, 0.14);
    color: var(--accent-deep);
}

.toggle-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--line);
}

.exam-intro {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.exam-intro p,
.exam-meta {
    margin: 0;
}

.live-panel {
    overflow: hidden;
}

.exam-stage {
    display: grid;
    gap: 18px;
    justify-items: center;
    text-align: center;
}

.progress-ring {
    --progress-angle: 36deg;
    position: relative;
    display: grid;
    place-items: center;
    width: min(68vw, 220px);
    aspect-ratio: 1;
    padding: 18px;
    border-radius: 50%;
    background:
        conic-gradient(var(--accent) 0deg, var(--accent) var(--progress-angle), rgba(24, 107, 99, 0.15) var(--progress-angle), rgba(24, 107, 99, 0.08) 360deg);
}

.progress-ring::after {
    content: "";
    position: absolute;
    inset: 14px;
    border-radius: 50%;
    background: rgba(255, 250, 243, 0.95);
}

.progress-ring span {
    position: relative;
    z-index: 1;
    width: 110px;
    font-family: "Noto Serif TC", serif;
    font-size: 1.28rem;
    font-weight: 700;
    line-height: 1.45;
}

.result-list {
    list-style: decimal;
    padding-left: 24px;
}

.result-item {
    list-style: inherit;
}

@media (min-width: 720px) {
    .app-shell {
        padding: 28px 24px 64px;
    }

    .hero,
    .panel {
        padding: 24px;
    }

    .item-card {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .item-actions {
        margin-top: 0;
        justify-content: flex-end;
    }
}
