/* Pronunciation bank — Grace design language: green on soft grey-green, white cards, 44px targets, RTL first. */
:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17211b;
  background: #f3f6f3;
  --surface: #ffffff;
  --line: #dbe4dc;
  --muted: #66736b;
  --green: #176b46;
  --green-dark: #0f5134;
  --green-soft: #e6f4ec;
  --amber: #8a5a00;
  --amber-soft: #fff5d8;
  --red: #b42318;
  --red-soft: #feeceb;
  --shadow: 0 12px 36px rgba(28, 45, 34, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100dvh; background: #f3f6f3; }
button, input, textarea, select { font: inherit; }
button, select, input { min-height: 44px; }
button { cursor: pointer; border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; transition: background-color 120ms ease, border-color 120ms ease; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
input, textarea, select { width: 100%; border: 1px solid #bdc9c0; border-radius: 10px; background: #fff; color: inherit; }
input, select { padding: 9px 12px; }
textarea { padding: 12px; resize: vertical; line-height: 1.7; min-height: 3.4em; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 3px solid rgba(23, 107, 70, 0.2); outline-offset: 2px; border-color: var(--green); }

.primary { background: var(--green); color: #fff; font-weight: 800; }
.primary:hover:not(:disabled) { background: var(--green-dark); }
.secondary { border-color: #bdc9c0; background: #fff; color: #26332b; font-weight: 750; }
.secondary:hover:not(:disabled) { background: #f5f8f6; }
.quiet { background: transparent; border-color: var(--line); color: #3e4c43; }
.danger { background: #fff; border-color: #e7b4ae; color: var(--red); font-weight: 750; }
.full { width: 100%; margin-top: 12px; }

.eyebrow { margin: 0 0 4px; color: var(--green); font-size: 0.78rem; font-weight: 850; letter-spacing: 0.04em; }
.muted { margin: 6px 0; color: var(--muted); }
.form-error { min-height: 24px; margin: 2px 0 0; color: var(--red); }
.card { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
kbd { display: inline-block; min-width: 1.6em; padding: 0 6px; border: 1px solid #bdc9c0; border-bottom-width: 2px; border-radius: 6px; background: #fff; font: 0.8rem ui-monospace, monospace; text-align: center; }

.page-shell { width: min(1180px, calc(100% - 24px)); margin-inline: auto; padding-block: 12px 40px; }

/* login / boot */
.login-wrap { min-height: calc(100dvh - 60px); display: grid; place-items: center; }
.login-card { width: min(430px, 100%); padding: 32px; display: grid; gap: 10px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.login-card h1 { margin: 0; }
.login-card label { margin-top: 8px; font-weight: 700; }

/* header */
.app-header { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; justify-content: space-between; padding: 8px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.app-header h1 { margin: 0; font-size: 1.05rem; }
.app-header .eyebrow { margin-bottom: 1px; font-size: 0.68rem; }
.header-stats { display: flex; gap: 16px; margin: 0; }
.header-stats div { min-width: 70px; }
.header-stats dt { color: var(--muted); font-size: 0.68rem; }
.header-stats dd { margin: 1px 0 0; font-size: 0.9rem; font-weight: 850; font-variant-numeric: tabular-nums; }
.user-box { display: flex; align-items: center; gap: 8px; }
.user-box span { font-weight: 750; }
.header-link { display: inline-flex; min-height: 44px; align-items: center; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; color: #3e4c43; text-decoration: none; }

/* home */
.home-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px; margin: 18px 0 14px; }
.home-header h1 { margin: 0; }
.home-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.metrics-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 0 0 14px; }
.metrics-strip div { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.metrics-strip dt { color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.metrics-strip dd { margin: 4px 0 0; font-size: 1.5rem; font-weight: 850; font-variant-numeric: tabular-nums; }
.start-card { padding: 22px 24px; display: grid; gap: 10px; }
.start-card h2 { margin: 0; }
.rules { margin: 4px 0 0; padding-inline-start: 20px; line-height: 1.8; color: #2c3a31; }
.empty-note { padding: 14px 16px; border-radius: 12px; background: var(--amber-soft); color: var(--amber); font-weight: 700; }

/* task */
#task-view { display: grid; gap: 10px; }
.word-card { padding: 16px 20px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; align-items: center; }
.target-word { margin: 0; font-size: 2.1rem; font-weight: 850; line-height: 1.2; }
.reading { font-size: 1.35rem; color: #1f3527; }
.reading b { color: var(--green-dark); font-size: 1.55rem; }
.form-note { color: var(--muted); font-size: 0.9rem; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 800; white-space: nowrap; }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.green { background: var(--green-soft); color: var(--green-dark); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.grey { background: #eef2ef; color: #4b5a50; }
.sentence { padding: 14px 20px; font-size: 1.6rem; line-height: 1.9; }
.sentence mark { padding: 0 0.15em; border-radius: 6px; background: #ffe08a; color: inherit; }

.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; }
.panel { padding: 14px 16px; display: grid; gap: 10px; align-content: start; border: 2px solid var(--line); border-radius: 16px; background: var(--surface); }
.panel.focused { border-color: var(--green); box-shadow: 0 0 0 4px rgba(23, 107, 70, 0.12); }
.panel.approved { background: #f6fbf7; border-color: #9fd0b4; }
.panel.unfixable { background: #fdf6f5; border-color: #e7b4ae; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.panel-head h3 { margin: 0; font-size: 1.05rem; }
.panel audio { width: 100%; }
.used-text { margin: 0; padding: 8px 10px; border-radius: 10px; background: #f7f9f7; font-size: 1.05rem; line-height: 1.7; }
.used-text small { display: block; color: var(--muted); font-size: 0.74rem; font-weight: 700; }
.verdicts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.verdicts button { font-weight: 800; padding-inline: 6px; }
.v-good { background: var(--green-soft); color: var(--green-dark); border-color: #b9ddc8; }
.v-bad { background: var(--red-soft); color: var(--red); border-color: #f1c4bf; }
.v-unsure { background: #eef2ef; color: #3e4c43; border-color: var(--line); }
.verdicts button.chosen { outline: 3px solid currentColor; outline-offset: -3px; }
.defects { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 36px; padding: 5px 12px; border: 1px solid #bdc9c0; border-radius: 999px; background: #fff; font-size: 0.86rem; font-weight: 700; }
.chip.chosen { background: var(--red-soft); border-color: #e7b4ae; color: var(--red); }
.edit-box { display: grid; gap: 6px; }
.edit-box label { font-size: 0.82rem; font-weight: 800; color: #3e4c43; }
.edit-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.5); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.history summary { cursor: pointer; color: var(--muted); font-size: 0.86rem; font-weight: 700; }
.history ol { margin: 6px 0 0; padding-inline-start: 18px; display: grid; gap: 6px; }
.history li { font-size: 0.92rem; line-height: 1.6; }
.history button { min-height: 32px; padding: 2px 10px; font-size: 0.8rem; }
.task-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; }
.task-footer .hint { color: var(--muted); font-size: 0.86rem; }

/* toast + dialog */
.toast { position: fixed; inset-inline: 0; bottom: 18px; margin-inline: auto; width: fit-content; max-width: min(640px, calc(100% - 24px)); padding: 10px 16px; border-radius: 12px; background: #17211b; color: #fff; font-weight: 700; box-shadow: var(--shadow); z-index: 20; }
.toast.error { background: var(--red); }
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; box-shadow: var(--shadow); max-width: min(560px, calc(100% - 24px)); }
dialog::backdrop { background: rgba(23, 33, 27, 0.35); }
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 10px 0 14px; }
.shortcuts dt { text-align: center; }
.shortcuts dd { margin: 0; }

/* admin */
.admin-grid { display: grid; gap: 12px; margin-top: 12px; }
.admin-section { padding: 16px 18px; }
.admin-section h2 { margin: 0 0 10px; font-size: 1.05rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: middle; }
th { color: var(--muted); font-size: 0.76rem; font-weight: 800; white-space: nowrap; }
td.num { font-variant-numeric: tabular-nums; }
td input[type=number] { width: 110px; min-height: 36px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.inline-form > * { flex: 1 1 160px; }
.inline-form button { flex: 0 0 auto; }
.ltr { direction: ltr; unicode-bidi: isolate; }

@media (max-width: 640px) {
  .word-card { grid-template-columns: 1fr; }
  .sentence { font-size: 1.35rem; }
  .target-word { font-size: 1.7rem; }
}

/* admin (English, LTR): tabs, tiles, voice cards, settings */
body.admin { direction: ltr; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tab { min-height: 38px; padding: 6px 14px; border: 1px solid transparent; border-radius: 999px; background: transparent; color: #3e4c43; font-weight: 750; }
.tab:hover { background: #f5f8f6; }
.tab.active { background: var(--green-soft); border-color: #b9ddc8; color: var(--green-dark); }
.tab-panel { display: grid; gap: 12px; margin-top: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.tile { display: grid; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.tile span { color: var(--muted); font-size: 0.8rem; font-weight: 750; }
.tile b { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.tile small { color: var(--muted); }
.voice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.voice { padding: 16px; display: grid; gap: 10px; }
.voice-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.voice-head h3 { margin: 0; }
.voice label { display: grid; gap: 4px; font-weight: 700; font-size: 0.86rem; }
.voice label.inline { display: inline-flex; align-items: center; gap: 2px; }
.voice .cap { width: 80px; min-height: 34px; padding: 4px 8px; }
.meter { height: 8px; border-radius: 999px; background: #eef2ef; overflow: hidden; }
.meter div { height: 100%; background: var(--green); }
.spend-line { font-size: 0.9rem; color: #3e4c43; }
dl.mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0; }
dl.mini dt { color: var(--muted); font-size: 0.72rem; }
dl.mini dd { margin: 0; font-weight: 850; font-variant-numeric: tabular-nums; }
.settings { display: grid; gap: 14px; max-width: 720px; }
.settings h2 { margin: 6px 0 0; }
.setting { display: grid; grid-template-columns: 240px 1fr; gap: 2px 16px; align-items: center; }
.setting > span:first-child { font-weight: 750; }
.setting .field { display: inline-flex; align-items: center; gap: 8px; color: #3e4c43; }
.setting .field input, .setting .field select { width: 110px; }
.setting small { grid-column: 2; color: var(--muted); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
details > summary { cursor: pointer; list-style: none; }
tr.inactive td { opacity: 0.55; }
button.small { min-height: 32px; padding: 4px 10px; font-size: 0.82rem; }
input.check { width: auto; min-height: auto; }
@media (max-width: 640px) { .setting { grid-template-columns: 1fr; } .setting small { grid-column: 1; } }

.pw-box { display: flex; align-items: center; gap: 10px; margin: 10px 0 14px; }
.pw-box code { padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #f7f9f7; font-size: 1.15rem; letter-spacing: 0.05em; user-select: all; }
