:root {
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #292524;
  background: #fffbf7;
  font-synthesis: none;
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-active: #7c2d12;
  --accent-soft: #ffedd5;
  --surface: #fff;
  --text: #292524;
  --muted: #78716c;
  --line: #eadfd5;
  --focus-ring: #c2410c;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --success: #166534;
  --success-soft: #f0fdf4;
  --safe-left: env(safe-area-inset-left,0px);
  --safe-right: env(safe-area-inset-right,0px);
  --safe-bottom: env(safe-area-inset-bottom,0px);
  --text-body: 1rem;
  --text-label: .9375rem;
  --text-small: .875rem;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-decoration: none; text-underline-offset: .2em; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
a:active { color: var(--accent-active); }
button, input, textarea { font: inherit; }
button, a, input, textarea { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 1; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}
h1, h2, h3, p { margin: 0; }
img { max-width: 100%; }
.site { min-height: 100dvh; display: flex; flex-direction: column; font-size: var(--text-body); line-height: 1.65; }
.site h1 { font-size: 2rem; line-height: 1.3; font-weight: 700; letter-spacing: -.025em; overflow-wrap: anywhere; }
.site h2 { font-size: 1.375rem; line-height: 1.4; font-weight: 650; }
.site h3 { font-size: 1.125rem; line-height: 1.5; font-weight: 650; }
.site p { font-size: var(--text-body); line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.header { display: flex; align-items: center; gap: 24px; padding: 20px max(24px, calc((100vw - 1320px) / 2)); border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; font-weight: 750; white-space: nowrap; }
.brand img { width: 36px; height: 36px; object-fit: contain; }
.nav { display: flex; gap: 8px; flex: 1; align-items: center; flex-wrap: wrap; }
.nav a, .admin-nav a { color: #57534e; font-size: var(--text-label); border-radius: 8px; padding: 8px 10px; }
.nav a:hover, .admin-nav a:hover { color: var(--accent-hover); background: #fff7ed; text-decoration: none; }
.nav a[aria-current], .admin-nav a[aria-current], .chat-sidebar > a[aria-current], .actions > a[aria-current] {
  color: var(--accent-hover); background: var(--accent-soft); font-weight: 600; text-decoration: none;
}
.main { width: min(1180px, 100%); margin: 0 auto; padding: 40px 24px 64px; flex: 1; }
.main > div { display: flex; flex-direction: column; gap: 24px; }
.footer { border-top: 1px solid var(--line); padding: 24px; display: flex; justify-content: center; align-items: center; gap: 24px; flex-wrap: wrap; color: var(--muted); }
.site .footer, .site .footer p { font-size: var(--text-small); }
.hero { padding: 56px 0 44px; max-width: 880px; display: flex; flex-direction: column; gap: 24px; }
.site .hero h1 { font-size: clamp(2.25rem, 5vw, 4rem); max-width: 850px; line-height: 1.2; }
.site .hero p { font-size: 1.125rem; color: var(--muted); max-width: 640px; }
.site .eyebrow { font-size: var(--text-small); letter-spacing: .1em; color: var(--accent); font-weight: 650; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 24px; }
.panel { display: flex; flex-direction: column; align-items: stretch; gap: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; min-width: 0; box-shadow: 0 4px 20px #451a0306; }
.actions, .choices, .admin-nav { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.actions > a { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-size: var(--text-body); }
.actions > a:hover { border-color: var(--accent); background: #fff7ed; text-decoration: none; }
.hero .actions > a:first-child { background: var(--accent); border-color: var(--accent); color: white; }
.hero .actions > a:first-child:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.hero .actions > a:first-child:active { background: var(--accent-active); }
.field { display: flex; flex-direction: column; gap: 8px; width: 100%; min-width: 0; font-size: var(--text-label); }
.field > [data-gly-kind=text] { font-size: var(--text-label); line-height: 1.5; font-weight: 500; }
.field input, .field textarea { width: 100%; min-height: 44px; border-radius: 9px !important; padding: 10px 12px !important; }
.field textarea { min-height: 140px; resize: vertical; }
.sapid-button { min-height: 44px !important; border-radius: 9px !important; white-space: normal; overflow-wrap: anywhere; }
.sapid-text-field:disabled { cursor: not-allowed; }
.sapid-button-primary:active:enabled { background: var(--accent-active) !important; border-color: var(--accent-active) !important; }
:is(.sapid-button-outline, .sapid-button-subtle, .sapid-button-secondary, .sapid-button-light):active:enabled {
  background: var(--accent-soft) !important; color: var(--accent-active) !important; border-color: var(--accent-active) !important;
}
.sapid-button-danger:active:enabled { filter: brightness(.85); }
.auth-card { max-width: 500px; width: 100%; margin: 24px auto; gap: 24px; }
.site .auth-card h1 { font-size: 1.625rem; line-height: 1.35; letter-spacing: -.02em; }
.auth-card > [data-gly-kind=view]:not(.field):not(.choices):not(.feedback) { display: flex; flex-direction: column; gap: 18px; }
.site .auth-card > p { font-size: var(--text-small); color: var(--muted); }
.feedback { display: flex; flex-direction: column; gap: 10px; }
.feedback:empty { display: none; }
.error, .success, .loading-status, .empty-state { border-radius: 9px; padding: 12px 14px; font-size: var(--text-small); line-height: 1.65; overflow-wrap: anywhere; white-space: pre-wrap; }
.error { color: var(--danger); background: var(--danger-soft); border: 1px solid #fecaca; }
.success { color: var(--success); background: var(--success-soft); border: 1px solid #bbf7d0; }
.loading-status { display: flex; align-items: center; gap: 10px; color: var(--accent-hover); background: #fff7ed; }
.loading-status::before { content: ""; width: 15px; height: 15px; flex-shrink: 0; border: 2px solid #fed7aa; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.empty-state { color: var(--muted); background: #fafaf9; border: 1px dashed var(--line); }
.site .empty-state p, .site .success p { font-size: var(--text-small); line-height: 1.65; }
.site .muted { color: var(--muted); font-size: var(--text-small); line-height: 1.65; }
.word-card { max-width: 900px; }
.site .word-card > h2:first-child { font-size: 2rem; }
.pronunciation, .history-row, .provider-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; min-width: 0; }
.word-image { max-width: 420px; border-radius: 12px; }
.translation-result, .answer { display: flex; flex-direction: column; gap: 16px; background: #fff4e5; border-radius: 12px; padding: 24px; min-width: 0; }
.details { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.detail { display: grid; grid-template-columns: minmax(105px, 24%) minmax(0, 1fr); gap: 16px; line-height: 1.65; padding: 5px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail > [data-gly-kind=text] { font-size: var(--text-body); }
.detail > .muted { font-size: var(--text-small); }
.chat-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; }
.chat-sidebar { align-self: start; }
.chat-sidebar > a { padding: 10px 12px; border-radius: 8px; overflow-wrap: anywhere; }
.chat-sidebar > a:hover { background: #fff7ed; text-decoration: none; }
.conversation { min-height: 550px; }
.message { padding: 20px; border-radius: 12px; display: flex; flex-direction: column; gap: 12px; border: 1px solid var(--line); margin: 12px 0; min-width: 0; }
.user-message { background: #fff1df; margin-left: 32px; }
.ai-message { margin-right: 32px; }
.practice-card { max-width: 850px; width: 100%; margin: 10px auto; }
.site .practice-card h2 { font-size: 1.625rem; line-height: 1.45; overflow-wrap: anywhere; }
.recorder { display: flex; flex-direction: column; gap: 12px; }
.admin-nav { gap: 8px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.admin-section { display: flex; flex-direction: column; gap: 24px; margin: 16px 0; }
.editor { max-width: 760px; }
.record .details { max-height: 380px; overflow: auto; }
.legal { max-width: 900px; margin: auto; gap: 24px; }
.legal p { color: #57534e; }
.search { display: grid; grid-template-columns: 1fr auto; align-items: end; }
.profile-avatar { width: 80px; height: 80px; object-fit: cover; border-radius: 50%; }
.site .plan-price { font-size: 1.75rem; line-height: 1.4; font-weight: 700; color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 950px) {
  .header { padding: 16px; gap: 12px; }
  .header > .nav { order: 3; flex-basis: 100%; gap: 4px; }
  .nav a { padding: 6px 8px; }
  .main { padding: 24px 16px 48px; }
  .site h1 { font-size: 1.625rem; }
  .site h2 { font-size: 1.25rem; }
  .site .auth-card h1 { font-size: 1.5rem; }
  .hero { padding: 32px 0; }
  .site .hero p { font-size: var(--text-body); }
  .panel { padding: 20px; border-radius: 14px; }
  .chat-layout, .cards { grid-template-columns: 1fr; }
  .chat-sidebar { max-height: 370px; overflow: auto; }
  .detail { grid-template-columns: 100px minmax(0, 1fr); gap: 12px; }
  .conversation { min-height: 400px; }
  .footer { gap: 16px; }
  .search { grid-template-columns: 1fr; }
  .user-message { margin-left: 12px; }
  .ai-message { margin-right: 12px; }
  .translation-result, .answer { padding: 18px; }
}
@media (max-width: 480px) { .detail { grid-template-columns: 1fr; gap: 3px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.social-login { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.social-login .feedback:empty { display: none; }

/* Preserve the pre-WASM page structure; colour and type remain shared tokens. */
body { background: linear-gradient(125deg,#fff7ed,#fffbeb); }
.header { position: sticky; top: 0; z-index: 30; padding: 8px 20px; }
.header-inner { width: min(1120px,100%); margin: auto; display: flex; align-items: center; gap: 18px; }
.brand { color: var(--accent); font-size: 1.125rem; }
.brand img { width: 36px; height: 36px; }
.desktop-navigation { flex: 1; display: flex; justify-content: center; }
.nav { flex: initial; gap: 2px; }
.nav a { padding: 8px 9px; white-space: nowrap; }
.mobile-navigation { display: none; }
.header-inner > [data-sapid] { flex-shrink: 0; }
.main { width: min(1152px,100%); padding: 24px 16px 56px; }
.panel { gap: 16px; padding: 24px; border-radius: 12px; border-color: #f1e8df; box-shadow: 0 6px 14px #2925240b; }
.site h2 { font-size: 1.125rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading a { font-size: 14px; }
.dashboard { display: grid !important; grid-template-columns: minmax(0,2fr) minmax(260px,1fr); gap: 16px !important; }
.dashboard-primary,.dashboard-secondary { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.site .welcome-card h1 { font-size: 1.375rem; }
.welcome-card { background: linear-gradient(120deg,#fff,#fffaf2); }
.welcome-card > p { color: var(--muted); }
.primary-actions > a:first-child { background: var(--accent); border-color: var(--accent); color: white; }
.word-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.word-chips a,.badge { border-radius: 8px; background: #f5f5f4; padding: 3px 8px; font-size: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.stat-card { display: flex; flex-direction: column; gap: 8px; padding: 16px 12px; background: #fafaf9; border-radius: 8px; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.study-bar-row { display: grid; grid-template-columns: 50px minmax(0,1fr) 75px; gap: 8px; align-items: center; font-size: 14px; }
.study-bar-track { height: 12px; background: #f5f5f4; border-radius: 4px; overflow: hidden; }
.study-bar { height: 100%; background: #fb923c; border-radius: 4px; }
.scene-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.scene-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 7px; border-radius: 9px; background: #fafaf9; padding: 20px 12px; color: var(--text); }
.scene-card:hover { background: var(--accent-soft); text-decoration: none; }
.scene-emoji { font-size: 2rem; }
.task-card,.insight-card { background: #fafaf9; border-radius: 9px; padding: 14px; }
.task-card p { color: var(--muted); font-size: 14px; }
.insight-card { background: #fff7ed; }
.help-card a { font-size: 15px; }
.profile-page { gap: 24px; }
.profile-hero { overflow: hidden; border-radius: 12px; background: white; box-shadow: 0 6px 14px #29252414; }
.profile-cover { height: 96px; background: linear-gradient(105deg,#f97316,#f59e0b,#fb923c); }
.profile-identity { display: flex; align-items: center; gap: 18px; padding: 0 24px 20px; }
.profile-identity .profile-avatar { width: 96px; height: 96px; margin-top: -48px; border: 4px solid white; border-radius: 16px; background: white; }
.site .profile-identity h1 { font-size: 2rem; }
.profile-name { font-weight: 650; }
.profile-columns { grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; }
.profile-columns > :last-child { grid-column: 1 / -1; }
.account-information p { padding: 12px; background: #fafaf9; border-radius: 8px; }
.account-menu { display: flex; flex-direction: column; gap: 12px; min-width: 200px; }
.account-menu a { padding: 6px 8px; border-radius: 6px; }
.account-menu a:hover { background: var(--accent-soft); text-decoration: none; }
.achievement-page { display: flex; flex-direction: column; gap: 24px; }
.achievement-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; }
.achievement-card { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 20px; opacity: .65; }
.achievement-card.earned { background: #fff7ed; opacity: 1; }
.linked-account { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; align-items: center; padding: 12px; background: #fafaf9; border-radius: 9px; }
.dialog-form { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sapid-layer { max-width: calc(100vw - 24px) !important; max-height: calc(var(--app-height,100dvh) - 24px) !important; overflow-y: auto !important; overscroll-behavior: contain; }
.sapid-dialog { width: min(560px,calc(100vw - 32px)) !important; border-radius: 12px !important; }
.sapid-popover { max-height: calc(var(--app-height,100dvh) - 90px) !important; border-radius: 12px !important; }
.sapid-layer-header { position: sticky; top: -20px; z-index: 2; padding: 6px 0; background: var(--surface); flex-shrink: 0; }
.sapid-layer-title { font-size: 18px !important; }
[role=tablist] { margin-bottom: 24px; border-radius: 8px; background: #fff1e6; }
[role=tab] { font-size: 16px !important; min-height: 44px; border-radius: 7px; }
[role=tab][aria-selected=true] { color: var(--accent-hover) !important; background: var(--accent-soft) !important; border-color: var(--accent) !important; }
.provider-row { padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.provider-row > p { flex-basis: 100%; font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.chat-page { gap: 12px !important; }
.chat-layout { gap: 0; border-radius: 12px; overflow: hidden; background: white; box-shadow: 0 6px 18px #29252412; border: 1px solid var(--line); height: calc(100dvh - 130px); min-height: 500px; }
.chat-sidebar { height: 100%; min-height: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: #fafaf9; }
.chat-new-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px; border-bottom: 1px solid var(--line); }
.chat-links { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.chat-list-row { padding: 12px; border-radius: 8px; display: flex; flex-direction: column; gap: 4px; }
.chat-list-row:has([aria-current]) { background: var(--accent-soft); }
.chat-list-row:hover { background: #fff7ed; }
.chat-list-row a { color: var(--text); font-weight: 550; }
.chat-list-row .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.conversation > .feedback { flex-shrink: 0; max-height: 130px; overflow-y: auto; padding: 0 16px; }
.chat-content { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-toolbar { display: flex; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-title { flex: 1; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chat-toolbar .sapid-button { padding: 6px 10px !important; }
.chat-display-options { display: flex; justify-content: flex-end; gap: 6px; padding: 6px 16px; background: #fafaf9; }
.chat-display-options .sapid-button { min-height: 36px !important; padding: 4px 8px !important; }
.chat-display-options [aria-pressed=false] { opacity: .55; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 20px; overflow-anchor: none; }
.message { padding: 14px 16px; gap: 8px; width: fit-content; max-width: 90%; margin: 12px 0; border-radius: 12px; }
.user-message { margin-left: auto; background: #fff1df; }
.ai-message { background: #f5f5f4; border-color: #efeeeb; }
.message .eyebrow { font-size: 13px; letter-spacing: 0; }
.message-zh { color: #57534e; }
.message-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.message-actions .sapid-button { min-height: 36px !important; padding: 4px 8px !important; background: transparent !important; }
.message-actions .sapid-button-danger { color: var(--danger) !important; border-color: transparent !important; }
.hide-ai-en .ai-message .message-en,.hide-ai-zh .ai-message .message-zh,.hide-user-en .user-message .message-en,.hide-user-zh .user-message .message-zh { display: none; }
.chat-composer { border-top: 1px solid var(--line); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.compose-text { display: flex; align-items: end; gap: 10px; }
.compose-text .field > [data-gly-kind=text] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.compose-text textarea { min-height: 64px; max-height: 140px; }
.compose-text > .sapid-button { flex-shrink: 0; }
.chat-composer .recorder { flex-direction: row; align-items: center; gap: 10px; }
.chat-composer > .muted { font-size: 13px; }
.chat-composer .recorder .muted { font-size: 13px; }
.chat-empty { display: flex; flex: 1; align-items: center; justify-content: center; flex-direction: column; padding: 24px; gap: 20px; }
.mobile-chat-navigation { display: none; }
.dictionary-tabs { display: flex; margin: 0 auto; width: min(448px,100%); padding: 4px; border-radius: 9px; background: #ffedd5; }
.dictionary-tabs a { flex: 1; text-align: center; padding: 9px; color: #57534e; border-radius: 6px; font-size: 16px; }
.dictionary-tabs a[aria-current] { background: white; color: var(--accent-hover); box-shadow: 0 1px 4px #2925240c; font-weight: 600; }
.dictionary-layout { display: grid; grid-template-columns: minmax(0,1fr) 200px; gap: 16px; align-items: start; }
.dictionary-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.dictionary-history { position: sticky; top: 86px; padding: 16px; }
.dictionary-history > .panel { padding: 0; border: none; box-shadow: none; }
.dictionary-history .history-row { justify-content: space-between; }
.dictionary-history .history-row .sapid-button { background: transparent !important; color: var(--danger) !important; border: none !important; padding: 4px 6px !important; }
.dictionary-empty { min-height: 280px; justify-content: center; align-items: center; color: var(--muted); text-align: center; }
.word-card { max-width: none; }
.dictionary-result { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.word-card { padding: 20px; gap: 8px; }
.word-heading-row,.word-title,.word-badges { display: flex; align-items: center; gap: 8px; min-width: 0; }
.word-heading-row { justify-content: space-between; flex-wrap: wrap; }
.site .word-title h2 { font-size: 30px; line-height: 1.2; overflow-wrap: anywhere; }
.word-badges { flex-wrap: wrap; }
.word-badge { display: inline-block; width: fit-content; padding: 2px 8px; border-radius: 5px; background: #ffedd5; color: #9a3412; font-size: 12px; }
.site .word-icon { min-width: 36px; width: 36px; min-height: 36px !important; height: 36px; padding: 0 !important; border: none !important; background: transparent !important; flex-shrink: 0; }
.word-icon { display: inline-flex !important; align-items: center; justify-content: center; }
.word-icon-symbol { line-height: 1; }
.word-favorite .word-icon-symbol { font-size: 26px; }
.site .word-favorite { color: #a8a29e !important; }
.site .word-favorite[aria-pressed=true] { color: #eab308 !important; }
.site .word-favorite:hover:enabled { color: #ca8a04 !important; }
.word-audio .word-icon-symbol { font-size: 16px; }
.word-ipa { font-family: Georgia,serif; font-style: italic; }
.dictionary-section { padding: 20px; gap: 12px; }
.site .dictionary-section > h2 { font-size: 14px; color: var(--muted); font-weight: 500; }
.dictionary-section-tabs [role=tablist] { margin-bottom: 0; background: transparent; border-bottom: 1px solid var(--line); gap: 12px; padding: 0; }
.dictionary-section-tabs [role=tab] { border-radius: 0 !important; background: transparent !important; border: none !important; border-bottom: 2px solid transparent !important; padding: 8px 4px !important; }
.dictionary-section-tabs [role=tab][aria-selected=true] { border-bottom-color: #f97316 !important; }
.dictionary-section-tabs [role=tabpanel] { padding: 12px 0 0; }
.word-section { display: flex; flex-direction: column; gap: 12px; }
.definition-entry { padding: 4px 0; display: flex; flex-direction: column; gap: 4px; }
.word-part-of-speech:empty { display: none; }
.word-part-of-speech { color: #c2410c; font-style: italic; }
.related-word { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dictionary-history > .sapid-button { width: fit-content; align-self: end; background: transparent !important; color: var(--danger) !important; border: none !important; padding: 4px 6px !important; }
.translation-workspace { display: grid; grid-template-columns: minmax(0,1fr) 280px; align-items: start; }
.translation-source,.translation-options { display: flex; flex-direction: column; gap: 16px; }
.translation-source textarea { min-height: 250px !important; }
.translation-options { background: #fafaf9; border-radius: 9px; padding: 16px; grid-column: 2; grid-row: 1 / span 5; }
.translation-options .choices { gap: 6px; }
.translation-options .sapid-button { padding: 6px 8px !important; }
.translate-submit { justify-self: start; }
.translation-result { grid-column: 1; }
.review-page { max-width: 900px; margin: auto; }
.review-page > h1,.review-page > p { text-align: center; }
.smart-review { color: var(--text); background: linear-gradient(110deg,#fff1df,#fffaf0); border: 1px solid #fed7aa; }
.review-mode { color: var(--text); transition: border-color .15s,box-shadow .15s; }
.smart-review:hover,.review-mode:hover { border-color: var(--accent); box-shadow: 0 5px 18px #c2410c12; text-decoration: none; }
.review-mode p { font-size: 14px; color: var(--muted); }
.review-modes { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.practice-card { text-align: center; max-width: 850px; padding: 32px; }
.practice-card > .actions { justify-content: center; }
.practice-card .recorder { align-items: center; }
.reading-progress { width: fit-content; align-self: center; }
.subject-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); }
.pronunciation-feedback .stat-grid { text-align: center; }
.pronunciation-feedback .panel { box-shadow: none; padding: 16px; }
.pronunciation-feedback:has(> .feedback:only-child:empty) { display: none; }
.table-scroll { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: white; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
.data-table th { padding: 13px 16px; background: #fafaf9; font-weight: 600; color: #57534e; white-space: nowrap; }
.data-table td { border-top: 1px solid #f1e8df; padding: 12px 16px; max-width: 300px; overflow-wrap: anywhere; vertical-align: middle; }
.data-table tbody tr:hover { background: #fffaf4; }
.data-table td .actions { gap: 6px; flex-wrap: nowrap; }
.data-table .sapid-button { padding: 5px 8px !important; min-width: 60px; }
.admin-section > .field { max-width: 380px; }
.admin-nav { flex-wrap: nowrap; overflow-x: auto; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.admin-nav a { white-space: nowrap; }
.editor { max-width: none; }
button { font-size: 16px !important; font-family: Inter,"Segoe UI","Microsoft YaHei",sans-serif !important; }
.sapid-layer-close { min-width: 44px !important; min-height: 44px !important; }
.sapid-dialog-trigger,.sapid-drawer-trigger,.sapid-popover-trigger { min-height: 44px !important; border-radius: 9px !important; }
.header .sapid-popover-trigger { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 22px !important; }
.profile-name { display: block; }
.profile-identity .muted { display: block; }
body:has(.profile-page) { background: #f8fafc; }
.welcome-card { display: grid; grid-template-columns: minmax(0,1.1fr) minmax(0,1fr); gap: 24px; align-items: start; }
.welcome-greeting,.welcome-search { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.welcome-greeting > p { color: #57534e; }
.welcome-card .primary-actions > a { padding: 8px 12px; }
.welcome-search .quick-search { padding: 0; gap: 8px; }
.dashboard-data-body { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.4fr); gap: 16px; }
.dashboard-data .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.dashboard-data .stat-card { align-items: center; justify-content: center; text-align: center; }
.dashboard-data .stat-value { order: -1; font-size: 1.375rem; }
.study-chart { min-width: 0; background: #fafaf9; border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.study-chart .choices { flex-wrap: nowrap; gap: 3px; }
.study-chart .choices .sapid-button { padding: 4px 7px !important; min-height: 36px !important; }
.study-columns { display: flex; align-items: stretch; gap: 6px; min-height: 120px; }
.study-column { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: stretch; text-align: center; gap: 4px; }
.study-column .muted { font-size: 12px; }
.study-column-track { display: flex; align-items: flex-end; height: 90px; border-bottom: 1px solid var(--line); }
.study-column-fill { width: 100%; background: #fb923c; border-radius: 3px 3px 0 0; }
.study-chart > .muted { font-size: 12px; }
.avatar-delete { color: var(--danger) !important; }
.avatar-actions .sapid-button { flex: initial; }
.status-badge { display: inline-block; padding: 3px 8px; border-radius: 6px; white-space: nowrap; font-size: 14px; }
.status-badge.active { color: var(--success); background: var(--success-soft); }
.status-badge.inactive { color: var(--muted); background: #f5f5f4; }
.record-cell { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.cell-label { display: none; }
.cell-main { display: flex; align-items: center; gap: 10px; }
.table-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.nav a,.account-menu a { display: flex; align-items: center; min-height: 44px; }
.word-chips a,.footer a { display: inline-flex; align-items: center; min-height: 44px; }
.footer { padding: 16px; gap: 8px 16px; }
.toolbar-action { display: flex; align-items: center; justify-content: center; gap: 8px; }
.chat-toolbar :is(.sapid-dialog-trigger,.sapid-popover-trigger,.sapid-drawer-trigger) { min-width: 44px; }
.profile-identity > div { flex: 1; min-width: 0; }
.profile-identity .profile-avatar { flex-shrink: 0; }
.translation-settings-fields { display: flex; flex-direction: column; gap: 16px; }
.translation-options { padding: 8px; }
.translation-options h3 { margin: 0; }
.word-section h2 { font-size: 18px; }
.welcome-search .quick-search,.dictionary-page > .search { grid-template-columns: minmax(0,1fr) auto; gap: 10px; }
.section-heading { flex-wrap: wrap; }
.stat-value { overflow-wrap: normal; white-space: nowrap; }
/* The conversation owns the visible viewport; only its history scrolls. */
body:has(.chat-page) { overflow: hidden; }
body:has(.chat-page) #app { position: fixed; inset-inline: 0; top: var(--app-top,0px); height: var(--app-height,100dvh); }
body:has(.chat-page) .site { height: 100%; min-height: 0; }
body:has(.chat-page) .header { flex-shrink: 0; }
body:has(.chat-page) .main { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 16px max(16px,var(--safe-right)) max(16px,var(--safe-bottom)) max(16px,var(--safe-left)); }
body:has(.chat-page) .main > div { flex: 1; min-height: 0; }
body:has(.chat-page) .footer { display: none; }
.chat-page { min-height: 0; width: 100%; gap: 8px !important; }
.chat-layout { flex: 1; height: auto; min-height: 0; width: 100%; }
.compose-text textarea { min-height: 48px !important; max-height: 96px !important; }
.chat-toolbar .mobile-chat-navigation { flex-shrink: 0; }
.chat-display-options .sapid-button,.message-actions .sapid-button { min-height: 44px !important; }
.chat-links { flex: 1; }
.sapid-drawer .chat-links { max-height: calc(var(--app-height,100dvh) - 180px); }
.short-viewport .chat-composer > .muted,.short-viewport .chat-composer .recorder .muted { display: none; }
.short-viewport .compose-text textarea { height: 48px !important; max-height: 72px !important; }
.short-viewport .sapid-dialog[data-gly-layer=center] { position: fixed !important; inset: auto !important; top: calc(var(--app-top,0px) + 12px) !important; left: 50% !important; margin: 0 !important; transform: translateX(-50%) !important; }
@media(max-width:1000px) { .header-inner { gap: 8px; } .desktop-navigation .nav a { padding: 6px; font-size: 14px; } .brand { font-size: 16px; } }
@media(max-width:950px) {
 .header { padding: 8px max(16px,var(--safe-right)) 8px max(16px,var(--safe-left)); } .header-inner { flex-wrap: nowrap; } .brand { flex: 1; }
 .header .sapid-popover-trigger { max-width: clamp(96px,33vw,140px); flex-shrink: 0; }
 .brand { min-width: 0; gap: 8px; } .brand img { flex-shrink: 0; }
 .mobile-navigation .sapid-drawer-trigger { width: 44px; padding: 6px !important; }
 .desktop-navigation { display: none; } .mobile-navigation { display: block; }
 .main { padding: 20px max(16px,var(--safe-right)) 40px max(16px,var(--safe-left)); } .dashboard { grid-template-columns: 1fr; }
 .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } .scene-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
 .profile-columns { grid-template-columns: 1fr; } .profile-identity { padding: 0 16px 16px; align-items: start; }
 .site .profile-identity h1 { font-size: 1.625rem; } .profile-identity .muted { overflow-wrap: anywhere; }
 .achievement-grid { grid-template-columns: 1fr; } .panel { padding: 20px; }
 .sapid-layer [role=navigation] { flex-direction: column; align-items: stretch; }
 .chat-layout { grid-template-columns: minmax(0,1fr); }
 .chat-layout > .chat-sidebar { display: none; }
 .mobile-chat-navigation { display: block; }
 .chat-toolbar { padding: 8px; flex-wrap: nowrap; }
 .chat-title { flex-basis: auto; }
 .toolbar-action-label { display: none; }
 .chat-messages { padding: 8px 12px; }
 .chat-composer { padding: 10px; } .chat-composer .recorder .muted { display: none; }
 .message { max-width: 95%; }
 .dictionary-layout,.translation-workspace { grid-template-columns: 1fr; }
 .dictionary-history { position: static; }
 .translation-options { grid-column: 1; grid-row: auto; }
 .translation-source textarea { min-height: 180px !important; }
 .review-modes { grid-template-columns: 1fr; }
 .subject-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
 .practice-card { padding: 24px 16px; }

}
@media(min-width:601px) and (max-width:950px) {
 .dashboard-secondary { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; }
 .cards:not(.profile-columns):not(.review-modes) { grid-template-columns: repeat(2,minmax(0,1fr)); }
 .review-modes { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media(max-width:600px) {
 .header { padding-left: max(12px,var(--safe-left)); padding-right: max(12px,var(--safe-right)); }
 .brand img { width: 32px; height: 32px; }
 .main { padding: 16px max(12px,var(--safe-right)) 32px max(12px,var(--safe-left)); }
 .panel { padding: 16px; gap: 16px; }
 .welcome-card,.dashboard-data-body { grid-template-columns: 1fr; }
 .welcome-card { gap: 20px; }
 .profile-cover { height: 80px; }
 .profile-identity { gap: 12px; padding-inline: 16px; }
 .profile-identity .profile-avatar { width: 72px; height: 72px; margin-top: -36px; border-radius: 14px; }
 .site .profile-identity h1 { font-size: 26px; }
 .profile-name { overflow-wrap: anywhere; }
 [role=tablist] { margin-bottom: 16px; }
 .sapid-dialog[data-gly-layer=center] { position: fixed !important; inset: auto !important; top: calc(var(--app-top,0px) + 12px) !important; left: 50% !important; margin: 0 !important; transform: translateX(-50%) !important; }
 .sapid-layer { padding: 16px !important; }
 .sapid-layer-header { top: -16px; }
 .sapid-layer .scene-grid,.subject-grid { grid-template-columns: 1fr; }
 .chat-composer { padding-bottom: max(8px,env(safe-area-inset-bottom)); }
 body:has(.chat-page) .main { padding: 8px max(8px,var(--safe-right)) max(8px,var(--safe-bottom)) max(8px,var(--safe-left)); }
 .chat-display-options { padding: 2px 8px; gap: 4px; }
 .chat-toolbar { gap: 6px; }
 .chat-messages { padding: 6px 10px; }
 .message { padding: 12px; }
 .chat-composer { gap: 6px; padding: 8px; }
 .chat-composer > .muted { display: none; }
 .translation-source textarea { min-height: 150px !important; }
 .translate-submit { justify-self: stretch; }
 .translation-options { grid-row: auto; }
 /* Keep table semantics and headers while presenting each row as a labelled card. */
 .table-scroll { border: none; overflow: visible; background: transparent; }
 .data-table { display: block; }
 .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
 .data-table tbody { display: grid; gap: 12px; }
 .data-table tr { display: grid; min-width: 0; background: white; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
 .data-table td { display: grid; grid-template-columns: 76px minmax(0,1fr); gap: 10px; border: none; padding: 8px 0; max-width: none; min-width: 0; }
 .cell-label { display: block; color: var(--muted); font-size: 14px; }
 .data-table td:has(.actions) { display: block; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; }
 .data-table td .actions { flex-wrap: wrap; gap: 8px; }
 .data-table td .actions > :is(button,a) { flex: 1 1 auto; justify-content: center; }
 .record-cell { -webkit-line-clamp: 3; }
 .admin-nav { gap: 2px; }
 .admin-nav a { min-height: 44px; }
}
@media(max-height:500px) {
 .compose-text textarea { height: 48px !important; max-height: 72px !important; }
 .chat-composer > .muted,.chat-composer .recorder .muted { display: none; }
 .chat-composer { padding: 6px 8px; gap: 4px; }
 .chat-display-options { padding-block: 2px; }
 body:has(.chat-page) .main { padding-top: 6px; padding-bottom: max(6px,var(--safe-bottom)); }
 .sapid-dialog[data-gly-layer=center] { position: fixed !important; inset: auto !important; top: calc(var(--app-top,0px) + 12px) !important; left: 50% !important; margin: 0 !important; transform: translateX(-50%) !important; }
}
@media(pointer:coarse) { .message-actions .sapid-button,.study-chart .choices .sapid-button { min-height: 44px !important; } }

/* Provider selectors and modality controls share the application type scale. */
.provider-form .sapid-combobox { width:100%; min-width:0; }
.provider-form input { font-size:16px; }
.provider-models { display:grid; gap:12px; min-width:0; }
.provider-capability { display:grid; gap:12px; padding:14px; border:1px solid var(--line); border-radius:10px; min-width:0; }
.provider-capability h2 { font-size:16px; margin:0; }
.provider-capability.unavailable { color:var(--muted); background:var(--surface-soft,#fffaf5); }
.provider-capability p { font-size:14px; margin:0; }
.provider-card { display:grid; gap:12px; margin-top:16px; }
.provider-card h2 { font-size:18px; margin:0; }
.provider-card p { margin:0; overflow-wrap:anywhere; }
.provider-usage-row { display:flex; gap:12px; justify-content:space-between; align-items:center; min-width:0; }
.provider-usage-row p { min-width:0; flex:1; }
.provider-usage-row button { flex-shrink:0; }
.provider-catalog-marker { display:none; }
@media(max-width:400px) { .provider-capability { padding:12px; } .provider-usage-row { align-items:flex-start; flex-direction:column; } }

.sentence-audio { display:inline-flex; flex-wrap:wrap; align-items:center; gap:8px; max-width:100%; }
.sentence-audio p { font-size:14px; margin:0; }
.audio-review-card h2 { font-size:20px; line-height:1.5; overflow-wrap:anywhere; }
.audio-review-card p { overflow-wrap:anywhere; }

.provider-select-field { position:relative; min-width:0; }
.provider-select-field::after { content:'⌄'; pointer-events:none; position:absolute; right:14px; top:50%; transform:translateY(-50%); color:var(--muted); font-size:18px; }
.provider-select-field input { padding-right:36px!important; }

.audio-admin { display:grid; gap:20px; min-width:0; }

.dictionary-page > .search { padding: 0; border: none; background: transparent; box-shadow: none; }
.dictionary-page > .search .field > [data-gly-kind=text] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.dictionary-section-tabs [role=tablist] { max-width: 100%; overflow-x: auto; }
.dictionary-section-tabs [role=tab] { white-space: nowrap; }

.definition-group { border-left: 2px solid #f97316; padding-left: 12px; }
.definition-group .word-part-of-speech { display: inline-block; width: fit-content; font-size: 12px; background: #ffedd5; border-radius: 4px; padding: 1px 6px; }
.definition-group .word-part-of-speech:empty { display: none; }
.definition-group .definition-entry { padding: 2px 0; }
.site .definition-expand { align-self: start; background: transparent !important; color: var(--muted) !important; border: none !important; padding: 4px 0 !important; }
