:root {
  --paper: #f3f8fa;
  --surface: #ffffff;
  --ink: #17313d;
  --muted: #5e7280;
  --line: #d4e2e7;
  --green: #1f6f82;
  --green-soft: #e3f0f3;
  --reading-emphasis: #9c343d;
  --red: #c5533d;
  --amber: #a86121;
  --panel-radius: 16px;
  --control-radius: 10px;
  --shadow-sm: 0 1px 2px rgba(38, 51, 50, .035), 0 1px 3px rgba(38, 51, 50, .05);
  --shadow-panel: 0 10px 32px rgba(38, 51, 50, .055);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1080px; background: var(--paper); }
button, input { font: inherit; }
button { color: inherit; }
.app-shell { min-height: 100vh; }
.topbar { height: 72px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; width: max-content; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; background: var(--green); color: white; border-radius: 50% 50% 50% 12px; font: 700 18px Georgia, serif; }
.brand strong, .brand small { display: block; }
.brand strong { font: 700 17px Georgia, "Songti SC", serif; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 10px; letter-spacing: .12em; }
.mode-switch { align-self: stretch; display: flex; gap: 28px; }
.mode-tab { border: 0; border-bottom: 3px solid transparent; padding: 3px 5px 0; background: transparent; color: var(--muted); cursor: pointer; }
.mode-tab.active { border-color: var(--green); color: var(--green); font-weight: 700; }
.streak { justify-self: end; display: flex; align-items: baseline; gap: 5px; color: var(--muted); font-size: 12px; }
.streak strong { color: var(--amber); font: 700 22px Georgia, serif; }
.workspace { display: grid; grid-template-columns: minmax(255px, 21%) minmax(500px, 46%) minmax(330px, 33%); height: calc(100vh - 72px); }
.panel { min-width: 0; background: var(--surface); }
.library-panel, .conversation-panel { border-right: 1px solid var(--line); }
.library-panel, .analysis-panel { padding: 26px 22px; overflow-y: auto; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.eyebrow { color: var(--green); font-size: 9px; font-weight: 800; letter-spacing: .16em; }
h1, h2 { margin: 4px 0 0; font: 700 22px Georgia, "Songti SC", serif; }
.icon-button { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; background: transparent; font-size: 21px; cursor: pointer; }
.search-box { height: 40px; margin-top: 22px; padding: 0 12px; display: flex; align-items: center; gap: 8px; background: #f1f2ed; border: 1px solid transparent; }
.search-box:focus-within { border-color: var(--green); background: white; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 12px; }
.category-row { display: flex; gap: 15px; margin-top: 18px; overflow: hidden; }
.category { padding: 0 0 6px; border: 0; border-bottom: 2px solid transparent; background: transparent; white-space: nowrap; color: var(--muted); font-size: 11px; cursor: pointer; }
.category.active { color: var(--green); border-color: var(--green); font-weight: 700; }
.sort-note { margin: 18px 0 9px; color: #9aa29e; font-size: 10px; }
.sort-note span { color: var(--green); }
.phrase-list { display: grid; gap: 9px; }
.phrase-card { padding: 14px; border: 1px solid var(--line); border-left: 3px solid transparent; background: white; cursor: pointer; }
.phrase-card.selected { border-left-color: var(--green); background: #fbfcf9; }
.phrase-meta, .block-title, .pattern-card > div { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tag { color: var(--green); font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.count { color: var(--muted); font-size: 9px; }
.count b { color: var(--amber); font-size: 14px; }
.phrase-card p { margin: 11px 0 5px; font: 600 13px Georgia, serif; line-height: 1.45; }
.phrase-card small { color: var(--muted); font-size: 10px; }
.phrase-card .entry-details { display: none; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); }
.phrase-card.selected .entry-details { display: grid; gap: 8px; }
.detail-row { display: grid; gap: 3px; }
.detail-row span { color: #9aa29e; font-size: 8px; font-weight: 800; letter-spacing: .09em; }
.detail-row p { margin: 0; color: #4f5d57; font: 10px/1.55 Georgia, serif; }
.detail-row.zh p { font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif; }
.load-more { width: 100%; margin-top: 10px; padding: 9px; border: 1px solid var(--line); background: transparent; color: var(--green); font-size: 9px; cursor: pointer; }
.load-more:hover { border-color: var(--green); background: var(--green-soft); }
.conversation-panel { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; background: #f0efe9; }
.conversation-header { padding: 18px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.conversation-header > div { display: grid; grid-template-columns: auto 1fr; column-gap: 9px; }
.conversation-header strong { font: 700 14px Georgia, "Songti SC", serif; }
.conversation-header small { grid-column: 2; margin-top: 4px; color: var(--muted); font-size: 10px; }
.status-dot { width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: #4fa079; box-shadow: 0 0 0 3px #dcebe3; }
.outline-button { padding: 7px 11px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; }
.chat-stream { padding: 14px 28px 28px; overflow-y: auto; }
.date-divider { display: flex; align-items: center; gap: 10px; margin: 4px 0 21px; color: #9aa29e; font-size: 9px; }
.date-divider::before, .date-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.message { display: flex; align-items: flex-start; gap: 9px; margin: 0 0 20px; }
.message.user { justify-content: flex-end; }
.avatar { flex: 0 0 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: white; font-size: 9px; font-weight: 800; }
.message.user .avatar { background: #c8a975; color: #392d1c; }
.bubble { max-width: 430px; padding: 13px 15px; background: white; border: 1px solid var(--line); box-shadow: 0 5px 18px rgba(24, 42, 35, .04); }
.message.user .bubble { background: var(--green-soft); border-color: #c6dcd2; }
.bubble p { margin: 0; font: 13px/1.55 Georgia, serif; }
.play-button { display: flex; align-items: center; gap: 8px; width: 100%; margin: 0 0 9px; padding: 0; border: 0; background: transparent; color: var(--green); text-align: left; cursor: pointer; }
.coach .play-button { margin: 11px 0 0; }
.wave { flex: 1; letter-spacing: 2px; }
.play-button small { color: var(--muted); }
.message time { display: block; margin-top: 5px; color: #9aa29e; font-size: 8px; }
.message.user time { text-align: right; }
.message.compact .bubble { padding-block: 10px; }
.voice-composer { min-height: 82px; padding: 13px 18px; display: grid; grid-template-columns: 35px 1fr auto; align-items: center; gap: 12px; background: var(--surface); border-top: 1px solid var(--line); }
.keyboard-button { height: 35px; border: 0; background: transparent; cursor: pointer; }
.hold-to-talk { height: 54px; border: 1px solid #b5cec4; background: var(--green-soft); display: grid; grid-template-columns: auto auto; justify-content: center; align-content: center; column-gap: 8px; cursor: pointer; user-select: none; }
.hold-to-talk .mic { grid-row: 1 / 3; align-self: center; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: white; font-size: 7px; }
.hold-to-talk strong { font-size: 12px; }
.hold-to-talk small { color: var(--muted); font-size: 8px; }
.end-button { border: 0; background: transparent; color: var(--red); font-size: 10px; cursor: pointer; }
.score-ring { width: 44px; height: 44px; display: grid; place-items: center; border: 4px solid #dce8e2; border-top-color: var(--green); border-radius: 50%; color: var(--green); font: 700 15px Georgia, serif; }
.analysis-tabs { display: flex; gap: 24px; margin: 21px 0 18px; border-bottom: 1px solid var(--line); }
.analysis-tabs button { padding: 0 0 9px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; }
.analysis-tabs button.active { color: var(--green); border-color: var(--green); font-weight: 700; }
.analysis-block { padding: 0 0 17px; margin-bottom: 17px; border-bottom: 1px solid var(--line); }
.block-label { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .08em; }
.original { margin: 8px 0 0; color: #53615b; font: 13px/1.7 Georgia, serif; }
.message .bubble mark.topic-highlight { color: var(--reading-emphasis); background: transparent; }
.improved > p { margin: 9px 0 13px; font: 14px/1.7 Georgia, serif; }
.improved strong { color: var(--green); }
.block-title button { border: 0; background: transparent; color: var(--muted); font-size: 9px; cursor: pointer; }
.tip { padding: 11px 12px; border-left: 2px solid var(--amber); background: #faf5eb; }
.tip b { color: #7c5b30; font-size: 9px; }
.tip p { margin: 5px 0 0; color: #796e5f; font-size: 10px; line-height: 1.55; }
.pattern-card { padding: 14px; border: 1px solid #b7d1c6; background: var(--green-soft); }
.save-pattern { border: 0; background: transparent; color: var(--green); font-size: 9px; font-weight: 700; cursor: pointer; }
.pattern-card > strong { display: block; margin-top: 14px; font: 700 14px Georgia, serif; }
.pattern-card > p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.taxonomy-heading { display: flex; justify-content: space-between; align-items: center; margin-top: 17px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .08em; }
.taxonomy-heading button { padding: 0; border: 0; background: transparent; color: var(--green); font-size: 8px; cursor: pointer; }
.category-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; margin-top: 8px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.category { min-width: 0; padding: 8px 7px; display: flex; justify-content: space-between; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 9px; text-align: left; cursor: pointer; }
.category b { color: #a5aca8; font-weight: 500; }
.category.active { background: var(--green); color: white; font-weight: 700; }
.category.active b { color: #c7ddd4; }
[hidden] { display: none !important; }
.text-composer { min-width: 0; height: 42px; display: flex; border: 1px solid #b5cec4; background: white; }
.text-composer input { min-width: 0; flex: 1; border: 0; outline: 0; padding: 0 12px; }
.text-composer button { border: 0; padding: 0 14px; background: var(--green); color: white; cursor: pointer; }
.hold-to-talk.recording { background: #f8ded7; border-color: #d69a8d; }
.hold-to-talk.recording .mic { background: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(184,92,74,.13); } }
.prompt-panel, .editor-panel { border-right: 1px solid var(--line); }
.prompt-panel, .feedback-panel { padding: 26px 22px; overflow-y: auto; }
.library-view-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-top: 18px; border-bottom: 1px solid var(--line); }
.library-view-tabs button { padding: 9px 4px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; }
.library-view-tabs button.active { border-color: var(--green); color: var(--green); font-weight: 700; }
.library-view-tabs b { display: inline-grid; min-width: 18px; margin-left: 3px; color: var(--amber); font-size: 9px; }
.writing-library-filters { display: flex; gap: 5px; margin-top: 12px; overflow-x: auto; padding-bottom: 3px; }
.writing-library-filters button { flex: 0 0 auto; padding: 6px 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 8px; cursor: pointer; }
.writing-library-filters button.active { border-color: var(--green); background: var(--green); color: white; }
.writing-library-list { display: grid; gap: 9px; }
.writing-entry { padding: 13px; border: 1px solid var(--line); border-left: 3px solid transparent; background: white; cursor: pointer; }
.writing-entry.selected { border-left-color: var(--green); background: #fbfcf9; }
.writing-entry .entry-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.writing-entry .entry-head span { color: var(--green); font-size: 8px; font-weight: 800; letter-spacing: .06em; }
.writing-entry .entry-head small { color: #a0a7a3; font-size: 8px; }
.writing-entry > p { margin: 9px 0 5px; font: 600 12px/1.5 Georgia, serif; }
.writing-entry > small { display: block; color: var(--muted); font-size: 9px; line-height: 1.45; }
.writing-entry .entry-details { display: none; margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line); }
.writing-entry.selected .entry-details { display: grid; gap: 8px; }
.prompt-filters { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 17px; border: 1px solid var(--line); }
.prompt-filters button { border: 0; border-right: 1px solid var(--line); padding: 8px 4px; background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; }
.prompt-filters button:last-child { border-right: 0; }
.prompt-filters button.active { background: var(--green); color: white; }
.prompt-list { display: grid; gap: 9px; }
.prompt-card { padding: 14px; border: 1px solid var(--line); border-left: 3px solid transparent; background: white; cursor: pointer; }
.prompt-card.selected { border-left-color: var(--green); background: #fbfcf9; }
.prompt-card > div { display: flex; justify-content: space-between; color: var(--green); font-size: 9px; font-weight: 800; }
.prompt-card time { color: #a4aaa7; font-weight: 400; }
.prompt-card p { margin: 10px 0 8px; font: 12px/1.55 Georgia, serif; }
.prompt-card small { color: var(--muted); font-size: 9px; }
.editor-panel { display: grid; grid-template-rows: auto auto 1fr auto; min-height: 0; background: #f0efe9; }
.editor-header { min-height: 79px; padding: 17px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.editor-header h2 { font-size: 17px; }
.editor-settings { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.editor-settings .switch-row { white-space: nowrap; }
.editor-header > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.switch-row { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; }
.switch-row i { position: relative; width: 29px; height: 16px; border-radius: 20px; background: #c9cecb; transition: .2s; }
.switch-row i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: white; transition: .2s; }
.switch-row input:checked + i { background: var(--green); }
.switch-row input:checked + i::after { transform: translateX(13px); }
.question-brief { padding: 12px 24px; background: #e6ece8; border-bottom: 1px solid #ccd8d2; }
.question-brief span { color: var(--green); font-size: 8px; font-weight: 800; letter-spacing: .12em; }
.question-brief p { margin: 5px 0 0; color: #47564f; font: 11px/1.5 Georgia, serif; }
.writing-surface { min-height: 0; margin: 20px 26px 12px; display: grid; grid-template-rows: 1fr auto; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 28px rgba(24, 42, 35, .05); }
#essayEditor { width: 100%; min-height: 360px; resize: none; padding: 28px 34px; border: 0; outline: 0; background: transparent; color: #2c3733; font: 14px/1.9 Georgia, serif; }
.editor-footer { padding: 9px 16px; display: flex; justify-content: space-between; border-top: 1px solid var(--line); color: #9ba39f; font-size: 9px; }
.editor-footer b { color: var(--green); }
.submit-bar { padding: 0 26px 17px; display: flex; justify-content: space-between; align-items: center; }
.kbd { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 3px; border: 1px solid var(--line); background: white; color: var(--muted); font-size: 9px; box-shadow: 0 2px 0 var(--line); }
.submit-bar small { margin-left: 5px; color: var(--muted); font-size: 9px; }
.primary-button { padding: 11px 18px; border: 0; background: var(--green); color: white; font-size: 11px; cursor: pointer; }
.primary-button span { margin-left: 15px; }
.writing-score { border-top-color: var(--amber); color: var(--amber); }
.band-grid { display: grid; grid-template-columns: repeat(4, 1fr); margin: 20px 0 18px; border: 1px solid var(--line); }
.band-grid > div { padding: 9px 2px; display: grid; text-align: center; border-right: 1px solid var(--line); }
.band-grid > div:last-child { border-right: 0; }
.band-grid span { color: var(--green); font-size: 8px; font-weight: 800; }
.band-grid strong { margin: 3px 0; font: 700 14px Georgia, serif; }
.band-grid small { color: var(--muted); font-size: 7px; }
.feedback-tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); }
.feedback-tabs button { padding: 0 0 9px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; }
.feedback-tabs button.active { border-color: var(--green); color: var(--green); font-weight: 700; }
.feedback-content { padding-top: 15px; }
.dictionary-selection-menu { position: fixed; z-index: 150; display: flex; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--ink); box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.dictionary-selection-menu[hidden], .dictionary-selection-action[hidden] { display: none; }
.dictionary-selection-action { min-height: 44px; padding: 6px 12px; border: 0; border-radius: 8px; background: transparent; color: inherit; font-size: .875rem; font-weight: 650; white-space: nowrap; cursor: pointer; }
.dictionary-selection-action + .dictionary-selection-action { color: var(--ocean-deep); }
.dictionary-selection-action:hover { background: var(--sky); }
.dictionary-selection-action:focus-visible { outline: 2px solid var(--ocean-deep); outline-offset: 2px; }
.dictionary-dialog { width: min(480px, calc(100vw - 28px)); max-height: min(78vh, 680px); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.22); }
.dictionary-dialog[open] { display: flex; flex-direction: column; }
.dictionary-dialog::backdrop { background: rgba(18, 24, 24, .48); }
.dictionary-heading { display: flex; align-items: center; gap: 6px; padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.dictionary-title { flex: 1 1 auto; min-width: 0; }
.dictionary-heading small { color: var(--muted); font-size: .75rem; }
.dictionary-heading h2 { margin: 4px 0 0; color: var(--ink); font-size: 1.35rem; line-height: 1.25; overflow-wrap: anywhere; }
.dictionary-heading form { padding: 0; }
.dictionary-heading button { display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 1.5rem; line-height: 1; cursor: pointer; }
.dictionary-heading button:hover, .dictionary-heading button:focus-visible { background: var(--sky); color: var(--ink); }
.dictionary-heading .dictionary-icon-button { flex: 0 0 auto; font-size: 1.25rem; }
.dictionary-heading .dictionary-icon-button:disabled { opacity: .35; cursor: not-allowed; }
.dictionary-content { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 20px; overflow-wrap: anywhere; }
.dictionary-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
.dictionary-actions button { flex: 0 1 auto; min-height: 42px; padding: 8px 14px; border-radius: 9px; font-size: .875rem; font-weight: 650; }
.dictionary-actions button:disabled { opacity: .58; cursor: default; }
.dictionary-actions button:focus-visible { outline: 2px solid var(--ocean-deep); outline-offset: 2px; }
.dictionary-status { margin: 0; color: var(--muted); line-height: 1.6; }
.dictionary-card + .dictionary-card { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.dictionary-headword { margin: 0 0 6px; font-weight: 700; }
.dictionary-pronunciation { margin: 0 0 10px; color: var(--muted); }
.dictionary-pos { margin: 12px 0 4px; color: var(--ocean-deep); font-weight: 700; }
.dictionary-definition { margin: 5px 0; line-height: 1.55; }
.dictionary-example { margin: 5px 0 10px; color: var(--muted); font-style: italic; line-height: 1.5; }
@media (max-width: 599px) {
  .dictionary-dialog { margin: auto 0 0; width: 100%; max-width: none; max-height: 74dvh; border-radius: 16px 16px 0 0; border-bottom: 0; }
  .dictionary-actions { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .dictionary-actions button { flex: 1 1 auto; }
}
.correction-card { padding: 0 0 14px; margin-bottom: 14px; display: grid; grid-template-columns: 24px 1fr; gap: 9px; border-bottom: 1px solid var(--line); }
.sentence-number { color: #a4aaa7; font: 11px Georgia, serif; }
.correction-card p { margin: 0 0 6px; color: #4a5751; font: 11px/1.55 Georgia, serif; }
.correction-card .replacement { padding: 8px; background: var(--green-soft); color: var(--green); }
.good-note, .grammar-note { color: #5a9077; font-size: 8px; }
.grammar-note { color: var(--red); }
.logic-note { padding: 11px; margin-bottom: 14px; border-left: 2px solid var(--amber); background: #faf5eb; }
.logic-note span { color: #89643c; font-size: 9px; font-weight: 700; }
.logic-note p { margin: 5px 0 0; color: #796e5f; font-size: 9px; line-height: 1.55; }
.vocab-suggestion { padding: 13px; border: 1px solid #b7d1c6; background: var(--green-soft); }
.vocab-suggestion > div { display: flex; justify-content: space-between; gap: 8px; }
.save-writing { border: 0; background: transparent; color: var(--green); font-size: 8px; font-weight: 700; cursor: pointer; }
.vocab-suggestion strong { display: block; margin-top: 12px; font: 700 12px/1.4 Georgia, serif; }
.vocab-suggestion p { margin: 5px 0 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
dialog { width: min(480px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 28px 80px rgba(20,40,32,.22); color: var(--ink); }
dialog::backdrop { background: rgba(20,30,27,.34); backdrop-filter: blur(3px); }
dialog form { padding: 24px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.dialog-heading > button { border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
#entryForm > label { display: grid; gap: 7px; margin-bottom: 14px; color: var(--muted); font-size: 10px; font-weight: 700; }
#entryForm input, #entryForm textarea { width: 100%; padding: 10px 11px; border: 1px solid var(--line); background: #fafaf7; outline: 0; color: var(--ink); font: 12px/1.5 Georgia, serif; resize: vertical; }
#entryForm textarea { min-height: 66px; }
#entryForm input:focus, #entryForm textarea:focus { border-color: var(--green); background: white; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.dialog-actions button { padding: 9px 15px; border: 1px solid var(--line); background: transparent; font-size: 10px; cursor: pointer; }
.dialog-actions button:last-child { border-color: var(--green); background: var(--green); color: white; }
.taxonomy-dialog { width: min(760px, calc(100vw - 32px)); }
.taxonomy-intro { color: var(--muted); font-size: 11px; line-height: 1.7; }
.taxonomy-grid { display: grid; grid-template-columns: repeat(2, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.taxonomy-grid section { padding: 13px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.taxonomy-grid b { color: var(--green); font-size: 11px; }
.taxonomy-grid p { margin: 7px 0 0; color: var(--muted); font-size: 9px; line-height: 1.65; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 24px; transform: translate(-50%, 20px); padding: 10px 16px; background: var(--ink); color: white; opacity: 0; pointer-events: none; font-size: 10px; transition: .25s; box-shadow: 0 8px 24px rgba(0,0,0,.16); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 980px) {
  body { min-width: 0; }
  .topbar { height: auto; min-height: 64px; grid-template-columns: 1fr auto; padding: 10px 16px; }
  .mode-switch { grid-column: 1 / -1; grid-row: 2; height: 40px; justify-self: center; }
  .streak { grid-column: 2; grid-row: 1; }
  .workspace { height: auto; grid-template-columns: 1fr; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .library-panel, .prompt-panel { max-height: 520px; }
  .conversation-panel { min-height: 680px; }
  .analysis-panel, .feedback-panel { min-height: 560px; }
  .editor-panel { min-height: 760px; }
}
@media (max-height: 720px) { .library-panel, .analysis-panel { padding-top: 18px; } .bubble { padding: 10px 13px; } .message { margin-bottom: 14px; } }

/* Library navigation keeps sentence frames and lexical items on separate surfaces. */
.library-browser { margin-top: 14px; }
.library-filter { display: grid; gap: 6px; min-width: 0; color: #4f6259; font-size: .875rem; }
.library-filter select, .entry-classification-fields select { width: 100%; min-width: 0; min-height: 40px; padding: 8px; border: 1px solid var(--line); background: white; color: var(--ink); font: inherit; }
.library-kind-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; margin: 14px 0; background: #edf0eb; }
.library-kind-tabs button { min-height: 42px; padding: 8px 5px; border: 0; background: transparent; color: #586b61; font-size: .875rem; cursor: pointer; }
.library-kind-tabs button.active { background: var(--green); color: white; }
.library-kind-tabs b { font-size: .75rem; font-weight: 500; opacity: .8; }
.dimension-filters { display: grid; gap: 10px; }
.library-hint { color: #617269; font-size: .8125rem; line-height: 1.6; margin: 12px 0 0; }
.library-panel .sort-note, #writingResultCount { color: #627469; font-size: .8125rem; line-height: 1.6; }
.phrase-meta { align-items: flex-start; flex-wrap: wrap; }
.phrase-card .tag, .writing-entry .tag { font-size: .75rem; letter-spacing: 0; line-height: 1.6; }
.phrase-card .count { white-space: nowrap; font-size: .75rem; }
.entry-kind { display: inline-block; margin-top: 8px; padding: 2px 6px; background: #eef2ee; color: #496253; font-size: .75rem; line-height: 1.4; }
[data-kind="vocabulary"] .entry-kind { background: #f4ece0; color: #79582f; }
.phrase-card .entry-english, .writing-entry .entry-english { font: 600 1rem/1.55 Georgia, serif; overflow-wrap: anywhere; }
.phrase-card .entry-note, .writing-entry .entry-note { display: block; color: #5c6c62; font-size: .875rem; line-height: 1.6; margin-bottom: 6px; }
.text-action { display: block; padding: 6px 0; margin-top: 5px; border: 0; background: transparent; color: var(--green); font-size: .875rem; text-align: left; cursor: pointer; }
.text-action:hover { text-decoration: underline; }
.entry-details .detail-row p { font-size: 1rem; line-height: 1.6; overflow-wrap: anywhere; }
.entry-details .detail-row span { font-size: .75rem; color: #66786d; letter-spacing: 0; }
.library-empty { padding: 20px 14px; border: 1px dashed var(--line); color: #63736a; }
.library-empty p { font-size: 1rem; line-height: 1.5; }
.library-empty small { font-size: .875rem; line-height: 1.6; }
.load-more, .library-panel .search-box input, #writingLibraryView .search-box input { font-size: .875rem; }
.entry-classification-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.entry-classification-fields label { display: grid; gap: 7px; font-size: .875rem; }
.entry-classification-fields label[hidden] { display: none; }
#entryForm > label, #entryForm input, #entryForm textarea, #entryForm select { font-size: .875rem; }
#entryForm textarea[readonly] { background: #eef1ec; color: #506357; }
.taxonomy-intro { font-size: 1rem; }
.taxonomy-grid b { font-size: .875rem; }
.taxonomy-grid p { font-size: .8125rem; }
.library-browser :focus-visible, .text-action:focus-visible, #entryForm :focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
@media (max-width: 980px) {
  .library-panel, .prompt-panel { max-height: 760px; }
  .dimension-filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 420px) {
  .dimension-filters, .entry-classification-fields, .taxonomy-grid { grid-template-columns: 1fr; }
}

/* Live practice extends the existing green, three-column working surface. */
.connection-button { justify-self: end; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); padding: 10px 12px; color: var(--green); background: transparent; font: inherit; font-size: .875rem; cursor: pointer; }
.connection-button .status-dot { margin: 0; }
.conversation-header > div { grid-template-columns: 1fr; min-width: 0; }
.conversation-header small { grid-column: 1; }
.conversation-panel { grid-template-rows: auto minmax(120px, 1fr) auto; grid-auto-rows: auto; }
.editor-panel { grid-template-rows: auto auto minmax(250px, 1fr) auto auto; }
#essayEditor { min-height: 0; font-size: 1rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
.conversation-header strong { font-size: 1rem; }
.conversation-header small { max-width: 420px; font-size: .875rem; line-height: 1.5; overflow-wrap: anywhere; }
.conversation-header .outline-button, .end-button { font-size: .875rem; white-space: nowrap; }
.message .bubble p { font-size: 1rem; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.message time { font-size: .75rem; }
.message audio { width: min(260px, 100%); margin-top: 10px; }
.message .text-action { padding: 3px 0; font-size: .8125rem; }
.play-button { font-size: .875rem; }
.practice-status { flex-shrink: 0; margin: 0; padding: 10px 20px; font-size: .875rem; line-height: 1.6; color: #52675a; background: #edf3ed; overflow-wrap: anywhere; }
.is-error { color: #a52a2a !important; background: #fff0ef; }
.voice-composer { flex-wrap: wrap; gap: 10px; }
.hold-to-talk { min-height: 54px; touch-action: manipulation; }
.hold-to-talk strong { font-size: 1rem; }
.hold-to-talk small { font-size: .75rem; }
.text-composer { min-width: 0; }
.text-composer input { min-width: 0; font-size: 1rem; }
.text-composer button { font-size: .875rem; }
.voice-message-label { display: block; color: var(--green); font-size: .875rem; font-weight: 600; }
.message .bubble .voice-message-status { display: block; margin: 8px 0; font: .875rem/1.6 Inter, "Microsoft YaHei", sans-serif; color: #63746b; }
.message audio + p { margin-top: 10px; }
.real-analysis { overflow-y: auto; min-height: 0; flex: 1; }
.real-analysis h3, #feedbackContent h3 { font-size: 1rem; color: var(--green); margin: 20px 0 10px; }
.ai-sentence { padding: 18px 0; border-bottom: 1px solid var(--line); }
.ai-sentence .block-label { font-size: .75rem; }
.sentence-label { display: block; margin-top: 12px; color: #68756d; font-size: .75rem; }
.ai-original, .ai-improved, .ai-english { margin: 7px 0 12px; font: 1rem/1.7 Georgia, serif; overflow-wrap: anywhere; white-space: pre-wrap; }
.ai-original { color: #6b6c66; }
.ai-improved { color: #21573b; background: #edf3e9; padding: 10px; }
.ai-explanation { font-size: .875rem; line-height: 1.8; color: #495e50; white-space: pre-wrap; overflow-wrap: anywhere; }
.answer-feedback { padding: 16px; border: 1px solid #d2ded0; border-radius: 10px; background: #f0f5eb; }
.answer-feedback h3 { margin-top: 0; }
.answer-feedback h4 { margin: 16px 0 4px; font-size: .8125rem; color: #35563f; }
.answer-feedback .ai-explanation { margin: 4px 0 10px; }
.speaking-verdict { display: inline-block; margin-left: 10px; padding: 4px 8px; border-radius: 6px; font-size: .75rem; line-height: 1.5; background: #edf3e9; color: #21573b; }
.verdict-accuracy { background: #fff0e0; color: #855014; }
.verdict-uncertain { background: #edf0f2; color: #52616c; }
.verdict-naturalness { background: #eaf1f7; color: #355c7a; }
.natural-answer { border-top: 1px solid #d2ded0; padding-top: 12px; margin-top: 14px; }
.natural-answer summary { cursor: pointer; color: #35563f; font-size: .8125rem; line-height: 1.8; }
.natural-answer summary:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
.sentence-actions { display: flex; gap: 16px; align-items: center; }
.sentence-actions .text-action { display: inline-flex; flex: 0 0 auto; white-space: nowrap; }
.ai-suggestion { padding: 14px; margin: 16px 0; border: 1px solid #d2ded0; background: #f0f5eb; }
.ai-suggestion .ai-english { font-weight: 600; }
.assessment-note { flex-shrink: 0; font-size: .8125rem; line-height: 1.6; padding-top: 12px; color: #68756b; }
.empty-feedback { margin: 24px 0; font-size: 1rem; line-height: 1.7; color: #617267; }
.analysis-tabs button, .feedback-tabs button { font-size: .875rem; }
.settings-dialog { width: min(560px, calc(100vw - 32px)); }
.settings-dialog p, #topicDialog p { font-size: .875rem; line-height: 1.8; }
.settings-dialog small { display: block; margin-top: 10px; font-size: .8125rem; line-height: 1.6; }
.settings-dialog dl { display: grid; grid-template-columns: 110px minmax(0, 1fr); font-size: .875rem; gap: 12px; padding: 16px; background: #edf3ed; }
.settings-dialog dd { margin: 0; overflow-wrap: anywhere; }
.settings-option { display: flex; gap: 10px; align-items: center; }
#topicDialog label { display: grid; gap: 8px; margin: 16px 0; font-size: .875rem; }
#topicDialog select, #topicDialog textarea { width: 100%; padding: 10px; font: inherit; border: 1px solid var(--line); }
#topicDialog textarea { min-height: 100px; }
#topicDialog label[hidden], [hidden] { display: none !important; }
.primary-button { font-size: .875rem; }
.editor-settings .switch-row, .editor-footer, .question-brief p { font-size: .875rem; }
.switch-row input:focus-visible + i { outline: 2px solid var(--green); outline-offset: 3px; }
.kbd { width: auto; min-width: 20px; padding: 0 4px; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
.toast { max-width: min(90vw, 640px); font-size: .875rem; line-height: 1.6; }
@media (max-width: 980px) {
  .connection-button { grid-column: 2; grid-row: 1; }
  .conversation-panel { min-height: 600px; }
  .real-analysis { max-height: 680px; }
}

/* Tablets retain the desktop workspace. Phones switch panels without rebuilding them. */
body { min-width: 0; }
.mobile-panels { display: none; }
@media (min-width: 600px) {
  .topbar { height: 72px; min-height: 0; grid-template-columns: 1fr auto 1fr; padding: 0 16px; }
  .mode-switch { grid-column: 2; grid-row: 1; height: 100%; }
  .connection-button { grid-column: 3; grid-row: 1; }
  .workspace { height: calc(100dvh - 116px); grid-template-columns: minmax(180px, 24%) minmax(240px, 39%) minmax(220px, 37%); }
  .workspace > .panel { min-height: 0; max-height: none; border-right: 1px solid var(--line); }
  .real-analysis { max-height: none; }
}
@media (min-width: 1200px) {
  .workspace { grid-template-columns: minmax(255px, 23%) minmax(400px, 42%) minmax(330px, 35%); }
}
@media (min-width: 600px) and (max-width: 1100px) {
  .library-panel, .analysis-panel, .prompt-panel, .feedback-panel { padding: 18px 12px; }
  .conversation-header, .editor-header { padding: 14px 12px; flex-wrap: wrap; }
  .editor-settings { flex-wrap: wrap; }
  .voice-composer { padding: 10px 8px; gap: 6px; }
  .chat-stream { padding: 12px 8px; }
}
@media (max-width: 599px) {
  html, body { height: 100%; overflow: hidden; }
  .app-shell { height: 100dvh; min-height: 0; display: flex; flex-direction: column; }
  .topbar { flex-shrink: 0; min-height: 0; padding: 8px 12px 0; gap: 6px; }
  .brand small { display: none; }
  .brand strong { font-size: 1rem; }
  .brand-mark { width: 28px; height: 28px; }
  .mode-switch { width: 100%; height: 42px; justify-content: center; gap: 36px; }
  .mode-tab { font-size: .9375rem; }
  .mobile-panels { display: flex; flex-shrink: 0; gap: 6px; padding: 7px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .mobile-panels button { flex: 1; min-height: 42px; border: 1px solid var(--line); border-radius: 8px; background: transparent; font-size: .875rem; }
  .mobile-panels button[aria-pressed="true"] { color: white; border-color: var(--green); background: var(--green); }
  .workspace { flex: 1; height: auto; min-height: 0; overflow: hidden; grid-template-columns: minmax(0, 1fr); }
  .workspace > .panel { min-height: 0; max-height: none; padding: 12px; overflow: auto; }
  .speaking-workspace[data-mobile-panel="library"] > .conversation-panel,
  .speaking-workspace[data-mobile-panel="library"] > .analysis-panel,
  .speaking-workspace[data-mobile-panel="practice"] > .library-panel { display: none; }
  .speaking-workspace[data-mobile-panel="library"] { grid-template-rows: minmax(0, 1fr); }
  .speaking-workspace[data-mobile-panel="practice"] { grid-template-rows: minmax(255px, .42fr) minmax(0, .58fr); }
  .speaking-workspace > .conversation-panel { padding: 0; overflow: hidden; grid-template-rows: auto minmax(0, 1fr) auto auto; }
  .conversation-header { padding: 7px 12px; min-height: 0; gap: 8px; }
  .conversation-header strong { font-size: .875rem; }
  .conversation-header small { display: none; }
  .conversation-header .outline-button { padding: 6px 10px; min-height: 36px; }
  .chat-stream { padding: 8px 12px; min-height: 0; }
  .message { margin-bottom: 10px; gap: 8px; }
  .avatar { flex-basis: 24px; width: 24px; height: 24px; min-width: 24px; font-size: .75rem; }
  .bubble { padding: 8px 10px; }
  .message .bubble p { font-size: .9375rem; line-height: 1.55; }
  .message audio { max-height: 34px; }
  .message time { font-size: .75rem; }
  .voice-composer { min-height: 56px; padding: 6px 10px; gap: 8px; flex-shrink: 0; }
  .hold-to-talk { height: 44px; min-height: 44px; padding: 7px; }
  .hold-to-talk small { display: none; }
  .keyboard-button, .end-button { min-height: 44px; }
  #speakingStatus { margin: 0; padding: 3px 12px; max-height: 38px; overflow-y: auto; font-size: .75rem; line-height: 1.4; flex-shrink: 0; }
  .analysis-panel { display: flex; flex-direction: column; overflow: hidden !important; border-top: 2px solid var(--green); }
  .analysis-panel .eyebrow { display: none; }
  .analysis-panel h2 { font-size: 1rem; margin: 0; }
  .analysis-tabs { margin: 8px 0; gap: 24px; flex-shrink: 0; }
  .analysis-tabs button { padding-bottom: 6px; }
  .real-analysis { flex: 1; min-height: 0; max-height: none; overscroll-behavior: contain; }
  .analysis-panel > .assessment-note { margin: 5px 0 0; padding: 0; font-size: .75rem; line-height: 1.4; }
  .answer-feedback { padding: 10px; }
  .writing-workspace { grid-template-rows: minmax(0, 1fr); }
  .writing-workspace[data-mobile-panel="prompts"] > :not(.prompt-panel),
  .writing-workspace[data-mobile-panel="editor"] > :not(.editor-panel),
  .writing-workspace[data-mobile-panel="feedback"] > :not(.feedback-panel) { display: none; }
  .editor-header { padding: 4px 0 12px; flex-wrap: wrap; gap: 12px; }
  .editor-settings { width: 100%; justify-content: space-between; }
  .question-brief { padding: 10px; margin: 0; }
  .writing-surface { min-height: 160px; }
  #essayEditor { font-size: 1rem; padding: 14px; }
  .submit-bar { padding: 10px 0 max(10px, env(safe-area-inset-bottom)); }
  .panel-heading h1, .panel-heading h2 { font-size: 1.2rem; }
  .feedback-panel { display: flex; flex-direction: column; }
  .feedback-content { flex: 1; min-height: 0; overflow-y: auto; }
  .panel input, .panel textarea, dialog input, dialog textarea { font-size: 1rem; }
  .taxonomy-grid { grid-template-columns: 1fr; }
}
.storage-bar { height: 44px; flex-shrink: 0; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); background: #e7f0ec; min-width: 0; }
.storage-bar button { min-height: 36px; flex-shrink: 0; font-size: .875rem; border: 0; background: none; color: var(--green); font-weight: 600; cursor: pointer; }
#cloudStatus { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .8125rem; }
.account-chip { flex-shrink: 0; max-width: 150px; overflow: hidden; color: var(--muted); font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.storage-bar .logout-button { padding-inline: 8px; color: #8c440f; border-color: #ffc486; background: var(--orange-soft); }
.cloud-dialog { width: min(760px, calc(100vw - 24px)); max-height: 90dvh; overflow-y: auto; }
.cloud-dialog p, .cloud-dialog pre { font-size: .875rem; line-height: 1.75; }
.cloud-dialog pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.cloud-dialog h3 { font-size: 1rem; margin: 24px 0 10px; }
.cloud-dialog button:not(.dialog-heading button) { min-height: 44px; padding: 8px 12px; font-size: .875rem; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.backup-actions, .history-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.cloud-conflict { padding: 14px; margin: 14px 0; background: #fff1dd; border: 1px solid #d2ab72; }
.cloud-history-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 12px 0; font-size: .875rem; }
.cloud-history-row span { min-width: 0; overflow-wrap: anywhere; }
.cloud-history-row button { flex-shrink: 0; }

.library-transfer-tools {
  display: grid;
  grid-template-columns: 1.2fr .9fr .9fr;
  gap: 6px;
  margin: 12px 0 10px;
}
.library-transfer-tools button {
  min-width: 0;
  min-height: 34px;
  padding: 6px 7px;
  border: 1px solid #cadde2;
  border-radius: 9px;
  color: var(--ocean-deep);
  background: rgba(255,255,255,.76);
  font-size: .72rem;
  white-space: nowrap;
  cursor: pointer;
}
.library-transfer-tools button:first-child { color: #8c440f; border-color: #ffc486; background: var(--orange-soft); }
.library-transfer-tools button:hover:not(:disabled) { border-color: #6fa4af; background: #eef7f8; }
.library-transfer-tools button:disabled { opacity: .55; cursor: wait; }
.corpus-import-dialog { width: min(620px, calc(100vw - 28px)); }
.corpus-import-dialog > p { color: var(--muted); line-height: 1.7; }
.import-summary { margin: 18px 0; padding: 13px 14px; border: 1px solid #cfe1e5; border-radius: 10px; color: var(--ocean-deep); background: var(--sky); line-height: 1.6; }
.import-errors { max-height: 280px; overflow: auto; margin: -6px 0 18px; padding: 12px 14px; border: 1px solid #f3b6a8; border-radius: 10px; color: #983d2c; background: #fff5f2; font-size: .8125rem; line-height: 1.65; }
.import-errors ol { margin: 0; padding-left: 22px; }
.access-form label small { color: var(--muted); font-weight: 500; }

/* Modern study workspace: a calm shadcn-inspired visual layer. */
html { color-scheme: light; }
body {
  color: var(--ink);
  font-size: 1rem;
  background:
    radial-gradient(circle at 12% -8%, rgba(64, 93, 97, .09), transparent 30rem),
    radial-gradient(circle at 92% 2%, rgba(14, 165, 233, .055), transparent 26rem),
    var(--paper);
}
button, input, textarea, select { font-family: inherit; }
button { transition: color .18s ease, background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
button:not(:disabled):active { transform: translateY(1px); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible,
.library-browser :focus-visible, .text-action:focus-visible, #entryForm :focus-visible {
  outline: 3px solid rgba(64, 93, 97, .22);
  outline-offset: 2px;
}
::selection { color: #334f53; background: #c7d8d7; }
* { scrollbar-color: #c7c9d1 transparent; scrollbar-width: thin; }

.app-shell { min-height: 100dvh; background: transparent; }
.topbar {
  position: relative;
  z-index: 3;
  height: 72px;
  padding: 0 24px;
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid rgba(228, 228, 231, .88);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .8);
  backdrop-filter: blur(18px);
}
.brand { gap: 12px; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(145deg, #607a7f, #405f64);
  box-shadow: 0 8px 20px rgba(64, 93, 97, .24), inset 0 1px 0 rgba(255, 255, 255, .26);
  font: 750 1.05rem/1 Inter, ui-sans-serif, sans-serif;
}
.brand strong {
  color: #18181b;
  font: 720 1.0625rem/1.2 Inter, ui-sans-serif, sans-serif;
  letter-spacing: -.02em;
}
.brand small { margin-top: 3px; color: #8b8b95; font-size: .75rem; letter-spacing: .04em; }
.mode-switch {
  align-self: center;
  height: 44px;
  gap: 4px;
  padding: 4px;
  border: 1px solid #e8e8ed;
  border-radius: 13px;
  background: #f4f4f5;
}
.mode-tab {
  min-width: 132px;
  padding: 0 18px;
  border: 0;
  border-radius: 9px;
  color: #71717a;
  font-size: .875rem;
  font-weight: 600;
}
.mode-tab:hover { color: #3f3f46; }
.mode-tab.active {
  color: #405f64;
  border: 0;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.connection-button {
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid #e4e4e7;
  border-radius: 12px;
  color: #52525b;
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 1px 2px rgba(24, 24, 27, .03);
  font-size: .8125rem;
  font-weight: 600;
}
.connection-button:hover { border-color: #c7d8d7; color: #405f64; background: #f6f9f8; }
.status-dot { width: 8px; height: 8px; background: #22c55e; box-shadow: 0 0 0 4px #dcfce7; }
.storage-bar {
  height: 42px;
  justify-content: flex-end;
  padding: 0 24px;
  border-bottom: 0;
  background: transparent;
}
.storage-bar button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #dbe8e7;
  border-radius: 9px;
  color: #557277;
  background: rgba(238, 242, 255, .78);
  font-size: .8125rem;
}
.storage-bar button:hover { border-color: #c7d8d7; background: #dbe8e7; }
#cloudStatus { color: #71717a; font-size: .75rem; }

.workspace {
  gap: 12px;
  padding: 0 12px 12px;
  background: transparent;
}
.workspace > .panel {
  border: 1px solid rgba(228, 228, 231, .92);
  border-radius: var(--panel-radius);
  background: rgba(255, 255, 255, .95);
  box-shadow: var(--shadow-panel);
}
.library-panel, .analysis-panel, .prompt-panel, .feedback-panel { padding: 22px 20px; }
.conversation-panel, .editor-panel { background: #f8f9fc !important; }
.panel-heading { gap: 16px; }
.eyebrow {
  color: #607a7f;
  font-size: .6875rem;
  font-weight: 750;
  letter-spacing: .12em;
}
h1, h2, .brand strong, .conversation-header strong, .editor-header h2,
.phrase-card p, .prompt-card p, .writing-entry > p, .bubble p,
.original, .improved > p, .pattern-card > strong, .band-grid strong,
.correction-card p, .vocab-suggestion strong, .ai-original, .ai-improved, .ai-english {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
h1, h2 { margin-top: 5px; color: #27272a; font-size: 1.25rem; font-weight: 720; line-height: 1.3; letter-spacing: -.025em; }
.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  color: #557277;
  background: #fff;
  box-shadow: 0 1px 2px rgba(24, 24, 27, .03);
  font-size: 1.25rem;
}
.icon-button:hover { border-color: #c7d8d7; background: #e4eeec; }
.search-box {
  height: 44px;
  margin-top: 20px;
  padding: 0 13px;
  border: 1px solid #e4e4e7;
  border-radius: var(--control-radius);
  color: #8b8b95;
  background: #fafafa;
}
.search-box:focus-within { border-color: #9db7b8; background: #fff; box-shadow: 0 0 0 3px rgba(85, 114, 119, .10); }
.search-box input, .load-more, .library-panel .search-box input, #writingLibraryView .search-box input { font-size: .875rem; }
.taxonomy-heading { margin-top: 19px; color: #8b8b95; font-size: .75rem; letter-spacing: .055em; }
.taxonomy-heading button, .text-action { color: #557277; }

.library-filter { gap: 7px; color: #52525b; font-size: .8125rem; font-weight: 600; }
.library-filter select, .entry-classification-fields select,
#topicDialog select, #topicDialog textarea {
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid #e4e4e7;
  border-radius: 9px;
  color: #27272a;
  background: #fff;
}
.library-kind-tabs {
  gap: 4px;
  padding: 4px;
  border-radius: 11px;
  background: #f4f4f5;
}
.library-kind-tabs button {
  min-height: 40px;
  border-radius: 8px;
  color: #71717a;
  font-size: .8125rem;
  font-weight: 600;
}
.library-kind-tabs button.active { color: #405f64; background: #fff; box-shadow: var(--shadow-sm); }
.library-hint, .library-panel .sort-note, #writingResultCount, .sort-note { color: #8b8b95; font-size: .75rem; }
.phrase-list, .writing-library-list, .prompt-list { gap: 10px; }
.phrase-card, .writing-entry, .prompt-card {
  padding: 14px;
  border: 1px solid #e4e4e7;
  border-left-width: 1px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(24, 24, 27, .025);
}
.phrase-card:hover, .writing-entry:hover, .prompt-card:hover { border-color: #c7d8d7; box-shadow: 0 5px 16px rgba(64, 93, 97, .07); }
.phrase-card.selected, .writing-entry.selected, .prompt-card.selected {
  border-color: #9db7b8;
  border-left-width: 1px;
  background: linear-gradient(145deg, #f6f9f8, #e4eeec);
  box-shadow: 0 0 0 1px rgba(85, 114, 119, .06), 0 7px 18px rgba(64, 93, 97, .075);
}
.phrase-card .tag, .writing-entry .tag, .writing-entry .entry-head span, .prompt-card > div { color: #557277; font-size: .75rem; }
.count { color: #8b8b95; font-size: .75rem; }
.count b { color: #557277; font-size: .9375rem; }
.phrase-card .entry-english, .writing-entry .entry-english { color: #27272a; font-size: .9375rem; line-height: 1.6; }
.phrase-card .entry-note, .writing-entry .entry-note { color: #71717a; font-size: .8125rem; }
.entry-kind {
  padding: 3px 8px;
  border-radius: 999px;
  color: #557277;
  background: #e4eeec;
  font-size: .6875rem;
  font-weight: 650;
}
[data-kind="vocabulary"] .entry-kind { color: #a16207; background: #fef3c7; }
.entry-details .detail-row span { color: #8b8b95; font-size: .6875rem; }
.entry-details .detail-row p { color: #52525b; font-size: .875rem; }
.load-more {
  min-height: 42px;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  color: #557277;
  background: #fff;
}
.load-more:hover { border-color: #c7d8d7; background: #e4eeec; }

.conversation-panel { overflow: hidden; }
.conversation-header, .editor-header {
  min-height: 72px;
  padding: 15px 20px;
  border-bottom: 1px solid #e8e8ed;
  border-radius: var(--panel-radius) var(--panel-radius) 0 0;
  background: rgba(255, 255, 255, .91);
  backdrop-filter: blur(12px);
}
.conversation-header strong { color: #27272a; font-size: .9375rem; font-weight: 700; }
.conversation-header small { color: #8b8b95; font-size: .8125rem; }
.outline-button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #e4e4e7;
  border-radius: 9px;
  color: #52525b;
  background: #fff;
  font-size: .8125rem;
  font-weight: 600;
}
.outline-button:hover { border-color: #c7d8d7; color: #405f64; background: #f6f9f8; }
.chat-stream { padding: 20px 24px 24px; }
.message { gap: 10px; margin-bottom: 18px; }
.avatar {
  flex-basis: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(145deg, #607a7f, #405f64);
  box-shadow: 0 4px 12px rgba(64, 93, 97, .18);
  font-size: .6875rem;
}
.message.user .avatar { color: #78350f; background: linear-gradient(145deg, #fde68a, #fbbf24); box-shadow: 0 4px 12px rgba(217, 119, 6, .16); }
.bubble {
  padding: 13px 15px;
  border: 1px solid #e4e4e7;
  border-radius: 5px 14px 14px 14px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(24, 24, 27, .045);
}
.message.user .bubble {
  color: #fff;
  border-color: #557277;
  border-radius: 14px 5px 14px 14px;
  background: linear-gradient(145deg, #66868a, #405f64);
  box-shadow: 0 7px 18px rgba(64, 93, 97, .18);
}
.message .bubble p { color: inherit; font-size: .9375rem; line-height: 1.65; }
.message time { color: #a1a1aa; font-size: .6875rem; }
.message.user .voice-message-label, .message.user .text-action { color: #dbe8e7; }
.play-button { color: #557277; }
.message.user .play-button, .message.user .play-button small { color: #e4eeec; }
.practice-status {
  padding: 8px 18px;
  color: #607a7f;
  border-top: 1px solid #e8e8ed;
  background: #eef3f2;
  font-size: .75rem;
}
.voice-composer {
  min-height: 86px;
  padding: 13px 16px;
  border-top: 1px solid #e8e8ed;
  border-radius: 0 0 var(--panel-radius) var(--panel-radius);
  background: #fff;
}
.keyboard-button, .end-button {
  min-height: 40px;
  border-radius: 9px;
  font-size: .8125rem;
}
.keyboard-button:hover { background: #f4f4f5; }
.end-button { padding: 0 9px; color: #dc2626; }
.end-button:hover { background: #fef2f2; }
.hold-to-talk {
  min-height: 56px;
  border: 0;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, #607a7f, #557277 55%, #405f64);
  box-shadow: 0 8px 22px rgba(64, 93, 97, .24), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.hold-to-talk:hover { box-shadow: 0 11px 26px rgba(64, 93, 97, .29), inset 0 1px 0 rgba(255, 255, 255, .2); transform: translateY(-1px); }
.hold-to-talk .mic { color: #557277; background: #fff; box-shadow: 0 0 0 5px rgba(255, 255, 255, .14); }
.hold-to-talk strong { font-size: .9375rem; }
.hold-to-talk small { color: #dbe8e7; font-size: .6875rem; }
.hold-to-talk.recording { color: #fff; border-color: transparent; background: linear-gradient(135deg, #ef4444, #dc2626); }
.hold-to-talk.recording .mic { color: #fff; background: #991b1b; }
.text-composer { height: 48px; overflow: hidden; border: 1px solid #c7d8d7; border-radius: 11px; }
.text-composer input { font-size: .9375rem; }
.text-composer button { background: #557277; }

.analysis-tabs, .feedback-tabs, .library-view-tabs {
  gap: 4px;
  padding: 4px;
  margin-top: 18px;
  border: 0;
  border-radius: 11px;
  background: #f4f4f5;
}
.analysis-tabs button, .feedback-tabs button, .library-view-tabs button {
  flex: 1;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  color: #71717a;
  font-size: .8125rem;
  font-weight: 600;
}
.analysis-tabs button.active, .feedback-tabs button.active, .library-view-tabs button.active {
  color: #405f64;
  border: 0;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.real-analysis h3, #feedbackContent h3 { color: #405f64; }
.answer-feedback, .ai-suggestion {
  padding: 16px;
  border: 1px solid #dbe5e3;
  border-radius: 13px;
  background: linear-gradient(145deg, #fafaff, #eef3f2);
}
.answer-feedback h4 { color: #405f64; }
.ai-sentence { padding: 17px 0; border-color: #ededf0; }
.ai-original { color: #71717a; font-size: .9375rem; }
.ai-improved {
  padding: 12px 13px;
  border: 1px solid #dbe5e3;
  border-radius: 10px;
  color: #405f64;
  background: #e4eeec;
  font-size: .9375rem;
}
.ai-explanation { color: #52525b; font-size: .875rem; line-height: 1.75; }
.speaking-verdict { border-radius: 999px; color: #166534; background: #dcfce7; }
.verdict-accuracy { color: #b45309; background: #fef3c7; }
.verdict-uncertain { color: #52525b; background: #f4f4f5; }
.verdict-naturalness { color: #405f64; background: #dbe8e7; }
.natural-answer { border-color: #dbe5e3; }
.natural-answer summary { color: #405f64; }
.assessment-note { color: #8b8b95; font-size: .75rem; }
.empty-feedback {
  padding: 20px;
  border: 1px dashed #d4d4d8;
  border-radius: 12px;
  color: #71717a;
  background: #fafafa;
  font-size: .875rem;
  text-align: center;
}

.prompt-filters, .band-grid { overflow: hidden; border-color: #e4e4e7; border-radius: 10px; }
.prompt-filters button { min-height: 38px; border-color: #e4e4e7; color: #71717a; font-size: .8125rem; }
.prompt-filters button.active { color: #fff; background: #557277; }
.writing-library-filters button { min-height: 34px; border-color: #e4e4e7; border-radius: 999px; font-size: .75rem; }
.writing-library-filters button.active { border-color: #557277; background: #557277; }
.editor-header h2 { color: #27272a; font-size: 1rem; }
.switch-row { color: #71717a; font-size: .8125rem; }
.switch-row i { width: 34px; height: 19px; background: #d4d4d8; }
.switch-row i::after { width: 15px; height: 15px; }
.switch-row input:checked + i { background: #557277; }
.switch-row input:checked + i::after { transform: translateX(15px); }
.question-brief {
  padding: 13px 20px;
  border-bottom: 1px solid #dbe8e7;
  color: #405f64;
  background: #e4eeec;
}
.question-brief span { color: #607a7f; font-size: .6875rem; }
.question-brief p { color: #405f64; font-size: .875rem; line-height: 1.6; }
.writing-surface {
  margin: 16px 18px 10px;
  overflow: hidden;
  border: 1px solid #e4e4e7;
  border-radius: 14px;
  box-shadow: 0 8px 26px rgba(24, 24, 27, .05);
}
#essayEditor {
  padding: 26px 30px;
  color: #27272a;
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.9;
}
.editor-footer { padding: 10px 14px; border-color: #ededf0; color: #8b8b95; font-size: .75rem; }
.editor-footer b { color: #557277; }
.submit-bar { padding: 0 18px 16px; }
.kbd { border-color: #d4d4d8; border-radius: 5px; color: #71717a; box-shadow: 0 2px 0 #d4d4d8; }
.submit-bar small { color: #8b8b95; font-size: .75rem; }
.primary-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  background: linear-gradient(135deg, #66868a, #405f64);
  box-shadow: 0 6px 16px rgba(64, 93, 97, .2);
  font-size: .8125rem;
  font-weight: 650;
}
.primary-button:hover { box-shadow: 0 9px 21px rgba(64, 93, 97, .27); transform: translateY(-1px); }
.band-grid > div { padding: 10px 3px; border-color: #e4e4e7; }
.band-grid span { color: #557277; font-size: .6875rem; }
.band-grid small { color: #8b8b95; font-size: .6875rem; }
.correction-card { grid-template-columns: 28px 1fr; gap: 10px; border-color: #ededf0; }
.correction-card p { color: #52525b; font-size: .875rem; line-height: 1.65; }
.correction-card .replacement, .vocab-suggestion {
  padding: 11px;
  border: 1px solid #dbe5e3;
  border-radius: 9px;
  color: #405f64;
  background: #e4eeec;
}
.logic-note { border: 1px solid #fde68a; border-left: 4px solid #f59e0b; border-radius: 10px; background: #fffbeb; }

dialog {
  overflow: hidden;
  border: 1px solid #e4e4e7;
  border-radius: 16px;
  box-shadow: 0 30px 90px rgba(24, 24, 27, .24);
}
dialog::backdrop { background: rgba(24, 24, 27, .42); backdrop-filter: blur(6px); }
dialog form { padding: 24px; }
.dialog-heading > button { width: 36px; height: 36px; border-radius: 9px; }
.dialog-heading > button:hover { color: #27272a; background: #f4f4f5; }
#entryForm > label, .entry-classification-fields label, #topicDialog label { color: #52525b; font-size: .8125rem; }
#entryForm input, #entryForm textarea {
  padding: 11px 12px;
  border-color: #e4e4e7;
  border-radius: 9px;
  color: #27272a;
  background: #fafafa;
  font-family: inherit;
  font-size: .875rem;
}
.dialog-actions button, .cloud-dialog button:not(.dialog-heading button) {
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid #e4e4e7;
  border-radius: 9px;
  background: #fff;
  font-size: .8125rem;
  font-weight: 600;
}
.dialog-actions button:last-child { border-color: #557277; background: #557277; }
.settings-dialog dl { border: 1px solid #e4e4e7; border-radius: 11px; background: #fafafa; }
.taxonomy-grid { overflow: hidden; border-color: #e4e4e7; border-radius: 12px; }
.taxonomy-grid section { border-color: #e4e4e7; }
.taxonomy-grid b { color: #405f64; }
.toast { border-radius: 11px; background: #27272a; box-shadow: 0 12px 30px rgba(24, 24, 27, .22); }
.cloud-dialog { border-radius: 18px; }
.cloud-dialog h3 { color: #27272a; }
.cloud-conflict { border-color: #fcd34d; border-radius: 11px; background: #fffbeb; }
.cloud-history-row { border-color: #ededf0; }
.is-error { color: #b91c1c !important; background: #fef2f2; }

@media (min-width: 600px) {
  .topbar { height: 72px; padding: 0 24px; }
  .mode-switch { height: 44px; }
  .workspace { height: calc(100dvh - 114px); }
  .workspace > .panel { border: 1px solid rgba(228, 228, 231, .92); }
}
@media (min-width: 600px) and (max-width: 1100px) {
  .topbar { padding: 0 14px; }
  .mode-tab { min-width: 112px; padding: 0 12px; }
  .workspace { gap: 8px; padding-inline: 8px; padding-bottom: 8px; }
  .library-panel, .analysis-panel, .prompt-panel, .feedback-panel { padding: 18px 14px; }
  .conversation-header, .editor-header { padding: 14px; }
  .chat-stream { padding: 14px 12px; }
}
@media (max-width: 599px) {
  .account-chip { display: none; }
  .storage-bar .logout-button { padding-inline: 7px; }
  body { background: #f6f7fb; }
  .topbar { padding: 8px 12px 7px; background: rgba(255, 255, 255, .95); }
  .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
  .connection-button { min-height: 36px; padding-inline: 9px; }
  .mode-switch { height: 40px; margin-top: 2px; border-radius: 11px; }
  .mode-tab { min-width: 0; flex: 1; padding: 0 10px; font-size: .8125rem; }
  .storage-bar { height: 36px; padding: 0 12px; justify-content: space-between; }
  .storage-bar button { min-height: 28px; }
  .mobile-panels { gap: 6px; padding: 7px 10px; border-bottom: 0; background: rgba(255, 255, 255, .94); }
  .mobile-panels button {
    min-height: 40px;
    border: 1px solid #e4e4e7;
    border-radius: 10px;
    color: #71717a;
    background: #f8f8fa;
    font-size: .8125rem;
    font-weight: 650;
  }
  .mobile-panels button[aria-pressed="true"] { color: #fff; border-color: #557277; background: #557277; box-shadow: 0 5px 14px rgba(64, 93, 97, .18); }
  .workspace { gap: 8px; padding: 0 8px 8px; }
  .workspace > .panel { padding: 14px; border-radius: 14px; }
  .speaking-workspace > .conversation-panel { padding: 0; }
  .speaking-workspace[data-mobile-panel="practice"] { grid-template-rows: minmax(255px, .42fr) minmax(0, .58fr); }
  .conversation-header { min-height: 48px; padding: 7px 11px; border-radius: 14px 14px 0 0; }
  .chat-stream { padding: 9px 11px; }
  .message { margin-bottom: 10px; }
  .avatar { flex-basis: 27px; width: 27px; min-width: 27px; height: 27px; border-radius: 9px; }
  .bubble { padding: 9px 11px; border-radius: 4px 12px 12px 12px; }
  .message.user .bubble { border-radius: 12px 4px 12px 12px; }
  .message .bubble p { font-size: .875rem; line-height: 1.55; }
  .practice-status { padding: 4px 11px; }
  .voice-composer { min-height: 58px; padding: 6px 9px; border-radius: 0 0 14px 14px; }
  .hold-to-talk { height: 44px; min-height: 44px; border-radius: 11px; }
  .analysis-panel { border-top: 1px solid #e4e4e7; box-shadow: var(--shadow-panel); }
  .analysis-tabs { margin: 8px 0; }
  .analysis-panel > .assessment-note { padding-top: 5px; }
  .writing-surface { margin: 10px 0 8px; border-radius: 12px; }
  #essayEditor { padding: 16px; }
  .empty-feedback { margin: 12px 0; padding: 14px; }
  dialog { border-radius: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Realtime speaking: the call stays compact so the transcript and coaching remain visible. */
.conversation-actions { display: flex; align-items: center; gap: 8px; }
.conversation-actions .end-button { min-height: 34px; padding: 0 12px; }
.voice-mode-tabs { display: flex; gap: 4px; padding: 8px 18px 0; background: var(--surface); border-top: 1px solid var(--line); }
.voice-mode-tabs button { min-height: 32px; padding: 0 13px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-weight: 700; cursor: pointer; }
.voice-mode-tabs button.active { color: #405f64; background: #e4eeec; box-shadow: inset 0 0 0 1px #c7d8d7; }
.realtime-composer { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 12px; align-items: stretch; padding: 8px 18px 12px; background: var(--surface); }
.live-captions { min-width: 0; display: grid; gap: 5px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: #f8fafc; }
.live-captions p { min-width: 0; margin: 0; display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: baseline; gap: 7px; }
.live-captions span { color: #607a7f; font-size: .6875rem; font-weight: 800; }
.live-captions strong { overflow: hidden; color: #475569; font-size: .8125rem; font-weight: 550; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.live-captions .is-speaking { color: #0f172a; }
.realtime-toggle { min-height: 58px; display: grid; grid-template-columns: 18px minmax(0, 1fr); align-content: center; column-gap: 8px; padding: 8px 12px; border: 0; border-radius: 12px; color: #fff; background: linear-gradient(135deg, #557277, #607a7f); box-shadow: 0 9px 22px rgba(64, 93, 97, .24); cursor: pointer; }
.realtime-toggle:hover { transform: translateY(-1px); }
.realtime-toggle .call-dot { grid-row: 1 / 3; align-self: center; width: 13px; height: 13px; border: 3px solid rgba(255,255,255,.45); border-radius: 50%; background: #fff; }
.realtime-toggle strong { text-align: left; font-size: .875rem; }
.realtime-toggle small { color: #dbe8e7; text-align: left; font-size: .6875rem; }
.realtime-toggle.connecting .call-dot { animation: pulse 1s infinite; }
.realtime-toggle.active { background: linear-gradient(135deg, #059669, #10b981); box-shadow: 0 9px 22px rgba(5, 150, 105, .24); }
.realtime-toggle.active .call-dot { background: #d1fae5; animation: pulse 1.4s infinite; }
.realtime-toggle:disabled { cursor: wait; opacity: .7; transform: none; }
.message-analysis-pending { color: #607a7f !important; }
.message-analysis-error { color: #b91c1c !important; }

@media (max-width: 599px) {
  .conversation-actions { gap: 5px; }
  .conversation-actions .outline-button, .conversation-actions .end-button { padding-inline: 8px; font-size: .72rem; }
  .voice-mode-tabs { padding: 5px 9px 0; }
  .voice-mode-tabs button { min-height: 29px; padding: 0 10px; font-size: .75rem; }
  .realtime-composer { grid-template-columns: minmax(0, 1fr) 116px; gap: 7px; padding: 6px 9px 8px; }
  .live-captions { gap: 3px; padding: 6px 8px; }
  .live-captions p { grid-template-columns: 20px minmax(0, 1fr); gap: 4px; }
  .live-captions span { font-size: .6rem; }
  .live-captions strong { font-size: .7rem; }
  .realtime-toggle { min-height: 49px; grid-template-columns: 12px minmax(0, 1fr); gap: 5px; padding: 6px 8px; }
  .realtime-toggle .call-dot { width: 10px; height: 10px; border-width: 2px; }
  .realtime-toggle strong { font-size: .72rem; }
  .realtime-toggle small { font-size: .58rem; }
}

/* Public entrance: the application is not initialized before server authorization. */
.access-pending { min-width: 0; }
.access-pending .app-shell { display: none; }
.access-gate {
  min-height: 100dvh;
  padding: 24px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 18% 10%, rgba(85, 114, 119, .16), transparent 34rem),
    radial-gradient(circle at 88% 90%, rgba(14, 165, 233, .10), transparent 30rem),
    #f6f7fb;
}
.access-gate[hidden] { display: none; }
.access-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid rgba(228, 228, 231, .92);
  border-radius: 22px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 28px 80px rgba(49, 46, 129, .13), 0 2px 8px rgba(24, 24, 27, .04);
  backdrop-filter: blur(18px);
}
.access-brand { display: flex; align-items: center; gap: 12px; }
.access-brand strong, .access-brand small { display: block; }
.access-brand strong { font-size: 1rem; letter-spacing: -.02em; }
.access-brand small { margin-top: 2px; color: #8b8b95; font-size: .75rem; }
.access-copy { margin: 34px 0 24px; }
.access-copy h1 { margin-top: 8px; font-size: 1.75rem; }
.access-copy p { margin: 12px 0 0; color: #71717a; font-size: .875rem; line-height: 1.75; }
.access-form { display: grid; gap: 16px; }
.access-form label { display: grid; gap: 7px; color: #52525b; font-size: .8125rem; font-weight: 650; }
.access-form input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  color: #27272a;
  background: #fafafa;
  font-size: 1rem;
}
.access-form input:focus { border-color: #9db7b8; background: #fff; box-shadow: 0 0 0 3px rgba(85, 114, 119, .10); }
.access-form .primary-button { width: 100%; min-height: 48px; margin-top: 2px; }
.access-status { min-height: 22px; margin: 16px 0 0; color: #607a7f; font-size: .8125rem; line-height: 1.6; }
.access-note { display: block; margin-top: 12px; color: #8b8b95; font-size: .75rem; line-height: 1.6; }
.danger-action { color: #b42318; }
@media (max-width: 520px) {
  .access-gate { padding: 14px; }
  .access-card { padding: 26px 22px; border-radius: 18px; }
  .access-copy { margin: 28px 0 20px; }
}

/* Orange-sea study theme: crisp sky, deep ocean focus, and vivid citrus accents. */
:root {
  --paper: #f3f8fa;
  --surface: #ffffff;
  --ink: #17313d;
  --muted: #5e7280;
  --line: #d4e2e7;
  --green: #1f6f82;
  --green-soft: #e3f0f3;
  --amber: #a86121;
  --red: #c5533d;
  --ocean: #1f6f82;
  --ocean-deep: #155667;
  --sky: #e3f0f3;
  --orange: #ff7a1a;
  --orange-soft: #fff0e2;
  --shadow-sm: 0 2px 8px rgba(23, 49, 61, .06);
  --shadow-panel: 0 14px 38px rgba(23, 49, 61, .08);
}
body {
  color: var(--ink);
  background: var(--paper);
  font-family: Aptos, "Segoe UI Variable", "Microsoft YaHei UI", "PingFang SC", sans-serif;
}
button, input, textarea, select { color: var(--ink); }
button { transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible,
.library-browser :focus-visible, .text-action:focus-visible, #entryForm :focus-visible {
  outline: 3px solid rgba(31,111,130,.32);
  outline-offset: 3px;
}
.topbar {
  border-color: rgba(212, 226, 231, .95);
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 1px 0 rgba(255,255,255,.8);
  backdrop-filter: blur(18px);
}
.brand-mark {
  color: #17313d;
  background: #fff1df;
  border: 1px solid #ffd1a6;
  border-radius: 44% 56% 48% 52% / 55% 42% 58% 45%;
  box-shadow: 0 6px 18px rgba(255, 122, 26, .20);
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  font-size: 1.25rem;
  line-height: 1;
}
.brand strong { color: var(--ink); letter-spacing: -.025em; }
.brand small { color: var(--muted); }
.mode-switch { padding: 4px; border: 1px solid #cddfe5; border-radius: 15px; background: #e8f2f5; }
.mode-tab { border-radius: 11px; color: #58717d; }
.mode-tab.active { color: var(--ocean-deep); background: var(--surface); box-shadow: inset 0 -3px 0 var(--orange), 0 3px 12px rgba(23,49,61,.08); }
.mode-tab.active::after { display: none; }
.connection-button[hidden] { display: none !important; }
.connection-button { border-color: #cddfe5; color: #4d6875; background: #f8fbfc; }
.connection-button:hover { border-color: #8eb7c2; color: var(--ocean-deep); background: #eef6f8; }
.status-dot { background: #5c9a7a; box-shadow: 0 0 0 4px rgba(92,154,122,.12); }
.storage-bar { color: #536f7b; border-color: #cfe0e5; background: rgba(227,240,243,.9); }
.storage-bar button { color: var(--ocean-deep); border-color: #bdd4db; background: rgba(255,255,255,.82); }
.storage-bar button:hover { border-color: #7daab6; background: var(--surface); }
.workspace { background: transparent; }
.workspace > .panel { border-color: rgba(202, 219, 225, .98); box-shadow: none; }
.conversation-panel, .editor-panel { box-shadow: var(--shadow-panel); }
.library-panel, .prompt-panel { background: rgba(247,250,251,.98) !important; }
.analysis-panel, .feedback-panel { background: rgba(241,247,249,.99) !important; }
.conversation-panel, .editor-panel { background: #ffffff !important; }
.panel-heading h1, .panel-heading h2, .editor-header h2 { color: var(--ink); letter-spacing: -.025em; }
.eyebrow { color: var(--ocean); font-size: .6875rem; letter-spacing: .055em; }
.icon-button { color: var(--ocean-deep); border-color: #b9d2da; background: #e3f0f3; }
.icon-button:hover { border-color: #78a8b4; background: #d6e9ee; }
.search-box { border-color: #d2e1e6; border-radius: 12px; background: #f0f6f8; }
.search-box:focus-within { border-color: #6ca0ad; background: var(--surface); box-shadow: 0 0 0 4px rgba(31,111,130,.12); }
.search-box span { color: #758784; }
.taxonomy-heading { color: #65736e; }
.taxonomy-heading button, .text-action { color: var(--ocean); }
.library-filter { color: #596a67; }
.library-filter select, .entry-classification-fields select,
.entry-form input, .entry-form textarea, .entry-form select { border-color: #d9e2df; border-radius: 10px; background: #fafbf9; }
.library-kind-tabs { border: 1px solid #cfe0e5; border-radius: 12px; background: #e6f1f4; }
.library-kind-tabs button { border-radius: 9px; color: #536f7b; }
.library-kind-tabs button.active { color: var(--ocean-deep); background: var(--surface); box-shadow: inset 0 -3px 0 var(--orange), 0 3px 10px rgba(23,49,61,.07); }
.phrase-card, .writing-entry, .prompt-card {
  border-color: #d8e5e9;
  border-radius: 13px 13px 13px 5px;
  background: rgba(255,255,255,.98);
  box-shadow: none;
}
.phrase-card:hover, .writing-entry:hover, .prompt-card:hover { border-color: #8eb7c2; box-shadow: 0 6px 17px rgba(23,49,61,.07); }
.phrase-card.selected, .writing-entry.selected, .prompt-card.selected {
  border-color: #78a8b4;
  background: #e8f3f5;
  box-shadow: inset 4px 0 0 var(--orange);
}
.phrase-card .tag, .writing-entry .tag, .writing-entry .entry-head span, .prompt-card > div { color: var(--ocean-deep); }
.phrase-card .entry-english, .writing-entry .entry-english,
.phrase-card p, .prompt-card p, .writing-entry > p, .bubble p,
.ai-original, .ai-improved, .ai-english, #essayEditor {
  font-family: Georgia, "Noto Serif", "Songti SC", serif;
}
.phrase-card .entry-english, .writing-entry .entry-english { color: var(--ink); }
.phrase-card .entry-note, .writing-entry .entry-note { color: var(--muted); }
.load-more { color: #5a7476; border-color: #d1dcda; border-radius: 11px; background: #f5f8f7; }
.load-more:hover { border-color: #a9bfc0; background: #eaf0ef; }
.conversation-header, .editor-header { border-color: #d4e2e7; background: rgba(255,255,255,.97); }
.conversation-header strong { color: var(--ink); }
.conversation-header small { color: var(--muted); }
.outline-button, .end-button, .keyboard-button { border-color: #c5dbe1; color: var(--ocean-deep); background: #f8fbfc; }
.outline-button:hover, .end-button:hover, .keyboard-button:hover { border-color: #82adb8; background: #eaf4f6; }
.chat-stream {
  background:
    linear-gradient(rgba(249,252,253,.96), rgba(249,252,253,.96)),
    repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(31,111,130,.07) 32px);
}
.avatar { color: #fff; background: var(--ocean); border-radius: 46% 54% 45% 55% / 56% 43% 57% 44%; box-shadow: 0 4px 12px rgba(31,111,130,.16); }
.message.user .avatar { color: #733000; background: #ffb25e; box-shadow: 0 4px 12px rgba(255,122,26,.20); }
.bubble { color: var(--ink); border-color: #d9e5e9; border-radius: 5px 17px 17px 17px; background: rgba(255,255,255,.99); box-shadow: 0 6px 20px rgba(23,49,61,.05); }
.message.user .bubble { color: #fff; border-color: var(--ocean); border-radius: 17px 5px 17px 17px; background: var(--ocean); box-shadow: 0 7px 20px rgba(31,111,130,.16); }
.message.user .voice-message-label, .message.user .text-action { color: #eaf7f9; }
.message.user .play-button, .message.user .play-button small { color: #fff; }
.message time { color: #687671; }
.live-captions { border-color: #cfe0e5; background: #eaf4f6; }
.live-captions span { color: var(--ocean); }
.live-captions strong { color: #496875; }
.live-captions .is-speaking { color: var(--ink); }
.realtime-toggle {
  color: #fefefc;
  border-radius: 46% 54% 48% 52% / 57% 46% 54% 43%;
  background: var(--ocean);
  box-shadow: 0 10px 24px rgba(31,111,130,.20), inset 0 1px 0 rgba(255,255,255,.24);
}
.realtime-toggle:hover { background: var(--ocean-deep); box-shadow: 0 13px 28px rgba(31,111,130,.24); }
.realtime-toggle.active { background: #b84a0a; box-shadow: 0 10px 26px rgba(184,74,10,.22), 0 0 0 5px rgba(255,122,26,.16); }
.realtime-toggle .call-dot { background: #f0f5f4; }
.realtime-toggle small { color: #e4eeec; }
.practice-status { color: #4f6d79; border-color: #cfe0e5; background: #edf6f8; }
.voice-composer { border-color: #dbe4e1; background: var(--surface); }
.hold-to-talk { color: #fff; border: 0; border-radius: 14px; background: var(--ocean); box-shadow: 0 8px 20px rgba(31,111,130,.18); }
.hold-to-talk:hover { background: var(--ocean-deep); box-shadow: 0 11px 24px rgba(31,111,130,.22); }
.hold-to-talk .mic { color: var(--ocean); background: #fff; }
.hold-to-talk small { color: #eaf7f9; }
.text-composer input { border-color: #d9e2df; background: #fafbf9; }
.text-composer button, .primary-button { border-color: var(--ocean); color: #fff; background: var(--ocean); }
.text-composer button:hover, .primary-button:hover { border-color: var(--ocean-deep); background: var(--ocean-deep); }
.analysis-tabs, .feedback-tabs, .library-view-tabs { border-color: #dfe5e3; }
.analysis-tabs button, .feedback-tabs button, .library-view-tabs button { color: #65736e; }
.analysis-tabs button.active, .feedback-tabs button.active, .library-view-tabs button.active { color: var(--ocean-deep); border-color: var(--orange); }
.answer-feedback { border-color: #cfe0e5; border-radius: 6px 15px 15px 15px; background: #eaf4f6; }
.answer-feedback h3, .real-analysis h3, .feedback-content h3 { color: var(--ocean-deep); }
.answer-feedback h4 { color: #5c7071; }
.ai-sentence { border-color: #e2e7e5; }
.ai-original { color: #65736e; }
.ai-improved { color: var(--ink); border-left-color: var(--orange); border-radius: 5px 12px 12px 5px; background: #eaf4f6; }
.ai-explanation { color: #566460; }
.ai-suggestion { border-color: #cfe0e5; border-radius: 6px 14px 14px 14px; background: #edf6f8; }
.speaking-verdict { border-radius: 999px; }
.verdict-accuracy { color: #9e3d2d; background: #fdece8; }
.verdict-naturalness { color: var(--ocean-deep); background: #dfeff3; }
.verdict-keep { color: #4f7362; background: #e7f0eb; }
.verdict-uncertain { color: #8b430c; background: var(--orange-soft); }
.message-analysis-pending { color: #5f7376 !important; }
.writing-surface { border-color: #cfe0e5; border-radius: 7px 19px 19px 19px; background: var(--surface); box-shadow: 0 16px 38px rgba(23,49,61,.07); }
#essayEditor { color: var(--ink); caret-color: var(--orange); }
#essayEditor::placeholder { color: #98a29f; }
.editor-footer { border-color: #e2e8e5; color: #65736e; }
.editor-footer b { color: #55767a; }
.switch-row i { border-color: #ccd7d3; background: #e8eeec; }
.switch-row input:checked + i { border-color: var(--ocean); background: var(--ocean); }
dialog { color: var(--ink); border-color: #d3dfdc; border-radius: 8px 20px 20px 20px; background: var(--surface); box-shadow: 0 30px 85px rgba(38,51,50,.18); }
dialog::backdrop { background: rgba(38,51,50,.30); backdrop-filter: blur(7px); }
.dialog-heading { border-color: #d4e2e7; background: #edf6f8; }
.dialog-actions button, .cloud-dialog button:not(.dialog-heading button) { border-color: #d5dfdc; color: #526967; background: #fafbf9; }
.dialog-actions button:last-child { border-color: var(--ocean); color: #fff; background: var(--ocean); }
.toast { color: #fff; border-radius: 7px 14px 14px 14px; background: #17313d; box-shadow: 0 14px 32px rgba(23,49,61,.20); }
.is-error { color: #995448 !important; background: #f8ece8; }
.access-gate {
  background: var(--paper);
}
.access-card { border-color: #cbdfe5; border-radius: 9px 27px 27px 27px; background: rgba(255,255,255,.98); box-shadow: 0 30px 80px rgba(23,49,61,.12); }
.access-copy h1 { color: var(--ink); }
.access-copy p, .access-note { color: var(--muted); }
.access-form label { color: #596b68; }
.access-form input { border-color: #d9e2df; color: var(--ink); background: #f8faf9; }
.access-form input:focus { border-color: #6ca0ad; box-shadow: 0 0 0 4px rgba(31,111,130,.12); }
.access-status { color: #607572; }

@media (max-width: 599px) {
  body { background: var(--paper); }
  .topbar { background: rgba(255,255,255,.97); }
  .mobile-panels { background: rgba(243,248,250,.96); }
  .mobile-panels button { color: #536f7b; border-color: #cfe0e5; border-radius: 12px; background: #fff; }
  .mobile-panels button[aria-pressed="true"] { color: #fff; border-color: var(--ocean); background: var(--ocean); box-shadow: inset 0 -3px 0 var(--orange), 0 6px 16px rgba(31,111,130,.16); }
  .workspace > .panel { border-color: #d5dfdc; }
  .conversation-header { border-radius: 14px 14px 0 0; }
  .realtime-toggle { border-radius: 12px; }
  .voice-composer { border-radius: 0 0 14px 14px; }
}

/* Compact speaking input dock: three direct actions, no explanatory chrome. */
.voice-dock {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 9px;
  padding: 9px 18px 11px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 -8px 24px rgba(23, 49, 61, .06);
}
.voice-dock [hidden], .live-captions[hidden] { display: none !important; }
.voice-dock-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.voice-tool {
  position: relative;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  color: #58717d;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  transition: color .16s ease, background-color .16s ease, border-color .16s ease, box-shadow .16s ease, filter .14s ease;
}
.voice-tool svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.voice-dock .voice-tool:active:not(:disabled) { filter: brightness(.78); }
.voice-tool:focus-visible { outline: 3px solid rgba(31, 111, 130, .28); outline-offset: 2px; }
.voice-tool:disabled { cursor: not-allowed; opacity: .38; transform: none; }
#holdToTalk.recording {
  color: #fff;
  border-color: #b84a0a;
  background: #b84a0a;
  box-shadow: 0 0 0 6px rgba(255, 122, 26, .16);
  animation: voice-recording-pulse 1.35s ease-in-out infinite;
}
#realtimeToggle.connecting { animation: voice-connecting-pulse 1.1s ease-in-out infinite; }
#realtimeToggle.active {
  color: #fff;
  border-color: #b84a0a;
  background: #b84a0a;
  box-shadow: 0 0 0 6px rgba(255, 122, 26, .16);
}
.voice-dock-input {
  width: min(620px, 100%);
  height: 44px;
  justify-self: center;
  border-color: #bdd4db;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 7px 18px rgba(23, 49, 61, .07);
}
.voice-dock-input input { color: var(--ink); background: transparent; }
.voice-dock-input button { min-width: 64px; border-radius: 0 12px 12px 0; }
.live-captions {
  margin: 8px 18px 0;
  padding: 7px 11px;
  gap: 4px;
  border-color: #cfe0e5;
  border-radius: 11px;
  background: rgba(234, 244, 246, .98);
}
.live-captions p { grid-template-columns: 26px minmax(0, 1fr); }
.live-captions strong { white-space: normal; }
.compact-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.compact-status.is-error {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  padding: 7px 18px;
  clip: auto;
  clip-path: none;
  white-space: normal;
  border-top: 1px solid #e8c9c1;
  font-size: .78rem;
}
@keyframes voice-recording-pulse {
  50% { box-shadow: 0 0 0 10px rgba(255, 122, 26, .10); }
}
@keyframes voice-connecting-pulse {
  50% { box-shadow: 0 0 0 7px rgba(31, 111, 130, .13); }
}
@media (max-width: 599px) {
  .voice-dock { gap: 7px; padding: 7px 10px calc(8px + env(safe-area-inset-bottom)); border-radius: 0 0 14px 14px; }
  .voice-dock-actions { gap: 18px; }
  .voice-tool { width: 44px; height: 44px; }
  .voice-tool svg { width: 22px; height: 22px; }
  .voice-dock-input { height: 42px; }
  .live-captions { margin: 6px 10px 0; padding: 6px 9px; }
  .compact-status.is-error { padding: 6px 10px; }
}

/* Speaking round context: temporary recommendations, durable history, and paired actions. */
.speaking-library-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  margin: 18px 0 4px;
  border: 1px solid #cfe0e5;
  border-radius: 12px;
  background: #e6f1f4;
}
.speaking-library-tabs button {
  min-height: 40px;
  padding: 7px 8px;
  border: 0;
  border-radius: 9px;
  color: #536f7b;
  background: transparent;
  font-size: .8125rem;
  font-weight: 700;
  cursor: pointer;
}
.speaking-library-tabs button.active { color: var(--ocean-deep); background: #fff; box-shadow: inset 0 -3px 0 var(--orange), 0 3px 10px rgba(23,49,61,.07); }
.speaking-library-tabs button:disabled { cursor: not-allowed; opacity: .48; }
.speaking-library-tabs b { display: inline-grid; min-width: 20px; height: 20px; place-items: center; margin-left: 3px; border-radius: 999px; color: #8b430c; background: var(--orange-soft); font-size: .7rem; }
.round-library { padding-top: 10px; }
.round-library-intro { margin: 0 0 16px; color: #526c78; font-size: .8125rem; line-height: 1.65; }
.round-library-section { margin: 0 0 22px; }
.round-library-section h2 { margin: 0 0 9px; color: var(--ocean-deep); font: 700 .8125rem/1.4 Aptos, "Segoe UI Variable", "Microsoft YaHei UI", sans-serif; }
.round-library-section > .phrase-card { margin-bottom: 8px; }
.round-library-empty { margin: 0; padding: 12px; border: 1px dashed #c9dce2; border-radius: 11px; color: #687f8a; background: rgba(255,255,255,.65); font-size: .8125rem; line-height: 1.6; }
.round-library-card.round-recommended { border-color: #b8d4dc; background: #f4fafb; }
.round-library-card.round-mentioned, .round-library-card.round-added { border-color: #ffc489; background: var(--orange-soft); box-shadow: inset 4px 0 0 var(--orange); }
.round-library-state { flex: 0 0 auto; padding: 3px 7px; border-radius: 999px; color: var(--ocean-deep); background: var(--sky); font-size: .6875rem; font-weight: 750; white-space: nowrap; }
.round-mentioned .round-library-state, .round-added .round-library-state { color: #8b430c; background: #ffd8b4; }

.conversation-panel { grid-template-rows: auto auto auto minmax(120px, 1fr) auto auto auto; }
.conversation-panel > .conversation-header { grid-row: 1; }
.conversation-panel > .conversation-history { grid-row: 2; }
.conversation-panel > .history-viewing-banner { grid-row: 3; }
.conversation-panel > .chat-stream { grid-row: 4; min-height: 0; }
.conversation-panel > .live-captions { grid-row: 5; }
.conversation-panel > .practice-status { grid-row: 6; }
.conversation-panel > .voice-dock { grid-row: 7; }
.conversation-history { border-bottom: 1px solid #d4e2e7; background: #f8fbfc; }
.conversation-history summary { min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 18px; color: var(--ocean-deep); cursor: pointer; list-style: none; font-size: .8125rem; font-weight: 750; }
.conversation-history summary::-webkit-details-marker { display: none; }
.conversation-history summary::before { content: "＋"; width: 18px; color: var(--orange); font-size: 1rem; }
.conversation-history[open] summary::before { content: "−"; }
.conversation-history summary span { margin-right: auto; }
.conversation-history summary small { color: #6c808a; font-size: .75rem; font-weight: 500; }
.conversation-history-list { max-height: 210px; overflow-y: auto; padding: 0 10px 10px; }
.conversation-history-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; margin-top: 5px; border: 1px solid #d4e2e7; border-radius: 10px; background: #fff; }
.conversation-history-row.active { border-color: #ffb36b; box-shadow: inset 3px 0 0 var(--orange); }
.history-record-main { min-width: 0; display: grid; gap: 3px; padding: 9px 10px; border: 0; color: var(--ink); background: transparent; text-align: left; cursor: pointer; }
.history-record-main strong { overflow: hidden; font-size: .8125rem; text-overflow: ellipsis; white-space: nowrap; }
.history-record-main small { color: #6a7e88; font-size: .72rem; }
.history-delete { margin-right: 7px; padding: 6px 8px; border: 0; border-radius: 7px; color: #a23f30; background: #fdece8; font-size: .72rem; cursor: pointer; }
.history-delete:hover { background: #f9d7d0; }
.history-load-more { width: 100%; min-height: 34px; margin-top: 8px; border: 1px solid #c9dce2; border-radius: 9px; color: var(--ocean-deep); background: #fff; cursor: pointer; }
.history-viewing-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 18px; color: #7e3b0b; background: var(--orange-soft); border-bottom: 1px solid #ffc489; font-size: .8125rem; }
.history-viewing-banner[hidden] { display: none !important; }
.conversation-panel[data-history-mode="true"] .voice-dock,
.conversation-panel[data-history-mode="true"] .live-captions,
.conversation-panel[data-history-mode="true"] .practice-status { display: none !important; }
.sentence-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: center; }
.sentence-actions .text-action, .sentence-actions .play-button { width: auto; min-width: 0; justify-self: start; margin: 0; padding: 6px 0; white-space: nowrap; }

@media (max-width: 599px) {
  .library-transfer-tools { grid-template-columns: 1fr 1fr; }
  .library-transfer-tools button:first-child { grid-column: 1 / -1; }
  .cloud-history-row { grid-template-columns: minmax(0, 1fr) auto; }
  .cloud-history-row .danger-action { grid-column: 2; }
  .speaking-library-tabs { margin-top: 12px; }
  .conversation-panel { grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto !important; }
  .conversation-history summary { min-height: 36px; padding: 6px 11px; }
  .conversation-history-list { max-height: 168px; padding: 0 7px 8px; }
  .history-viewing-banner { padding: 6px 11px; }
}

/* Theme control: the icon reflects the current light or dark reading environment. */
.theme-toggle {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #c9dce2;
  border-radius: 50%;
  color: var(--ocean-deep);
  background: rgba(255,255,255,.82);
  box-shadow: 0 4px 14px rgba(23,49,61,.08);
  cursor: pointer;
}
.theme-toggle:hover { border-color: #83afba; background: #eaf4f6; transform: translateY(-1px); }
.theme-toggle:focus-visible { outline: 3px solid rgba(255,122,26,.38); outline-offset: 3px; }
.theme-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-icon-moon { display: none; }
[data-theme="dark"] .theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-moon { display: block; }

/* Deep-ocean night palette: lower glare without losing the orange-sea identity. */
[data-theme="dark"] {
  --paper: #0e1b22;
  --surface: #16272f;
  --ink: #f1eee6;
  --muted: #abc0c8;
  --line: #2d4651;
  --green: #69b4c4;
  --green-soft: #1b3944;
  --amber: #ffac62;
  --red: #ff8d79;
  --ocean: #4d9fb2;
  --ocean-deep: #8bcbd8;
  --sky: #1c3944;
  --orange: #ff943d;
  --orange-soft: #3b291d;
  --shadow-sm: 0 2px 10px rgba(0,0,0,.22);
  --shadow-panel: 0 16px 42px rgba(0,0,0,.25);
  color-scheme: dark;
  background: var(--paper);
}
[data-theme="dark"] body { color: var(--ink); background: var(--paper); }
[data-theme="dark"] .topbar { border-color: #29414b; background: rgba(18,34,42,.96); box-shadow: 0 1px 0 rgba(255,255,255,.025); }
[data-theme="dark"] .brand-mark { color: #ffb66f; border-color: #704323; background: #32251b; box-shadow: 0 6px 20px rgba(255,148,61,.13); }
[data-theme="dark"] .mode-switch { border-color: #2d4b56; background: #10232b; }
[data-theme="dark"] .mode-tab { color: #9fb4bc; }
[data-theme="dark"] .mode-tab.active { color: #d9f0f4; background: #203640; box-shadow: inset 0 -3px 0 var(--orange), 0 4px 13px rgba(0,0,0,.22); }
[data-theme="dark"] .theme-toggle { color: #ffd19f; border-color: #3b5661; background: #1d333d; box-shadow: 0 5px 16px rgba(0,0,0,.20); }
[data-theme="dark"] .theme-toggle:hover { color: #ffe0bb; border-color: #6f9aa5; background: #284650; }
[data-theme="dark"] .storage-bar { color: #a7bbc3; border-color: #294550; background: rgba(20,47,57,.94); }
[data-theme="dark"] .storage-bar button { color: #b7dce4; border-color: #3a5c67; background: rgba(20,39,47,.9); }
[data-theme="dark"] .storage-bar button:hover { border-color: #6797a3; background: #213b45; }
[data-theme="dark"] .workspace > .panel { border-color: #29414c; }
[data-theme="dark"] .library-panel,
[data-theme="dark"] .prompt-panel { background: rgba(18,34,42,.99) !important; }
[data-theme="dark"] .analysis-panel,
[data-theme="dark"] .feedback-panel { background: rgba(16,31,39,.99) !important; }
[data-theme="dark"] .conversation-panel,
[data-theme="dark"] .editor-panel { background: #14262e !important; }
[data-theme="dark"] .panel-heading h1,
[data-theme="dark"] .panel-heading h2,
[data-theme="dark"] .editor-header h2,
[data-theme="dark"] .conversation-header strong { color: var(--ink); }
[data-theme="dark"] .eyebrow,
[data-theme="dark"] .taxonomy-heading button,
[data-theme="dark"] .text-action { color: #78bdcb; }
[data-theme="dark"] .icon-button { color: #b4dce4; border-color: #3b5964; background: #1b3741; }
[data-theme="dark"] .icon-button:hover { border-color: #6899a5; background: #244550; }
[data-theme="dark"] .search-box { border-color: #304b56; background: #10252d; }
[data-theme="dark"] .search-box:focus-within { border-color: #70aeba; background: #142c35; box-shadow: 0 0 0 4px rgba(77,159,178,.14); }
[data-theme="dark"] .search-box span,
[data-theme="dark"] .taxonomy-heading,
[data-theme="dark"] .library-filter,
[data-theme="dark"] .library-hint,
[data-theme="dark"] .sort-note,
[data-theme="dark"] .library-panel .sort-note,
[data-theme="dark"] #writingResultCount { color: #9db1b9; }
[data-theme="dark"] .library-filter select,
[data-theme="dark"] .entry-classification-fields select,
[data-theme="dark"] .entry-form input,
[data-theme="dark"] .entry-form textarea,
[data-theme="dark"] .entry-form select,
[data-theme="dark"] #topicDialog select,
[data-theme="dark"] #topicDialog textarea { color: var(--ink); border-color: #38515b; background: #10232b; }
[data-theme="dark"] .library-kind-tabs,
[data-theme="dark"] .speaking-library-tabs { border-color: #31515d; background: #102831; }
[data-theme="dark"] .library-kind-tabs button,
[data-theme="dark"] .speaking-library-tabs button { color: #a1b9c1; }
[data-theme="dark"] .library-kind-tabs button.active,
[data-theme="dark"] .speaking-library-tabs button.active { color: #d9eef2; background: #213c46; box-shadow: inset 0 -3px 0 var(--orange), 0 4px 12px rgba(0,0,0,.22); }
[data-theme="dark"] .phrase-card,
[data-theme="dark"] .writing-entry,
[data-theme="dark"] .prompt-card { color: var(--ink); border-color: #304a54; background: #172b34; }
[data-theme="dark"] .phrase-card:hover,
[data-theme="dark"] .writing-entry:hover,
[data-theme="dark"] .prompt-card:hover { border-color: #5d909c; box-shadow: 0 7px 20px rgba(0,0,0,.18); }
[data-theme="dark"] .phrase-card.selected,
[data-theme="dark"] .writing-entry.selected,
[data-theme="dark"] .prompt-card.selected { border-color: #6195a1; background: #1c3943; }
[data-theme="dark"] .phrase-card .entry-english,
[data-theme="dark"] .writing-entry .entry-english,
[data-theme="dark"] .phrase-card .tag,
[data-theme="dark"] .writing-entry .tag,
[data-theme="dark"] .writing-entry .entry-head span,
[data-theme="dark"] .prompt-card > div { color: #d9edf1; }
[data-theme="dark"] .phrase-card .entry-note,
[data-theme="dark"] .writing-entry .entry-note,
[data-theme="dark"] .detail-row p,
[data-theme="dark"] .entry-details .detail-row p { color: #b2c2c6; }
[data-theme="dark"] .entry-kind { color: #b9d2d8; background: #203b44; }
[data-theme="dark"] [data-kind="vocabulary"] .entry-kind { color: #f3c391; background: #3a2a20; }
[data-theme="dark"] .load-more,
[data-theme="dark"] .round-library-empty { color: #b5cbd1; border-color: #395661; background: #152a32; }
[data-theme="dark"] .conversation-header,
[data-theme="dark"] .editor-header { border-color: #2c4651; background: rgba(22,39,47,.98); }
[data-theme="dark"] .outline-button,
[data-theme="dark"] .end-button,
[data-theme="dark"] .keyboard-button { color: #b5d9e1; border-color: #3a5863; background: #172d36; }
[data-theme="dark"] .outline-button:hover,
[data-theme="dark"] .end-button:hover,
[data-theme="dark"] .keyboard-button:hover { border-color: #6999a5; background: #21404a; }
[data-theme="dark"] .chat-stream { background: linear-gradient(rgba(15,30,37,.97),rgba(15,30,37,.97)),repeating-linear-gradient(0deg,transparent 0,transparent 31px,rgba(105,180,196,.06) 32px); }
[data-theme="dark"] .bubble { color: var(--ink); border-color: #33505b; background: #1a3039; box-shadow: 0 7px 20px rgba(0,0,0,.20); }
[data-theme="dark"] .message.user .bubble { color: #fff; border-color: #347f91; background: #246f80; }
[data-theme="dark"] .message time { color: #9fb1b7; }
[data-theme="dark"] .live-captions,
[data-theme="dark"] .practice-status { color: #b3c8ce; border-color: #31505b; background: #18343e; }
[data-theme="dark"] .live-captions span,
[data-theme="dark"] .live-captions strong { color: #b8dce3; }
[data-theme="dark"] .voice-dock,
[data-theme="dark"] .voice-composer { border-color: #2c4651; background: rgba(19,36,44,.99); box-shadow: 0 -8px 24px rgba(0,0,0,.20); }
[data-theme="dark"] .voice-tool { color: #a9c5cc; }
[data-theme="dark"] .voice-dock-input,
[data-theme="dark"] .text-composer input { color: var(--ink); border-color: #3c5a65; background: #10232b; }
[data-theme="dark"] .analysis-tabs,
[data-theme="dark"] .feedback-tabs,
[data-theme="dark"] .library-view-tabs { border-color: #2e4852; background: #10232b; }
[data-theme="dark"] .analysis-tabs button,
[data-theme="dark"] .feedback-tabs button,
[data-theme="dark"] .library-view-tabs button { color: #9fb2b9; }
[data-theme="dark"] .analysis-tabs button.active,
[data-theme="dark"] .feedback-tabs button.active,
[data-theme="dark"] .library-view-tabs button.active { color: #dceff3; border-color: var(--orange); background: #213b45; box-shadow: 0 3px 10px rgba(0,0,0,.22); }
[data-theme="dark"] .answer-feedback h3,
[data-theme="dark"] .real-analysis h3,
[data-theme="dark"] .feedback-content h3 { color: #91ceda; }
[data-theme="dark"] .answer-feedback,
[data-theme="dark"] .ai-suggestion { color: var(--ink); border-color: #31515c; background: #18343e; }
[data-theme="dark"] .answer-feedback h4,
[data-theme="dark"] .ai-explanation { color: #bfd0d4; }
[data-theme="dark"] .ai-sentence { border-color: #2e4751; }
[data-theme="dark"] .ai-original { color: #aebfc5; }
[data-theme="dark"] .ai-improved { color: #f3eee5; border-left-color: var(--orange); background: #1b3943; }
[data-theme="dark"] .empty-feedback { color: #b8c8cc; border-color: #3a5560; background: #142830; }
[data-theme="dark"] .prompt-filters,
[data-theme="dark"] .band-grid { border-color: #334e59; }
[data-theme="dark"] .prompt-filters button,
[data-theme="dark"] .writing-library-filters button { color: #a9bbc1; border-color: #334e59; background: #172c34; }
[data-theme="dark"] .prompt-filters button.active,
[data-theme="dark"] .writing-library-filters button.active { color: #fff; border-color: #4b96a8; background: #347f91; }
[data-theme="dark"] .question-brief { color: #c0d2d7; border-color: #2e4954; background: #19343e; }
[data-theme="dark"] .question-brief span,
[data-theme="dark"] .question-brief p { color: #b9cdd2; }
[data-theme="dark"] .switch-row { color: #afc0c5; }
[data-theme="dark"] .natural-answer { border-color: #31505b; }
[data-theme="dark"] .natural-answer summary { color: #aed5dd; }
[data-theme="dark"] .writing-surface { border-color: #31505b; background: #13272f; box-shadow: 0 16px 38px rgba(0,0,0,.22); }
[data-theme="dark"] #essayEditor { color: var(--ink); }
[data-theme="dark"] #essayEditor::placeholder { color: #758c95; }
[data-theme="dark"] .editor-footer { color: #9db0b7; border-color: #2e4751; }
[data-theme="dark"] .editor-footer b { color: #c5dce1; }
[data-theme="dark"] .switch-row i { border-color: #405a63; background: #263b43; }
[data-theme="dark"] dialog { color: var(--ink); border-color: #3a5560; background: #16272f; box-shadow: 0 30px 85px rgba(0,0,0,.48); }
[data-theme="dark"] dialog::backdrop { background: rgba(3,10,14,.70); }
[data-theme="dark"] .dialog-heading { border-color: #31505b; background: #193640; }
[data-theme="dark"] .dialog-heading > button:hover { color: var(--ink); background: #28424c; }
[data-theme="dark"] .dialog-actions button,
[data-theme="dark"] .cloud-dialog button:not(.dialog-heading button) { color: #c1d3d8; border-color: #38525c; background: #172d35; }
[data-theme="dark"] .dialog-actions button:last-child { color: #fff; border-color: #438fa1; background: #347f91; }
[data-theme="dark"] .settings-dialog dl { color: #bed0d4; border-color: #38525c; background: #10232b; }
[data-theme="dark"] .cloud-dialog h3 { color: var(--ink); }
[data-theme="dark"] .cloud-conflict { color: #f7d7a6; border-color: #76542b; background: #352b1d; }
[data-theme="dark"] .cloud-history-row { border-color: #304953; }
[data-theme="dark"] .library-transfer-tools button { color: #b8dce3; border-color: #385762; background: #172f38; }
[data-theme="dark"] .library-transfer-tools button:first-child { color: #ffd0a5; border-color: #83512b; background: #39291e; }
[data-theme="dark"] .library-transfer-tools button:hover:not(:disabled) { border-color: #6f9aa5; background: #244550; }
[data-theme="dark"] .import-summary { color: #b8dce3; border-color: #355661; background: #17343e; }
[data-theme="dark"] .import-errors { color: #ffb1a4; border-color: #77463d; background: #402622; }
[data-theme="dark"] .conversation-history { border-color: #2e4954; background: #132a33; }
[data-theme="dark"] .conversation-history summary { color: #b9dde4; }
[data-theme="dark"] .conversation-history summary small,
[data-theme="dark"] .history-record-main small { color: #9eb1b8; }
[data-theme="dark"] .conversation-history-row { border-color: #34515c; background: #172e37; }
[data-theme="dark"] .history-record-main { color: var(--ink); }
[data-theme="dark"] .history-delete { color: #ffac9c; background: #442923; }
[data-theme="dark"] .history-load-more { color: #b6dce4; border-color: #3b5a65; background: #162e37; }
[data-theme="dark"] .history-viewing-banner { color: #ffd0a5; border-color: #6d4828; background: #39291e; }
[data-theme="dark"] .round-library-intro { color: #b1c5cc; }
[data-theme="dark"] .round-library-section h2 { color: #a9d5de; }
[data-theme="dark"] .round-library-card.round-recommended { border-color: #3d6370; background: #17323b; }
[data-theme="dark"] .round-library-card.round-mentioned,
[data-theme="dark"] .round-library-card.round-added { border-color: #9b5f2e; background: #3b291d; }
[data-theme="dark"] .round-library-state { color: #c6e1e6; background: #244650; }
[data-theme="dark"] .round-mentioned .round-library-state,
[data-theme="dark"] .round-added .round-library-state { color: #ffd1a5; background: #633d24; }
[data-theme="dark"] .access-gate { background: var(--paper); }
[data-theme="dark"] .access-card { border-color: #36525d; background: rgba(20,38,46,.99); box-shadow: 0 30px 80px rgba(0,0,0,.36); }
[data-theme="dark"] .access-copy h1 { color: var(--ink); }
[data-theme="dark"] .access-copy p,
[data-theme="dark"] .access-note,
[data-theme="dark"] .access-form label,
[data-theme="dark"] .access-status { color: #afc1c7; }
[data-theme="dark"] .access-form input { color: var(--ink); border-color: #38535d; background: #10232b; }
[data-theme="dark"] .toast { color: #f5f2eb; background: #0a1419; box-shadow: 0 14px 34px rgba(0,0,0,.40); }
[data-theme="dark"] .is-error { color: #ffb1a4 !important; background: #402622; }

@media (max-width: 980px) {
  .theme-toggle { grid-column: 2; grid-row: 1; }
}
@media (max-width: 599px) {
  .theme-toggle { width: 36px; height: 36px; }
  .theme-icon { width: 18px; height: 18px; }
  [data-theme="dark"] body { background: var(--paper); }
  [data-theme="dark"] .topbar { background: rgba(18,34,42,.98); }
  [data-theme="dark"] .mobile-panels { border-color: #29434d; background: rgba(15,30,37,.97); }
  [data-theme="dark"] .mobile-panels button { color: #a9bbc1; border-color: #304c57; background: #172c35; }
  [data-theme="dark"] .mobile-panels button[aria-pressed="true"] { color: #fff; border-color: #4b96a8; background: #347f91; box-shadow: inset 0 -3px 0 var(--orange), 0 6px 16px rgba(0,0,0,.23); }
  [data-theme="dark"] .analysis-panel { border-color: #2d4651; }
}

/* Danzhe clay study room: caramel wood, paper surfaces, and roasted-orange focus. */
:root {
  --paper: #be7e4a;
  --surface: #fff9f1;
  --ink: #33251e;
  --muted: #725d50;
  --line: #dfc2a9;
  --green: #7b4528;
  --green-soft: #f3dfcc;
  --amber: #9c562c;
  --red: #a94532;
  --ocean: #8a4b28;
  --ocean-deep: #6b371f;
  --sky: #f4e2d2;
  --orange: #d76524;
  --orange-soft: #f9e1ca;
  --shadow-sm: 0 3px 12px rgba(67,41,29,.09);
  --shadow-panel: 0 16px 34px rgba(67,41,29,.13);
}
body {
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255,242,219,.13), transparent 28%),
    radial-gradient(circle at 88% 76%, rgba(87,47,26,.10), transparent 34%),
    linear-gradient(115deg, rgba(255,255,255,.035), transparent 42%, rgba(91,48,25,.035));
}
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible,
.library-browser :focus-visible, .text-action:focus-visible, #entryForm :focus-visible {
  outline-color: rgba(107,55,31,.46);
}
.topbar {
  color: #fffaf4;
  border-color: rgba(91,52,31,.28);
  background: linear-gradient(102deg, rgba(151,91,53,.97), rgba(190,126,74,.97));
  box-shadow: 0 5px 20px rgba(67,41,29,.16);
}
.brand strong { color: #fffaf4; }
.brand small { color: #f7e4d3; }
.brand-mark { color: #fff; border-color: rgba(255,242,225,.55); background: rgba(92,49,26,.27); box-shadow: 0 6px 18px rgba(72,39,23,.20); }
.mode-switch { border-color: rgba(255,245,235,.34); background: rgba(82,44,25,.20); }
.mode-tab { color: #f4dfce; }
.mode-tab.active { color: #4b2c1c; background: #fff6ea; box-shadow: inset 0 -3px 0 #d76524, 0 4px 14px rgba(75,42,24,.18); }
.theme-toggle { color: #fff8ef; border-color: rgba(255,245,233,.46); background: rgba(83,44,25,.25); box-shadow: 0 5px 16px rgba(67,41,29,.14); }
.theme-toggle:hover { color: #fff; border-color: rgba(255,255,255,.72); background: rgba(70,36,20,.34); }
.storage-bar { color: #fff3e7; border-color: rgba(84,47,27,.20); background: rgba(116,65,36,.84); }
.storage-bar button { color: #5b311e; border-color: #ebc8a9; background: #fff1df; }
.storage-bar button:hover { border-color: #fff5e9; background: #fffaf4; }
.storage-bar .logout-button { color: #fff8f0; border-color: rgba(255,236,218,.42); background: rgba(83,44,25,.30); }
.account-chip, #cloudStatus { color: #f2dac7; }
.workspace { gap: 10px; padding: 10px; background: transparent; }
.workspace > .panel { border: 1px solid rgba(102,58,34,.22); border-radius: 17px; box-shadow: 0 12px 30px rgba(67,41,29,.13); }
.library-panel, .prompt-panel { background: rgba(250,238,226,.98) !important; }
.analysis-panel, .feedback-panel { background: rgba(247,230,213,.99) !important; }
.conversation-panel, .editor-panel { background: #fffaf4 !important; box-shadow: 0 17px 38px rgba(67,41,29,.16); }
.conversation-header, .editor-header { border-color: #e5cbb4; background: rgba(255,249,241,.97); }
.eyebrow, .taxonomy-heading button, .text-action { color: #8a4b28; }
.icon-button { color: #66351f; border-color: #d9ae89; background: #f3d5b8; }
.icon-button:hover { border-color: #be7e4a; background: #ecc6a4; }
.search-box { border-color: #dec1a8; background: #f7e7d7; }
.search-box:focus-within { border-color: #a86439; background: #fffaf4; box-shadow: 0 0 0 4px rgba(190,126,74,.16); }
.library-filter select, .entry-classification-fields select,
.entry-form input, .entry-form textarea, .entry-form select,
#topicDialog select, #topicDialog textarea { border-color: #dec1a8; color: var(--ink); background: #fffaf4; }
.library-kind-tabs, .speaking-library-tabs { border-color: #d9b797; background: #edcfb3; }
.library-kind-tabs button, .speaking-library-tabs button { color: #71513f; }
.library-kind-tabs button.active, .speaking-library-tabs button.active { color: #4d2d1d; background: #fff7ed; box-shadow: inset 0 -3px 0 #d76524, 0 4px 12px rgba(89,49,27,.10); }
.phrase-card, .writing-entry, .prompt-card { border-color: #dec1a8; background: #fffaf4; }
.phrase-card:hover, .writing-entry:hover, .prompt-card:hover { border-color: #b87546; box-shadow: 0 7px 20px rgba(86,48,27,.10); }
.phrase-card.selected, .writing-entry.selected, .prompt-card.selected { border-color: #be7e4a; background: #f7e3cf; }
.phrase-card .tag, .writing-entry .tag, .writing-entry .entry-head span, .prompt-card > div { color: #704029; }
.entry-kind { color: #6d4733; background: #ead4bf; }
[data-kind="vocabulary"] .entry-kind { color: #80401f; background: #f5dac1; }
.load-more, .round-library-empty { color: #714b36; border-color: #d8b99d; background: #f8e9dc; }
.outline-button, .end-button, .keyboard-button { color: #683a23; border-color: #d5ad8b; background: #fff8ee; }
.outline-button:hover, .end-button:hover, .keyboard-button:hover { border-color: #b46d3e; background: #f4dfcc; }
.chat-stream {
  background:
    linear-gradient(rgba(255,250,244,.965),rgba(255,250,244,.965)),
    repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(151,91,53,.09) 32px);
}
.avatar { background: #7b4528; box-shadow: 0 4px 12px rgba(94,49,25,.18); }
.message.user .avatar { color: #512b18; background: #e59a5e; }
.bubble { border-color: #dfc5ae; background: #fffdf9; box-shadow: 0 7px 20px rgba(75,42,24,.07); }
.message.user .bubble { color: #fff; border-color: #834625; background: #834625; box-shadow: 0 8px 20px rgba(90,47,25,.18); }
.live-captions, .practice-status { color: #684938; border-color: #dcb995; background: #f6e1cc; }
.voice-dock, .voice-composer { border-color: #dfc3a9; background: rgba(255,249,241,.985); box-shadow: 0 -8px 24px rgba(74,41,23,.07); }
.voice-tool { color: #77513d; }
.analysis-tabs, .feedback-tabs, .library-view-tabs { border-color: #dcc3ad; background: transparent; }
.analysis-tabs button, .feedback-tabs button, .library-view-tabs button { color: #72594b; }
.analysis-tabs button.active, .feedback-tabs button.active, .library-view-tabs button.active { color: #63341e; border-color: #d76524; background: #f9ebde; }
.answer-feedback, .ai-suggestion { border-color: #dcb997; background: #f5ddc6; }
.answer-feedback h3, .real-analysis h3, .feedback-content h3 { color: #6b371f; }
.ai-sentence { border-color: #e2cab5; }
.ai-original { color: #786154; }
.ai-improved { border-left-color: #d76524; background: #f5dfca; }
.writing-surface { border-color: #dcb997; background: #fffdf8; box-shadow: 0 16px 38px rgba(70,39,23,.10); }
#essayEditor { color: #33251e; caret-color: #d76524; }
.text-composer button, .primary-button, .dialog-actions button:last-child { color: #fff; border-color: #794124; background: #794124; }
.text-composer button:hover, .primary-button:hover, .dialog-actions button:last-child:hover { border-color: #60311d; background: #60311d; }
.library-transfer-tools button { color: #673821; border-color: #d5b08f; background: #fff7ed; }
.library-transfer-tools button:first-child { color: #fff; border-color: #96522c; background: #96522c; }
.library-transfer-tools button:hover:not(:disabled) { border-color: #b16b3e; background: #f3dcc7; }
dialog { border-color: #d4aa86; color: var(--ink); background: #fff9f1; box-shadow: 0 30px 85px rgba(60,32,18,.28); }
dialog::backdrop { background: rgba(49,28,18,.46); }
.dialog-heading { border-color: #dfc1a7; background: #f2dcc7; }
.dialog-actions button, .cloud-dialog button:not(.dialog-heading button) { color: #654431; border-color: #d9b99d; background: #fffaf4; }
.toast { background: #43291d; box-shadow: 0 14px 34px rgba(56,30,17,.28); }
.access-gate { background-color: #be7e4a; background-image: radial-gradient(circle at 20% 20%, rgba(255,241,222,.16), transparent 30%), linear-gradient(115deg, transparent, rgba(83,43,22,.10)); }
.access-card { border-color: rgba(105,57,31,.26); background: rgba(255,249,241,.98); box-shadow: 0 32px 84px rgba(70,37,20,.24); }
.access-form input { border-color: #ddbea4; color: var(--ink); background: #fffdf9; }
.access-form input:focus { border-color: #a9653b; box-shadow: 0 0 0 4px rgba(190,126,74,.18); }

[data-theme="dark"] {
  --paper: #251811;
  --surface: #38271e;
  --ink: #fff5e9;
  --muted: #d5baa5;
  --line: #684936;
  --green: #d49461;
  --green-soft: #4a3123;
  --amber: #efaa72;
  --red: #f09b87;
  --ocean: #c67f4d;
  --ocean-deep: #f0b17e;
  --sky: #493125;
  --orange: #ee8c43;
  --orange-soft: #4d3121;
  --shadow-sm: 0 3px 12px rgba(0,0,0,.25);
  --shadow-panel: 0 18px 38px rgba(0,0,0,.28);
}
[data-theme="dark"] body { color: var(--ink); background-color: #251811; background-image: radial-gradient(circle at 12% 18%, rgba(190,126,74,.09), transparent 28%), radial-gradient(circle at 88% 76%, rgba(0,0,0,.15), transparent 34%); }
[data-theme="dark"] .topbar { border-color: #5a3d2c; background: linear-gradient(102deg, rgba(66,39,27,.98), rgba(91,53,34,.98)); }
[data-theme="dark"] .brand strong { color: #fff7ee; }
[data-theme="dark"] .brand small { color: #dcbfa9; }
[data-theme="dark"] .brand-mark { color: #fff; border-color: #805133; background: #4a2e20; }
[data-theme="dark"] .mode-switch { border-color: #76513a; background: #342119; }
[data-theme="dark"] .mode-tab { color: #d2b49f; }
[data-theme="dark"] .mode-tab.active { color: #fff4e8; background: #5a3b2b; box-shadow: inset 0 -3px 0 #ee8c43, 0 4px 13px rgba(0,0,0,.22); }
[data-theme="dark"] .theme-toggle { color: #ffd8b7; border-color: #79543d; background: #4d3326; }
[data-theme="dark"] .storage-bar { color: #dcc0ac; border-color: #5f402e; background: rgba(57,36,27,.96); }
[data-theme="dark"] .storage-bar button { color: #ffe6d0; border-color: #7b553e; background: #503529; }
[data-theme="dark"] .account-chip, [data-theme="dark"] #cloudStatus { color: #d8baa4; }
[data-theme="dark"] .workspace > .panel { border-color: #674735; box-shadow: 0 14px 34px rgba(0,0,0,.24); }
[data-theme="dark"] .library-panel, [data-theme="dark"] .prompt-panel { background: #322219 !important; }
[data-theme="dark"] .analysis-panel, [data-theme="dark"] .feedback-panel { background: #2d1e17 !important; }
[data-theme="dark"] .conversation-panel, [data-theme="dark"] .editor-panel { background: #39271e !important; }
[data-theme="dark"] .conversation-header, [data-theme="dark"] .editor-header { border-color: #674735; background: #3a281f; }
[data-theme="dark"] .search-box, [data-theme="dark"] .library-kind-tabs, [data-theme="dark"] .speaking-library-tabs { border-color: #6e4b37; background: #2b1c15; }
[data-theme="dark"] .library-filter select, [data-theme="dark"] .entry-classification-fields select,
[data-theme="dark"] .entry-form input, [data-theme="dark"] .entry-form textarea, [data-theme="dark"] .entry-form select,
[data-theme="dark"] #topicDialog select, [data-theme="dark"] #topicDialog textarea { color: var(--ink); border-color: #704d39; background: #291b14; }
[data-theme="dark"] .library-kind-tabs button, [data-theme="dark"] .speaking-library-tabs button { color: #cdb09b; }
[data-theme="dark"] .library-kind-tabs button.active, [data-theme="dark"] .speaking-library-tabs button.active { color: #fff4e8; background: #513629; }
[data-theme="dark"] .phrase-card, [data-theme="dark"] .writing-entry, [data-theme="dark"] .prompt-card { color: var(--ink); border-color: #684936; background: #3c2a20; }
[data-theme="dark"] .phrase-card.selected, [data-theme="dark"] .writing-entry.selected, [data-theme="dark"] .prompt-card.selected { border-color: #b9794d; background: #4b3224; }
[data-theme="dark"] .entry-kind { color: #ead0bc; background: #54392b; }
[data-theme="dark"] [data-kind="vocabulary"] .entry-kind { color: #ffd4b2; background: #5a3724; }
[data-theme="dark"] .chat-stream { background: linear-gradient(rgba(48,32,24,.97),rgba(48,32,24,.97)), repeating-linear-gradient(0deg,transparent 0,transparent 31px,rgba(238,140,67,.06) 32px); }
[data-theme="dark"] .bubble { color: var(--ink); border-color: #704d39; background: #422d22; }
[data-theme="dark"] .message.user .bubble { color: #fff; border-color: #9b5b34; background: #8b4b2a; }
[data-theme="dark"] .live-captions, [data-theme="dark"] .practice-status,
[data-theme="dark"] .answer-feedback, [data-theme="dark"] .ai-suggestion { color: #e6cdb9; border-color: #714d37; background: #4a3123; }
[data-theme="dark"] .voice-dock, [data-theme="dark"] .voice-composer { border-color: #684936; background: #35231b; }
[data-theme="dark"] .voice-tool { color: #d6b8a3; }
[data-theme="dark"] .analysis-tabs, [data-theme="dark"] .feedback-tabs, [data-theme="dark"] .library-view-tabs { border-color: #664633; background: transparent; }
[data-theme="dark"] .analysis-tabs button, [data-theme="dark"] .feedback-tabs button, [data-theme="dark"] .library-view-tabs button { color: #cdb3a0; }
[data-theme="dark"] .analysis-tabs button.active, [data-theme="dark"] .feedback-tabs button.active, [data-theme="dark"] .library-view-tabs button.active { color: #ffe7d1; background: #493126; }
[data-theme="dark"] .ai-improved { color: #fff4e9; border-left-color: #ee8c43; background: #4a3226; }
[data-theme="dark"] .writing-surface { border-color: #6f4b37; background: #2e1e17; }
[data-theme="dark"] #essayEditor { color: #fff4e9; }
[data-theme="dark"] .library-transfer-tools button { color: #f0d5c0; border-color: #76513c; background: #3b281f; }
[data-theme="dark"] .library-transfer-tools button:first-child { color: #fff; border-color: #aa653c; background: #8b4b2a; }
[data-theme="dark"] dialog { color: var(--ink); border-color: #76503a; background: #37251c; }
[data-theme="dark"] .dialog-heading { border-color: #6f4b37; background: #4a3124; }
[data-theme="dark"] .access-gate { background-color: #2a1b14; background-image: radial-gradient(circle at 20% 20%, rgba(190,126,74,.13), transparent 32%); }
[data-theme="dark"] .access-card { border-color: #694735; background: rgba(55,37,28,.99); }

@media (max-width: 980px) {
  .workspace { gap: 8px; padding: 8px; }
}
@media (max-width: 599px) {
  body { background-color: var(--paper); }
  .topbar { background: linear-gradient(102deg, rgba(151,91,53,.98), rgba(190,126,74,.98)); }
  .mobile-panels { border-color: rgba(92,51,29,.28); background: rgba(111,61,34,.90); }
  .mobile-panels button { color: #5e3a27; border-color: #ddbd9f; background: #fff5e8; }
  .mobile-panels button[aria-pressed="true"] { color: #fff; border-color: #814523; background: #814523; box-shadow: inset 0 -3px 0 #f19a56, 0 6px 16px rgba(67,36,20,.18); }
  .workspace { padding: 8px; }
  .workspace > .panel { border-color: rgba(94,51,29,.26); }
  [data-theme="dark"] .topbar { background: linear-gradient(102deg, #42271b, #5b3522); }
  [data-theme="dark"] .mobile-panels { border-color: #644431; background: rgba(49,31,23,.97); }
  [data-theme="dark"] .mobile-panels button { color: #d7baa5; border-color: #76513b; background: #3b281f; }
  [data-theme="dark"] .mobile-panels button[aria-pressed="true"] { color: #fff; border-color: #a7643d; background: #8b4b2a; }
}

/* Warm-detail cleanup: remove the last cool-blue remnants from high-specificity states. */
.round-library-card.round-recommended {
  border-color: #d8b18e;
  background: #f8e7d6;
}
.round-library-card.round-mentioned,
.round-library-card.round-added {
  border-color: #cf7b3b;
  background: #f9dfc5;
}
.round-library-state {
  color: #704029;
  background: #edd1b6;
}
.round-mentioned .round-library-state,
.round-added .round-library-state {
  color: #fff;
  background: #b85f28;
}
.conversation-history {
  border-color: #dfc2a9;
  background: #f7e4d1;
}
.conversation-history summary { color: #6b3a22; }
.conversation-history summary small,
.history-record-main small { color: #7a6153; }
.conversation-history-row {
  border-color: #dfc2a9;
  background: #fffaf4;
}
.history-delete { color: #8f382a; background: #f6ddd3; }
.history-delete:hover { background: #efc9bc; }
.history-load-more {
  color: #6b371f;
  border-color: #d5ad8b;
  background: #fff8ee;
}
.history-viewing-banner {
  color: #6e371e;
  border-color: #d89055;
  background: #f8ddc2;
}
.empty-feedback {
  color: #705b4e;
  border-color: #d9b99c;
  background: #fffaf4;
}
.round-library-section h2 { color: #6b371f; }
.round-library-intro { color: #725d50; }

[data-theme="dark"] .eyebrow,
[data-theme="dark"] .taxonomy-heading button,
[data-theme="dark"] .text-action { color: #e0a574; }
[data-theme="dark"] .icon-button {
  color: #ffe4ce;
  border-color: #85583d;
  background: #543523;
}
[data-theme="dark"] .icon-button:hover {
  border-color: #b47a55;
  background: #66412b;
}
[data-theme="dark"] .outline-button,
[data-theme="dark"] .end-button,
[data-theme="dark"] .keyboard-button {
  color: #f4d8c2;
  border-color: #7d563f;
  background: #422c22;
}
[data-theme="dark"] .outline-button:hover,
[data-theme="dark"] .end-button:hover,
[data-theme="dark"] .keyboard-button:hover {
  border-color: #ad744d;
  background: #543729;
}
[data-theme="dark"] .round-library-card.round-recommended {
  border-color: #744c35;
  background: #3f2a20;
}
[data-theme="dark"] .round-library-card.round-mentioned,
[data-theme="dark"] .round-library-card.round-added {
  border-color: #ae673d;
  background: #4f3121;
}
[data-theme="dark"] .round-library-state {
  color: #f2d2ba;
  background: #5b3b2c;
}
[data-theme="dark"] .round-mentioned .round-library-state,
[data-theme="dark"] .round-added .round-library-state {
  color: #fff1e4;
  background: #8d4e2c;
}
[data-theme="dark"] .empty-feedback {
  color: #dcc4b2;
  border-color: #6e4b38;
  background: #3b281f;
}
[data-theme="dark"] .conversation-history {
  border-color: #684936;
  background: #322119;
}
[data-theme="dark"] .conversation-history summary { color: #efcfb5; }
[data-theme="dark"] .conversation-history summary small,
[data-theme="dark"] .history-record-main small { color: #c6aa96; }
[data-theme="dark"] .conversation-history-row {
  border-color: #6f4c38;
  background: #3b281f;
}
[data-theme="dark"] .history-delete {
  color: #ffc1ae;
  background: #583126;
}
[data-theme="dark"] .history-load-more {
  color: #efd0b8;
  border-color: #79533d;
  background: #3b281f;
}
[data-theme="dark"] .history-viewing-banner {
  color: #ffd5b2;
  border-color: #8a5935;
  background: #4b3020;
}
[data-theme="dark"] .round-library-intro { color: #cbb09d; }
[data-theme="dark"] .round-library-section h2 { color: #edb484; }

/* Night-mode component map: every interactive state stays inside the roasted-earth palette. */
[data-theme="dark"] .theme-toggle:hover {
  color: #ffe4cb;
  border-color: #a96f49;
  background: #64412e;
}
[data-theme="dark"] .storage-bar button:hover {
  border-color: #a97450;
  background: #62412f;
}
[data-theme="dark"] .search-box:focus-within {
  border-color: #bc7c51;
  background: #332219;
  box-shadow: 0 0 0 4px rgba(190,126,74,.18);
}
[data-theme="dark"] .search-box span,
[data-theme="dark"] .taxonomy-heading,
[data-theme="dark"] .library-filter,
[data-theme="dark"] .library-hint,
[data-theme="dark"] .sort-note,
[data-theme="dark"] .library-panel .sort-note,
[data-theme="dark"] #writingResultCount { color: #c8aa95; }
[data-theme="dark"] .phrase-card:hover,
[data-theme="dark"] .writing-entry:hover,
[data-theme="dark"] .prompt-card:hover {
  border-color: #a8704c;
  box-shadow: 0 7px 20px rgba(0,0,0,.18);
}
[data-theme="dark"] .phrase-card .entry-english,
[data-theme="dark"] .writing-entry .entry-english,
[data-theme="dark"] .phrase-card .tag,
[data-theme="dark"] .writing-entry .tag,
[data-theme="dark"] .writing-entry .entry-head span,
[data-theme="dark"] .prompt-card > div { color: #f2d8c4; }
[data-theme="dark"] .phrase-card .entry-note,
[data-theme="dark"] .writing-entry .entry-note,
[data-theme="dark"] .detail-row p,
[data-theme="dark"] .entry-details .detail-row p { color: #c8b09f; }
[data-theme="dark"] .load-more,
[data-theme="dark"] .round-library-empty {
  color: #ead0bc;
  border-color: #72503b;
  background: #3d291f;
}
[data-theme="dark"] .message time { color: #c5aa96; }
[data-theme="dark"] .live-captions span,
[data-theme="dark"] .live-captions strong { color: #f0cfb5; }
[data-theme="dark"] .voice-dock-input,
[data-theme="dark"] .text-composer input {
  color: var(--ink);
  border-color: #76513c;
  background: #2c1d16;
}
[data-theme="dark"] .answer-feedback h3,
[data-theme="dark"] .real-analysis h3,
[data-theme="dark"] .feedback-content h3 { color: #efb684; }
[data-theme="dark"] .answer-feedback h4,
[data-theme="dark"] .ai-explanation { color: #dac0ac; }
[data-theme="dark"] .prompt-filters,
[data-theme="dark"] .band-grid { border-color: #654633; }
[data-theme="dark"] .prompt-filters button,
[data-theme="dark"] .writing-library-filters button {
  color: #d5b9a4;
  border-color: #6d4b37;
  background: #3a281f;
}
[data-theme="dark"] .prompt-filters button.active,
[data-theme="dark"] .writing-library-filters button.active {
  color: #fff;
  border-color: #b56e42;
  background: #8b4b2a;
}
[data-theme="dark"] .question-brief {
  color: #ead0bc;
  border-color: #684936;
  background: #402b20;
}
[data-theme="dark"] .question-brief span,
[data-theme="dark"] .question-brief p { color: #d7baa5; }
[data-theme="dark"] .switch-row { color: #ccb09c; }
[data-theme="dark"] .natural-answer { border-color: #6c4a37; }
[data-theme="dark"] .natural-answer summary { color: #e5bd9d; }
[data-theme="dark"] #essayEditor::placeholder { color: #a78b78; }
[data-theme="dark"] .editor-footer {
  color: #c4a894;
  border-color: #684936;
}
[data-theme="dark"] .editor-footer b { color: #e7c9b2; }
[data-theme="dark"] .switch-row i {
  border-color: #79543e;
  background: #4a3327;
}
[data-theme="dark"] .dialog-heading > button:hover { color: var(--ink); background: #5a3a2b; }
[data-theme="dark"] .dialog-actions button,
[data-theme="dark"] .cloud-dialog button:not(.dialog-heading button) {
  color: #e7cdb9;
  border-color: #74503b;
  background: #3d291f;
}
[data-theme="dark"] .dialog-actions button:last-child {
  color: #fff;
  border-color: #a7613a;
  background: #874827;
}
[data-theme="dark"] .settings-dialog dl {
  color: #dfc4af;
  border-color: #714e3a;
  background: #2c1d16;
}
[data-theme="dark"] .cloud-history-row { border-color: #674735; }
[data-theme="dark"] .library-transfer-tools button:hover:not(:disabled) {
  border-color: #a9704c;
  background: #543729;
}
[data-theme="dark"] .import-summary {
  color: #e2c4ac;
  border-color: #73503b;
  background: #432d22;
}
[data-theme="dark"] .access-copy p,
[data-theme="dark"] .access-note,
[data-theme="dark"] .access-form label,
[data-theme="dark"] .access-status { color: #cdb19d; }
[data-theme="dark"] .access-form input {
  color: var(--ink);
  border-color: #72503b;
  background: #2c1d16;
}

/* Writing controls use the same caramel language in daylight. */
.prompt-filters button.active,
.writing-library-filters button.active {
  color: #fff;
  border-color: #98512d;
  background: #98512d;
}
.switch-row input:checked + i {
  border-color: #9c562c;
  background: #9c562c;
}
.question-brief {
  color: #573522;
  border-color: #dfb995;
  background: #f3dfcc;
}
.question-brief span { color: #7c4326; }
.question-brief p { color: #604637; }

/* Desktop density: mirror an 80% browser zoom while preserving a full-height workspace. */
@media (min-width: 981px) {
  body { min-width: 1080px; zoom: .8; }
  .access-granted .app-shell { height: 125dvh; }
}

@media (max-width: 599px) {
  .topbar {
    height: 96px;
    min-height: 96px;
    grid-template-columns: 1fr auto;
    grid-template-rows: 36px 40px;
    gap: 6px 10px;
    padding: 7px 12px;
  }
  .brand { grid-column: 1; grid-row: 1; }
  .theme-toggle { grid-column: 2; grid-row: 1; }
  .mode-switch {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    height: 40px;
    margin: 0;
  }
}

/* Compact palette tray: color identity is separate from day/night brightness. */
.appearance-controls {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid rgba(255,245,233,.42);
  border-radius: 999px;
  background: rgba(65,34,19,.20);
}
.palette-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0;
  border: 0;
  background: transparent;
}
.palette-option {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  color: #fff7ef;
  background: transparent;
  cursor: pointer;
}
.palette-option:hover { background: rgba(255,255,255,.14); }
.palette-option[aria-pressed="true"] {
  border-color: rgba(255,255,255,.72);
  background: rgba(255,255,255,.20);
  box-shadow: 0 3px 10px rgba(49,27,16,.18);
}
.palette-option:focus-visible { outline: 3px solid rgba(255,236,217,.62); outline-offset: 2px; }
.palette-option > span { font-size: 17px; line-height: 1; }
.palette-option svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.appearance-controls .theme-toggle {
  width: 32px;
  height: 32px;
  border: 0;
  border-left: 1px solid rgba(255,255,255,.30);
  border-radius: 0 50% 50% 0;
  background: transparent;
  box-shadow: none;
}
.appearance-controls .theme-toggle:hover { border-color: rgba(255,255,255,.30); background: rgba(255,255,255,.14); transform: none; }

/* Orange Sea: clear ocean structure with a bright orange practice signal. */
:root[data-palette="orange-sea"] {
  --paper: #e8f4f7;
  --surface: #ffffff;
  --ink: #17313d;
  --muted: #5e7280;
  --line: #c9dce2;
  --green: #1f6f82;
  --green-soft: #e3f0f3;
  --amber: #bd651f;
  --ocean: #287f92;
  --ocean-deep: #15586a;
  --sky: #dceff3;
  --orange: #ff7a1a;
  --orange-soft: #fff0e2;
  --shadow-sm: 0 3px 12px rgba(23,49,61,.08);
  --shadow-panel: 0 16px 34px rgba(23,49,61,.12);
}
[data-palette="orange-sea"] body { background-color: var(--paper); background-image: radial-gradient(circle at 10% 15%,rgba(255,122,26,.10),transparent 24%),radial-gradient(circle at 90% 78%,rgba(40,127,146,.13),transparent 32%); }
[data-palette="orange-sea"] .topbar { color: #fff; border-color: #164b59; background: linear-gradient(105deg,#145568,#2b8191); box-shadow: 0 5px 20px rgba(18,73,88,.20); }
[data-palette="orange-sea"] .brand strong { color: #fff; }
[data-palette="orange-sea"] .brand small { color: #d7edf1; }
[data-palette="orange-sea"] .brand-mark { border-color: rgba(255,255,255,.38); background: rgba(7,45,56,.26); }
[data-palette="orange-sea"] .mode-switch,
[data-palette="orange-sea"] .appearance-controls { border-color: rgba(224,247,250,.34); background: rgba(6,45,56,.25); }
[data-palette="orange-sea"] .mode-tab { color: #cbe7ec; }
[data-palette="orange-sea"] .mode-tab.active { color: #124e5f; background: #fff; box-shadow: inset 0 -3px 0 #ff7a1a,0 4px 14px rgba(7,44,54,.18); }
[data-palette="orange-sea"] .theme-toggle { color: #fff1e4; border-color: rgba(229,249,251,.43); background: rgba(7,48,59,.25); }
[data-palette="orange-sea"] .storage-bar { color: #d8edf1; border-color: #123f4d; background: rgba(18,72,87,.94); }
[data-palette="orange-sea"] .storage-bar button { color: #164f60; border-color: #bcdce3; background: #effbfc; }
[data-palette="orange-sea"] .storage-bar .logout-button { color: #fff; border-color: rgba(255,255,255,.34); background: rgba(5,42,52,.30); }
[data-palette="orange-sea"] .account-chip,
[data-palette="orange-sea"] #cloudStatus { color: #c6e4ea; }
[data-palette="orange-sea"] .workspace > .panel { border-color: #bad3da; box-shadow: 0 12px 30px rgba(23,73,86,.11); }
[data-palette="orange-sea"] .library-panel,
[data-palette="orange-sea"] .prompt-panel { background: rgba(237,247,249,.98) !important; }
[data-palette="orange-sea"] .analysis-panel,
[data-palette="orange-sea"] .feedback-panel { background: rgba(229,242,245,.99) !important; }
[data-palette="orange-sea"] .conversation-panel,
[data-palette="orange-sea"] .editor-panel { background: #fbfeff !important; }
[data-palette="orange-sea"] .conversation-header,
[data-palette="orange-sea"] .editor-header { border-color: #c9dce2; background: rgba(255,255,255,.97); }
[data-palette="orange-sea"] .eyebrow,
[data-palette="orange-sea"] .taxonomy-heading button,
[data-palette="orange-sea"] .text-action,
[data-palette="orange-sea"] .round-library-section h2 { color: #15586a; }
[data-palette="orange-sea"] .icon-button { color: #15586a; border-color: #acd0d8; background: #dbeff3; }
[data-palette="orange-sea"] .search-box { border-color: #c2dce2; background: #e3f1f4; }
[data-palette="orange-sea"] .library-kind-tabs,
[data-palette="orange-sea"] .speaking-library-tabs { border-color: #b9d6dd; background: #d6e9ed; }
[data-palette="orange-sea"] .library-kind-tabs button.active,
[data-palette="orange-sea"] .speaking-library-tabs button.active { color: #124e5f; background: #fff; }
[data-palette="orange-sea"] .phrase-card,
[data-palette="orange-sea"] .writing-entry,
[data-palette="orange-sea"] .prompt-card,
[data-palette="orange-sea"] .round-library-card.round-recommended { border-color: #c3dbe1; background: #fff; }
[data-palette="orange-sea"] .round-library-card.round-mentioned,
[data-palette="orange-sea"] .round-library-card.round-added { border-color: #ffad70; background: #fff0e2; }
[data-palette="orange-sea"] .round-library-state { color: #15586a; background: #d8edf1; }
[data-palette="orange-sea"] .round-mentioned .round-library-state,
[data-palette="orange-sea"] .round-added .round-library-state { color: #fff; background: #e56812; }
[data-palette="orange-sea"] .outline-button,
[data-palette="orange-sea"] .end-button,
[data-palette="orange-sea"] .keyboard-button { color: #15586a; border-color: #bdd6dc; background: #f8fcfd; }
[data-palette="orange-sea"] .conversation-history { border-color: #c7dde2; background: #e8f4f6; }
[data-palette="orange-sea"] .conversation-history summary { color: #15586a; }
[data-palette="orange-sea"] .chat-stream { background: linear-gradient(rgba(249,253,254,.97),rgba(249,253,254,.97)),repeating-linear-gradient(0deg,transparent 0,transparent 31px,rgba(31,111,130,.07) 32px); }
[data-palette="orange-sea"] .avatar { background: #1f6f82; }
[data-palette="orange-sea"] .message.user .avatar { color: #743408; background: #ff9a50; }
[data-palette="orange-sea"] .bubble { border-color: #c9dce2; background: #fff; }
[data-palette="orange-sea"] .message.user .bubble { color: #fff; border-color: #1f6f82; background: #1f6f82; }
[data-palette="orange-sea"] .voice-dock,
[data-palette="orange-sea"] .voice-composer { border-color: #c9dce2; background: rgba(255,255,255,.985); }
[data-palette="orange-sea"] .analysis-tabs button.active,
[data-palette="orange-sea"] .feedback-tabs button.active,
[data-palette="orange-sea"] .library-view-tabs button.active { color: #15586a; border-color: #ff7a1a; background: #eef8fa; }
[data-palette="orange-sea"] .answer-feedback,
[data-palette="orange-sea"] .ai-suggestion { border-color: #c3dce2; background: #e6f2f4; }
[data-palette="orange-sea"] .empty-feedback { color: #5e7280; border-color: #c7dce2; background: #fbfeff; }
[data-palette="orange-sea"] .question-brief { color: #234755; border-color: #c3dce2; background: #e3f0f3; }
[data-palette="orange-sea"] .question-brief span { color: #15586a; }
[data-palette="orange-sea"] .question-brief p { color: #405f6a; }
[data-palette="orange-sea"] .prompt-filters button.active,
[data-palette="orange-sea"] .writing-library-filters button.active { border-color: #1f6f82; background: #1f6f82; }
[data-palette="orange-sea"] .text-composer button,
[data-palette="orange-sea"] .primary-button,
[data-palette="orange-sea"] .dialog-actions button:last-child { border-color: #176173; background: #176173; }

/* Business Blue: cooler, quieter surfaces for a formal study-desk mood. */
:root[data-palette="business-blue"] {
  --paper: #dfeaf3;
  --surface: #fafdff;
  --ink: #172c3e;
  --muted: #5c7182;
  --line: #bfd1de;
  --green: #315f84;
  --green-soft: #dceaf4;
  --amber: #856326;
  --ocean: #376c94;
  --ocean-deep: #244e70;
  --sky: #dceaf5;
  --orange: #4f86af;
  --orange-soft: #e5eff7;
  --shadow-sm: 0 3px 12px rgba(23,44,62,.08);
  --shadow-panel: 0 16px 34px rgba(23,44,62,.12);
}
[data-palette="business-blue"] body { background-color: var(--paper); background-image: linear-gradient(120deg,rgba(255,255,255,.14),transparent 45%),radial-gradient(circle at 88% 78%,rgba(55,108,148,.12),transparent 32%); }
[data-palette="business-blue"] .topbar { color: #fff; border-color: #173b56; background: linear-gradient(105deg,#183b58,#376c94); box-shadow: 0 5px 20px rgba(20,52,76,.20); }
[data-palette="business-blue"] .brand strong { color: #fff; }
[data-palette="business-blue"] .brand small { color: #d8e7f1; }
[data-palette="business-blue"] .brand-mark { border-color: rgba(255,255,255,.40); background: rgba(13,39,58,.30); }
[data-palette="business-blue"] .mode-switch,
[data-palette="business-blue"] .appearance-controls { border-color: rgba(224,239,249,.34); background: rgba(10,34,52,.26); }
[data-palette="business-blue"] .mode-tab { color: #d0e0eb; }
[data-palette="business-blue"] .mode-tab.active { color: #183f5d; background: #fff; box-shadow: inset 0 -3px 0 #74a7cc,0 4px 14px rgba(10,34,52,.18); }
[data-palette="business-blue"] .theme-toggle { color: #f1f7fb; border-color: rgba(229,241,250,.44); background: rgba(10,34,52,.24); }
[data-palette="business-blue"] .storage-bar { color: #d9e7f0; border-color: #16364f; background: rgba(27,63,91,.96); }
[data-palette="business-blue"] .storage-bar button { color: #244e70; border-color: #bfd3e1; background: #f4f9fc; }
[data-palette="business-blue"] .storage-bar .logout-button { color: #fff; border-color: rgba(255,255,255,.34); background: rgba(10,33,50,.28); }
[data-palette="business-blue"] .account-chip,
[data-palette="business-blue"] #cloudStatus { color: #ccdeea; }
[data-palette="business-blue"] .workspace > .panel { border-color: #b7cad8; box-shadow: 0 12px 30px rgba(23,52,75,.11); }
[data-palette="business-blue"] .library-panel,
[data-palette="business-blue"] .prompt-panel { background: rgba(237,244,249,.99) !important; }
[data-palette="business-blue"] .analysis-panel,
[data-palette="business-blue"] .feedback-panel { background: rgba(230,239,246,.99) !important; }
[data-palette="business-blue"] .conversation-panel,
[data-palette="business-blue"] .editor-panel { background: #fafdff !important; }
[data-palette="business-blue"] .conversation-header,
[data-palette="business-blue"] .editor-header { border-color: #c2d2de; background: rgba(250,253,255,.98); }
[data-palette="business-blue"] .eyebrow,
[data-palette="business-blue"] .taxonomy-heading button,
[data-palette="business-blue"] .text-action,
[data-palette="business-blue"] .round-library-section h2 { color: #244e70; }
[data-palette="business-blue"] .icon-button { color: #244e70; border-color: #b2cadb; background: #dceaf4; }
[data-palette="business-blue"] .search-box { border-color: #bfd2df; background: #e6f0f7; }
[data-palette="business-blue"] .library-kind-tabs,
[data-palette="business-blue"] .speaking-library-tabs { border-color: #b9cedc; background: #d9e7f0; }
[data-palette="business-blue"] .library-kind-tabs button.active,
[data-palette="business-blue"] .speaking-library-tabs button.active { color: #244e70; background: #fff; }
[data-palette="business-blue"] .phrase-card,
[data-palette="business-blue"] .writing-entry,
[data-palette="business-blue"] .prompt-card,
[data-palette="business-blue"] .round-library-card.round-recommended { border-color: #c1d3df; background: #fff; }
[data-palette="business-blue"] .round-library-card.round-mentioned,
[data-palette="business-blue"] .round-library-card.round-added { border-color: #79a6c7; background: #e4eff7; }
[data-palette="business-blue"] .round-library-state { color: #244e70; background: #d9e8f2; }
[data-palette="business-blue"] .round-mentioned .round-library-state,
[data-palette="business-blue"] .round-added .round-library-state { color: #fff; background: #376c94; }
[data-palette="business-blue"] .outline-button,
[data-palette="business-blue"] .end-button,
[data-palette="business-blue"] .keyboard-button { color: #244e70; border-color: #bccfdd; background: #f8fbfd; }
[data-palette="business-blue"] .conversation-history { border-color: #c2d3df; background: #e6f0f6; }
[data-palette="business-blue"] .conversation-history summary { color: #244e70; }
[data-palette="business-blue"] .chat-stream { background: linear-gradient(rgba(249,252,254,.97),rgba(249,252,254,.97)),repeating-linear-gradient(0deg,transparent 0,transparent 31px,rgba(49,95,132,.07) 32px); }
[data-palette="business-blue"] .avatar { background: #315f84; }
[data-palette="business-blue"] .message.user .avatar { color: #fff; background: #5d88a8; }
[data-palette="business-blue"] .bubble { border-color: #c1d2de; background: #fff; }
[data-palette="business-blue"] .message.user .bubble { color: #fff; border-color: #315f84; background: #315f84; }
[data-palette="business-blue"] .voice-dock,
[data-palette="business-blue"] .voice-composer { border-color: #c2d3df; background: rgba(250,253,255,.985); }
[data-palette="business-blue"] .analysis-tabs button.active,
[data-palette="business-blue"] .feedback-tabs button.active,
[data-palette="business-blue"] .library-view-tabs button.active { color: #244e70; border-color: #4f86af; background: #edf4f9; }
[data-palette="business-blue"] .answer-feedback,
[data-palette="business-blue"] .ai-suggestion { border-color: #c1d3df; background: #e3edf5; }
[data-palette="business-blue"] .empty-feedback { color: #5c7182; border-color: #c3d3df; background: #fafdff; }
[data-palette="business-blue"] .question-brief { color: #26475f; border-color: #c1d2df; background: #e1ecf4; }
[data-palette="business-blue"] .question-brief span { color: #244e70; }
[data-palette="business-blue"] .question-brief p { color: #496273; }
[data-palette="business-blue"] .prompt-filters button.active,
[data-palette="business-blue"] .writing-library-filters button.active,
[data-palette="business-blue"] .text-composer button,
[data-palette="business-blue"] .primary-button,
[data-palette="business-blue"] .dialog-actions button:last-child { border-color: #315f84; background: #315f84; }

/* Each optional palette has its own low-glare night treatment. */
:root[data-theme="dark"][data-palette="orange-sea"] {
  --paper: #0e1b22;
  --surface: #16272f;
  --ink: #f1f5f4;
  --muted: #abc0c8;
  --line: #2d4651;
  --green: #69b4c4;
  --green-soft: #1b3944;
  --ocean: #4d9fb2;
  --ocean-deep: #8bcbd8;
  --sky: #1c3944;
  --orange: #ff943d;
  --orange-soft: #3b291d;
}
[data-theme="dark"][data-palette="orange-sea"] body { background-color: #0e1b22; background-image: radial-gradient(circle at 12% 18%,rgba(77,159,178,.10),transparent 28%),radial-gradient(circle at 88% 76%,rgba(0,0,0,.18),transparent 34%); }
[data-theme="dark"][data-palette="orange-sea"] .topbar { border-color: #29414b; background: linear-gradient(102deg,#102832,#174a58); }
[data-theme="dark"][data-palette="orange-sea"] .storage-bar { color: #b8d0d7; border-color: #294550; background: rgba(14,36,44,.97); }
[data-theme="dark"][data-palette="orange-sea"] .workspace > .panel { border-color: #294852; }
[data-theme="dark"][data-palette="orange-sea"] .library-panel,
[data-theme="dark"][data-palette="orange-sea"] .prompt-panel { background: #12262e !important; }
[data-theme="dark"][data-palette="orange-sea"] .analysis-panel,
[data-theme="dark"][data-palette="orange-sea"] .feedback-panel { background: #101f27 !important; }
[data-theme="dark"][data-palette="orange-sea"] .conversation-panel,
[data-theme="dark"][data-palette="orange-sea"] .editor-panel { background: #14262e !important; }
[data-theme="dark"][data-palette="orange-sea"] .conversation-header,
[data-theme="dark"][data-palette="orange-sea"] .editor-header { border-color: #2c4651; background: #16272f; }
[data-theme="dark"][data-palette="orange-sea"] .phrase-card,
[data-theme="dark"][data-palette="orange-sea"] .writing-entry,
[data-theme="dark"][data-palette="orange-sea"] .prompt-card,
[data-theme="dark"][data-palette="orange-sea"] .round-library-card.round-recommended { color: var(--ink); border-color: #304a54; background: #172b34; }
[data-theme="dark"][data-palette="orange-sea"] .conversation-history { border-color: #2e4954; background: #132a33; }
[data-theme="dark"][data-palette="orange-sea"] .chat-stream { background: linear-gradient(rgba(15,30,37,.97),rgba(15,30,37,.97)),repeating-linear-gradient(0deg,transparent 0,transparent 31px,rgba(105,180,196,.06) 32px); }
[data-theme="dark"][data-palette="orange-sea"] .bubble { color: var(--ink); border-color: #33505b; background: #1a3039; }
[data-theme="dark"][data-palette="orange-sea"] .message.user .bubble { color: #fff; border-color: #347f91; background: #246f80; }
[data-theme="dark"][data-palette="orange-sea"] .voice-dock,
[data-theme="dark"][data-palette="orange-sea"] .voice-composer { border-color: #2c4651; background: #13242c; }
[data-theme="dark"][data-palette="orange-sea"] .answer-feedback,
[data-theme="dark"][data-palette="orange-sea"] .ai-suggestion,
[data-theme="dark"][data-palette="orange-sea"] .empty-feedback { color: #c5d8dd; border-color: #31515c; background: #18343e; }

:root[data-theme="dark"][data-palette="business-blue"] {
  --paper: #101a24;
  --surface: #182735;
  --ink: #f2f7fa;
  --muted: #a9bfce;
  --line: #304858;
  --green: #77a8cb;
  --green-soft: #21394a;
  --ocean: #6fa4cc;
  --ocean-deep: #a3cbe7;
  --sky: #203748;
  --orange: #77add4;
  --orange-soft: #22394a;
}
[data-theme="dark"][data-palette="business-blue"] body { background-color: #101a24; background-image: radial-gradient(circle at 14% 16%,rgba(74,124,163,.12),transparent 30%),radial-gradient(circle at 86% 78%,rgba(0,0,0,.16),transparent 34%); }
[data-theme="dark"][data-palette="business-blue"] .topbar { border-color: #294254; background: linear-gradient(102deg,#132b3d,#234e6c); }
[data-theme="dark"][data-palette="business-blue"] .storage-bar { color: #c1d4e1; border-color: #294355; background: rgba(17,39,55,.97); }
[data-theme="dark"][data-palette="business-blue"] .workspace > .panel { border-color: #2d4657; }
[data-theme="dark"][data-palette="business-blue"] .library-panel,
[data-theme="dark"][data-palette="business-blue"] .prompt-panel { background: #152531 !important; }
[data-theme="dark"][data-palette="business-blue"] .analysis-panel,
[data-theme="dark"][data-palette="business-blue"] .feedback-panel { background: #121f2a !important; }
[data-theme="dark"][data-palette="business-blue"] .conversation-panel,
[data-theme="dark"][data-palette="business-blue"] .editor-panel { background: #182936 !important; }
[data-theme="dark"][data-palette="business-blue"] .conversation-header,
[data-theme="dark"][data-palette="business-blue"] .editor-header { border-color: #304a5b; background: #1a2d3b; }
[data-theme="dark"][data-palette="business-blue"] .phrase-card,
[data-theme="dark"][data-palette="business-blue"] .writing-entry,
[data-theme="dark"][data-palette="business-blue"] .prompt-card,
[data-theme="dark"][data-palette="business-blue"] .round-library-card.round-recommended { color: var(--ink); border-color: #324d60; background: #1c303e; }
[data-theme="dark"][data-palette="business-blue"] .conversation-history { border-color: #304c5e; background: #162a37; }
[data-theme="dark"][data-palette="business-blue"] .chat-stream { background: linear-gradient(rgba(17,32,43,.97),rgba(17,32,43,.97)),repeating-linear-gradient(0deg,transparent 0,transparent 31px,rgba(111,164,204,.06) 32px); }
[data-theme="dark"][data-palette="business-blue"] .bubble { color: var(--ink); border-color: #355368; background: #1e3342; }
[data-theme="dark"][data-palette="business-blue"] .message.user .bubble { color: #fff; border-color: #477ca3; background: #315f84; }
[data-theme="dark"][data-palette="business-blue"] .voice-dock,
[data-theme="dark"][data-palette="business-blue"] .voice-composer { border-color: #304a5b; background: #172733; }
[data-theme="dark"][data-palette="business-blue"] .answer-feedback,
[data-theme="dark"][data-palette="business-blue"] .ai-suggestion,
[data-theme="dark"][data-palette="business-blue"] .empty-feedback { color: #c9d8e2; border-color: #345165; background: #1d3342; }

@media (max-width: 980px) {
  .appearance-controls { grid-column: 2; grid-row: 1; }
}
@media (max-width: 599px) {
  .appearance-controls { grid-column: 2; grid-row: 1; gap: 1px; padding: 2px; }
  .palette-switcher { gap: 1px; padding: 0; }
  .palette-option { width: 28px; height: 28px; }
  .palette-option > span { font-size: 15px; }
  .palette-option svg { width: 16px; height: 16px; }
  [data-palette="orange-sea"] .topbar { background: linear-gradient(102deg,#145568,#2b8191); }
  [data-palette="orange-sea"] .mobile-panels { border-color: #176173; background: rgba(18,82,98,.94); }
  [data-palette="orange-sea"] .mobile-panels button { color: #15586a; border-color: #bcd8df; background: #f7fcfd; }
  [data-palette="orange-sea"] .mobile-panels button[aria-pressed="true"] { color: #fff; border-color: #176173; background: #176173; }
  [data-palette="business-blue"] .topbar { background: linear-gradient(102deg,#183b58,#376c94); }
  [data-palette="business-blue"] .mobile-panels { border-color: #244e70; background: rgba(29,65,93,.95); }
  [data-palette="business-blue"] .mobile-panels button { color: #244e70; border-color: #bed1df; background: #f7fbfd; }
  [data-palette="business-blue"] .mobile-panels button[aria-pressed="true"] { color: #fff; border-color: #315f84; background: #315f84; }
  [data-theme="dark"][data-palette="orange-sea"] .mobile-panels { border-color: #294b57; background: rgba(13,35,43,.97); }
  [data-theme="dark"][data-palette="business-blue"] .mobile-panels { border-color: #2d4759; background: rgba(15,32,44,.97); }
}

/* Keep every appearance glyph monochrome and inside one shared control. */
:root .appearance-controls .theme-toggle {
  width: 32px;
  height: 32px;
  color: inherit;
  border: 0;
  border-left: 1px solid rgba(255,255,255,.30);
  border-radius: 0 50% 50% 0;
  background: transparent;
  box-shadow: none;
}
:root .appearance-controls .theme-toggle:hover {
  color: inherit;
  border-color: rgba(255,255,255,.30);
  background: rgba(255,255,255,.14);
  transform: none;
}

.site-compliance {
  display: flex;
  justify-content: center;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  background: var(--paper);
}
.site-compliance a { color: inherit; text-decoration: none; }
.site-compliance a:hover { color: var(--ocean-deep); text-decoration: underline; }

body.access-pending { min-width: 0; height: 100dvh; overflow: auto; zoom: 1; }
.access-pending .access-gate {
  --login-inset-x: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  --login-inset-y: max(16px, env(safe-area-inset-top), env(safe-area-inset-bottom));
  min-height: 100dvh;
  padding: var(--login-inset-y) var(--login-inset-x);
}
.access-pending .site-compliance { position: fixed; inset: auto 0 0; background: transparent; }

/* ------------------------------------------------------------------
   Mobile app shell
   Phones use a four-tab bottom bar. The speaking tab is voice-first:
   the chat fills the screen and the live review opens as an in-app
   bottom sheet instead of a second stacked column.
   Larger screens use the desktop navigation.
------------------------------------------------------------------ */
.mobile-appbar,
.mobile-tabbar,
.mobile-account,
.mobile-sheet-backdrop,
.mobile-voice-toolbar,
.mobile-sheet-actions,
.pwa-install-banner { display: none; }

@media (min-width: 600px) {
  .mobile-appbar,
  .mobile-tabbar,
  .mobile-account,
  .mobile-sheet-backdrop,
  .mobile-voice-toolbar,
  .mobile-sheet-actions { display: none !important; }
}

@media (max-width: 599px) {
  :root {
    --mobile-appbar-h: 50px;
    --mobile-tabbar-h: 64px;
    --mobile-shell-bottom: calc(var(--mobile-tabbar-h) + env(safe-area-inset-bottom));
  }

  html, body { height: 100%; overflow: hidden; }
  body { background: var(--paper); }
  /* iOS zooms the page when a focused control is under 16px. */
  input, textarea, select { font-size: 16px !important; }
  .site-compliance { display: none; }
  .topbar, .storage-bar { display: none !important; }

  /* Fixed-to-viewport shell: iOS standalone can report a short dvh under the
     status bar, which left the tab bar floating above the bottom edge. */
  .app-shell { position: fixed; inset: 0; bottom: var(--keyboard-inset, 0px); height: auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; transition: bottom .18s ease; }

  /* Compact app bar */
  .mobile-appbar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    height: calc(var(--mobile-appbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 14px 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }
  .mobile-brand { display: flex; min-width: 0; align-items: center; gap: 9px; font: 700 16px Georgia, "Songti SC", serif; }
  .mobile-brand .brand-mark { width: 27px; height: 27px; font-size: 14px; }
  .mobile-appbar-action {
    position: relative;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: var(--green-soft);
    color: var(--green);
    cursor: pointer;
  }
  .mobile-appbar-action svg { width: 20px; height: 20px; }
  .mobile-sync-dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: #4fa079; box-shadow: 0 0 0 2px var(--green-soft); }
  .mobile-sync-dot.is-error { background: var(--red, #c5533d); }

  /* Bottom tab bar */
  .mobile-tabbar {
    position: fixed;
    z-index: 40;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 30px rgba(23, 49, 61, .07);
    transition: transform .18s ease, opacity .18s ease;
  }
  .mobile-tabbar button {
    display: grid;
    justify-items: center;
    gap: 3px;
    min-height: 50px;
    padding: 3px 2px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: .6875rem;
    font-weight: 600;
    opacity: .55;
    cursor: pointer;
    transition: color .18s ease, opacity .18s ease;
  }
  .mobile-tabbar svg { width: 24px; height: 24px; padding: 3px; border-radius: 10px; transition: background-color .18s ease; }
  .mobile-tabbar button.active { color: var(--green); opacity: 1; font-weight: 700; }
  .mobile-tabbar button.active svg { background: var(--green-soft); }
  .mobile-tabbar button:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
  body.keyboard-open { --mobile-shell-bottom: 0px; }
  body.keyboard-open .mobile-tabbar { transform: translateY(130%); opacity: 0; pointer-events: none; }
  body.keyboard-open .pwa-install-banner { display: none !important; }

  /* Screens sit between the app bar and the fixed tab bar */
  .workspace, .mobile-account { flex: 1 1 auto; min-height: 0; padding-bottom: var(--mobile-shell-bottom); }
  .workspace { height: auto; overflow: hidden; }
  .workspace > .panel { min-height: 0; max-height: none; }

  /* Speaking tab: only the conversation, full height */
  #speakingMobileNav { display: none !important; }
  .speaking-workspace, .speaking-workspace[data-mobile-panel="practice"], .speaking-workspace[data-mobile-panel="library"] { display: block; }
  .speaking-workspace[data-mobile-panel="practice"] > .library-panel,
  .speaking-workspace[data-mobile-panel="library"] > .conversation-panel,
  .speaking-workspace[data-mobile-panel="library"] > .analysis-panel { display: none !important; }
  .speaking-workspace[data-mobile-panel="practice"] > .conversation-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    background: var(--surface);
  }
  .speaking-workspace[data-mobile-panel="library"] > .library-panel { height: 100%; border: 0; padding: 12px 14px 18px; background: var(--surface); }

  .conversation-header { flex: 0 0 auto; align-items: center; flex-wrap: nowrap; gap: 8px; padding: 9px 12px; }
  .conversation-header > div { grid-template-columns: 1fr; min-width: 0; }
  .conversation-header strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
  .conversation-header small { display: none; }
  .conversation-header .conversation-actions { display: flex; flex: 0 0 auto; gap: 4px; }
  .conversation-header .outline-button,
  .conversation-header .end-button { min-height: 32px; padding: 5px 9px; border-radius: 999px; font-size: .75rem; }

  .mobile-voice-toolbar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 12px 8px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }
  .mobile-voice-mode { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: .75rem; font-weight: 650; }
  .mobile-voice-mode::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
  .mobile-analysis-open { min-height: 32px; padding: 5px 6px; border: 0; background: transparent; color: var(--green); font: inherit; font-size: .75rem; font-weight: 700; cursor: pointer; }

  .conversation-history { flex: 0 0 auto; margin: 8px 12px 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
  .conversation-history summary { min-height: 34px; padding: 6px 12px; font-size: .75rem; }
  .conversation-history summary::before { width: 14px; font-size: .875rem; }
  .conversation-history-list { max-height: 180px; }
  .history-viewing-banner { margin: 8px 12px 0; border-radius: 12px; }

  .chat-stream { flex: 1 1 auto; min-height: 0; padding: 12px 14px 16px; overscroll-behavior: contain; }
  .date-divider { margin-bottom: 14px; }
  .message { margin-bottom: 14px; }
  .bubble { max-width: 82%; border-radius: 14px; }
  .message .bubble p { font-size: .9375rem; line-height: 1.55; }
  .live-captions { flex: 0 0 auto; margin: 0 12px 8px; }
  .practice-status { flex: 0 0 auto; }

  .voice-dock { flex: 0 0 auto; gap: 8px; padding: 10px 14px 12px; border-top: 1px solid var(--line); background: var(--surface); }
  .voice-dock-actions { gap: 18px; }
  .voice-dock .voice-tool { width: 46px; height: 46px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); box-shadow: none; }
  #realtimeToggle.active, #realtimeToggle.connecting { color: #fff; border-color: #b84a0a; background: #b84a0a; box-shadow: 0 0 0 5px rgba(184, 74, 10, .14); }

  /* Live review sheet, opened from inside the voice tab */
  .speaking-workspace[data-mobile-panel="practice"] > .analysis-panel {
    display: flex;
    position: fixed;
    z-index: 60;
    left: 0;
    right: 0;
    bottom: 0;
    height: min(52dvh, 460px);
    min-height: 0;
    margin: 0;
    padding: 8px 16px calc(14px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: 22px 22px 0 0;
    background: var(--surface);
    box-shadow: 0 -22px 55px rgba(23, 26, 30, .28);
    transform: translateY(104%);
    transition: transform .3s cubic-bezier(.22, .8, .24, 1);
    overflow: hidden;
  }
  .speaking-workspace[data-mobile-panel="practice"] > .analysis-panel::before { content: ""; flex: 0 0 auto; width: 40px; height: 4px; margin: 0 auto 8px; border-radius: 999px; background: var(--line); }
  body.analysis-open .speaking-workspace[data-mobile-panel="practice"] > .analysis-panel { transform: translateY(0); }
  body.analysis-full .speaking-workspace[data-mobile-panel="practice"] > .analysis-panel { height: min(86dvh, 760px); }
  .mobile-sheet-actions { display: flex; align-items: center; gap: 2px; }
  .mobile-sheet-actions #mobileAnalysisExpand { min-height: 32px; padding: 4px 9px; border: 0; border-radius: 999px; background: var(--green-soft); color: var(--green); font: inherit; font-size: .75rem; font-weight: 700; cursor: pointer; }
  .analysis-close { width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--paper); color: var(--muted); font-size: 1.15rem; line-height: 1; cursor: pointer; }
  .analysis-panel .panel-heading { flex: 0 0 auto; }
  .analysis-panel .analysis-tabs { flex: 0 0 auto; margin: 10px 0 8px; }
  .analysis-panel .real-analysis { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .analysis-panel .assessment-note { flex: 0 0 auto; }
  .mobile-sheet-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(24, 18, 12, .38); opacity: 0; pointer-events: none; transition: opacity .28s ease; }
  body.analysis-open .mobile-sheet-backdrop { opacity: 1; pointer-events: auto; }

  /* Library tab */
  .library-panel .panel-heading h1 { font-size: 1.35rem; }
  .library-panel .search-box { margin-top: 14px; }

  /* Writing tab: one segmented control instead of three stacked columns */
  #writingMobileNav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; flex: 0 0 auto; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
  #writingMobileNav button { min-height: 38px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--muted); font: inherit; font-size: .8125rem; font-weight: 650; cursor: pointer; }
  #writingMobileNav button[aria-pressed="true"] { color: #fff; border-color: var(--green); background: var(--green); box-shadow: 0 6px 14px rgba(23, 49, 61, .16); }
  .writing-workspace > .panel { height: 100%; border: 0; padding: 14px; }
  .writing-workspace[data-mobile-panel="editor"] > .editor-panel { display: flex; flex-direction: column; overflow: hidden; }
  .editor-panel .writing-surface { flex: 1 1 auto; min-height: 140px; display: flex; flex-direction: column; }
  .editor-panel #essayEditor { flex: 1 1 auto; min-height: 120px; }

  /* Account tab */
  .mobile-account { display: block; overflow-y: auto; padding: 14px 14px calc(24px + var(--mobile-shell-bottom)); background: var(--paper); }
  .mobile-account[hidden] { display: none !important; }
  .mobile-account-hero { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--panel-radius); background: var(--surface); box-shadow: var(--shadow-sm); }
  .mobile-account-hero .brand-mark { width: 46px; height: 46px; font-size: 22px; }
  .mobile-account-hero strong { display: block; font-size: 1.05rem; }
  .mobile-account-hero small { color: var(--muted); font-size: .75rem; }
  .mobile-account-card { margin-top: 12px; padding: 2px 14px; border-radius: var(--panel-radius); background: var(--surface); box-shadow: var(--shadow-sm); }
  .mobile-account-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .mobile-account-card .mobile-account-row:last-child { border-bottom: 0; }
  .mobile-account-row strong { display: block; font-size: .9375rem; }
  .mobile-account-row small { display: block; margin-top: 2px; color: var(--muted); font-size: .75rem; line-height: 1.45; }
  .mobile-account-row button { min-height: 34px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--green); font: inherit; font-size: .75rem; font-weight: 700; cursor: pointer; }
  .mobile-account-row a { color: var(--green); font-size: .8125rem; text-decoration: none; }
  .mobile-palette-row { display: flex; gap: 10px; padding: 2px 0 12px; }
  .mobile-palette-row .palette-option { width: 40px; height: 40px; border: 0; border-radius: 14px; color: #fff; }
  .mobile-palette-row .palette-clay { background: #be7e4a; }
  .mobile-palette-row .palette-orange-sea { background: #1f6f82; }
  .mobile-palette-row .palette-business-blue { background: #244e70; }
  .mobile-palette-row .palette-option[aria-pressed="true"] { border-color: transparent; background-image: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
  .mobile-palette-row .palette-clay > span { width: 18px; height: 18px; border-width: 2px; box-shadow: inset 0 0 0 4px currentColor; }
  .mobile-palette-row .palette-option svg { width: 20px; height: 20px; }
  .mobile-switch { position: relative; width: 50px !important; height: 30px; min-height: 30px !important; padding: 0 !important; border: 0 !important; border-radius: 999px !important; background: var(--line) !important; }
  .mobile-switch i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s ease; }
  .mobile-switch[aria-checked="true"] { background: var(--green) !important; }
  .mobile-switch[aria-checked="true"] i { transform: translateX(20px); }
  .mobile-logout { width: 100%; min-height: 48px; margin-top: 16px; border: 1px solid var(--line); border-radius: var(--panel-radius); background: var(--surface); color: var(--red, #c5533d); font: inherit; font-size: .9375rem; font-weight: 700; cursor: pointer; }

  /* Per-answer review sheet */
  .message .inspect-analysis { display: none; }
  .message.user .message-body { display: flex; flex-direction: column; align-items: flex-end; }
  dialog.message-detail-dialog { width: 100%; max-width: none; max-height: 88dvh; margin: auto 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); border: 0; border-radius: 22px 22px 0 0; background: var(--surface); }
  dialog.message-detail-dialog[open] { display: flex; flex-direction: column; }
  dialog.message-detail-dialog::backdrop { background: rgba(24, 18, 12, .38); }
  .message-detail-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 2px 0 12px; }
  .message-detail-body h3 { margin: 16px 0 8px; font-size: .9375rem; color: var(--green); }
  .message-detail-answer { margin: 4px 0 10px; padding: 10px 12px; border-radius: 12px; background: var(--green-soft); color: var(--ink); font: 600 .9375rem/1.6 Georgia, "Songti SC", serif; overflow-wrap: anywhere; }
  .message-match-card { padding: 12px; margin: 8px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
  .message-match-card .entry-kind { margin: 0 0 6px; }
  .message-match-card .ai-english { margin: 2px 0 6px; font-size: .9375rem; }
  .message-match-card .ai-explanation { margin: 0; font-size: .8125rem; }
  .message-match-meta { display: block; margin-top: 6px; color: var(--muted); font-size: .6875rem; }

  /* Installable app affordances */
  .pwa-install-banner.show { position: fixed; z-index: 38; left: 12px; right: 12px; bottom: calc(var(--mobile-shell-bottom) + 10px); display: flex !important; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 14px 32px rgba(23, 49, 61, .18); }
  .pwa-install-banner span { flex: 1; min-width: 0; }
  .pwa-install-banner strong { display: block; font-size: .875rem; }
  .pwa-install-banner small { display: block; margin-top: 2px; color: var(--muted); font-size: .6875rem; }
  .pwa-install-banner button { min-height: 34px; padding: 6px 12px; border: 0; border-radius: 999px; background: var(--green); color: #fff; font: inherit; font-size: .75rem; font-weight: 700; cursor: pointer; }
  .pwa-install-banner .pwa-install-dismiss { flex: 0 0 auto; width: 30px; min-height: 30px; padding: 0; background: transparent; color: var(--muted); font-size: 1.05rem; }
  .pwa-install-dialog { width: min(420px, calc(100vw - 32px)); }
  .pwa-install-dialog ol { margin: 6px 0 0; padding-left: 20px; color: var(--ink); font-size: .875rem; line-height: 1.9; }

  .toast { bottom: calc(var(--mobile-shell-bottom) + 14px); }
}

/* Topic-first mobile room, styled as a familiar private messenger. */
.mobile-topic-rail { display: none; }
@media (max-width: 599px) {
  .mobile-appbar { height: calc(52px + env(safe-area-inset-top)); padding-inline: 16px; background: var(--paper); border-bottom: 0; }
  .mobile-brand { gap: 8px; font-family: Inter, "Segoe UI", sans-serif; letter-spacing: -.025em; }
  .mobile-brand .brand-mark { width: 29px; height: 29px; border-radius: 10px; }
  .mobile-appbar-actions { display: flex; align-items: center; gap: 8px; }
  .mobile-appbar-action { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--ink); }
  .mobile-appbar-action svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-appbar-action .mobile-moon { display: none; }
  [data-theme="dark"] .mobile-appbar-action .mobile-sun { display: none; }
  [data-theme="dark"] .mobile-appbar-action .mobile-moon { display: block; }

  .mobile-tabbar { padding-inline: 12px; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(18px); }
  .mobile-tabbar button { opacity: .72; }
  .mobile-tabbar button.active { color: var(--green); }
  .mobile-tabbar button.active svg { background: var(--green-soft); }
  .mobile-account-row a { display: none; }

  .speaking-workspace[data-mobile-panel="practice"] > .conversation-panel { gap: 0; background: var(--paper); }
  .conversation-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px 8px;
    min-height: 0;
    padding: 0 14px 9px;
    background: var(--paper);
    border-bottom: 0;
  }
  .mobile-topic-rail {
    grid-column: 1 / -1;
    display: flex;
    gap: 7px;
    width: calc(100% + 28px);
    margin: 0 -14px;
    padding: 5px 14px 9px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    background: var(--paper);
  }
  .mobile-topic-rail::-webkit-scrollbar { display: none; }
  .mobile-topic-rail button {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font: inherit;
    font-size: .75rem;
    font-weight: 650;
    cursor: pointer;
  }
  .mobile-topic-rail button.active { border-color: var(--green); background: var(--green); color: #fff; box-shadow: 0 4px 10px color-mix(in srgb, var(--green) 20%, transparent); }
  .conversation-header > div:first-of-type { display: block; min-width: 0; }
  .conversation-header > div:first-of-type::before { content: "正在练习"; display: block; margin-bottom: 3px; color: var(--muted); font-size: .625rem; font-weight: 650; }
  .conversation-header strong { display: block; font: 700 1rem/1.25 Inter, "Segoe UI", sans-serif; color: var(--ink); }
  .conversation-header small { display: -webkit-box; max-width: 36ch; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: .6875rem; line-height: 1.35; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
  .conversation-header .conversation-actions { display: flex; align-self: center; gap: 5px; }
  .conversation-header .outline-button, .conversation-header .end-button { min-height: 32px; padding: 5px 9px; border-radius: 999px; font-size: .6875rem; }
  .conversation-header .outline-button { color: var(--green); border-color: color-mix(in srgb, var(--green) 22%, var(--line)); background: var(--surface); }
  .conversation-header .end-button { color: var(--muted); border: 1px solid var(--line); background: transparent; }

  .mobile-voice-toolbar { min-height: 42px; gap: 5px; padding: 3px 13px 8px; background: var(--paper); border-bottom: 0; }
  .mobile-voice-mode { flex: 1; font-size: .6875rem; }
  .mobile-corpus-open, .mobile-analysis-open { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 31px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-size: .6875rem; font-weight: 650; white-space: nowrap; cursor: pointer; }
  .mobile-analysis-open { color: var(--green); }
  .mobile-analysis-open b { padding: 1px 5px; border-radius: 999px; background: var(--orange, #e87622); color: #fff; font-size: .5625rem; }

  .conversation-history { flex: 0 0 auto; margin: 0 12px 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
  .conversation-history summary { min-height: 33px; }
  .history-viewing-banner { margin: 0 12px 5px; }
  .chat-stream { padding: 9px 13px 14px; background: var(--paper); overscroll-behavior: contain; }
  .date-divider { margin: 4px 0 15px; }
  .message { gap: 0; margin-bottom: 10px; }
  .message .avatar { display: none; }
  .message .message-body { max-width: 86%; }
  .message.user .message-body { max-width: 86%; align-items: flex-end; }
  .message .bubble { max-width: 100%; padding: 10px 12px 8px; border: 1px solid color-mix(in srgb, var(--line) 72%, transparent); border-radius: 16px 16px 16px 5px; background: var(--surface); box-shadow: 0 1px 1px rgba(0,0,0,.035); }
  .message.user .bubble { border-color: color-mix(in srgb, var(--green) 70%, transparent); border-radius: 16px 16px 5px 16px; background: var(--green); color: #fff; box-shadow: 0 2px 5px color-mix(in srgb, var(--green) 14%, transparent); }
  .message .bubble p { font: 400 .9375rem/1.48 Inter, "Segoe UI", sans-serif; color: inherit; }
  .message .bubble p[data-topic-context]::after { content: attr(data-topic-context); display: table; width: max-content; max-width: 100%; padding: 2px 6px; margin-top: 6px; border-radius: 999px; background: var(--green-soft); color: var(--green); font: 600 .625rem/1.3 Inter, sans-serif; }
  .message.user .bubble p[data-topic-context]::after { background: rgba(255,255,255,.18); color: #fff; }
  .message time { margin: 3px 4px 0; font-size: .5625rem; }
  .message.user time { color: var(--muted); }
  .live-captions { margin: 0 13px 7px; }
  .practice-status { flex: 0 0 auto; max-height: 56px; overflow-y: auto; padding: 5px 13px; background: var(--paper); font-size: .6875rem; line-height: 1.4; }

  .voice-dock { flex: 0 0 auto; gap: 7px; padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
  .voice-dock-actions { width: min(100%, 330px); justify-content: space-around; gap: 5px; margin-inline: auto; }
  .voice-dock .voice-tool { width: 78px; height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 1px solid transparent; border-radius: 15px; background: transparent; color: var(--muted); box-shadow: none; }
  .voice-dock .voice-tool svg { width: 21px; height: 21px; }
  .voice-dock .voice-tool span { font-size: .625rem; line-height: 1; }
  #realtimeToggle.active, #realtimeToggle.connecting { border-color: #a95322; background: #a95322; color: #fff; box-shadow: 0 4px 12px rgba(169,83,34,.2); }
  .voice-dock .text-composer { min-height: 48px; border-radius: 14px; }
  .voice-dock .text-composer input { min-height: 46px; border: 0; background: transparent; }

  .speaking-workspace[data-mobile-panel="practice"] > .analysis-panel { padding: 9px 16px calc(14px + env(safe-area-inset-bottom)); background: var(--surface); }
  .analysis-panel .panel-heading h2 { font-size: 1.125rem; }
  .analysis-panel .assessment-note { padding: 8px 0 0; background: var(--surface); }
  .mobile-sheet-backdrop { backdrop-filter: blur(2px); }
}

@media (max-width: 380px) {
  .conversation-header { padding-inline: 11px; }
  .conversation-header .conversation-actions { gap: 3px; }
  .conversation-header .outline-button, .conversation-header .end-button { padding-inline: 7px; font-size: .65625rem; }
  .mobile-corpus-open, .mobile-analysis-open { padding-inline: 6px; font-size: .625rem; }
  .message .message-body, .message.user .message-body { max-width: 91%; }
  .voice-dock-actions { gap: 1px; }
}

/* Mobile voice inbox and one-to-one room, styled as a focused messenger. */
.mobile-chat-home, .mobile-chat-back { display: none; }
@media (max-width: 599px) {
  body {
    --paper: #be7e4a;
    --surface: #fff9f1;
    --ink: #33251e;
    --muted: #725d50;
    --line: #dfc2a9;
    --green: #7b4528;
    --green-soft: #f3dfcc;
    --amber: #9c562c;
    --orange: #d76524;
    background: var(--paper);
  }
  .speaking-workspace[data-mobile-panel="inbox"] {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    background: var(--paper);
  }
  .speaking-workspace[data-mobile-panel="inbox"] > :not(.mobile-chat-home) { display: none !important; }
  .mobile-chat-home {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 16px 16px calc(var(--mobile-shell-bottom) + 16px);
    background: var(--paper);
    color: var(--ink);
    overscroll-behavior: contain;
  }
  .mobile-inbox-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 3px 2px 14px; }
  .mobile-inbox-kicker { display: block; color: var(--green); font-size: .65rem; font-weight: 800; letter-spacing: .12em; }
  .mobile-inbox-heading h1 { margin: 3px 0 0; color: var(--ink); font: 750 1.45rem/1.15 Inter, "Segoe UI", sans-serif; }
  .mobile-inbox-topics { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 15px; scrollbar-width: none; overscroll-behavior-inline: contain; }
  .mobile-inbox-topics::-webkit-scrollbar { display: none; }
  .mobile-inbox-topics button { flex: 0 0 auto; min-height: 37px; padding: 7px 13px; border: 1px solid color-mix(in srgb, var(--line) 75%, var(--green)); border-radius: 999px; background: var(--surface); color: var(--green); font: 650 .79rem/1 Inter, "Segoe UI", sans-serif; white-space: nowrap; cursor: pointer; }
  .mobile-inbox-topics button.active { border-color: var(--green); background: var(--green); color: #fff; }
  .mobile-chat-list-title { display: flex; align-items: baseline; justify-content: space-between; margin: 6px 1px 9px; }
  .mobile-chat-list-title h2 { margin: 0; color: var(--ink); font: 750 1rem/1.2 Inter, "Segoe UI", sans-serif; }
  .mobile-chat-list-title span { color: var(--muted); font-size: .73rem; }
  .mobile-current-chat, .mobile-chat-history-row { width: 100%; min-height: 72px; display: flex; align-items: center; gap: 12px; margin: 0 0 9px; padding: 11px 12px; border: 1px solid color-mix(in srgb, var(--line) 78%, #bd7944); border-radius: 17px; background: var(--surface); color: var(--ink); text-align: left; box-shadow: 0 4px 12px rgba(78,47,28,.08); }
  .mobile-current-chat { cursor: pointer; }
  .mobile-chat-symbol { width: 43px; height: 43px; flex: 0 0 43px; display: grid; place-items: center; border-radius: 15px; background: var(--green-soft); color: var(--green); }
  .mobile-chat-symbol svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-chat-copy { min-width: 0; flex: 1 1 auto; display: grid; gap: 4px; }
  .mobile-chat-copy strong, .mobile-chat-history-row .history-record-main strong { overflow: hidden; color: var(--ink); font: 700 .9rem/1.25 Inter, "Segoe UI", sans-serif; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-chat-copy small, .mobile-chat-history-row .history-record-main small { overflow: hidden; color: var(--muted); font-size: .74rem; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-chat-meta { align-self: stretch; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; color: var(--muted); }
  .mobile-chat-meta b { padding: 4px 7px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: .62rem; font-weight: 700; }
  .mobile-chat-meta span { font-size: 1.25rem; line-height: 1; }
  .mobile-chat-history-list { display: grid; gap: 0; }
  .mobile-chat-history-row { min-width: 0; margin-bottom: 9px; }
  .mobile-chat-history-row .history-record-main { min-width: 0; flex: 1 1 auto; display: grid; gap: 5px; padding: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
  .mobile-chat-history-row .history-delete { flex: 0 0 auto; min-height: 34px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); font: 600 .72rem Inter, sans-serif; }
  .mobile-chat-empty { margin: 3px 0 0; padding: 17px 14px; border: 1px dashed color-mix(in srgb, var(--line) 80%, var(--green)); border-radius: 15px; color: var(--muted); font-size: .78rem; line-height: 1.5; text-align: center; }
  .mobile-history-load-more { margin: 1px 0 12px; border-color: var(--line); border-radius: 12px; background: var(--surface); color: var(--green); }

  .speaking-workspace[data-mobile-panel="practice"] > .mobile-chat-home { display: none !important; }
  .conversation-header { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 9px 12px; background: var(--surface); }
  .mobile-chat-back { width: 34px; height: 34px; place-items: center; border: 0; border-radius: 11px; background: var(--green-soft); color: var(--green); cursor: pointer; }
  .mobile-chat-back svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .conversation-header .mobile-topic-rail { display: none; }
  .conversation-header > div:first-of-type { grid-column: 2; grid-row: 1; }
  .conversation-header .mobile-chat-back { grid-column: 1; grid-row: 1; }
  .conversation-header .conversation-actions { grid-column: 3; grid-row: 1; }
  .mobile-appbar { color: #fffaf4; background: linear-gradient(105deg, #965832, #be7e4a); border-bottom-color: rgba(91,52,31,.28); }
  .mobile-brand .brand-mark { color: #fff; border: 1px solid rgba(255,242,225,.55); background: rgba(92,49,26,.27); }
  .mobile-appbar-action { border: 1px solid rgba(255,245,233,.46); background: rgba(83,44,25,.25); color: #fff8ef; }
  .mobile-tabbar { border-top-color: color-mix(in srgb, var(--line) 85%, #9b623d); background: color-mix(in srgb, var(--surface) 95%, transparent); }
  .mobile-tabbar button.active { color: var(--green); }
  .mobile-tabbar button.active svg { background: var(--green-soft); }
  .conversation-panel, .speaking-workspace[data-mobile-panel="practice"] > .conversation-panel { background: var(--paper); }
  .chat-stream { background: linear-gradient(color-mix(in srgb, var(--surface) 35%, transparent),color-mix(in srgb, var(--surface) 35%, transparent)),var(--paper); }
  .message .bubble { border-color: color-mix(in srgb, var(--line) 78%, #ad724c); background: var(--surface); color: var(--ink); }
  .message.user .bubble { border-color: var(--green); background: var(--green); color: #fffaf4; }
  .voice-dock { border-top-color: var(--line); background: var(--surface); }
  #realtimeToggle.active, #realtimeToggle.connecting { border-color: #834625; background: #834625; color: #fff; }
}

@media (max-width: 599px) {
  html[data-theme="dark"] body {
    --paper: #251811;
    --surface: #38271e;
    --ink: #f4e8dd;
    --muted: #c1a48e;
    --line: #614935;
    --green: #d59661;
    --green-soft: #523a28;
    --amber: #e2a36f;
    --orange: #e77939;
  }
  html[data-theme="dark"] .mobile-appbar { background: linear-gradient(105deg, #39271d, #563722); }
}

/* Mobile conversation redesign: calm paper surfaces, topic search, and a compact messenger composer. */
@media (max-width: 599px) {
  body {
    --paper: #f4f2eb;
    --surface: #fffefa;
    --ink: #28332f;
    --muted: #717a74;
    --line: #e2e5dc;
    --green: #35685a;
    --green-soft: #e4efe9;
    --amber: #ac633d;
    --orange: #dc783d;
    background: var(--paper);
  }
  [data-palette="orange-sea"] body { --paper:#eff5f3; --surface:#fbfefd; --ink:#21353a; --muted:#6f8588; --line:#d7e5e2; --green:#176c78; --green-soft:#dcefee; --amber:#a76131; --orange:#eb762d; }
  [data-palette="business-blue"] body { --paper:#f0f3f7; --surface:#fff; --ink:#26374b; --muted:#718096; --line:#dce4ee; --green:#365f91; --green-soft:#e2ebf7; --amber:#a36537; --orange:#d77732; }
  html[data-theme="dark"] body { --paper:#191f1c; --surface:#232b27; --ink:#edf2ec; --muted:#a3b0a8; --line:#39453e; --green:#8dbba6; --green-soft:#2b4035; --amber:#dfa17b; --orange:#f09a63; }
  html[data-theme="dark"][data-palette="orange-sea"] body { --paper:#172122; --surface:#202d2e; --ink:#edf5f3; --muted:#a4b9b9; --line:#354746; --green:#72c2ca; --green-soft:#263f40; }
  html[data-theme="dark"][data-palette="business-blue"] body { --paper:#171d28; --surface:#212b3b; --ink:#eef2fa; --muted:#a3aec0; --line:#3a4658; --green:#91b7e8; --green-soft:#2a3a51; }

  .mobile-appbar { background:var(--surface); color:var(--ink); border-bottom:1px solid var(--line); }
  .mobile-brand .brand-mark { color:#fff; border:0; background:var(--orange); }
  .mobile-appbar-action { border-color:var(--line); background:var(--paper); color:var(--ink); }
  .mobile-tabbar { border-top-color:var(--line); }
  .mobile-chat-home { gap:0; background:var(--paper); }
  .mobile-inbox-heading { padding-bottom:13px; }
  .mobile-topic-search { display:flex; gap:8px; margin:0 0 19px; }
  .mobile-topic-search label { min-width:0; flex:1; height:47px; display:flex; align-items:center; gap:9px; padding:0 13px; border:1px solid var(--line); border-radius:15px; background:var(--surface); color:var(--muted); }
  .mobile-topic-search label span { font-size:1.35rem; }
  .mobile-topic-search input { width:100%; min-width:0; border:0; outline:0; background:transparent; color:var(--ink); font:400 .85rem Inter,"Segoe UI",sans-serif; }
  .mobile-topic-search button { min-width:58px; border:0; border-radius:14px; background:var(--green); color:#fff; font:650 .83rem Inter,"Segoe UI",sans-serif; cursor:pointer; }
  .mobile-recent-heading { display:flex; align-items:baseline; justify-content:space-between; margin:0 1px 9px; }
  .mobile-recent-heading h2 { margin:0; color:var(--ink); font:700 .9rem Inter,"Segoe UI",sans-serif; }
  .mobile-recent-heading span { color:var(--muted); font-size:.7rem; }
  .mobile-inbox-topics { margin-inline:-16px; padding:2px 16px 16px; }
  .mobile-inbox-topics button { min-height:34px; padding-inline:12px; border-color:var(--line); background:var(--surface); color:var(--ink); font-size:.75rem; }
  .mobile-inbox-topics button.active { border-color:var(--green); background:var(--green); color:#fff; }
  .mobile-chat-list-title { margin-top:4px; }
  .mobile-current-chat, .mobile-chat-history-row { border-color:var(--line); border-radius:17px; background:var(--surface); box-shadow:0 2px 9px rgba(38,51,45,.045); }
  .mobile-chat-symbol { border-radius:50%; background:var(--green-soft); color:var(--green); }
  .mobile-chat-meta b, .history-topic-tag { padding:4px 7px; border-radius:999px; background:var(--green-soft); color:var(--green); font-size:.62rem; font-weight:700; white-space:nowrap; }
  .mobile-chat-history-row .history-record-main { gap:4px; }
  .mobile-chat-history-row .history-record-main .history-topic-tag { justify-self:start; }
  .mobile-chat-empty { border-color:var(--line); }

  body.mobile-chat-open .mobile-appbar,
  body.mobile-chat-open .mobile-tabbar { display:none !important; }
  body.mobile-chat-open .app-shell { --mobile-shell-bottom:0px; padding-top:env(safe-area-inset-top); padding-bottom:0; }
  .conversation-header, .mobile-voice-toolbar { background:var(--surface); }
  .conversation-header { border-bottom:1px solid var(--line); }
  .conversation-header .mobile-chat-back { display:grid; }
  .mobile-chat-back { border-radius:50%; background:var(--green-soft); color:var(--green); }
  .mobile-voice-mode { color:var(--muted); }
  .chat-stream { background:var(--paper); }
  .message .bubble { border-color:var(--line); background:var(--surface); box-shadow:0 1px 2px rgba(28,43,36,.04); }
  .message.user .bubble { border-color:var(--green); background:var(--green); }
  .voice-dock { display:grid; grid-template-columns:minmax(0,1fr) 92px; align-items:center; gap:7px; padding:8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .voice-dock .text-composer { grid-column:1; min-width:0; min-height:45px; border:1px solid var(--line); border-radius:24px; background:var(--paper); }
  .voice-dock .text-composer input { min-width:0; min-height:43px; padding-inline:15px; border:0; background:transparent; font-size:.875rem; }
  .voice-dock-actions { grid-column:2; width:auto; display:flex; justify-content:flex-end; gap:5px; margin:0; }
  .voice-dock .voice-tool { width:40px; height:40px; border-radius:50%; background:var(--green-soft); color:var(--green); }
  .voice-dock .voice-tool svg { width:19px; height:19px; }
  .voice-dock .voice-tool span, .voice-dock #keyboardToggle { display:none; }
  #realtimeToggle.active, #realtimeToggle.connecting { border-color:var(--green); background:var(--green); color:#fff; box-shadow:none; }
}

@media (max-width: 380px) {
  .mobile-chat-home { padding-inline:12px; }
  .mobile-inbox-topics { margin-inline:-12px; padding-inline:12px; }
  .voice-dock { grid-template-columns:minmax(0,1fr) 82px; padding-inline:7px; }
  .voice-dock-actions { gap:2px; }
  .voice-dock .voice-tool { width:37px; height:37px; }
}

/* The mobile app has its own light messenger palette, independent of desktop appearance settings. */
@media (max-width: 599px) {
  html[data-theme] { color-scheme: light !important; background:#fff !important; }
  html[data-theme] body { color-scheme: light !important; }
  html[data-theme][data-palette] body {
    --paper: #ffffff !important;
    --surface: #ffffff !important;
    --ink: #1f2328 !important;
    --muted: #747b82 !important;
    --line: #eceef0 !important;
    --green: #168c56 !important;
    --green-soft: #e8f5ed !important;
    --amber: #b46632 !important;
    --orange: #e88738 !important;
    background: #fff !important;
    color: #1f2328 !important;
  }
  .workspace { gap:0 !important; padding:0 !important; background:#fff !important; }
  .speaking-workspace > .panel { border:0 !important; border-radius:0 !important; box-shadow:none !important; }
  .mobile-theme-action { display:none !important; }
  .mobile-palette-row { display:none !important; }
  .mobile-appearance-label { padding:4px 9px; border-radius:999px; background:#edf6f0; color:#168c56; font-size:.7rem; font-weight:650; }
  html[data-theme][data-palette] body .mobile-appbar,
  html[data-theme][data-palette] body .mobile-tabbar { color:#202124 !important; border-color:#eceef0 !important; background:#fff !important; }
  html[data-theme][data-palette] body .mobile-appbar-action { color:#168c56 !important; border:1px solid #eceef0 !important; background:#f7f8f7 !important; }
  html[data-theme][data-palette] body .mobile-chat-home,
  html[data-theme][data-palette] body .conversation-panel,
  html[data-theme][data-palette] body .conversation-header,
  html[data-theme][data-palette] body .mobile-voice-toolbar,
  html[data-theme][data-palette] body .voice-dock,
  html[data-theme][data-palette] body .analysis-panel { color:#202124 !important; background:#fff !important; }
  .mobile-appbar { box-shadow:none; }
  .mobile-chat-home { padding:12px 0 calc(var(--mobile-shell-bottom) + 12px); }
  .mobile-inbox-heading { min-height:56px; padding:0 18px 12px; border-bottom:1px solid #f0f0f0; }
  .mobile-inbox-heading h1 { font:700 1.35rem/1.2 Inter,"Segoe UI",sans-serif; }
  .mobile-inbox-kicker { display:none; }
  .mobile-inbox-caption { color:#8a9096; font-size:.75rem; }
  .mobile-topic-picker { margin:12px 16px 4px; }
  .mobile-topic-picker > summary { min-height:42px; display:flex; align-items:center; gap:8px; padding:0 13px; border:1px solid #e7e9eb; border-radius:12px; background:#fff; color:#3b4147; font-size:.82rem; font-weight:600; list-style:none; cursor:pointer; }
  .mobile-topic-picker > summary::-webkit-details-marker { display:none; }
  .mobile-topic-picker > summary > span { color:#168c56; font-size:1.1rem; }
  .mobile-topic-picker > summary > b { margin-left:auto; color:#8a9096; font-size:.9rem; transition:transform .18s ease; }
  .mobile-topic-picker[open] > summary > b { transform:rotate(180deg); }
  .mobile-topic-picker-panel { padding:12px 12px 5px; margin-top:7px; border:1px solid #eef0f2; border-radius:14px; background:#fafafa; }
  .mobile-topic-search { margin-bottom:11px; }
  .mobile-topic-search label { height:42px; border-color:#e7e9eb; border-radius:11px; background:#fff; }
  .mobile-topic-search button { border-radius:11px; background:#168c56; }
  .mobile-recent-heading { margin-bottom:7px; }
  .mobile-recent-heading h2 { color:#555d64; font-size:.78rem; }
  .mobile-recent-heading span { font-size:.66rem; }
  .mobile-inbox-topics { flex-wrap:wrap; gap:6px; margin:0; padding:0 0 5px; overflow:visible; }
  .mobile-inbox-topics button { min-height:31px; padding:6px 10px; border-color:#e6e9e7; border-radius:999px; color:#3b5c4c; font-size:.72rem; }
  .mobile-inbox-topics button.active { border-color:#168c56; background:#e8f5ed; color:#168c56; }
  .mobile-chat-list-title { margin:15px 17px 2px; }
  .mobile-chat-list-title h2 { font-size:.8rem; color:#858c91; font-weight:600; }
  .mobile-chat-list-title span { font-size:.68rem; }
  .mobile-current-chat, .mobile-chat-history-row { min-height:76px; margin:0; padding:12px 17px; border:0; border-bottom:1px solid #f0f1f2; border-radius:0; background:#fff; box-shadow:none; }
  .mobile-chat-symbol { width:47px; height:47px; flex-basis:47px; border-radius:50%; background:#edf5f0; color:#168c56; }
  .mobile-chat-copy { gap:4px; }
  .mobile-chat-copy strong { font-size:.92rem; }
  .mobile-chat-copy small { color:#8a9096; font-size:.73rem; }
  .mobile-chat-meta { align-items:flex-end; justify-content:center; gap:5px; }
  .mobile-chat-meta b, .history-topic-tag { background:#edf6f0; color:#168c56; }
  .mobile-chat-empty { margin:12px 16px; border-color:#e9ece9; color:#8a9096; }

  body.mobile-chat-open .mobile-appbar,
  body.mobile-chat-open .mobile-tabbar { display:none !important; }
  body.mobile-chat-open .app-shell { --mobile-shell-bottom:0px; padding-top:env(safe-area-inset-top); padding-bottom:0; }
  html[data-theme][data-palette] body .speaking-workspace[data-mobile-panel="practice"] > .conversation-panel { background:var(--paper) !important; }
  html[data-theme][data-palette] body .conversation-header { border-color:#eef0f0 !important; }
  .conversation-header strong { color:#202124; }
  .conversation-header small { color:#858c91; }
  .mobile-chat-back { background:#f0f2f1; color:#48534d; }
  html[data-theme][data-palette] body .mobile-voice-toolbar { border-color:#f0f1f1 !important; }
  .mobile-corpus-open, .mobile-analysis-open { border-color:#e8ebea; background:#fff; color:#454c50; }
  .mobile-analysis-open { color:#168c56; }
  html[data-theme][data-palette] body .conversation-history { color:#626970 !important; border-color:#e9ecee !important; background:#fff !important; }
  html[data-theme][data-palette] body .conversation-history summary { color:#626970 !important; }
  html[data-theme][data-palette] body .conversation-history summary::before { color:#168c56 !important; }
  .chat-stream { background:#fff !important; }
  html[data-theme][data-palette] body .message .bubble { border-color:#eef0ee !important; border-radius:17px 17px 17px 5px !important; background:#f5f6f5 !important; color:#202124 !important; box-shadow:none !important; }
  html[data-theme][data-palette] body .message.user .bubble { border-color:#d0f0ca !important; border-radius:17px 17px 5px 17px !important; background:#d9fdd3 !important; color:#183024 !important; }
  html[data-theme][data-palette] body .message time { color:#8a9096 !important; }
  html[data-theme][data-palette] body .message.user time { color:#64776b !important; }
  html[data-theme][data-palette] body .message .play-button { color:#168c56 !important; border-color:#e5eae6 !important; }
  .voice-dock { border-top:1px solid #eceeed; }
  .voice-dock .text-composer { border-color:#e7eae8; background:#f7f8f7; }
  .voice-dock .voice-tool { background:#f0f5f2; color:#168c56; }
  #realtimeToggle.active, #realtimeToggle.connecting { border-color:#168c56; background:#168c56; color:#fff; }
}

/* Mobile visual system: phone colors follow the OS and never read the desktop palette. */
@media (max-width: 599px) {
  html[data-theme][data-palette] {
    --paper: #ffffff;
    --surface: #ffffff;
    --ink: #202722;
    --muted: #68736d;
    --line: #e5ebe7;
    --green: #17784f;
    --green-soft: #eaf4ee;
    --amber: #92571f;
    --orange: #b86531;
    color-scheme: light !important;
    background: #ffffff !important;
  }
  html[data-theme][data-palette] body {
    --paper: #ffffff;
    --surface: #ffffff;
    --ink: #202722;
    --muted: #68736d;
    --line: #e5ebe7;
    --green: #17784f;
    --green-soft: #eaf4ee;
    --amber: #92571f;
    --orange: #b86531;
    color-scheme: light !important;
    min-width: 0;
    background: #ffffff !important;
    color: #202722 !important;
  }
  .app-shell { background: #fff; }
  .workspace, .workspace > .panel, .mobile-account, .mobile-account-card,
  .mobile-appbar, .mobile-tabbar, .conversation-panel, .conversation-header,
  .mobile-voice-toolbar, .voice-dock, .analysis-panel, .library-panel,
  .writing-workspace > .panel { background-color: #fff !important; color: var(--ink); }
  .workspace { background: #fff !important; }
  .mobile-tabbar, .mobile-appbar, #writingMobileNav { border-color: var(--line) !important; box-shadow: none; }
  .mobile-appbar-action { border-color: var(--line) !important; background: #f5f8f6 !important; color: var(--green) !important; }
  .mobile-tabbar button { color: var(--muted); }
  .mobile-tabbar button.active { color: var(--green); }
  .mobile-tabbar button.active svg { background: var(--green-soft); }
  .mobile-account, .mobile-chat-home, .mobile-current-chat-row,
  .speaking-workspace[data-mobile-panel="library"] > .library-panel { background: #fff !important; }
  .mobile-account-hero, .mobile-account-card { border: 1px solid var(--line); box-shadow: 0 3px 14px rgba(25, 45, 35, .045); }
  .mobile-appearance-label { background: var(--green-soft); color: var(--green); }
  .mobile-chat-home { color: var(--ink) !important; }
  .mobile-inbox-heading { border-color: var(--line); }
  .mobile-inbox-heading h1, .mobile-chat-list-title h2 { color: var(--ink); }
  .mobile-inbox-caption, .mobile-chat-list-title span,
  .mobile-chat-copy small, .mobile-chat-history-row small { color: var(--muted); }
  .mobile-topic-picker > summary, .mobile-topic-search label,
  .mobile-topic-search input, .mobile-inbox-topics button { border-color: var(--line); background: #fff; color: var(--ink); }
  .mobile-topic-picker-panel { border-color: var(--line); background: #f8faf8; }
  .mobile-topic-search button, .mobile-inbox-topics button.active { background: var(--green); color: #fff; }
  .mobile-current-chat-row, .mobile-chat-history-row { position: relative; overflow: hidden; min-height: 74px; margin: 0; padding: 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: #fff; }
  .mobile-current-chat-row[hidden] { display: none !important; }
  .mobile-current-chat, .mobile-chat-history-row .history-record-main {
    position: relative; z-index: 1; width: 100%; min-width: 0; min-height: 73px;
    margin: 0; padding: 11px 17px; border: 0; border-radius: 0; background: #fff;
    color: var(--ink); box-shadow: none; text-align: left; transition: transform .2s ease;
  }
  .mobile-current-chat { display: flex; align-items: center; gap: 12px; cursor: pointer; }
  .mobile-chat-symbol { border-radius: 50%; background: var(--green-soft); color: var(--green); }
  .mobile-chat-copy strong, .mobile-chat-history-row .history-record-main strong { color: var(--ink); }
  .mobile-chat-meta b, .mobile-pinned-tag { background: var(--green-soft); color: var(--green); }
  .mobile-chat-history-list { display: grid; gap: 0; }
  .mobile-chat-history-row .history-record-main { display: grid; align-content: center; gap: 4px; }
  .mobile-chat-title-line { display: flex; min-width: 0; align-items: center; gap: 7px; }
  .mobile-chat-title-line strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-pinned-tag { flex: 0 0 auto; padding: 2px 6px; border-radius: 999px; font-size: .62rem; font-weight: 700; }
  .mobile-chat-actions { position: absolute; z-index: 0; inset: 0 0 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 5px; width: 184px; padding: 0 8px; background: #f2f5f3; }
  .mobile-chat-action { width: 51px; min-height: 42px; padding: 4px; border: 0; border-radius: 11px; background: #e3eee7; color: #245b40; font: 700 .68rem/1.15 Inter, sans-serif; cursor: pointer; }
  .mobile-chat-action:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
  .mobile-chat-action.delete-action { background: #f9e9e6; color: #a53c34; }
  .mobile-chat-empty { border-color: var(--line); color: var(--muted); }
  .mobile-history-load-more { border-color: var(--line); background: #fff; color: var(--green); }
  .conversation-header { border-color: var(--line); }
  .conversation-header strong { color: var(--ink); }
  .conversation-header small, .mobile-voice-mode { color: var(--muted); }
  .mobile-chat-back { background: #eef3f0; color: #42564a; }
  .mobile-voice-toolbar { border-color: var(--line) !important; }
  .mobile-corpus-open, .mobile-analysis-open { border-color: var(--line); background: #fff; color: var(--green); }
  .conversation-history { display: none !important; }
  .history-viewing-banner { background: #f5f8f6; color: var(--muted); }
  .chat-stream { background: #fff !important; }
  .message .bubble { border-color: #e9eeeb !important; background: #f3f6f4 !important; color: #202722 !important; box-shadow: none !important; }
  .message.user .bubble { border-color: #cce8d5 !important; background: #dff2e4 !important; color: #183a28 !important; }
  .message time { color: #68736d !important; }
  .message.user time { color: #536d5d !important; }
  .voice-dock { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: 0; padding: 7px 12px calc(8px + env(safe-area-inset-bottom)); border-color: var(--line); }
  .voice-dock .text-composer[hidden] { display: none !important; }
  .voice-dock .text-composer { display: none; min-width: 0; min-height: 42px; border: 1px solid var(--line); border-radius: 22px; background: #f5f8f6; }
  body.mobile-composer-open .voice-dock { grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
  body.mobile-composer-open .voice-dock .text-composer:not([hidden]) { display: flex; grid-column: 1; grid-row: 1; }
  .voice-dock .text-composer input { min-width: 0; min-height: 40px; padding: 0 12px; border: 0; background: transparent; color: var(--ink); font-size: 16px !important; }
  .voice-dock-actions { grid-column: 1; grid-row: 1; width: auto; display: flex; justify-content: flex-end; gap: 6px; margin: 0; }
  body.mobile-composer-open .voice-dock-actions { grid-column: 2; grid-row: 1; gap: 3px; }
  .voice-dock .voice-tool { display: grid !important; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: #eef4f0; color: var(--green); box-shadow: none; }
  .voice-dock .voice-tool svg { width: 20px; height: 20px; }
  .voice-dock .voice-tool span { display: none !important; }
  .voice-dock #keyboardToggle { display: grid !important; }
  .voice-dock #keyboardToggle[aria-expanded="true"] { background: #dfeee4; color: #145d3c; }
  #realtimeToggle.active, #realtimeToggle.connecting { border-color: var(--green); background: var(--green); color: #fff; }
  .practice-status { background: #fff; color: var(--muted); }
  .speaking-workspace[data-mobile-panel="library"] > .library-panel { background: #fff !important; }
  .library-panel .panel-heading h1, .library-panel .panel-heading h2,
  .taxonomy-heading, .taxonomy-heading button, .sort-note, .speaking-library-tabs button { color: var(--ink); }
  .speaking-library-tabs { border-color: var(--line); }
  .speaking-library-tabs button.active { color: var(--green); border-color: var(--green); }
  .search-box, .search-box:focus-within { border-color: var(--line); background: #f5f8f6; }
  .search-box input { color: var(--ink); }
  .phrase-card, .round-answer-review, .message-match-card { border-color: var(--line); background: #fff; color: var(--ink); }
  .phrase-card.selected { background: #f3f7f4; }
  .phrase-card p, .detail-row p, .round-library-intro, .assessment-note { color: var(--muted); }
  .round-library, .mobile-analysis-view, .mobile-analysis-content { color: var(--ink); }
  .round-library-empty, .empty-feedback { color: var(--muted); }
  .writing-workspace > .panel { color: var(--ink); }
  #writingMobileNav { background: #fff; }
  #writingMobileNav button { border-color: var(--line); background: #fff; color: var(--muted); }
  #writingMobileNav button[aria-pressed="true"] { border-color: var(--green); background: var(--green); color: #fff; }
  .editor-panel, .prompt-panel, .feedback-panel, .writing-surface,
  .feedback-content, .prompt-card, .writing-library-view { background: #fff; color: var(--ink); }
  .writing-surface, .prompt-card, .feedback-content { border-color: var(--line); }
  .editor-panel textarea, .editor-panel input, .mobile-account input,
  input:not([type="checkbox"], .voice-clip-progress), textarea, select { border-color: var(--line); background-color: #fff; color: var(--ink); }
  .feedback-tabs button, .library-view-tabs button { color: var(--muted); }
  .feedback-tabs button.active, .library-view-tabs button.active { color: var(--green); border-color: var(--green); }
  .mobile-sheet-backdrop { background: rgba(18, 27, 22, .42); }
}

@media (max-width: 599px) {
  html[data-theme="dark"][data-palette] {
    --paper: #1c1c1e;
    --surface: #2c2c2e;
    --ink: #f5f5f7;
    --muted: #a5a5ad;
    --line: #45454a;
    --green: #85beff;
    --green-soft: #2f455d;
    --amber: #ff9f0a;
    --orange: #ff9f0a;
    color-scheme: dark !important;
    background: #1c1c1e !important;
  }
  html[data-theme="dark"][data-palette] body {
    --paper: #1c1c1e !important;
    --surface: #2c2c2e !important;
    --ink: #f5f5f7 !important;
    --muted: #a5a5ad !important;
    --line: #45454a !important;
    --green: #85beff !important;
    --green-soft: #2f455d !important;
    --amber: #ff9f0a !important;
    --orange: #ff9f0a !important;
    color-scheme: dark !important;
    background: #1c1c1e !important;
    color: #f5f5f7 !important;
  }
  html[data-theme="dark"] .app-shell, html[data-theme="dark"] .workspace, html[data-theme="dark"] .workspace > .panel, html[data-theme="dark"] .mobile-account,
  html[data-theme="dark"] .mobile-account-card, html[data-theme="dark"] .mobile-appbar, html[data-theme="dark"] .mobile-tabbar, html[data-theme="dark"] .conversation-panel,
  html[data-theme="dark"] .conversation-header, html[data-theme="dark"] .mobile-voice-toolbar, html[data-theme="dark"] .voice-dock, html[data-theme="dark"] .analysis-panel,
  html[data-theme="dark"] .library-panel, html[data-theme="dark"] .writing-workspace > .panel, html[data-theme="dark"] .mobile-chat-home,
  html[data-theme="dark"] .speaking-workspace[data-mobile-panel="library"] > .library-panel { background-color: #1c1c1e !important; color: var(--ink); }
  html[data-theme="dark"] .mobile-account-hero, html[data-theme="dark"] .mobile-account-card, html[data-theme="dark"] .mobile-current-chat,
  html[data-theme="dark"] .mobile-chat-history-row .history-record-main, html[data-theme="dark"] .mobile-topic-picker > summary,
  html[data-theme="dark"] .mobile-inbox-topics button, html[data-theme="dark"] .mobile-topic-search label,
  html[data-theme="dark"] .mobile-topic-search input, html[data-theme="dark"] .mobile-history-load-more,
  html[data-theme="dark"] .mobile-appbar-action, html[data-theme="dark"] .mobile-analysis-view, html[data-theme="dark"] .round-answer-review,
  html[data-theme="dark"] .phrase-card, html[data-theme="dark"] .message-match-card, html[data-theme="dark"] .prompt-card, html[data-theme="dark"] .writing-surface,
  html[data-theme="dark"] .feedback-content, html[data-theme="dark"] .mobile-analysis-content { border-color: var(--line) !important; background: #2c2c2e !important; color: var(--ink) !important; }
  html[data-theme="dark"] .mobile-topic-picker-panel, html[data-theme="dark"] .history-viewing-banner, html[data-theme="dark"] .mobile-chat-actions { border-color: var(--line); background: #303033; }
  html[data-theme="dark"] .mobile-chat-action { background: #354758; color: #d7eaff; }
  html[data-theme="dark"] .mobile-chat-action.delete-action { background: #503233; color: #ffb4ad; }
  html[data-theme="dark"] .mobile-current-chat-row, html[data-theme="dark"] .mobile-chat-history-row { border-color: var(--line); background: #1c1c1e; }
  html[data-theme="dark"] .mobile-current-chat, html[data-theme="dark"] .mobile-chat-history-row .history-record-main { background: #1c1c1e !important; }
  html[data-theme="dark"] .mobile-chat-symbol, html[data-theme="dark"] .mobile-current-chat .mobile-chat-meta b,
  html[data-theme="dark"] .mobile-pinned-tag { background: #2f455d; color: #b9dafd; }
  html[data-theme="dark"] .mobile-inbox-heading { border-color: var(--line); }
  html[data-theme="dark"] .mobile-inbox-heading h1, html[data-theme="dark"] .mobile-chat-list-title h2,
  html[data-theme="dark"] .mobile-chat-copy strong, html[data-theme="dark"] .mobile-chat-history-row .history-record-main strong,
  html[data-theme="dark"] .mobile-recent-heading h2, html[data-theme="dark"] .conversation-header strong,
  html[data-theme="dark"] .library-panel .panel-heading h1, html[data-theme="dark"] .library-panel .panel-heading h2,
  html[data-theme="dark"] .taxonomy-heading, html[data-theme="dark"] .taxonomy-heading button, html[data-theme="dark"] .speaking-library-tabs button,
  html[data-theme="dark"] .message .bubble, html[data-theme="dark"] .writing-workspace { color: var(--ink) !important; }
  html[data-theme="dark"] .mobile-inbox-caption, html[data-theme="dark"] .mobile-chat-list-title span, html[data-theme="dark"] .mobile-chat-copy small,
  html[data-theme="dark"] .mobile-chat-history-row small, html[data-theme="dark"] .conversation-header small, html[data-theme="dark"] .mobile-voice-mode,
  html[data-theme="dark"] .practice-status, html[data-theme="dark"] .assessment-note, html[data-theme="dark"] .round-library-intro,
  html[data-theme="dark"] .phrase-card p, html[data-theme="dark"] .detail-row p, html[data-theme="dark"] .sort-note { color: var(--muted) !important; }
  html[data-theme="dark"] .mobile-topic-search label, html[data-theme="dark"] .search-box, html[data-theme="dark"] .search-box:focus-within,
  html[data-theme="dark"] input:not([type="checkbox"], .voice-clip-progress), html[data-theme="dark"] textarea, html[data-theme="dark"] select { border-color: var(--line) !important; background: #303033 !important; color: var(--ink) !important; }
  html[data-theme="dark"] .mobile-topic-search button, html[data-theme="dark"] .mobile-inbox-topics button.active,
  html[data-theme="dark"] #writingMobileNav button[aria-pressed="true"] { background: #0a84ff !important; color: #fff !important; }
  html[data-theme="dark"] .mobile-chat-back { background: #3a3a3c; color: #d6d6dc; }
  html[data-theme="dark"] #writingMobileNav { background: #1c1c1e !important; }
  html[data-theme="dark"] #writingMobileNav button { border-color: var(--line); background: #2c2c2e; color: var(--muted); }
  html[data-theme="dark"] .mobile-corpus-open, html[data-theme="dark"] .mobile-analysis-open, html[data-theme="dark"] .mobile-topic-picker > summary { color: #b9dafd; }
  html[data-theme="dark"] .message .bubble { border-color: #45454a !important; background: #303033 !important; color: #f5f5f7 !important; }
  html[data-theme="dark"] .message.user .bubble { border-color: #0a84ff !important; background: #0a84ff !important; color: #ffffff !important; }
  html[data-theme="dark"] .message time, html[data-theme="dark"] .message.user time { color: #a5a5ad !important; }
  html[data-theme="dark"] .voice-dock { border-color: var(--line); }
  html[data-theme="dark"] .voice-dock .text-composer { border-color: #45454a; background: #303033; }
  html[data-theme="dark"] .voice-dock .voice-tool { background: #2f455d; color: #b9dafd; }
  html[data-theme="dark"] .voice-dock #keyboardToggle[aria-expanded="true"] { background: #354758; color: #d7eaff; }
  html[data-theme="dark"] .analysis-tabs button, html[data-theme="dark"] .speaking-library-tabs button,
  html[data-theme="dark"] .feedback-tabs button, html[data-theme="dark"] .library-view-tabs button { color: var(--muted); }
  html[data-theme="dark"] .mobile-sheet-backdrop { background: rgba(0, 0, 0, .58); }
  html[data-theme="dark"][data-palette] body .mobile-appbar,
  html[data-theme="dark"][data-palette] body .mobile-tabbar,
  html[data-theme="dark"][data-palette] body .mobile-chat-home,
  html[data-theme="dark"][data-palette] body .conversation-panel,
  html[data-theme="dark"][data-palette] body .conversation-header,
  html[data-theme="dark"][data-palette] body .mobile-voice-toolbar,
  html[data-theme="dark"][data-palette] body .voice-dock,
  html[data-theme="dark"][data-palette] body .analysis-panel {
    border-color: var(--line) !important; background: #1c1c1e !important; color: var(--ink) !important;
  }
  html[data-theme="dark"][data-palette] body .mobile-appbar-action,
  html[data-theme="dark"][data-palette] body .mobile-topic-picker > summary {
    border-color: var(--line) !important; background: #2c2c2e !important; color: var(--ink) !important;
  }
  html[data-theme="dark"][data-palette] body .mobile-tabbar button { color: var(--muted) !important; }
  html[data-theme="dark"][data-palette] body .mobile-tabbar button.active { color: var(--green) !important; }
}

/* The library and writing views share the phone palette, independent of the desktop theme. */
@media (max-width: 599px) {
  html[data-theme][data-palette] body {
    --mobile-card: #ffffff;
    --mobile-soft: #f5f8f6;
    --mobile-accent-fill: #17784f;
    --mobile-accent-text: #ffffff;
  }
  html[data-theme][data-palette] body .speaking-library-tabs,
  html[data-theme][data-palette] body .library-kind-tabs,
  html[data-theme][data-palette] body .analysis-tabs,
  html[data-theme][data-palette] body .feedback-tabs,
  html[data-theme][data-palette] body .library-view-tabs {
    border-color: var(--line) !important;
    background: var(--mobile-soft) !important;
  }
  html[data-theme][data-palette] body .speaking-library-tabs button,
  html[data-theme][data-palette] body .library-kind-tabs button,
  html[data-theme][data-palette] body .analysis-tabs button,
  html[data-theme][data-palette] body .feedback-tabs button,
  html[data-theme][data-palette] body .library-view-tabs button {
    color: var(--muted) !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  html[data-theme][data-palette] body .speaking-library-tabs button.active,
  html[data-theme][data-palette] body .library-kind-tabs button.active,
  html[data-theme][data-palette] body .analysis-tabs button.active,
  html[data-theme][data-palette] body .feedback-tabs button.active,
  html[data-theme][data-palette] body .library-view-tabs button.active {
    color: var(--accent-ink, var(--green)) !important;
    border-color: transparent !important;
    background: var(--accent-tint, var(--green-soft)) !important;
    box-shadow: none !important;
  }
  html[data-theme][data-palette] body .library-transfer-tools button,
  html[data-theme][data-palette] body .library-transfer-tools button:first-child,
  html[data-theme][data-palette] body .load-more,
  html[data-theme][data-palette] body .round-library-empty,
  html[data-theme][data-palette] body .prompt-filters button,
  html[data-theme][data-palette] body .writing-library-filters button {
    color: var(--ink) !important;
    border-color: var(--line) !important;
    background: var(--mobile-card) !important;
    box-shadow: none !important;
  }
  html[data-theme][data-palette] body .library-transfer-tools button:first-child,
  html[data-theme][data-palette] body .prompt-filters button.active,
  html[data-theme][data-palette] body .writing-library-filters button.active {
    color: var(--mobile-accent-text) !important;
    border-color: var(--mobile-accent-fill) !important;
    background: var(--mobile-accent-fill) !important;
  }
  html[data-theme][data-palette] body .phrase-card,
  html[data-theme][data-palette] body .writing-entry,
  html[data-theme][data-palette] body .prompt-card,
  html[data-theme][data-palette] body .round-library-card,
  html[data-theme][data-palette] body .answer-feedback,
  html[data-theme][data-palette] body .ai-suggestion,
  html[data-theme][data-palette] body .correction-card {
    color: var(--ink) !important;
    border-color: var(--line) !important;
    background: var(--mobile-card) !important;
    box-shadow: none !important;
  }
  html[data-theme][data-palette] body .phrase-card.selected,
  html[data-theme][data-palette] body .writing-entry.selected,
  html[data-theme][data-palette] body .prompt-card.selected {
    border-color: var(--accent-line, var(--green)) !important;
    background: var(--accent-tint, var(--green-soft)) !important;
  }
  html[data-theme][data-palette] body .library-panel .eyebrow,
  html[data-theme][data-palette] body .writing-workspace .eyebrow,
  html[data-theme][data-palette] body .prompt-card > div,
  html[data-theme][data-palette] body .round-library-section h2,
  html[data-theme][data-palette] body .real-analysis h3,
  html[data-theme][data-palette] body .feedback-content h3 {
    color: var(--green) !important;
  }
  html[data-theme][data-palette] body .round-library-state {
    background: var(--green-soft) !important;
  }
  html[data-theme][data-palette] body .phrase-card .entry-english,
  html[data-theme][data-palette] body .writing-entry .entry-english,
  html[data-theme][data-palette] body .prompt-card p,
  html[data-theme][data-palette] body .editor-header h2,
  html[data-theme][data-palette] body .question-brief p {
    color: var(--ink) !important;
  }
  html[data-theme][data-palette] body .phrase-card .entry-note,
  html[data-theme][data-palette] body .writing-entry .entry-note,
  html[data-theme][data-palette] body .library-hint,
  html[data-theme][data-palette] body .library-panel .sort-note,
  html[data-theme][data-palette] body .sort-note,
  html[data-theme][data-palette] body .library-filter,
  html[data-theme][data-palette] body .search-box span,
  html[data-theme][data-palette] body .switch-row,
  html[data-theme][data-palette] body .question-brief span,
  html[data-theme][data-palette] body .editor-footer,
  html[data-theme][data-palette] body .assessment-note {
    color: var(--muted) !important;
  }
  html[data-theme][data-palette] body .editor-header,
  html[data-theme][data-palette] body .question-brief,
  html[data-theme][data-palette] body .writing-surface,
  html[data-theme][data-palette] body .editor-footer,
  html[data-theme][data-palette] body .practice-status,
  html[data-theme][data-palette] body .empty-feedback {
    color: var(--ink) !important;
    border-color: var(--line) !important;
    background: var(--mobile-card) !important;
    box-shadow: none !important;
  }
  html[data-theme][data-palette] body .question-brief,
  html[data-theme][data-palette] body .practice-status,
  html[data-theme][data-palette] body .empty-feedback {
    background: var(--mobile-soft) !important;
  }
  html[data-theme][data-palette] body .editor-footer { color: var(--muted) !important; }
  html[data-theme][data-palette] body .editor-footer b { color: var(--green) !important; }
  html[data-theme][data-palette] body .switch-row i {
    border-color: var(--line) !important;
    background: var(--mobile-soft) !important;
  }
  html[data-theme][data-palette] body .switch-row input:checked + i {
    border-color: var(--mobile-accent-fill) !important;
    background: var(--mobile-accent-fill) !important;
  }
  html[data-theme][data-palette] body .primary-button {
    color: var(--mobile-accent-text) !important;
    border-color: var(--mobile-accent-fill) !important;
    background: var(--mobile-accent-fill) !important;
    box-shadow: none !important;
  }
  html[data-theme][data-palette] body .panel-heading .icon-button {
    color: var(--mobile-accent-text) !important;
    border-color: var(--mobile-accent-fill) !important;
    background: var(--mobile-accent-fill) !important;
    box-shadow: none !important;
  }
  html[data-theme][data-palette] body .speaking-library-tabs b,
  html[data-theme][data-palette] body .library-kind-tabs b {
    color: var(--green) !important;
    background: var(--green-soft) !important;
  }
}
@media (max-width: 599px) {
  html[data-theme="dark"][data-palette] body {
    --mobile-card: #2c2c2e;
    --mobile-soft: #303033;
    --mobile-accent-fill: #0a84ff;
    --mobile-accent-text: #ffffff;
  }
  html[data-theme="dark"][data-palette] body .chat-stream {
    background: #1c1c1e !important;
    color: var(--ink) !important;
  }
  html[data-theme="dark"][data-palette] body .message .bubble {
    color: var(--ink) !important;
    border-color: var(--line) !important;
    background: #303033 !important;
    box-shadow: none !important;
  }
  html[data-theme="dark"][data-palette] body .message.user .bubble {
    color: #ffffff !important;
    border-color: #0a84ff !important;
    background: #0a84ff !important;
  }
  html[data-theme="dark"][data-palette] body .message .bubble p { color: inherit !important; }
  html[data-theme="dark"][data-palette] body .message time,
  html[data-theme="dark"][data-palette] body .message.user time { color: var(--muted) !important; }
  html[data-theme="dark"][data-palette] body .message .play-button {
    color: var(--green) !important;
    border-color: var(--line) !important;
  }
  html[data-theme="dark"][data-palette] body .mobile-corpus-open,
  html[data-theme="dark"][data-palette] body .mobile-analysis-open {
    color: var(--green) !important;
    border-color: var(--line) !important;
    background: #2c2c2e !important;
  }
  html[data-theme="dark"][data-palette] body .voice-dock .voice-tool {
    color: #b9dafd !important;
    border-color: transparent !important;
    background: #2f455d !important;
  }
  html[data-theme="dark"][data-palette] body .voice-dock .voice-tool[aria-expanded="true"] {
    color: #d7eaff !important;
    background: #354758 !important;
  }
}

/* Phone conversation controls: one primary action, with keyboard and call at its edges. */
@media (max-width: 599px) {
  .speaking-workspace .library-transfer-tools,
  .writing-workspace .library-transfer-tools { display: none !important; }
  html[data-theme][data-palette] body .speaking-library-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 3px; padding: 4px;
  }
  html[data-theme][data-palette] body .speaking-library-tabs button {
    min-width: 0; min-height: 42px; padding: 7px 3px;
    font-size: clamp(.7rem, 2.8vw, .82rem);
    white-space: nowrap;
  }
  html[data-theme][data-palette] body .speaking-library-tabs b {
    min-width: 17px; height: 17px; margin-left: 1px; font-size: .62rem;
  }
  .mobile-corpus-import-actions {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px; padding: 4px 0 14px;
  }
  .mobile-corpus-import-actions button {
    min-height: 43px; border: 1px solid var(--line); border-radius: 11px;
    background: var(--mobile-card); color: var(--ink);
    font: 650 .82rem/1.2 Inter, "PingFang SC", sans-serif; cursor: pointer;
  }
  .mobile-corpus-import-actions button:first-child {
    grid-column: 1 / -1; border-color: var(--mobile-accent-fill);
    background: var(--mobile-accent-fill); color: #fff;
  }
  .mobile-corpus-import-actions button:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
  html[data-theme][data-palette] body .message.user .voice-message-label,
  html[data-theme][data-palette] body .message.user .bubble .text-action,
  html[data-theme][data-palette] body .message.user .bubble p[data-topic-context]::after {
    color: #24583d !important;
  }
  html[data-theme][data-palette] body .message.user .message-body > .retry-message,
  html[data-theme][data-palette] body .message.user .message-body > .cancel-message {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 42px; margin-top: 7px; padding: 8px 12px;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--mobile-card); color: var(--ink) !important;
    font: 700 .8125rem/1.3 Inter, "PingFang SC", sans-serif;
    text-decoration: none;
  }
  html[data-theme][data-palette] body .message.user .message-body > .retry-message {
    background: var(--green-soft);
  }
  html[data-theme][data-palette] body .voice-dock {
    position: relative; grid-template-columns: 42px minmax(0, 1fr) 42px !important;
    gap: 10px !important; padding: 8px 14px calc(9px + env(safe-area-inset-bottom)) !important;
  }
  html[data-theme][data-palette] body .voice-dock-actions { display: contents !important; }
  html[data-theme][data-palette] body .voice-dock #keyboardToggle,
  html[data-theme][data-palette] body .voice-dock #realtimeToggle {
    display: grid !important; place-items: center; width: 42px; height: 42px;
    padding: 0; border: 1px solid var(--line) !important; border-radius: 50%;
    background: var(--mobile-card) !important; color: var(--green) !important;
    box-shadow: none !important;
  }
  html[data-theme][data-palette] body .voice-dock #keyboardToggle { grid-column: 1; grid-row: 1; }
  html[data-theme][data-palette] body .voice-dock #realtimeToggle { grid-column: 3; grid-row: 1; }
  html[data-theme][data-palette] body .voice-dock #keyboardToggle .voice-icon { display: none; }
  html[data-theme][data-palette] body .voice-dock #keyboardToggle.is-text-mode .keyboard-icon { display: none; }
  html[data-theme][data-palette] body .voice-dock #keyboardToggle.is-text-mode .voice-icon { display: block; }
  html[data-theme][data-palette] body .voice-dock #holdToTalk {
    grid-column: 2; grid-row: 1; display: flex !important;
    width: 100%; height: 46px; min-height: 46px; padding: 0 12px;
    border: 1px solid var(--line) !important; border-radius: 12px;
    background: var(--mobile-card) !important; color: var(--ink) !important;
    box-shadow: none !important; opacity: 1;
    touch-action: none; user-select: none; -webkit-user-select: none;
  }
  html[data-theme][data-palette] body .voice-dock #holdToTalk svg { display: none; }
  html[data-theme][data-palette] body .voice-dock #holdToTalk .hold-label {
    display: block !important; font-size: .94rem; font-weight: 700; line-height: 1;
  }
  html[data-theme][data-palette] body.mobile-recording .voice-dock #holdToTalk {
    border-color: var(--mobile-accent-fill) !important;
    background: var(--green-soft) !important;
  }
  html[data-theme][data-palette] body.mobile-composer-open .voice-dock #holdToTalk { display: none !important; }
  html[data-theme][data-palette] body .voice-dock .text-composer {
    grid-column: 2; grid-row: 1; min-height: 46px; border-radius: 13px;
  }
  html[data-theme][data-palette] body.mobile-composer-open .voice-dock .text-composer:not([hidden]) {
    display: flex !important; grid-column: 2; grid-row: 1;
  }
  body.mobile-chat-open .conversation-panel > :is(.conversation-header, .voice-dock) { border-radius: 0; }
  .voice-dock .text-composer > button[type="submit"] { display: none; }
  .voice-dock #textComposer:focus-within { outline: 1px solid var(--green); outline-offset: -1px; }
  .voice-dock #textComposer > input {
    width: 100%; appearance: none; border: 0; border-radius: 0; outline: none; box-shadow: none;
  }
  html[data-theme][data-palette] body .voice-dock #holdToTalk .realtime-wave { display: none !important; }
  html[data-theme][data-palette] body.mobile-realtime-mode .voice-dock #holdToTalk {
    flex-direction: row; gap: 10px; background: var(--green-soft) !important;
  }
  html[data-theme][data-palette] body.mobile-realtime-mode .voice-dock #holdToTalk .realtime-wave {
    display: flex !important; align-items: center; gap: 3px; height: 22px;
  }
  .realtime-wave i { width: 3px; height: 8px; border-radius: 3px; background: var(--green); animation: voice-wave 1s ease-in-out infinite alternate; }
  .realtime-wave i:nth-child(2), .realtime-wave i:nth-child(4) { animation-delay: .2s; }
  .realtime-wave i:nth-child(3) { animation-delay: .42s; }
  @keyframes voice-wave { to { height: 20px; } }
  html[data-theme][data-palette] body.mobile-realtime-mode .voice-dock #realtimeToggle {
    border-color: var(--mobile-accent-fill) !important;
    background: var(--mobile-accent-fill) !important; color: #fff !important;
  }
  .mobile-recording-overlay {
    position: absolute; z-index: 20; left: 50%; bottom: calc(100% + 14px);
    display: flex; width: min(68vw, 240px); min-height: 170px;
    transform: translateX(-50%); flex-direction: column; align-items: center;
    justify-content: center; gap: 7px; padding: 18px;
    border-radius: 24px; background: rgba(30, 53, 41, .96);
    color: #fff; box-shadow: 0 16px 40px rgba(13, 30, 20, .22);
    text-align: center; pointer-events: none;
  }
  .mobile-recording-overlay[hidden] { display: none !important; }
  .mobile-recording-overlay.is-cancelling { background: rgba(126, 48, 43, .96); }
  .mobile-recording-pulse {
    display: grid; place-items: center; width: 54px; height: 54px;
    margin-bottom: 3px; border-radius: 50%; background: rgba(255,255,255,.16);
    animation: recording-pulse 1.2s ease-in-out infinite;
  }
  .mobile-recording-pulse svg { width: 27px; height: 27px; fill: none; stroke: #fff; stroke-width: 1.9; stroke-linecap: round; }
  .mobile-recording-overlay strong { font-size: .95rem; }
  .mobile-recording-overlay span { font-variant-numeric: tabular-nums; font-size: 1.05rem; font-weight: 700; }
  .mobile-recording-overlay small { color: rgba(255,255,255,.86); font-size: .72rem; }
  @keyframes recording-pulse { 50% { transform: scale(1.12); box-shadow: 0 0 0 12px rgba(255,255,255,.07); } }
}

/* Mobile navigation gives the expression library and round review distinct destinations. */
@media (max-width: 599px) {
  #writingMobileNav, #writingWorkspace { display: none !important; }
  .speaking-workspace[data-mobile-panel="library"] > .mobile-chat-home { display: none !important; }
  html[data-theme][data-palette] body .speaking-workspace[data-mobile-section="library"] .speaking-library-tabs {
    display: none !important;
  }
  html[data-theme][data-palette] body .speaking-workspace[data-mobile-section="review"] .speaking-library-tabs {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  html[data-theme][data-palette] body .speaking-workspace[data-mobile-section="review"] .speaking-library-tabs [data-speaking-library-view="normal"],
  html[data-theme][data-palette] body .speaking-workspace[data-mobile-section="review"] #addSpeakingEntry {
    display: none !important;
  }
  .speaking-workspace[data-mobile-section="review"] .speaking-library-tabs button {
    min-height: 44px;
  }
}
@media (max-width: 599px) and (prefers-reduced-motion: reduce) {
  .mobile-recording-pulse, .realtime-wave i { animation: none; }
}
@media (max-width: 599px) {
  html[data-theme="dark"][data-palette] body .message.user .voice-message-label,
  html[data-theme="dark"][data-palette] body .message.user .bubble .text-action,
  html[data-theme="dark"][data-palette] body .message.user .bubble p[data-topic-context]::after {
    color: #eaf5ff !important;
  }
}

@media (max-width: 599px) {
  .mobile-appearance-switch {
    display: grid; grid-template-columns: repeat(2, 42px); flex: 0 0 auto;
    gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 15px;
    background: #f3f6f4;
  }
  .mobile-account-row .mobile-appearance-switch button {
    width: 42px; min-height: 40px; display: grid; place-items: center;
    padding: 0; border: 1px solid transparent; border-radius: 11px;
    background: transparent; color: #69766e; box-shadow: none;
  }
  .mobile-appearance-switch svg {
    width: 20px; height: 20px; fill: none; stroke: currentColor;
    stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  }
  .mobile-account-row .mobile-appearance-switch button[aria-pressed="true"] {
    border-color: #dbe5de; background: #fff; color: #17784f;
    box-shadow: 0 1px 3px rgba(20, 43, 30, .08);
  }
  .mobile-appearance-switch button:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
  html[data-theme="dark"] .mobile-appearance-switch {
    border-color: #45454a; background: #202022;
  }
  html[data-theme="dark"] .mobile-account-row .mobile-appearance-switch button { color: #a5a5ad; }
  html[data-theme="dark"] .mobile-account-row .mobile-appearance-switch button[aria-pressed="true"] {
    border-color: #55555a; background: #3a3a3c; color: #85beff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
  }
}

@media (min-width: 600px) {
  .speaking-library-tabs [data-speaking-library-view="analysis"],
  #speakingAnalysisMobile { display: none !important; }
}

/* A cloud or cache startup failure must never leave an unresponsive app shell. */
.startup-recovery {
  position: fixed; z-index: 10000; inset: 0; display: grid; place-items: center;
  padding: 24px; background: #f5f8f6; color: #1c2b22;
  font: 15px/1.55 Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.startup-recovery[hidden], .startup-recovery-actions button[hidden] { display: none !important; }
.startup-recovery-card {
  width: min(100%, 420px); padding: 28px; border: 1px solid #dce6df; border-radius: 24px;
  background: #fff; box-shadow: 0 18px 56px rgba(24, 45, 31, .08);
}
.startup-recovery-symbol { display: block; margin-bottom: 13px; font-size: 28px; }
.startup-recovery h2 { margin: 0 0 10px; color: inherit; font: 700 22px/1.25 Inter, "PingFang SC", "Microsoft YaHei", sans-serif; }
.startup-recovery p { margin: 0; color: #4a5c50; }
.startup-recovery-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.startup-recovery-actions button {
  min-height: 44px; padding: 0 18px; border: 1px solid #23714d; border-radius: 12px;
  background: #23714d; color: #fff; font: 700 14px Inter, "PingFang SC", "Microsoft YaHei", sans-serif; cursor: pointer;
}
.startup-recovery-actions button + button { background: transparent; color: #23714d; }
.startup-recovery-actions button:focus-visible { outline: 3px solid #8dc8a1; outline-offset: 2px; }
html[data-theme="dark"] .startup-recovery { background: #1c1c1e; color: #f5f5f7; }
html[data-theme="dark"] .startup-recovery-card { border-color: #45454a; background: #2c2c2e; box-shadow: 0 18px 56px rgba(0,0,0,.24); }
html[data-theme="dark"] .startup-recovery p { color: #a5a5ad; }
html[data-theme="dark"] .startup-recovery-actions button { border-color: #0a84ff; background: #0a84ff; color: #fff; }
html[data-theme="dark"] .startup-recovery-actions button + button { color: #b9dafd; }
.pwa-update-banner {
  position: fixed; z-index: 10001; right: 16px; bottom: 16px; display: flex; align-items: center;
  gap: 12px; max-width: min(420px, calc(100vw - 32px)); padding: 10px 12px 10px 16px;
  border: 1px solid #cfe0d4; border-radius: 14px; background: #fff; color: #20392a;
  box-shadow: 0 12px 36px rgba(16, 42, 25, .16); font: 13px/1.4 Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.pwa-update-banner[hidden] { display: none !important; }
.pwa-update-banner button { flex: 0 0 auto; min-height: 36px; padding: 0 12px; border: 0; border-radius: 9px; background: #23714d; color: #fff; font: 700 13px Inter, sans-serif; cursor: pointer; }
@media (max-width: 599px) {
  .pwa-update-banner { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); max-width: none; }
  body.mobile-chat-open .pwa-update-banner { bottom: calc(12px + env(safe-area-inset-bottom)); }
}
html[data-theme="dark"] .pwa-update-banner { border-color: #45454a; background: #2c2c2e; color: #f5f5f7; }
html[data-theme="dark"] .pwa-update-banner button { background: #0a84ff; color: #fff; }
.ai-suggestion.is-in-library { border-inline-start: 3px solid var(--green); }
.ai-suggestion.is-in-library > .assessment-note { color: var(--ink); font-weight: 600; }
.suggestion-library-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.suggestion-library-actions button { min-height: 40px; text-align: start; overflow-wrap: anywhere; }
.library-entry-preview { width: min(540px, calc(100vw - 28px)); max-height: 80dvh; overflow: auto; padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink); }
.library-entry-preview .phrase-card { margin-block: 16px; background: var(--surface); color: var(--ink); }

.prompt-card > .writing-prompt-action { display: none; }
.writing-enter, .writing-focus-question button, #writingOpenReview {
  font: inherit;
  cursor: pointer;
}
.writing-enter, .writing-focus-heading button, #writingFigure figcaption button, #writingOpenReview {
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--green);
  background: var(--surface);
  font-size: .875rem;
  font-weight: 600;
}
.writing-enter:hover, .writing-focus-heading button:hover, #writingFigure figcaption button:hover, #writingOpenReview:hover {
  border-color: var(--green);
  background: var(--green-soft);
}
#writingWorkspace :is(.writing-enter, .writing-focus-question button, #writingOpenReview):focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
.writing-custom-title { margin: 10px 0 0; font-size: .9375rem; overflow-wrap: anywhere; }
.writing-bank-meta { margin: 10px 2px 0; color: var(--muted); font-size: .75rem; line-height: 1.45; }
.prompt-card[data-bank-id] { cursor: pointer; }
.prompt-card[data-bank-id] p {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden;
}
.question-brief #questionText { white-space: pre-line; }
.question-figure { margin: 12px 0 0; }
.question-figure button {
  display: block; width: 100%; max-height: 190px; padding: 6px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; overflow: hidden; cursor: zoom-in;
}
.question-figure img { display: block; width: 100%; max-height: 176px; object-fit: contain; }
.question-figure figcaption { margin-top: 5px; color: var(--muted); font-size: .75rem; text-align: right; }
.question-figure button:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
@media (max-height: 760px) and (min-width: 600px) {
  .question-brief { max-height: 31dvh; overflow: auto; scrollbar-gutter: stable; }
  .question-figure button { max-height: 150px; }
  .question-figure img { max-height: 136px; }
}

@media (min-width: 600px) {
  .prompt-card > .writing-prompt-action { display: flex; margin-top: 7px; }
  .writing-enter { display: inline-flex; align-items: center; gap: 7px; min-height: 32px; padding: 0 10px; }
  .writing-enter > span { font-size: 1.15em; line-height: 1; }
  #writingWorkspace.is-writing-focused { position: relative; grid-template-columns: minmax(0, 44fr) minmax(0, 56fr); padding-inline-end: 56px; }
  #writingWorkspace.is-writing-focused > :is(.prompt-panel, .feedback-panel) { display: none; }
  #writingWorkspace.is-writing-focused .question-brief { display: none; }
  #writingWorkspace.is-writing-focused .editor-panel { min-width: 0; grid-template-rows: auto minmax(180px, 1fr) auto auto; }
  #writingOpenReview {
    position: absolute; z-index: 1; inset-inline-end: 9px; top: 50%; transform: translateY(-50%);
    display: grid; justify-items: center; gap: 2px; min-width: 39px; padding: 7px 5px 9px;
  }
  #writingOpenReview > span:first-child { font-size: 1.3rem; line-height: .9; }
}
#writingFocusQuestion {
  min-width: 0; overflow: auto; padding: clamp(18px, 2.4vw, 42px); color: var(--ink); background: var(--surface);
}
.writing-focus-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.writing-focus-heading h2, #writingFigureDialogTitle, #writingPromptDialogTitle { color: inherit; }
.writing-focus-heading h2 { margin: 5px 0 0; font-size: clamp(1.25rem, 2vw, 1.8rem); line-height: 1.3; overflow-wrap: anywhere; }
.writing-focus-heading h3 { margin: 0; align-self: center; font-size: 1rem; }
.writing-focus-heading small { color: var(--green); font-weight: 700; }
.writing-focus-heading button, #writingFigure figcaption button { flex: none; min-height: 34px; padding: 0 10px; }
#writingFocusText { margin: 20px 0 26px; padding-block-end: 22px; border-bottom: 1px solid var(--line); font-size: 1.0625rem; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
#writingFigureStatus { margin: 8px 0 14px; color: var(--muted); font-size: .8125rem; }
#writingFigureTabs { display: flex; gap: 8px; overflow-x: auto; padding: 3px 3px 10px; }
#writingFigureTabs button {
  display: grid; gap: 4px; flex: 0 0 76px; padding: 5px; border: 1px solid var(--line); border-radius: 9px;
  color: var(--ink); background: var(--surface); font-size: .8125rem;
}
#writingFigureTabs button[aria-pressed="true"] { border-color: var(--green); background: var(--green-soft); }
#writingFigureTabs img { display: block; width: 100%; height: 44px; object-fit: contain; border-radius: 4px; background: white; }
#writingFigure { margin: 2px 0 0; }
#writingFigureZoom { display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: white; overflow: hidden; cursor: zoom-in; }
#writingFigureImage { display: block; width: 100%; max-height: 51dvh; object-fit: contain; margin: auto; }
#writingFigure figcaption { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 10px; }
#writingPromptDialog { width: min(490px, calc(100vw - 30px)); max-height: 90dvh; overflow: auto; }
#writingPromptForm > label { display: grid; gap: 6px; margin: 14px 20px; font-weight: 600; }
#writingPromptForm :is(select, input, textarea) { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 400; }
#newWritingText { min-height: 110px; resize: vertical; }
#writingPromptError { margin: 14px 20px; color: var(--ink); font-size: .875rem; font-weight: 600; }
#writingFigureDialog { width: min(1250px, calc(100vw - 35px)); max-height: 90dvh; overflow: auto; }
#writingFigureDialogBody { display: grid; padding: 16px; gap: 16px; }
#writingFigureDialogBody.compares { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#writingFigureDialogBody figure { margin: 0; min-width: 0; }
#writingFigureDialogBody figcaption { margin-bottom: 6px; color: var(--muted); font-size: .875rem; }
#writingFigureDialogBody img { display: block; width: 100%; max-height: 73dvh; object-fit: contain; background: white; border-radius: 8px; }
@media (min-width: 981px) {
  :root[data-theme="dark"] :is(.writing-enter, .writing-focus-heading button, .writing-focus-heading small, #writingFigure figcaption button, #writingOpenReview) {
    color: var(--ocean-deep);
  }
}

#openDesktopSettings { margin-inline-start: 5px; }
#openDesktopSettings > span { font: 1.25rem/1 "Segoe UI Symbol", sans-serif; }
#desktopSettingsDialog, .writing-organize-dialog { width: min(440px, calc(100vw - 30px)); max-height: 90dvh; overflow: auto; }
#desktopSettingsDialog { padding: 0; border-color: var(--line); background: var(--surface); color: var(--ink); }
#desktopSettingsDialog .dialog-heading { padding: 12px 20px; border-color: var(--line); background: var(--surface); }
#desktopSettingsTitle, .writing-organize-dialog h2 { color: var(--ink); }
.desktop-settings-section { padding: 16px 20px 20px; }
.desktop-settings-section h3 { margin: 0 0 12px; font-size: 1rem; }
.typography-settings { border-bottom: 1px solid var(--line); }
.typography-fields { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 12px; }
.typography-fields label { display: grid; min-width: 0; gap: 6px; color: var(--muted); font-size: .875rem; }
.typography-fields select {
  width: 100%; min-width: 0; min-height: 44px; padding: 7px 9px; border: 1px solid var(--line);
  border-radius: 8px; color: var(--ink); background: var(--surface); font: inherit;
}
.typography-preview {
  display: grid; gap: 3px; margin: 14px 0 4px; padding: 12px; border: 1px solid var(--line);
  border-radius: 8px; color: var(--ink); background: var(--paper); font-size: 1rem; line-height: 1.5;
  overflow-wrap: anywhere;
}
.typography-settings #resetTypography { min-height: 36px; margin-top: 0; }
@media (max-width: 599px) {
  .desktop-corpus-settings { display: none; }
  .typography-settings { border-bottom: 0; }
}

:root[data-app-font-size="small"] { --app-text-scale: .875; }
:root[data-app-font-size="large"] { --app-text-scale: 1.125; }
:root[data-app-font-size="xlarge"] { --app-text-scale: 1.25; }
:root[data-app-font-size] { font-size: calc(100% * var(--app-text-scale)); }
:root[data-app-font="sans"] {
  --app-font: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
}
:root[data-app-font="serif"] {
  --app-font: Georgia, "Songti SC", SimSun, "Noto Serif CJK SC", serif;
}
:root[data-app-font="mono"] {
  --app-font: ui-monospace, "SFMono-Regular", Consolas, "Noto Sans Mono CJK SC", "Microsoft YaHei", monospace;
}
:root[data-app-font] :where(.app-shell, .access-gate, dialog, .app-shell *, .access-gate *, dialog *) :where(:not(svg, svg *, .brand-mark, [aria-hidden="true"])) {
  font-family: var(--app-font) !important;
}
:root[data-app-font-size] :is(.prompt-card p, .question-brief p, .question-brief small) { font-size: .875rem; }
:root[data-app-font-size] :is(.editor-footer, .storage-bar) { flex-wrap: wrap; }
:root[data-app-font-size] .storage-bar { height: auto; min-height: 40px; }
@media (max-width: 599px) {
  :root[data-app-font-size] :is(input, textarea, select, .voice-dock .text-composer input) {
    font-size: max(16px, 1rem) !important;
  }
}
.desktop-settings-section .library-transfer-tools { margin: 0; }
#desktopCorpusStatus { margin: 12px 0 0; color: var(--ink); font-size: .875rem; }

.writing-exam-row, .writing-recent-row, .writing-subcategory-row { display: flex; align-items: center; gap: 6px; }
.writing-exam-row { margin-top: 13px; }
.writing-exam-tabs { display: flex; min-width: 0; gap: 6px; overflow-x: auto; padding: 3px; margin-inline-start: -3px; }
.writing-exam-tabs button, .writing-add-category, .writing-classification-fields button {
  min-height: 34px; flex: 0 0 auto; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: .875rem; white-space: nowrap; cursor: pointer;
}
.writing-exam-tabs button.active { border-color: var(--green); background: var(--green-soft); font-weight: 700; }
.writing-add-category { min-width: 32px; padding: 0 5px; }
.writing-subcategory-row > .writing-add-category { min-height: 30px; min-width: 28px; }
.writing-exam-tabs button:hover, .writing-add-category:hover, .writing-classification-fields button:hover, .writing-manage:hover { border-color: var(--green); background: var(--green-soft); }
.writing-recent-row > span { color: var(--muted); font-size: .8125rem; white-space: nowrap; }
.writing-recent-row { justify-content: space-between; flex-wrap: wrap; margin: 12px 0 9px; }
.writing-subcategory-row { max-width: 100%; min-width: 0; }
.writing-recent-row .prompt-filters { display: flex; min-width: 0; margin: 0; padding: 2px; gap: 2px; border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
.writing-recent-row .prompt-filters button { flex: 0 0 auto; min-height: 28px; padding: 0 7px; border: 0; border-radius: 5px; font-size: .75rem; white-space: nowrap; transition: none; }
#promptView .prompt-filters button.active { color: #fff; background: var(--green); font-weight: 700; }
html[data-theme="dark"] #promptView .prompt-filters button.active { color: var(--ink); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.prompt-card .writing-prompt-action { justify-content: space-between; align-items: center; gap: 8px; }
.writing-card-category { min-width: 0; overflow-wrap: anywhere; font-size: .75rem; font-weight: 600; }
.writing-prompt-buttons { display: flex; align-items: center; gap: 5px; margin-inline-start: auto; flex: none; }
.writing-manage {
  min-width: 32px; min-height: 32px; padding: 0 4px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); background: var(--surface); font: inherit; font-size: 1rem; font-weight: 700; line-height: 1; cursor: pointer;
}
#writingWorkspace :is(.writing-manage, .writing-exam-row button, .writing-recent-row button):focus-visible {
  outline: 2px solid var(--green); outline-offset: -2px;
}
.writing-classification-fields { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; margin: 14px 20px; }
.writing-classification-fields label { display: grid; gap: 6px; margin: 0; font-size: .875rem; font-weight: 600; }
.writing-classification-fields select { min-height: 38px; }
.writing-classification-fields button { min-height: 38px; }
.essay-text-size {
  display: inline-flex; align-items: center; flex: none; gap: 2px; padding: 2px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
}
.essay-text-size button {
  min-width: 36px; min-height: 32px; padding: 0 6px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink); font: inherit; font-size: .875rem; font-weight: 700;
  cursor: pointer;
}
.essay-text-size button:hover:not([aria-disabled="true"]) { background: var(--green-soft); }
.essay-text-size button:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
.essay-text-size button[aria-disabled="true"] { opacity: .45; cursor: default; }
.essay-text-size output { min-width: 3.3em; text-align: center; color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.writing-surface #essayEditor { font-size: calc(1rem * var(--essay-text-scale, 1)); }
@media (max-width: 599px) {
  .writing-surface #essayEditor { font-size: max(16px, calc(1rem * var(--essay-text-scale, 1))) !important; }
}
.writing-organize-dialog form > label { display: grid; gap: 6px; margin: 14px 20px; font-size: .875rem; font-weight: 600; }
.writing-organize-dialog :is(input, select) {
  width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 400;
}
.writing-organize-dialog p { margin: 14px 20px; color: var(--ink); overflow-wrap: anywhere; }
.writing-organize-dialog #deleteWritingPrompt { color: var(--red); }
@media (max-width: 599px) { #openDesktopSettings { display: none; } }

.tablet-panel-switch { display: none; }
@media (min-width: 600px) and (max-width: 1100px), (min-width: 600px) and (hover: none) and (pointer: coarse) {
  body.access-granted { min-width: 0; zoom: 1; }
  .access-granted .app-shell {
    display: flex; flex-direction: column; height: 100dvh; min-height: 0;
    padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
    padding-block: env(safe-area-inset-top) env(safe-area-inset-bottom);
  }
  .app-shell .topbar {
    flex: 0 0 auto; height: 64px; min-height: 0; padding-inline: 14px;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }
  .topbar .appearance-controls { grid-column: 3; }
  .topbar .palette-switcher { display: none; }
  .topbar .mode-switch { gap: 4px; }
  .topbar .mode-tab { min-width: 0; padding-inline: 13px; white-space: nowrap; }
  .app-shell .storage-bar { height: 40px; gap: 8px; }
  .app-shell #cloudStatus { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .app-shell .workspace, .app-shell #listeningWorkspace {
    flex: 1 1 0; min-height: 0; height: auto;
  }
  .app-shell .workspace {
    grid-template-columns: minmax(220px, 30%) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }
  .tablet-panel-switch {
    display: flex; grid-column: 1 / -1; align-items: center; gap: 5px;
  }
  .tablet-panel-switch button {
    min-height: 44px; padding: 0 15px; border: 1px solid var(--line);
    border-radius: 9px; background: var(--surface); color: var(--ink);
    font-size: .875rem; cursor: pointer; white-space: nowrap;
  }
  .tablet-panel-switch button[aria-pressed="true"] {
    border-color: var(--green); background: var(--green-soft); color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--green); font-weight: 650;
  }
  .app-shell .workspace > .panel { grid-row: 2; min-height: 0; max-height: none; }
  .app-shell .workspace > :is(.library-panel, .prompt-panel, .analysis-panel, .feedback-panel) {
    grid-column: 1; overflow-y: auto; overflow-wrap: anywhere;
  }
  .app-shell .workspace > :is(.conversation-panel, .editor-panel) { grid-column: 2; overflow-y: auto; }
  .workspace:not([data-tablet-panel="details"]) > :is(.analysis-panel, .feedback-panel),
  .workspace[data-tablet-panel="details"] > :is(.library-panel, .prompt-panel),
  .workspace[data-tablet-panel="main"] > :is(.library-panel, .prompt-panel) { display: none; }
  .app-shell .workspace[data-tablet-panel="main"] > :is(.conversation-panel, .editor-panel) { grid-column: 1 / -1; }
  .app-shell .editor-panel { grid-template-rows: auto auto minmax(140px, 1fr) auto auto; }
  .app-shell .conversation-panel { grid-template-rows: auto auto auto minmax(90px, 1fr) auto auto auto; }
  .app-shell .writing-surface { margin-inline: 12px; }
  .app-shell .feedback-tabs button { min-width: 0; padding-inline: 4px; font-size: .8125rem; white-space: nowrap; }
  .app-shell #writingWorkspace.is-writing-focused { grid-template-rows: minmax(0, 1fr); }
  #writingWorkspace.is-writing-focused > .tablet-panel-switch { display: none; }
  .app-shell #writingWorkspace.is-writing-focused > :is(.writing-focus-question, .editor-panel) { grid-row: 1; }
  .app-shell #writingWorkspace.is-writing-focused > .editor-panel { grid-column: 2; }
  .app-shell #writingWorkspace.is-writing-focused > .writing-focus-question { grid-column: 1; }
}
@media (min-width: 600px) and (max-width: 739px) {
  .topbar .brand small { display: none; }
  .app-shell .topbar { grid-template-columns: minmax(0, 1fr) auto minmax(96px, 1fr); padding-inline: 10px; }
  .topbar .mode-tab { padding-inline: 9px; }
  .app-shell .workspace { grid-template-columns: minmax(0, 1fr); }
  .workspace:not([data-tablet-panel="library"]) > :is(.library-panel, .prompt-panel),
  .workspace:is([data-tablet-panel="library"], [data-tablet-panel="details"]):not(.is-writing-focused)
    > :is(.conversation-panel, .editor-panel) { display: none; }
  .app-shell .workspace > :is(.conversation-panel, .editor-panel) { grid-column: 1; }
  .app-shell #writingWorkspace.is-writing-focused {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 2fr) minmax(0, 3fr);
  }
  .app-shell #writingWorkspace.is-writing-focused > .editor-panel { grid-column: 1; grid-row: 2; }
}

#topicDialog {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  overflow-y: auto;
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}
#topicDialog form { padding: 18px 22px 20px; }
#topicDialog .dialog-heading { align-items: center; margin-bottom: 10px; background: var(--surface) !important; }
#topicDialog label { margin: 12px 0; color: var(--ink); }
#topicDialog :is(input, select, textarea) {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
}
#topicDialog textarea { min-height: 74px; resize: vertical; }
#topicDialog .dialog-actions { margin-top: 16px; }
#topicDialog .dialog-actions button[value="start"] { border-color: var(--green); background: var(--green); color: #fff; }
#topicDialog .dialog-actions button[value="cancel"] { border-color: var(--line); background: var(--surface); color: var(--muted); }
#topicDialog :is(input, select, textarea):focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
#topicTitle { overflow-wrap: anywhere; }
.mobile-add-topic {
  min-height: 42px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--green);
  font-family: inherit;
  font-size: .8125rem;
  font-weight: 650;
  cursor: pointer;
}
@media (max-width: 599px) {
  #topicDialog form { padding-inline: 16px; }
  #topicDialog :is(input, select, textarea) { font-size: 16px; }
}

#exportWritingReport { flex: none; min-height: 34px; padding: 5px 11px; white-space: nowrap; }
#exportWritingReport:disabled { opacity: .5; cursor: default; }

/* Shared controls for speech, recordings and sentence replay. */
.audio-action {
  --audio-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5.5a1 1 0 0 1 1.5-.86l10 6.5a1 1 0 0 1 0 1.72l-10 6.5A1 1 0 0 1 8 18.5z'/%3E%3C/svg%3E");
}
.audio-action[data-playback="playing"] {
  --audio-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='6' y='6' width='12' height='12' rx='2'/%3E%3C/svg%3E");
}
.audio-action[data-playback="paused-action"] {
  --audio-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 5h3.5v14H7zM13.5 5H17v14h-3.5z'/%3E%3C/svg%3E");
}
.audio-action[data-playback="replay"], .audio-action[data-playback="error"] {
  --audio-glyph: 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.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 10a8 8 0 1 1 2.1 7.5M4 5v5h5'/%3E%3C/svg%3E");
}
.audio-action[data-playback="loading"] {
  --audio-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4a8 8 0 1 1-8 8' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}
.audio-action[data-playback="speak"] {
  --audio-glyph: 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.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H3v6h3l5 4V5Zm4 4a4 4 0 0 1 0 6m3-9a8 8 0 0 1 0 12'/%3E%3C/svg%3E");
}
.audio-action::before {
  content: ""; flex: none; display: block; width: 16px; height: 16px;
  background: currentColor;
  -webkit-mask: var(--audio-glyph) center / contain no-repeat;
  mask: var(--audio-glyph) center / contain no-repeat;
}
.play-button.audio-action, .message .bubble .play-button.audio-action {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  width: fit-content; min-width: 66px; min-height: 32px; padding: 0 9px;
  border: 0 !important; border-radius: 8px; background: transparent;
  font: inherit; font-size: .75rem; font-weight: 600; line-height: 1.15;
}
.listening-answer-actions .audio-action { display: inline-flex; align-items: center; gap: 5px; }
.dictionary-heading .audio-action { display: grid; place-items: center; }
.message .bubble .play-button.audio-action { margin: 4px 0 0 -6px; }
.play-button.audio-action:is(:hover, [data-playback="playing"]), .voice-clip-play:hover {
  background: color-mix(in srgb, currentColor 9%, transparent);
}
.audio-action:focus-visible, .voice-clip-progress:focus-visible {
  outline: 2px solid currentColor; outline-offset: 2px;
}
.audio-action[data-playback="loading"] { cursor: progress; }
.audio-action[data-playback="loading"]::before { animation: audio-control-spin .85s linear infinite; }
.voice-clip {
  display: grid; grid-template-columns: 38px minmax(28px, 1fr) auto; align-items: center;
  width: 11.75rem; max-width: 100%; gap: 7px; padding-inline-end: 11px;
  border-radius: 11px; color: inherit; background: color-mix(in srgb, currentColor 9%, transparent);
}
.voice-clip-play {
  display: grid; place-items: center; min-width: 38px; min-height: 36px; padding: 0;
  border: 0; border-radius: 10px; color: inherit; background: transparent; cursor: pointer;
}
.voice-clip-time { white-space: nowrap; font: 600 .75rem/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.bubble.voice-bubble > p { margin-block-start: 8px; }
.message .bubble p[data-topic-context]::after { content: none !important; }
.message time:empty { display: none; }
.message.user .message-body > .inspect-analysis { color: var(--ink); }
.message .bubble.voice-just-sent {
  transform-origin: right bottom;
  animation: voice-message-arrive 260ms cubic-bezier(.19,.75,.29,1) var(--voice-send-offset, 0ms) both;
}
@keyframes voice-message-arrive {
  from { opacity: .35; transform: translate(10px, 16px) scale(.94); }
  to { opacity: 1; transform: none; }
}
@keyframes audio-control-spin { to { transform: rotate(360deg); } }
@media (max-width: 767px) {
  .play-button.audio-action, .message .bubble .play-button.audio-action,
  .voice-clip-play,
  .dictionary-heading .audio-action, .listening-answer-actions .audio-action { min-height: 44px; }
  .dictionary-heading .audio-action { min-width: 44px; }
  .voice-clip-play { min-width: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .message .bubble.voice-just-sent, .audio-action[data-playback="loading"]::before { animation: none; }
}
