:root {
  --paper: #f3f8fa;
  --surface: #ffffff;
  --ink: #17313d;
  --muted: #5e7280;
  --line: #d4e2e7;
  --green: #1f6f82;
  --green-soft: #e3f0f3;
  --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; }
.entry-source { color: #a1a7a4; font-size: 8px; line-height: 1.4; }
.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; }
mark { padding: 1px 3px; background: #f8ded7; color: #9e3f30; }
.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; gap: 16px; }
.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; }
.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; }
.source-note { margin-top: 14px; color: #8b928f; font-size: 8px; line-height: 1.5; }
.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; }
.entry-details .entry-source { font-size: .75rem; color: #738075; }
.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, .source-note { font-size: .8125rem; }
.source-note a { color: var(--green); }
.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: 768px) {
  .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: 768px) 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: 767px) {
  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: 768px) {
  .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: 768px) 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: 767px) {
  .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: 767px) {
  .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: 767px) {
  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, transform .16s 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-tool:hover:not(:disabled) { color: var(--ocean-deep); background: #eaf4f6; transform: translateY(-1px); }
.voice-tool.mode-selected { color: var(--ocean-deep); border-color: #9dc1ca; background: var(--sky); box-shadow: inset 0 -3px 0 var(--orange); }
.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: 767px) {
  .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; }
.history-viewing-banner button { padding: 5px 8px; border: 1px solid #ffad60; border-radius: 8px; color: #7e3b0b; background: #fff; cursor: pointer; white-space: nowrap; }
.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: 767px) {
  .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-tool:hover:not(:disabled) { color: #d8edf1; background: #1c3a44; }
[data-theme="dark"] .voice-tool.mode-selected { color: #d9eef2; border-color: #548895; background: #1a3b45; }
[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"] .history-viewing-banner button { color: #ffd0a5; border-color: #83512b; background: #241d18; }
[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: 767px) {
  .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; }
.voice-tool:hover:not(:disabled) { color: #60321e; background: #f2ddc9; }
.voice-tool.mode-selected { color: #5d311e; border-color: #c99065; background: #f2d8bf; }
.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"] .voice-tool:hover:not(:disabled), [data-theme="dark"] .voice-tool.mode-selected { color: #ffe9d6; border-color: #9d6948; background: #4c3327; }
[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: 767px) {
  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;
}
.history-viewing-banner button {
  color: #6e371e;
  border-color: #ce8a55;
  background: #fff9f1;
}
.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"] .history-viewing-banner button {
  color: #ffdabd;
  border-color: #93603a;
  background: #34231b;
}
[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; }
  .app-shell { min-height: 125dvh; }
  .workspace { height: calc(125dvh - 114px); }
}

@media (max-width: 767px) {
  .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-clay > span {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: transparent;
  box-shadow: inset 0 0 0 3px transparent, inset 0 0 0 4px currentColor;
}
.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: 767px) {
  .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; }

/* Keep the entrance centered even with the desktop density scaling. */
body.access-pending { min-width: 0; }
.access-pending .access-gate { min-height: 100dvh; box-sizing: border-box; padding: 28px 16px; }
.access-pending .site-compliance { position: fixed; inset: auto 0 0; background: transparent; }
@media (min-width: 981px) {
  .access-pending .access-gate { min-height: 125dvh; }
}
@media (max-width: 767px) {
  body.access-pending { overflow: auto; }
}
