:root {
  color-scheme: dark;
  --page: #17162d;
  --panel: #22203b;
  --input: #1d1b33;
  --line: #403b58;
  --text: #f7edf9;
  --quiet: #c3b9d1;
  --pink: #f5b9df;
  --mint: #94e2e1;
  font: 15px/1.5 "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box }
body { margin: 0; color: var(--text); background: var(--page); min-height: 100vh }
[hidden] { display: none !important }
button, input, textarea, select { font: inherit }
button, input, textarea, select { border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--input); min-height: 38px; padding: 7px 12px }
button { cursor: pointer; white-space: nowrap }
button:hover { border-color: var(--pink) }
button:disabled { opacity: .5; cursor: default }
.primary { color: #321835; background: var(--pink); border-color: var(--pink); font-weight: 700 }
.primary:not(:disabled):hover { background: #ffd3ef }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px }
.quiet { color: var(--quiet) }
.top { min-height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1240px)/2)); border-bottom: 1px solid var(--line); background: #1a192f; gap: 12px }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 750; font-size: 19px; white-space: nowrap }
.beat { background: #3b3152; width: 35px; height: 35px; border-radius: 10px; display: inline-flex; gap: 3px; justify-content: center; align-items: center }
.beat i { width: 3px; height: 13px; background: var(--pink); border-radius: 2px }
.beat i:nth-child(2) { height: 22px }
.beat i:nth-child(3) { height: 17px }
main { max-width: 1290px; margin: auto; padding: clamp(22px, 4vw, 48px) 24px 56px }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 18px; flex-wrap: wrap; margin-bottom: 25px }
h1, h2, h3, p { margin: 0 }
h1 { font-size: clamp(26px, 4vw, 40px); letter-spacing: -.035em; line-height: 1.2 }
h2 { font-size: 17px }
h3 { font-size: 16px }
.intro p { color: var(--quiet); margin-top: 11px }
#export { padding: 11px 16px }
#export span { margin-left: 8px }
.lesson-name { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 13px }
.lesson-name input { flex: 1 1 220px }
.lesson-name span { font-size: 13px }
.login-panel { width: min(100%, 430px); margin: clamp(28px, 7vh, 85px) auto; padding: clamp(22px, 4vw, 34px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px }
.login-panel > p { margin: 13px 0 21px }
.login-panel form { display: grid; gap: 9px }
.login-panel button { margin-top: 6px }
#login-status { color: #ffcbde }
#account-bar { justify-content: end }
#remaining { color: var(--mint); font-size: 14px }
.editor { display: grid; grid-template-columns: minmax(200px, 25%) minmax(0, 1fr); border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden }
aside { background: #1f1e36; border-right: 1px solid var(--line); padding: 17px 13px }
.aside-head, .words-head, .words-foot, .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap }
.aside-head, .words-head { justify-content: space-between }
.hint { font-size: 13px; margin: 10px 0 14px }
.groups { padding: 0; list-style: none; margin: 0 }
.groups li { display: flex; gap: 3px; margin-bottom: 5px }
.groups .pick { display: flex; align-items: center; justify-content: space-between; width: 100%; min-width: 0; gap: 8px; text-align: left }
.groups .pick span { text-overflow: ellipsis; overflow: hidden }
.groups .pick[aria-pressed="true"] { border-color: #9479aa; background: #3c3055; color: #ffe7f6 }
.groups .icon { min-height: 34px; padding-inline: 7px }
.groups .icon:disabled { opacity: .3 }
.words { padding: 17px; min-width: 0 }
.words-head { margin-bottom: 14px; align-items: end }
.group-name { flex: 1 1 180px; max-width: 350px; display: grid; gap: 5px }
.group-name label { font-size: 13px; color: var(--quiet) }
table { width: 100%; border-collapse: collapse; table-layout: fixed }
.table-wrap { overflow-x: auto }
th { text-align: left; font-weight: 600; font-size: 13px; color: var(--quiet); border-block: 1px solid var(--line); height: 38px }
td, th { padding: 5px 4px }
td input { width: 100%; min-width: 0 }
.number { width: 33px; color: var(--quiet) }
.spoken-column { width: 22% }
.row-actions { width: 162px }
.word-actions { display:flex; gap:4px }
.word-actions button { display:grid; place-items:center; width:34px; min-height:34px; padding:0 }
.word-actions svg { width:17px; height:17px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round }
.word-actions .delete-word:hover { color:#ffcbde }
.word-destination { margin-top:5px; font-size:13px }
.words-foot { margin-top: 12px }
.words-foot span { font-size: 13px }
.status, .review { padding: 12px 14px; border: 1px solid #636280; background: #282741; border-radius: 9px; margin-bottom: 12px }
.status[data-kind="error"] { border-color: #dc91b0; color: #ffcbde }
.status[data-kind="ok"] { color: var(--mint) }
.review h3, .review p, .review details { margin-bottom: 8px }
.review pre { white-space: pre-wrap; max-height: 200px; overflow: auto }
.review-list { max-height: 280px; overflow: auto; margin-bottom: 9px }
.preview-row { display: grid; grid-template-columns: auto 1fr 1fr 1fr; gap: 5px; margin: 4px 0; align-items: center }
.preview-row input { min-width: 0; width: 100% }
.preview-row input[type="checkbox"] { accent-color: var(--pink); margin-inline: 4px; width: auto }
dialog { width: min(550px, calc(100% - 28px)); border: 1px solid var(--line); border-radius: 12px; padding: 22px; background: var(--panel); color: var(--text) }
dialog::backdrop { background: #100c22bc }
dialog p { margin: 8px 0 12px }
textarea { width: 100%; resize: vertical; margin-bottom: 10px }
@media (max-width: 720px) {
  .editor { grid-template-columns: 1fr }
  aside { border-right: 0; border-bottom: 1px solid var(--line) }
  .groups { max-height: 190px; overflow: auto }
  table { min-width: 530px }
  .words { padding: 12px }
}
td select { width: 100%; padding-inline: 6px }

/* Workspace and account header */
.top { background:#201e38; padding-inline:max(24px, calc((100vw - 1164px)/2)) }
main { max-width:1240px; padding:30px 38px 40px }
h1 { font-size:clamp(28px,4vw,38px); letter-spacing:.01em }
.intro { margin-bottom:20px }
.intro p { margin-top:8px; font-size:14px }
.primary, .button-link.primary { color:#36213c; background:var(--pink); border-color:transparent }
.login-panel { width:min(100%,436px); margin:45px auto; padding:29px }
.login-panel h1 { font-size:28px; line-height:1.3 }
.login-panel > p { font-size:14px }
.login-panel form { gap:10px }
.editor { grid-template-columns:235px minmax(0, 1fr); border-radius:13px }
aside { background:#1e1c34; padding:17px 14px }
.aside-head button, .words-head button, .words-head .button-link, .words-foot button { font-size:13px; padding-inline:9px }
.words { padding:16px 19px 17px }
.words-head { align-items:end }
.group-name { max-width:255px; flex-basis:110px }
.words-head .actions { gap:7px }
.group-name input { width:100% }
.groups .pick[aria-pressed="true"] { background:#393056; border-color:#766287 }
th { background:#292641 }
td, th { padding-inline:6px }
.number { width:44px }
#rows td input { background:transparent; border-color:transparent; border-radius:5px }
#rows td input:hover, #rows td input:focus { background:var(--input); border-color:var(--line) }
#rows input[lang="en-US"] { font-weight:650 }
.word-kind { color:var(--mint); font-size:12px; margin-left:12px }
.status[data-kind="ok"] { background:#2a3446; border-color:var(--line); color:var(--mint) }
.status[data-kind="error"] { background:#3b2e3b; border-color:#6c4a5d; color:#ffd5b7 }

/* Import and export states */
dialog { max-height:calc(100dvh - 28px); overflow:auto; padding:26px; border-radius:13px }
dialog h2 { font-size:26px; line-height:1.3 }
dialog p { font-size:14px; margin:9px 0 14px }
.review-dialog { width:min(920px, calc(100% - 28px)) }
.export-dialog { width:min(720px, calc(100% - 28px)) }
.dialog-actions { justify-content:flex-end; margin-top:17px }
.review-file { padding:12px 14px; display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:9px; margin-bottom:14px; background:#292641; border:1px dashed #655a7c; border-radius:9px }
.review-file strong, .review-file span { display:block; overflow-wrap:anywhere }
.review-file span { font-size:13px; margin-top:3px }
.words > .status { padding:8px 10px; font-size:13px }
.review-selection { margin-bottom:8px }
.review-selection button { min-height:32px; padding:4px 10px; font-size:13px }
.review-table { max-height:310px; overflow:auto }
.preview-row { grid-template-columns:55px repeat(3,minmax(95px,1fr)); gap:9px; min-width:390px; padding:3px 8px }
.preview-row input[type="checkbox"] { justify-self:start }
.review-header { color:var(--quiet); font-size:13px; background:#292641; padding-block:7px }
.review-dialog details { margin:0 0 12px }
.review-dialog pre { white-space:pre-wrap; max-height:140px; overflow:auto }
.inline-error { color:#ffd5b7 }
.details { background:#292641; border:1px solid var(--line); border-radius:9px; padding:2px 14px; margin:16px 0 }
.details div { display:flex; justify-content:space-between; align-items:baseline; gap:12px; padding:9px 0 }
.details div+div { border-top:1px solid var(--line) }
.details dt { color:var(--quiet); flex-shrink:0 }
.details dd { margin:0; overflow-wrap:anywhere; text-align:right }
.details div:last-child dd { color:var(--mint) }
progress { width:100%; height:8px; accent-color:var(--pink) }
.button-link { display:inline-flex; align-items:center; min-height:38px; padding:7px 12px; border:1px solid var(--line); border-radius:8px; color:var(--text); text-decoration:none }
.button-link:hover { border-color:var(--pink) }
@media (max-width:780px) {
  main {padding-inline:16px}
  .top {padding-inline:16px}
  .editor {grid-template-columns:1fr}
  .words {padding:13px}
  aside {border-right:0;border-bottom:1px solid var(--line)}
  .words-head .actions {gap:5px}
}
@media (max-width:440px) {
  dialog {padding:19px}
  #account-bar {gap:5px}
  #remaining {font-size:12px}
  #logout {padding-inline:7px}
  .brand {gap:7px;font-size:17px}
}

.voice-panel { margin:0 0 13px; padding:14px 16px; border:1px solid var(--line); border-radius:10px; background:var(--panel); display:grid; grid-template-columns:150px minmax(0,1fr); align-items:center; gap:10px 16px }
.voice-panel h2 { margin-bottom:3px }
.voice-panel p { font-size:13px }
.voice-options { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px }
.voice-option { display:grid; grid-template-columns:32px minmax(0,1fr) auto; gap:10px; align-items:center; text-align:left; min-height:62px; white-space:normal }
.voice-option[aria-pressed=true] { background:#393056; border-color:#b08bc0 }
.voice-option small,.voice-state { color:var(--quiet); font-size:12px }
.voice-option strong,.voice-option small { display:block }
.voice-option[aria-pressed=true] .voice-state { color:var(--pink) }
.play-icon { display:grid; width:32px; height:32px; place-items:center; border-radius:50%; background:#483756; color:var(--pink) }
#voice-status { grid-column:2; margin-top:-2px }
@media(max-width:720px){.voice-panel{grid-template-columns:1fr} #voice-status{grid-column:1}}
@media(max-width:430px){.voice-options{grid-template-columns:1fr}}
