:root {
    color-scheme: light;
    --surface: #ffffff;
    --sidebar-bg: #f7f7f5;
    --hover: #efefec;
    --active: #e8e8e4;
    --secondary: #64645f;
    --ink: #292929;
    --muted: #92928f;
    --line: #ededeb;
    --sidebar-width: 248px;
    --selection-color: #dceafa;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--surface);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
    -webkit-font-smoothing: antialiased;
}
button, select, input { font: inherit; }
button, select { cursor: pointer; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button, select {
    min-height: 32px;
    padding: 5px 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--secondary);
    font-size: 13px;
    transition: background .15s, color .15s;
}
button:hover, select:hover { background: var(--hover); color: var(--ink); }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid #9dbde2; outline-offset: 3px; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    padding: 9px 10px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--line);
}
.new-page { position: absolute; top: 5%; left: 10px; transform: translateY(-50%); justify-content: flex-start; width: calc(100% - 20px); min-height: 36px; padding: 7px 9px; color: var(--secondary); font-size: 14px; }
.new-page svg { flex-shrink: 0; color: #888884; }
#page-list { margin-top: 76px; max-height: calc(100dvh - 200px); padding-bottom: 32px; overflow-y: auto; }
.saved-page { display: flex; justify-content: flex-start; gap: 7px; width: 100%; padding: 9px; text-align: left; }
.saved-page-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-page[aria-current="true"] { background: var(--active); color: var(--ink); }
.saved-page-row { display: flex; align-items: center; gap: 3px; }
.saved-page-row .saved-page { flex: 1; min-width: 0; }
.delete-page { flex-shrink: 0; width: 28px; min-height: 28px; padding: 5px; color: #999993; }
.delete-page:hover { color: #b16a60; background: #faf0ee; }
.delete-page svg { pointer-events: none; }
@media (max-width: 640px) {
    .sidebar { height: auto !important; }
    #page-list { display: flex; gap: 5px; margin-top: 7px; max-height: 80px; overflow-x: auto; }
    .saved-page { width: auto; max-width: 180px; flex-shrink: 0; }
    .saved-page-row { flex-shrink: 0; max-width: 220px; }
}
main {
    width: min(820px, calc(100% - var(--sidebar-width) - 112px));
    margin: 100px auto 0;
    position: relative;
    left: calc(var(--sidebar-width) / 2);
    padding-bottom: 100px;
}
.page-header { margin-bottom: 21px; }
.page-icon { display: block; width: fit-content; margin-bottom: 32px; font-size: 54px; line-height: 1.2; }
.title-row { display: flex; align-items: center; gap: 12px; width: 100%; }
.page-saved-check { position: relative; display: inline-flex; align-items: center; flex-shrink: 0; color: #75947c; cursor: help; }
.page-saved-check[hidden] { display: none; }
.page-saved-check::after { content: attr(data-tooltip); position: absolute; z-index: 20; top: calc(100% + 8px); right: -8px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: #687365; box-shadow: 0 3px 12px #2929290d; font-size: 11px; font-weight: 500; line-height: 1.4; white-space: nowrap; opacity: 0; transform: translateY(-3px); pointer-events: none; transition: opacity .15s, transform .15s; }
.page-saved-check:hover::after, .saved-page:focus-visible .page-saved-check::after { opacity: 1; transform: translateY(0); }
.page-title {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: var(--ink);
    font-size: clamp(29px, 3vw, 40px);
    font-weight: 750;
    line-height: 1.4;
    letter-spacing: -1.5px;
}
.page-title::placeholder { color: #b8b8b3; opacity: 1; }
.language-settings { display: flex; flex-wrap: wrap; gap: 16px 24px; margin-bottom: 31px; }
.language-field { display: flex; flex-direction: column; align-items: stretch; gap: 8px; font-size: 12px; color: var(--secondary); }
.language-field select {
    appearance: none;
    width: 100%;
    min-width: 140px;
    min-height: 38px;
    margin: 0;
    padding: 8px 34px 8px 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='m4 5.5 3 3 3-3' stroke='%238b8b85' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 11px center;
    color: var(--ink);
    font-size: 13px;
    line-height: 1.5;
}
.language-field select:hover { border-color: var(--muted); background-color: var(--hover); }
.language-field select:focus-visible { border-color: #9dbde2; }
.language-field option { color: var(--ink); background: var(--surface); }
.settings-menu { position: relative; flex-shrink: 0; }
.settings-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    color: var(--muted);
    list-style: none;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.settings-toggle::-webkit-details-marker { display: none; }
.settings-toggle:hover, .settings-menu[open] > .settings-toggle { background: var(--hover); color: var(--ink); }
.settings-menu > .language-settings {
    position: absolute;
    z-index: 5;
    top: calc(100% + 9px);
    right: 0;
    display: flex;
    flex-direction: column;
    width: 252px;
    max-width: calc(100vw - 48px);
    margin: 0;
    padding: 18px;
    gap: 17px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 4px 8px #20202005, 0 12px 32px #20202010;
}
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-bottom: 30px; }
#start { padding: 6px 13px; border-radius: 20px; background: var(--hover); color: var(--ink); font-weight: 600; }
#start:hover { background: var(--active); }
.record-dot { width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; background: #777773; }
.listening .record-dot { background: #d56c61; box-shadow: 0 0 0 3px #d56c6117; }
#status { color: inherit; font: inherit; }
#clear { margin-left: auto; color: #92928d; }
.content-tabs { display: flex; align-items: center; gap: 8px; }
.transcript-heading {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 0 0 29px;
    padding: 5px 11px;
    min-height: 0;
    border: 0;
    border-radius: 20px;
    background: var(--hover);
    color: var(--secondary);
    font-size: 13px;
    font-weight: 600;
}
.transcript-heading::before { content: "\224b"; color: var(--secondary); font-size: 17px; line-height: 1; }
.summary-heading::before {
    content: "";
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.4' stroke-linejoin='round'%3E%3Cpath d='m14 3 2.7 6.3L23 12l-6.3 2.7L14 21l-2.7-6.3L5 12l6.3-2.7Z'/%3E%3Cpath d='m5 1 1.2 2.8L9 5 6.2 6.2 5 9 3.8 6.2 1 5l2.8-1.2Z'/%3E%3C/svg%3E") center / contain no-repeat;
}
#page-summary { min-height: 350px; font-size: 15px; line-height: 1.9; letter-spacing: -.2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.summary-segment { margin: 0 0 22px; }
#page-summary[aria-busy="true"] { color: var(--muted); }
#page-summary::selection, #page-summary ::selection { background: var(--selection-color); color: #2c435f; }
#transcript { min-height: 350px; font-size: 15px; line-height: 1.9; letter-spacing: -.2px; overflow-wrap: anywhere; }
.segment { position: relative; margin: 0 0 22px; padding: 0 0 0 17px; border-left: 2px solid var(--active); }
.segment[data-time-label] { padding-top: 31px; }
.segment[data-time-label]::before {
    content: attr(data-time-label);
    position: absolute;
    top: 0;
    left: 16px;
    color: #9b9b95;
    font-size: 11px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    line-height: 1.8;
    letter-spacing: .1px;
    user-select: none;
    pointer-events: none;
}
.utterance-translation {
    margin: -15px 0 27px;
    padding: 4px 0 2px 17px;
    border-left: 2px solid var(--active);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.85;
    letter-spacing: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    user-select: none;
}
.utterance-translation[data-state="loading"] { color: #b0b0a9; }
.segment-translation { user-select: text; }
#interim { padding-left: 18px; color: #b0b0aa; }
#transcript::selection, #transcript ::selection { background: var(--selection-color); color: #2c435f; }
::highlight(saved-terms) { background: #e9eef4; color: #40536b; }
.explanation {
    position: fixed;
    z-index: 10;
    width: 360px;
    max-width: calc(100vw - 32px);
    max-height: min(480px, 70vh);
    overflow: auto;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 3px 7px #20202006, 0 12px 36px #20202012;
}
.explanation[hidden] { display: none; }
.explanation-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.explanation h3 { margin: 0 0 7px; color: #989891; font-size: 11px; font-weight: 500; }
.explanation-header h3 { margin: 0; }
#deleteExplanation { flex-shrink: 0; margin-top: 5px; min-height: 26px; padding: 3px 7px; color: #9b9b95; font-size: 11px; }
#deleteExplanation:hover { background: #faf0ee; color: #b16a60; }
#selectedTerm { min-width: 0; margin: 0; color: var(--ink); font-size: 13.5px; font-weight: 700; line-height: 1.4; letter-spacing: -.35px; overflow-wrap: anywhere; }
#response { color: var(--secondary); font-size: 12px; line-height: 1.85; overflow-wrap: anywhere; }
.term-translation, .term-description { margin: 0; white-space: pre-line; }
.term-translation { color: var(--muted); font-size: 12px; font-weight: 400; }
.term-description { margin-top: 13px; color: var(--secondary); font-size: 12px; }
.term-example { margin: 16px 0 0; padding: 13px 15px; border: 1px solid var(--line); border-left: 3px solid #d6dcd1; border-radius: 7px; background: var(--hover); color: var(--secondary); font-family: "SFMono-Regular", Consolas, "Malgun Gothic", monospace; font-size: 11px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.term-example code { font: inherit; }
@media (min-width: 1500px) { main { margin-top: 108px; } }
@media (max-width: 1000px) {
    :root { --sidebar-width: 192px; }
    main { width: calc(100% - var(--sidebar-width) - 72px); margin-top: 72px; }
}
@media (max-width: 640px) {
    .sidebar { position: static; width: 100%; height: 52px; padding: 7px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
    .new-page { position: static; transform: none; width: fit-content; min-height: 36px; }
    main { width: auto; margin: 36px 24px 0; left: 0; padding-bottom: 50px; }
    .page-icon { font-size: 43px; margin-bottom: 22px; }
    .page-title { font-size: 29px; letter-spacing: -1px; }
    .language-settings { gap: 12px 24px; margin-bottom: 19px; }
    .language-field select { min-height: 44px; font-size: 16px; max-width: 100%; }
    .toolbar { margin-bottom: 24px; }
    .toolbar button { min-height: 44px; }
    .transcript-heading { margin-bottom: 24px; }
    #transcript { font-size: 15px; }
    .explanation { padding: 17px; }
    #deleteExplanation { min-height: 36px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before { transition: none !important; } }

/* The same semantic palette drives both themes. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --surface: #191919;
    --sidebar-bg: #202020;
    --hover: #2b2b2b;
    --active: #343434;
    --ink: #e6e6e3;
    --secondary: #b3b3ad;
    --muted: #969690;
    --line: #343432;
    --selection-color: #304c68;
}
body { line-height: 1.6; }
.sidebar { display: flex; flex-direction: column; padding: 18px 12px; border-right: 0; }
.workspace-brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 24px; font-size: 15px; font-weight: 650; letter-spacing: -.3px; }
.workspace-mark { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 6px; background: var(--ink); color: var(--surface); font-size: 16px; font-family: Georgia, serif; }
.new-page { position: static; transform: none; width: 100%; color: var(--secondary); }
#page-list { margin-top: 16px; max-height: none; flex: 1; min-height: 0; padding-bottom: 24px; }
.saved-page { min-height: 36px; font-size: 13px; }
.theme-toggle { justify-content: flex-start; width: 100%; min-height: 40px; padding: 8px 10px; color: var(--secondary); }
.theme-toggle svg { flex-shrink: 0; }
.theme-toggle .sun-icon { display: none; }
[data-theme="dark"] .theme-toggle .sun-icon { display: block; }
[data-theme="dark"] .theme-toggle .moon-icon { display: none; }
main { margin-top: 88px; max-width: 800px; }
.page-icon { width: 42px; height: 42px; margin-bottom: 24px; }
.page-title { font-weight: 700; letter-spacing: -1.2px; }
.page-title::placeholder { color: var(--muted); }
.toolbar { margin-bottom: 24px; }
#start { border-radius: 6px; min-height: 34px; }
.content-tabs { gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.content-tab-list { display: flex; align-items: center; gap: 20px; }
#copy-content { margin-left: auto; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 5px; flex-shrink: 0; }
#copy-content:hover { color: var(--ink); background: var(--selection-color); }
#copy-content:focus-visible { outline: 2px solid var(--active); outline-offset: 2px; }
#copy-content .copy-check { display: none; }
#copy-content[data-copied="true"] { color: var(--ink); }
#copy-content[data-copied="true"] .copy-icon { display: none; }
#copy-content[data-copied="true"] .copy-check { display: block; }
.copy-feedback { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 640px) { #copy-content { width: 44px; height: 44px; } }
.transcript-heading { position: relative; margin: 0; padding: 10px 2px 12px; border-radius: 0; background: transparent; color: var(--muted); font-weight: 500; }
.transcript-heading:hover { background: transparent; color: var(--ink); }
.transcript-heading[aria-selected="true"] { color: var(--ink); }
.transcript-heading[aria-selected="true"]::after { content: ""; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px; background: var(--ink); }
.settings-menu > .language-settings, .explanation { border-radius: 8px; box-shadow: 0 4px 16px #0000000c; }
.page-saved-check::after { box-shadow: none; }
.segment, .utterance-translation { border-color: var(--line); }
.term-example { border-left-color: var(--muted); }
#page-summary[aria-busy="true"], .segment[data-time-label]::before, #interim { color: var(--muted); }
#transcript::selection, #transcript ::selection, #page-summary::selection, #page-summary ::selection { color: var(--ink); }
::highlight(saved-terms) { background: var(--selection-color); color: var(--ink); }
button:disabled:hover { background: transparent; }
@media (max-width: 1000px) and (min-width: 641px) {
    :root { --sidebar-width: 200px; }
    main { margin-top: 60px; width: calc(100% - var(--sidebar-width) - 64px); }
}
@media (max-width: 640px) {
    .sidebar { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 4px 8px; padding: 10px 16px 0; }
    .workspace-brand { padding: 0; }
    .new-page { width: auto; min-height: 44px; }
    .theme-toggle { width: 44px; height: 44px; justify-content: center; padding: 8px; }
    .theme-toggle span { display: none; }
    #page-list { grid-column: 1 / -1; margin-top: 6px; padding-bottom: 10px; max-height: 64px; }
    .saved-page { min-height: 40px; }
    main { margin: 34px 22px 0; width: auto; }
    .page-icon { margin-bottom: 18px; }
    .page-title { font-size: 30px; }
    .content-tabs { margin-bottom: 24px; }
    .transcript-heading { min-height: 44px; }
    .settings-toggle { width: 44px; height: 44px; }
}
@media (max-width: 360px) {
    .new-page { font-size: 12px; gap: 5px; }
    main { margin-inline: 16px; }
}

:root { --dictation-bg: #c6dcf2; --dictation-hover: #b4d0ec; --dictation-ink: #294766; }
:root[data-theme="dark"] { --dictation-bg: #3d6083; --dictation-hover: #496f95; --dictation-ink: #f0f5fc; }
#start { background: var(--dictation-bg); color: var(--dictation-ink); }
#start:hover { background: var(--dictation-hover); }
#start .record-dot { background: currentColor; }
#start[aria-pressed="true"] .record-dot { border-radius: 1px; box-shadow: none; }
@media (max-width: 640px) { .sidebar { grid-template-columns: 1fr auto; } }

.saved-page-row + .saved-page-row { margin-top: 8px; }
.segment[contenteditable="plaintext-only"] { cursor: text; white-space: pre-wrap; border-radius: 4px; }
.segment[contenteditable="plaintext-only"]:focus { outline: 2px solid var(--active); outline-offset: 5px; }
#edit-transcript[aria-pressed="true"] { background: var(--selection-color); color: var(--ink); }
@media (max-width: 640px) {
    #page-list { gap: 12px; }
    .saved-page-row + .saved-page-row { margin-top: 0; }
}
