:root {
    --font-sans: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --ink: #171714;
    --muted: #65645d;
    --paper: #f5f3ec;
    --paper-deep: #e7e1d5;
    --card: #fffdf6;
    --line: #171714;
    --soft-line: #cfc7ba;
    --red: #e94f37;
    --blue: #235fc5;
    --green: #19724b;
    --yellow: #d5b23f;
    --danger: #d93c42;
    --radius: 6px;
    --block-shadow: 6px 6px 0 var(--ink);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-width: 320px;
    color: var(--ink);
    background: var(--paper);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button, a { font: inherit; }
button { color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.page-noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 20;
    opacity: .035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.site-header {
    min-height: 76px;
    padding: 0 max(20px, 5vw);
    border-bottom: 2px solid var(--line);
    background: var(--paper);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    justify-self: start;
    color: var(--ink);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 35px;
    height: 35px;
    border: 2px solid var(--ink);
    background: var(--card);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    padding: 5px;
    box-shadow: 3px 3px 0 var(--ink);
}

.brand-mark span {
    display: block;
    align-self: end;
    width: 100%;
    background: var(--ink);
}

.brand-mark span:nth-child(1) { height: 58%; background: var(--blue); }
.brand-mark span:nth-child(2) { height: 100%; background: var(--red); }
.brand-mark span:nth-child(3) { height: 76%; background: var(--yellow); }

.brand-text {
    font-family: var(--font-sans);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: .02em;
}

.brand-text span { color: var(--red); }

.lesson-progress {
    width: min(330px, 32vw);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px 18px;
}

.lesson-label {
    font-family: var(--font-sans);
    font-size: 10px;
    letter-spacing: .2em;
    font-weight: 700;
    color: var(--blue);
}

.lesson-count {
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--muted);
}

.lesson-count b { color: var(--ink); }

.admin-link {
    justify-self: end;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    color: var(--ink);
    background: var(--card);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    transition: transform .18s ease, background .18s ease;
}

.admin-link:hover {
    transform: translate(-2px, -2px);
    background: #f2d953;
    box-shadow: 3px 3px 0 var(--ink);
}

.admin-link svg {
    width: 17px;
    fill: currentColor;
}

.learning-shell {
    width: min(1240px, calc(100% - 44px));
    margin: 0 auto;
    padding: 52px 0 28px;
}

.intro-row {
    display: grid;
    grid-template-columns: minmax(280px, .95fr) minmax(280px, 1.05fr);
    gap: 48px;
    align-items: end;
    margin: 0 0 28px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--line);
}

.eyebrow {
    display: block;
    margin-bottom: 9px;
    color: var(--red);
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .22em;
}

.intro-row h1,
.result-heading h2,
.fluency-title h2 {
    margin: 0;
    font-family: var(--font-sans);
    line-height: 1.15;
    word-break: keep-all;
}

.intro-row h1 {
    max-width: 720px;
    font-size: 52px;
    font-weight: 900;
}

.intro-row p {
    max-width: 560px;
    margin: 0 0 4px;
    color: var(--ink);
    font-size: 17px;
    line-height: 1.8;
    word-break: keep-all;
}

.intro-controls {
    display: grid;
    gap: 18px;
    justify-items: start;
}

.problem-actions {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 10px;
}

.choose-problem-button,
.random-problem-button {
    min-height: 44px;
    border: 2px solid var(--line);
    background: var(--card);
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
}

.choose-problem-button,
.random-problem-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 15px;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.choose-problem-button {
    background: var(--ink);
    color: #fff;
}

.random-problem-button {
    background: #f2d953;
}

.choose-problem-button:hover,
.random-problem-button:hover {
    transform: translate(-2px, -2px);
    box-shadow: 4px 4px 0 var(--ink);
}

.choose-problem-button:focus-visible,
.random-problem-button:focus-visible {
    outline: 3px solid var(--blue);
    outline-offset: 3px;
}

body.modal-open {
    overflow: hidden;
}

.problem-modal {
    width: min(1040px, calc(100% - 32px));
    max-height: min(84vh, 820px);
    padding: 0;
    border: 2px solid var(--line);
    background: var(--card);
    color: var(--ink);
    box-shadow: var(--block-shadow);
}

.problem-modal:not([open]) { display: none; }

.problem-modal::backdrop {
    background: rgba(23, 23, 20, .58);
}

.problem-modal-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    max-height: min(84vh, 820px);
}

.problem-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 24px 26px 20px;
    border-bottom: 2px solid var(--line);
    background: var(--paper);
}

.problem-modal-header h2 {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 34px;
    line-height: 1.15;
    word-break: keep-all;
}

.problem-modal-close {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border: 2px solid var(--line);
    background: var(--card);
    cursor: pointer;
    font-size: 26px;
    font-weight: 800;
    line-height: 1;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.problem-modal-close:hover {
    transform: translate(-2px, -2px);
    background: var(--red);
    color: #fff;
    box-shadow: 4px 4px 0 var(--ink);
}

.problem-modal-close:focus-visible,
.problem-card-link:focus-visible {
    outline: 3px solid var(--blue);
    outline-offset: 3px;
}

.problem-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 260px));
    justify-content: start;
    align-content: start;
    gap: 14px;
    padding: 24px 26px 28px;
    overflow: auto;
    background: var(--card);
}

.problem-card-link {
    min-width: 0;
    min-height: 344px;
    border: 2px solid var(--line);
    background: var(--paper);
    color: var(--ink);
    text-decoration: none;
    display: grid;
    grid-template-rows: auto auto auto;
    align-content: start;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.problem-card-link:hover {
    transform: translate(-3px, -3px);
    box-shadow: 5px 5px 0 var(--ink);
    background: #fff7d8;
}

.problem-card-link.is-current {
    background: #edf3ff;
    box-shadow: inset 0 0 0 6px #d8e6ff;
}

.problem-card-image {
    display: block;
    width: 100%;
    height: 190px;
    aspect-ratio: 1.25;
    border-bottom: 2px solid var(--line);
    background: var(--paper-deep);
    overflow: hidden;
}

.problem-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.problem-card-meta {
    display: grid;
    gap: 10px;
    align-content: start;
    min-height: 112px;
    padding: 22px 14px 12px;
}

.problem-card-index,
.problem-card-state {
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .14em;
}

.problem-card-index {
    color: var(--blue);
    display: block;
    line-height: 1;
}

.problem-card-meta strong {
    font-size: 18px;
    line-height: 1.35;
    word-break: keep-all;
}

.problem-card-state {
    align-self: end;
    justify-self: start;
    margin: 0 14px 14px;
    padding: 5px 8px;
    border: 1px solid var(--line);
    background: var(--ink);
    color: #fff;
}

.problem-card-link.is-current .problem-card-state {
    background: var(--blue);
}

.practice-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
    min-height: 620px;
    scroll-margin-top: 96px;
    border: 2px solid var(--line);
    background: var(--card);
    box-shadow: var(--block-shadow);
}

.picture-card,
.voice-card {
    position: relative;
    padding: 30px max(26px, 4vw) 36px;
}

.picture-card {
    border-right: 2px solid var(--line);
    background: var(--paper-deep);
}

.card-kicker {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .18em;
}

.card-kicker span {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: 2px solid currentColor;
    background: var(--card);
    font-size: 10px;
    letter-spacing: 0;
}

.picture-frame {
    position: relative;
    padding: 12px;
    border: 2px solid var(--line);
    background: var(--card);
}

.picture-frame::after {
    content: "";
    position: absolute;
    right: -8px;
    bottom: -8px;
    width: 34%;
    height: 35%;
    border-right: 2px solid var(--line);
    border-bottom: 2px solid var(--line);
    pointer-events: none;
}

.picture-frame img {
    width: 100%;
    aspect-ratio: 1.22;
    object-fit: cover;
    border: 1px solid var(--line);
    background: #d7dfd1;
}

.picture-tape {
    width: 92px;
    height: 24px;
    position: absolute;
    left: 30px;
    top: -13px;
    background: #f2d953;
    border: 1px solid rgba(23, 23, 20, .35);
}

.picture-caption {
    margin: 24px 0 0;
    padding-left: 14px;
    border-left: 4px solid var(--red);
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
}

.voice-card {
    display: flex;
    flex-direction: column;
    background: var(--card);
    overflow: hidden;
}

.voice-card .card-kicker span { background: var(--red); color: #fff; }

.voice-content,
.processing {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-bottom: 26px;
}

.voice-orbit {
    width: 172px;
    height: 172px;
    display: grid;
    place-items: center;
    position: relative;
    margin: 4px 0 26px;
    border: 2px solid var(--line);
    background: #f0ece3;
}

.voice-orbit::before,
.voice-orbit::after {
    content: "";
    position: absolute;
    width: 38px;
    height: 38px;
    pointer-events: none;
}

.voice-orbit::before {
    top: 10px;
    left: 10px;
    border-top: 3px solid var(--blue);
    border-left: 3px solid var(--blue);
}

.voice-orbit::after {
    right: 10px;
    bottom: 10px;
    border-right: 3px solid var(--red);
    border-bottom: 3px solid var(--red);
}

.record-button {
    width: 92px;
    height: 92px;
    border: 2px solid var(--line);
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
    background: var(--red);
    box-shadow: 5px 5px 0 var(--ink);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
    position: relative;
    z-index: 1;
}

.record-button:hover {
    transform: translate(-2px, -2px);
    box-shadow: 8px 8px 0 var(--ink);
    background: #f05d45;
}

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

.record-button:focus-visible {
    outline: 3px solid var(--blue);
    outline-offset: 4px;
}

.record-button svg {
    width: 34px;
    fill: #fff;
}

.voice-content h2,
.processing h2 {
    margin: 0;
    max-width: 420px;
    font-family: var(--font-sans);
    font-size: 30px;
    line-height: 1.25;
}

.voice-content > p,
.processing p {
    max-width: 390px;
    margin: 13px auto 0;
    color: var(--muted);
    line-height: 1.75;
    word-break: keep-all;
}

.voice-content .permission-note {
    margin-top: 24px;
    font-family: var(--font-sans);
    font-size: 11px;
    color: var(--muted);
}

.recording-panel {
    width: 100%;
    margin-top: 22px;
    padding: 18px;
    border: 2px solid var(--line);
    background: #f5f3ec;
}

#waveform {
    width: 100%;
    max-width: 440px;
    height: 84px;
}

.recording-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    color: var(--red);
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
}

.recording-meta b {
    margin-left: 9px;
    color: var(--ink);
    font-size: 14px;
    letter-spacing: 0;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
    animation: blink 1s steps(2, end) infinite;
}

@keyframes blink {
    50% { opacity: .25; }
}

.stop-button,
.retry-button {
    min-height: 44px;
    border: 2px solid var(--ink);
    background: var(--ink);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 11px 18px;
    font-size: 13px;
    font-weight: 800;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.stop-button { margin-top: 18px; }

.stop-button:hover,
.retry-button:hover {
    transform: translate(-2px, -2px);
    background: var(--blue);
    box-shadow: 4px 4px 0 var(--ink);
}

.stop-button span {
    width: 10px;
    height: 10px;
    background: var(--red);
}

.processing-art {
    width: 130px;
    height: 106px;
    position: relative;
    margin-bottom: 28px;
}

.processing-art svg {
    width: 100%;
    fill: none;
    stroke: var(--ink);
    stroke-width: 4;
    stroke-linecap: square;
    stroke-linejoin: miter;
}

.ink-dot {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--red);
    border: 2px solid var(--ink);
    animation: paintDot 1.1s steps(2, end) infinite;
}

.dot-one { left: 28px; top: 8px; }
.dot-two { left: 60px; top: 0; animation-delay: .16s; background: var(--yellow); }
.dot-three { left: 91px; top: 16px; animation-delay: .32s; background: var(--blue); }

@keyframes paintDot {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(13px); }
}

.loading-track {
    width: min(320px, 80%);
    height: 8px;
    margin-top: 28px;
    border: 1px solid var(--line);
    overflow: hidden;
    background: var(--card);
}

.loading-track span {
    display: block;
    width: 42%;
    height: 100%;
    background: var(--red);
    animation: loading 1.2s steps(12, end) infinite;
}

@keyframes loading {
    from { transform: translateX(-105%); }
    to { transform: translateX(245%); }
}

.error-banner {
    margin: 24px 0;
    padding: 14px 16px;
    border: 2px solid var(--line);
    background: #fff1eb;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 4px 4px 0 var(--ink);
}

.error-icon {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 2px solid var(--line);
    background: var(--danger);
    color: #fff;
    font-weight: 800;
}

.error-banner p {
    margin: 0;
    flex: 1;
    font-size: 13px;
}

.error-banner p span {
    display: block;
    margin-top: 2px;
    color: #7b342f;
}

.error-banner button {
    border: 0;
    background: none;
    font-size: 26px;
    cursor: pointer;
    color: var(--ink);
}

.result-section {
    padding-top: 86px;
    scroll-margin-top: 20px;
}

.result-heading,
.fluency-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
    margin-bottom: 28px;
}

.result-heading {
    padding-bottom: 20px;
    border-bottom: 2px solid var(--line);
}

.result-heading h2,
.fluency-title h2 {
    font-size: 42px;
    font-weight: 900;
}

.retry-button {
    background: var(--card);
    color: var(--ink);
}

.retry-button svg {
    width: 17px;
    fill: currentColor;
}

.canvas-comparison {
    display: grid;
    grid-template-columns: 1fr 62px 1fr;
    align-items: center;
    gap: 0;
}

.canvas-comparison article { min-width: 0; }

.image-label {
    display: inline-block;
    margin-bottom: 10px;
    padding: 4px 8px;
    border: 1px solid var(--line);
    background: var(--card);
    font-family: var(--font-sans);
    font-size: 10px;
    letter-spacing: .14em;
    font-weight: 700;
    color: var(--ink);
}

.image-label.generated {
    background: var(--red);
    color: #fff;
}

.result-image {
    border: 2px solid var(--line);
    background: var(--paper-deep);
}

.result-image img {
    width: 100%;
    aspect-ratio: 1.2;
    object-fit: cover;
}

.generated-image { background: #f8efe3; }

.comparison-arrow {
    width: 42px;
    height: 42px;
    border: 2px solid var(--line);
    display: grid;
    place-items: center;
    justify-self: center;
    color: #fff;
    background: var(--ink);
    font-family: var(--font-sans);
    font-weight: 700;
}

.image-unavailable {
    aspect-ratio: 1.2;
    display: grid;
    place-items: center;
    padding: 30px;
    text-align: center;
    color: var(--muted);
    line-height: 1.7;
}

.similarity-score-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 24px;
}

.similarity-score-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 20px;
    border: 2px solid var(--line);
    box-shadow: 4px 4px 0 var(--ink);
}

.similarity-score-card.sentence {
    background: var(--blue);
    color: #fff;
}

.similarity-score-card.image {
    background: var(--yellow);
}

.similarity-score-label {
    display: block;
    margin-bottom: 5px;
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .16em;
}

.similarity-score-card h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 900;
}

.similarity-score-value {
    flex: 0 0 auto;
    display: flex;
    align-items: baseline;
    font-family: var(--font-sans);
    white-space: nowrap;
}

.similarity-score-value strong {
    font-size: 42px;
    line-height: 1;
}

.similarity-score-value span {
    margin-left: 4px;
    font-size: 11px;
    font-weight: 700;
}

.recognized-sentence {
    margin: 40px 0 74px;
    padding: 26px;
    border: 2px solid var(--line);
    background: var(--card);
}

.recognized-sentence > span {
    font-family: var(--font-sans);
    font-size: 10px;
    letter-spacing: .18em;
    color: var(--blue);
    font-weight: 700;
}

.recognized-sentence p {
    margin: 10px 0 0;
    font-family: var(--font-sans);
    font-size: 34px;
    line-height: 1.35;
}

.recognized-sentence strong {
    font-weight: 900;
}

.fluency-panel {
    border-top: 2px solid var(--line);
    padding-top: 30px;
}

.fluency-title { align-items: flex-end; }

.score-stamp {
    width: 144px;
    min-height: 100px;
    padding: 14px 16px;
    border: 2px solid var(--ink);
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: baseline;
    background: #f2d953;
    box-shadow: 5px 5px 0 var(--ink);
}

.score-stamp strong {
    z-index: 1;
    font-family: var(--font-sans);
    color: var(--ink);
    font-size: 46px;
    line-height: 1;
}

.score-stamp span {
    z-index: 1;
    margin-left: 4px;
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 12px;
}

.score-stamp small {
    z-index: 1;
    grid-column: 1 / -1;
    margin-top: 6px;
    font-family: var(--font-sans);
    letter-spacing: .16em;
    font-size: 9px;
    font-weight: 700;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.metric-card {
    min-height: 188px;
    padding: 22px;
    border: 2px solid var(--line);
    background: var(--card);
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto 1fr;
    align-items: center;
    gap: 10px 13px;
}

.metric-icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 2px solid var(--line);
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 18px;
    font-weight: 700;
}

.metric-card > span {
    font-family: var(--font-sans);
    font-size: 10px;
    letter-spacing: .15em;
    color: var(--muted);
    font-weight: 700;
}

.metric-card > strong {
    grid-row: 1 / span 2;
    grid-column: 3;
    font-family: var(--font-sans);
    font-size: 38px;
}

.metric-card > p {
    grid-column: 1 / -1;
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.meter {
    grid-column: 1 / -1;
    height: 8px;
    border: 1px solid var(--line);
    background: var(--paper);
    align-self: end;
    overflow: hidden;
}

.meter span {
    display: block;
    height: 100%;
    width: 0;
    transition: width .7s steps(16, end);
    background: var(--blue);
}

.smoothness .metric-icon,
.smoothness .meter span { background: var(--yellow); color: var(--ink); }
.speed .metric-icon,
.speed .meter span { background: var(--green); color: #fff; }

.word-analysis,
.analysis-split > article {
    margin-top: 14px;
    border: 2px solid var(--line);
    background: var(--card);
    padding: 24px 26px 28px;
}

.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.analysis-header > div:first-child {
    display: flex;
    align-items: center;
    gap: 12px;
}

.analysis-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
}

.number-badge {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: 2px solid var(--line);
    background: var(--blue);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 700;
}

.legend {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.legend span {
    width: 9px;
    height: 9px;
    border: 1px solid var(--line);
    margin-left: 8px;
}

.legend .low { background: var(--danger); }
.legend .mid { background: var(--yellow); }
.legend .high { background: var(--green); }

.word-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 24px;
}

.word-chip {
    min-width: 74px;
    max-width: 180px;
    padding: 11px 12px 10px;
    border: 2px solid var(--line);
    background: #f5f3ec;
    text-align: left;
    position: relative;
    overflow-wrap: anywhere;
}

.word-chip b {
    display: block;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.2;
}

.word-chip small {
    display: block;
    margin-top: 4px;
    font-family: var(--font-sans);
    font-size: 10px;
    color: var(--muted);
}

.word-chip.low { background: #fff1eb; color: #9f222a; }
.word-chip.mid { background: #fff7d8; color: #7f5a00; }
.word-chip.high { background: #e7f5ed; color: #145f3d; }

.word-chip.accented::before {
    content: "STRESS";
    position: absolute;
    top: -10px;
    right: 8px;
    padding: 2px 5px;
    border: 1px solid var(--line);
    background: var(--ink);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 8px;
    letter-spacing: .08em;
}

.analysis-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.analysis-split .analysis-header {
    justify-content: flex-start;
}

.sentence-analysis {
    min-height: 72px;
    padding-top: 24px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 18px;
    line-height: 1.8;
}

.sentence-word {
    display: inline-block;
    padding: 2px 1px;
    overflow-wrap: anywhere;
}

.sentence-word.accented {
    color: var(--red);
    font-weight: 800;
    border-bottom: 3px solid var(--red);
    position: relative;
}

.sentence-word.accented::before {
    content: "^";
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-sans);
    font-size: 11px;
}

.pause-marker {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border: 1px solid var(--line);
    background: #edf3ff;
    color: var(--blue);
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 700;
}

.pause-marker::before { content: "..."; }

.analysis-help {
    margin: 13px 0 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.6;
}

.pause-sample {
    padding: 1px 5px;
    border: 1px solid var(--line);
    color: var(--blue);
    background: #edf3ff;
    font-family: var(--font-sans);
}

.accent-sample {
    color: var(--red);
    border-bottom: 2px solid currentColor;
    font-weight: 800;
}

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

.warning-note {
    margin-top: 14px;
    padding: 13px 16px;
    border: 2px solid var(--line);
    background: #fff7d8;
    color: #684b00;
    font-size: 12px;
    line-height: 1.6;
}

.lesson-nav {
    min-height: 104px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

.lesson-nav a {
    color: var(--ink);
    text-decoration: none;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 700;
}

.lesson-nav a:last-child { justify-self: end; }
.lesson-nav a:hover { color: var(--red); }

.nav-center {
    font-family: var(--font-sans);
    color: var(--muted);
    font-size: 11px;
    letter-spacing: .12em;
}

footer {
    padding: 28px max(20px, 5vw);
    border-top: 2px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 18px;
    color: var(--muted);
    font-size: 12px;
}

footer > span {
    font-family: var(--font-sans);
    letter-spacing: .22em;
    font-weight: 700;
    color: var(--ink);
}

footer p { margin: 0; }

.empty-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.empty-card {
    width: min(520px, 100%);
    padding: 54px 40px;
    border: 2px solid var(--line);
    background: var(--card);
    box-shadow: var(--block-shadow);
    text-align: center;
}

.empty-card h1 {
    margin-top: 36px;
    font-family: var(--font-sans);
}

.empty-card p {
    color: var(--muted);
    margin-bottom: 26px;
}

.empty-card .retry-button { text-decoration: none; }

@media (max-width: 1020px) {
    .intro-row h1 { font-size: 44px; }
    .result-heading h2,
    .fluency-title h2 { font-size: 36px; }
}

@media (max-width: 900px) {
    .site-header { grid-template-columns: 1fr auto; }
    .lesson-progress { display: none; }
    .intro-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .practice-grid { grid-template-columns: 1fr; }
    .picture-card {
        border-right: 0;
        border-bottom: 2px solid var(--line);
    }
    .voice-card { min-height: 540px; }
    .metric-grid { grid-template-columns: 1fr; }
    .metric-card { min-height: 136px; }
    .analysis-split { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
    .site-header {
        min-height: 68px;
        padding-inline: 16px;
    }
    .brand-mark {
        width: 31px;
        height: 31px;
    }
    .brand-text { font-size: 16px; }
    .admin-link {
        width: 38px;
        padding: 0;
        justify-content: center;
        font-size: 0;
    }
    .admin-link svg { width: 19px; }
    .learning-shell {
        width: min(100% - 28px, 1240px);
        padding-top: 38px;
    }
    .intro-row { margin-bottom: 22px; }
    .intro-row h1 { font-size: 34px; }
    .intro-row p { font-size: 14px; }
    .intro-controls,
    .problem-actions,
    .choose-problem-button,
    .random-problem-button {
        width: 100%;
    }
    .problem-modal {
        width: calc(100% - 24px);
        max-height: 86vh;
    }
    .problem-modal-shell { max-height: 86vh; }
    .problem-modal-header {
        padding: 20px 18px 18px;
        gap: 16px;
    }
    .problem-modal-header h2 { font-size: 27px; }
    .problem-modal-close {
        width: 40px;
        height: 40px;
    }
    .problem-card-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 18px;
    }
    .problem-card-link {
        min-height: 118px;
        grid-template-columns: 112px minmax(0, 1fr);
        grid-template-rows: 1fr;
        position: relative;
    }
    .problem-card-image {
        grid-row: 1;
        grid-column: 1;
        height: 100%;
        min-height: 116px;
        aspect-ratio: auto;
        border-right: 2px solid var(--line);
        border-bottom: 0;
    }
    .problem-card-meta {
        grid-column: 2;
        grid-row: 1;
        z-index: 1;
        min-height: 116px;
        padding: 16px 13px 44px;
    }
    .problem-card-meta strong { font-size: 16px; }
    .problem-card-state {
        grid-column: 2;
        grid-row: 1;
        z-index: 2;
        align-self: end;
        justify-self: start;
        margin: 0 13px 12px;
    }
    .picture-card,
    .voice-card {
        padding-inline: 18px;
    }
    .practice-grid {
        min-height: 0;
        box-shadow: 4px 4px 0 var(--ink);
    }
    .voice-card { min-height: 500px; }
    .voice-content h2,
    .processing h2 { font-size: 25px; }
    .result-section { padding-top: 60px; }
    .practice-grid { scroll-margin-top: 82px; }
    .result-section { scroll-margin-top: 18px; }
    .result-heading {
        align-items: flex-start;
        flex-direction: column;
    }
    .result-heading h2,
    .fluency-title h2 { font-size: 28px; }
    .canvas-comparison {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .comparison-arrow {
        transform: rotate(90deg);
    }
    .similarity-score-grid {
        grid-template-columns: 1fr;
    }
    .similarity-score-card {
        align-items: flex-start;
    }
    .recognized-sentence {
        margin-bottom: 56px;
        padding: 20px;
    }
    .recognized-sentence p { font-size: 24px; }
    .fluency-title {
        align-items: flex-start;
        flex-direction: column;
    }
    .score-stamp {
        width: 126px;
        min-height: 86px;
        padding: 12px;
    }
    .score-stamp strong { font-size: 38px; }
    .analysis-header {
        align-items: flex-start;
        flex-direction: column;
    }
    .word-analysis,
    .analysis-split > article {
        padding: 22px 18px;
    }
    .legend { flex-wrap: wrap; }
    .lesson-nav { grid-template-columns: 1fr 1fr; }
    .nav-center { display: none; }
    footer {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
