:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Lao", sans-serif;
  color: #202334;
  background: #f5f6fb;
  --accent: #6547d9;
  --accent-strong: #4f34bf;
  --accent-soft: #f0edff;
  --line: #dde1ed;
  --muted: #667085;
  --surface: #fff;
  --warning: #8a5510;
  --shadow: 0 18px 50px rgba(52, 45, 92, .08);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top left, #efecff 0, transparent 34rem), #f5f6fb; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid rgba(101, 71, 217, .3); outline-offset: 3px; }
[hidden] { display: none !important; }

.skip-link { position: fixed; z-index: 20; top: 10px; left: 10px; transform: translateY(-160%); padding: 10px 14px; border-radius: 10px; color: #fff; background: #202334; }
.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.public-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 72px; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 64px; margin-bottom: 24px; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-logo-frame { flex: 0 0 52px; width: 52px; height: 52px; }
.brand-logo { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand-copy strong, .brand-copy small { display: block; }
.brand-copy strong { color: #151858; font-size: 1.12rem; letter-spacing: -.01em; }
.brand-copy small { margin-top: 2px; color: var(--muted); }
.account-bar { display: flex; align-items: center; gap: 10px; }
.account-email { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.usage-pill { padding: 8px 12px; border-radius: 999px; color: var(--accent-strong); background: var(--accent-soft); font-weight: 700; }

.signed-out-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 24px; align-items: stretch; }
.public-hero, .login-card, .task-card, .search-card, .result-card { border: 1px solid var(--line); background: rgba(255, 255, 255, .94); box-shadow: var(--shadow); }
.public-hero { display: flex; flex-direction: column; justify-content: center; min-height: 500px; padding: clamp(32px, 6vw, 72px); border-radius: 32px; }
.public-hero h1 { max-width: 760px; margin: 12px 0 18px; font-size: clamp(2.35rem, 5.4vw, 4.9rem); line-height: 1.05; letter-spacing: -.045em; }
.hero-copy { max-width: 680px; margin: 0; color: var(--muted); font-size: 1.08rem; line-height: 1.75; }
.eyebrow { margin: 0; color: var(--accent); font-weight: 800; letter-spacing: .04em; }
.feature-chips { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 30px; }
.feature-chips span { padding: 9px 13px; border: 1px solid #dcd5ff; border-radius: 999px; background: #faf9ff; color: #4f4690; }
.login-card { align-self: center; padding: 32px; border-radius: 26px; }
.login-card h2 { margin: 9px 0 24px; font-size: 1.7rem; }
.closed-note, .phase-notice { padding: 12px 14px; border-radius: 12px; background: #fff6dc; color: var(--warning); line-height: 1.55; }

.stack-form { display: grid; gap: 10px; }
.auth-secondary-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.auth-secondary-actions .button { flex: 1 1 140px; }
#user-reset-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
#user-reset-form h3 { margin: 0 0 4px; }
label, legend, .field-label { color: #34394b; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid #cfd4e2; border-radius: 12px; background: #fff; color: #202334; }
input, select { min-height: 46px; padding: 0 13px; }
textarea { min-height: 120px; padding: 13px; resize: vertical; line-height: 1.65; }
input:hover, textarea:hover, select:hover { border-color: #aaa4d1; }
.button { min-height: 42px; padding: 9px 16px; border: 0; border-radius: 12px; cursor: pointer; font-weight: 800; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button-primary { color: #fff; background: var(--accent); }
.button-primary:hover:not(:disabled) { background: var(--accent-strong); }
.button-secondary { color: var(--accent-strong); background: var(--accent-soft); }
.button-quiet { color: #535b70; background: #edf0f6; }
.form-status { min-height: 1.35em; margin: 10px 0 0; color: var(--muted); }
.form-status[data-kind="error"] { color: #a23a3a; }
.form-status[data-kind="success"] { color: #18704b; }

.workspace { display: grid; gap: 18px; }
.account-settings-card { border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.94); }
.account-settings-card > summary { padding: 16px 18px; cursor: pointer; color: #4f4690; font-weight: 800; }
.account-settings-content { display: grid; gap: 8px; padding: 0 18px 18px; }
.account-settings-content p { margin: 0; color: var(--muted); line-height: 1.65; }
.consent-toggle { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }
.consent-toggle input { width: 20px; min-height: 20px; margin: 2px 0 0; }
.feature-nav { position: sticky; z-index: 5; top: 12px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 7px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.93); box-shadow: 0 8px 30px rgba(38, 35, 61, .08); backdrop-filter: blur(16px); }
.feature-nav a { padding: 11px 10px; border-radius: 11px; color: #626a7c; text-align: center; text-decoration: none; font-weight: 750; }
.feature-nav a[aria-current="page"] { color: #fff; background: var(--accent); }
.usage-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--line); }
.usage-strip div { padding: 16px 18px; background: #fff; }
.usage-strip span, .usage-strip strong { display: block; }
.usage-strip span { margin-bottom: 5px; color: var(--muted); font-size: .86rem; }

.feature-view { padding: clamp(22px, 4vw, 42px); border: 1px solid var(--line); border-radius: 28px; background: rgba(255,255,255,.72); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.section-heading h2 { margin: 8px 0 5px; font-size: clamp(1.8rem, 4vw, 2.65rem); }
.section-heading p:last-child { margin: 0; color: var(--muted); }
.task-card { display: grid; gap: 14px; padding: clamp(18px, 3vw, 28px); border-radius: 22px; }
.form-grid { display: grid; gap: 14px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid label { display: grid; gap: 7px; }
.tier-fieldset { min-width: 0; margin: 2px 0 0; padding: 0; border: 0; }
.tier-fieldset legend { margin-bottom: 9px; }
.tier-selector { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tier-selector button { display: grid; min-width: 0; min-height: 86px; align-content: center; gap: 5px; padding: 14px 16px; border: 1px solid #d6d9e6; border-radius: 15px; background: #f8f9fc; color: #4f566b; text-align: left; cursor: pointer; transition: border-color .16s ease, background-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.tier-selector button:hover:not(:disabled) { border-color: #aaa4d1; background: #fff; transform: translateY(-1px); }
.tier-selector button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.tier-selector button:disabled { border-color: #e2e4ec; background: #f4f5f8; color: #8f95a6; cursor: not-allowed; }
.tier-selector strong { display: block; font-size: 1rem; line-height: 1.25; }
.tier-selector small { min-width: 0; color: var(--muted); font-size: .82rem; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.tier-selector button[aria-pressed="true"] small { color: #62559a; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.audio-mount { min-height: 0; }
.user-audio-controls { display: grid; gap: 11px; }
.user-audio-upload { position: relative; display: grid; gap: 12px; min-width: 0; padding: 18px 20px; border: 1px dashed #bfb6ec; border-radius: 18px; background: #faf9ff; cursor: pointer; transition: border-color .16s ease, background-color .16s ease, box-shadow .16s ease; }
.user-audio-upload:hover { border-color: var(--accent); background: #f8f6ff; }
.user-audio-upload:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(101, 71, 217, .18); }
.user-audio-upload-copy { display: grid; gap: 4px; min-width: 0; }
.user-audio-upload-copy strong { color: #292d42; font-size: 1.05rem; }
.user-audio-upload-copy small { color: var(--muted); font-size: .86rem; font-weight: 500; line-height: 1.5; }
.user-audio-file-input { position: absolute; width: 1px; min-height: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.user-audio-upload .form-status, .user-audio-upload [data-user-audio-status] { min-height: 1.35em; margin: 0; color: #73798d; font-weight: 500; line-height: 1.45; }
.user-audio-controls audio { width: 100%; }
.user-audio-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.user-audio-action { min-width: 0; min-height: 44px; padding: 9px 15px; border: 1px solid transparent; border-radius: 12px; cursor: pointer; font-weight: 760; transition: border-color .16s ease, background-color .16s ease, color .16s ease; }
.user-audio-action-primary { border-color: var(--accent); color: #fff; background: var(--accent); }
.user-audio-action-primary:hover:not(:disabled) { border-color: var(--accent-strong); background: var(--accent-strong); }
.user-audio-action-secondary { border-color: #d7d2f1; color: var(--accent-strong); background: var(--accent-soft); }
.user-audio-action-secondary:hover:not(:disabled) { border-color: #b8afe9; background: #e8e2ff; }
.user-audio-action-quiet { border-color: #d9dce7; color: #535b70; background: #fff; }
.user-audio-action-quiet:hover:not(:disabled) { border-color: #b8bdcb; background: #f7f8fb; }
.user-audio-action:disabled { border-color: #e1e3eb; color: #969bad; background: #f3f4f7; cursor: not-allowed; }
.result-area { display: grid; gap: 14px; margin-top: 18px; }
.user-translation-feedback { display: grid; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #faf9ff; }
.user-translation-feedback-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.user-translation-feedback-button, .user-translation-edit-button, .user-translation-confirm-revision { min-height: 38px; padding: 8px 13px; border: 0; border-radius: 10px; cursor: pointer; color: var(--accent-strong); background: var(--accent-soft); font-weight: 750; }
.user-translation-revision { display: grid; gap: 8px; }
.user-translation-revision-label { display: grid; gap: 7px; }
.user-translation-feedback-status { min-height: 1.35em; margin: 0; color: var(--muted); }
.result-card { padding: 22px; border-radius: 20px; }
.result-card h3 { margin: 0 0 12px; }
.result-card p, .result-card li { line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.comparison-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.comparison-pane { padding: 15px; border-radius: 14px; background: #f7f8fc; }
.comparison-pane span { display: block; margin-bottom: 8px; color: var(--muted); font-size: .85rem; font-weight: 700; }
.result-card details { margin-top: 12px; border-top: 1px solid var(--line); }
.result-card summary { padding: 14px 0; cursor: pointer; font-weight: 800; }
.segment-list, .source-list, .analysis-list { display: grid; gap: 10px; }
.segment-row, .source-row, .dictionary-entry, .practice-error { padding: 15px; border-radius: 14px; background: #f7f8fc; }
.copy-row { display: flex; justify-content: flex-end; margin-top: 10px; }

.search-card { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 14px; border-radius: 18px; }
.dictionary-results { display: grid; gap: 10px; margin-top: 14px; }
.dictionary-entry { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: center; border: 1px solid var(--line); background: #fff; }
.dictionary-entry p { margin: 0; font-size: 1.1rem; overflow-wrap: anywhere; }
.practice-item { display: grid; gap: 13px; padding-top: 16px; border-top: 1px solid var(--line); }
.practice-item p { margin: 0; }
.practice-item .field-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: .84rem; }
.practice-comparison { padding: 14px; border-radius: 14px; background: #f7f8fc; line-height: 1.6; }
.practice-errors { display: grid; gap: 8px; padding-top: 10px; }

.toast { position: fixed; z-index: 30; right: 22px; bottom: 22px; max-width: min(420px, calc(100% - 44px)); padding: 12px 16px; border-radius: 12px; color: #fff; background: #26283a; box-shadow: var(--shadow); }

@media (max-width: 860px) {
  .signed-out-layout { grid-template-columns: 1fr; }
  .public-hero { min-height: 0; }
  .feature-nav { grid-template-columns: repeat(3, 1fr); position: static; }
  .usage-strip { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .public-shell { width: min(100% - 20px, 1180px); padding-top: 12px; }
  .site-header, .account-bar { align-items: flex-start; }
  .site-header { flex-direction: column; }
  .brand-copy small { display: none; }
  .account-bar { width: 100%; flex-wrap: wrap; }
  .account-email { flex: 1 1 100%; }
  .feature-nav { grid-template-columns: repeat(2, 1fr); }
  .usage-strip, .two-columns, .comparison-grid, .dictionary-entry { grid-template-columns: 1fr; }
  .feature-view { padding: 18px 12px; border-radius: 20px; }
  .tier-selector { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .tier-selector button { min-height: 84px; padding: 11px 8px; text-align: center; }
  .tier-selector small { font-size: .73rem; line-height: 1.35; }
  .user-audio-upload { padding: 16px; }
  .user-audio-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-audio-action { width: 100%; padding-inline: 10px; }
  .search-card { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
