:root {
  --ink: #171629;
  --indigo: #29245c;
  --indigo-deep: #1e1a47;
  --mango: #ffbd3d;
  --sky: #d9eff3;
  --paper: #f7f6fb;
  --white: #ffffff;
  --muted: #6c6a7c;
  --danger: #a72e3d;
  --shadow: 0 24px 70px rgb(41 36 92 / 14%);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 85% 12%, rgb(217 239 243 / 80%), transparent 32rem),
    var(--paper);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }

:focus-visible {
  outline: 4px solid var(--mango);
  outline-offset: 4px;
}

.shell {
  width: min(100% - 32px, 760px);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 0 max(36px, env(safe-area-inset-bottom));
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(48px, 10vh, 96px);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--indigo);
  font-weight: 700;
  letter-spacing: -.02em;
}

.wordmark-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  color: var(--white);
  background: var(--indigo);
  font-family: "Kohinoor Devanagari", "Noto Sans Devanagari", sans-serif;
  font-size: 1.35rem;
}

.masthead-actions { display: flex; align-items: center; gap: 18px; }
.logout-button { padding: 4px 0; font-size: .86rem; font-weight: 700; }

.privacy-chip {
  color: var(--indigo);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.view { animation: settle .42s ease-out both; }
.access-view { max-width: 650px; }

.eyebrow {
  margin: 0 0 12px;
  color: var(--indigo);
  font-size: .76rem;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1 {
  max-width: 13ch;
  margin: 0;
  color: var(--indigo-deep);
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: clamp(2.7rem, 8vw, 5.5rem);
  font-weight: 600;
  letter-spacing: -.055em;
  line-height: .98;
}

.intro {
  max-width: 48ch;
  margin: 26px 0 34px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.6;
}

.access-form { display: grid; gap: 20px; }
.access-form label:not(.consent-card) { display: grid; gap: 8px; font-weight: 750; }
.access-form small { color: var(--muted); font-weight: 500; }

input[type="password"], input[type="text"] {
  width: 100%;
  border: 1px solid #cfccdc;
  border-radius: 14px;
  padding: 15px 16px;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 2px 0 rgb(41 36 92 / 3%);
}

.consent-card {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 14px;
  padding: 18px;
  border-radius: 18px;
  color: #4e4b60;
  background: var(--sky);
  font-size: .91rem;
  line-height: 1.55;
}

.consent-card input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--indigo); }

.primary, .secondary {
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  padding: 14px 22px;
  font-weight: 800;
}

.primary { color: var(--white); background: var(--indigo); box-shadow: 0 8px 22px rgb(41 36 92 / 20%); }
.primary:hover { background: var(--indigo-deep); }
.secondary { color: var(--indigo); background: #ebe9f4; }
#welcome-add { background: #d8d2ed; box-shadow: inset 0 0 0 1px #a69cc8; }
#welcome-add:hover { background: #cbc2e5; }

.progress-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 700;
}

.task-card {
  padding: clamp(26px, 6vw, 52px);
  border: 1px solid rgb(41 36 92 / 8%);
  border-radius: 30px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.task-card h1 {
  max-width: none;
  min-height: 2.3em;
  font-family: "Kohinoor Devanagari", "Noto Sans Devanagari", "Mangal", sans-serif;
  font-size: clamp(2.5rem, 9vw, 5.2rem);
  font-weight: 650;
  letter-spacing: -.035em;
  line-height: 1.15;
}

.record-stage { display: grid; justify-items: center; margin: 48px 0 20px; text-align: center; }

.record-seal {
  position: relative;
  display: grid;
  width: 142px;
  height: 142px;
  place-content: center;
  gap: 10px;
  border: 9px solid var(--white);
  border-radius: 50%;
  color: var(--white);
  background: var(--indigo);
  box-shadow: 0 0 0 2px var(--indigo), 0 18px 40px rgb(41 36 92 / 25%);
  font-weight: 850;
  transition: transform .18s ease, background .18s ease;
}

.record-seal:hover { transform: translateY(-3px); }
.record-seal.recording { background: var(--danger); box-shadow: 0 0 0 2px var(--danger), 0 0 0 16px rgb(167 46 61 / 10%); animation: pulse 1.4s ease-in-out infinite; }
.record-dot { width: 24px; height: 24px; margin: 0 auto; border-radius: 50%; background: var(--mango); }
.recording .record-dot { border-radius: 5px; background: var(--white); }
.record-stage p { margin: 18px 0 0; color: var(--muted); font-size: .86rem; }
.record-stage .timer { margin-top: 8px; color: var(--indigo); font-variant-numeric: tabular-nums; font-weight: 800; }

.preview-panel { margin-top: 24px; padding-top: 24px; border-top: 1px solid #e5e2ed; }
.preview-panel audio { width: 100%; }
.button-row { display: grid; grid-template-columns: 1fr 1.35fr; gap: 12px; margin-top: 18px; }
.quiet-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 22px; margin-top: 28px; }
.text-button { border: 0; padding: 8px 0; color: var(--muted); background: transparent; text-decoration: underline; text-underline-offset: 4px; }
.text-button:hover { color: var(--indigo); }

.result-view { max-width: 590px; text-align: left; }
.result-view h1 { margin-bottom: 24px; }
.result-view p:not(.eyebrow) { margin: 0 0 30px; color: var(--muted); font-size: 1.1rem; }
.sent-mark { display: grid; width: 110px; height: 110px; place-items: center; margin-bottom: 34px; border-radius: 50%; color: var(--indigo); background: var(--mango); font-size: 3rem; font-weight: 850; transform: rotate(-6deg); }
.status { min-height: 24px; margin: 22px 0 0; color: var(--danger); font-size: .92rem; font-weight: 650; }

.status.is-info { color: var(--indigo); }

[hidden] { display: none !important; }

@keyframes settle { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { transform: scale(1.025); } }

@media (max-width: 540px) {
  .shell { width: min(100% - 24px, 760px); }
  .masthead { margin-bottom: 48px; }
  .privacy-chip { max-width: 90px; text-align: right; }
  .masthead:has(.logout-button:not([hidden])) .privacy-chip { display: none; }
  .task-card { border-radius: 24px; }
  .button-row { grid-template-columns: 1fr; }
  .record-seal { width: 128px; height: 128px; }
}

.welcome-view { max-width: 590px; }
.welcome-view h1 { margin-bottom: 18px; overflow-wrap: anywhere; }
.welcome-line { margin: 0 0 14px; color: var(--muted); font-size: 1.15rem; }
.welcome-line strong { color: var(--indigo); font-variant-numeric: tabular-nums; }
.welcome-next { display: inline-block; margin: 0 0 30px; padding: 10px 16px; border-radius: 999px; color: var(--indigo); background: var(--sky); font-size: .95rem; font-weight: 750; }
.welcome-view .button-row { margin-top: 18px; }
.welcome-seal { position: relative; width: 120px; height: 120px; margin-bottom: 34px; }
.welcome-mark {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 50%;
  color: var(--indigo); background: var(--mango); box-shadow: var(--shadow);
  font-family: "Kohinoor Devanagari", "Noto Sans Devanagari", sans-serif; font-size: 3.3rem; font-weight: 850;
  animation: stamp .7s cubic-bezier(.2, 1.6, .4, 1) both;
}
.welcome-view.is-returning .welcome-mark { background: var(--indigo); color: var(--mango); animation-name: stamp, wave 1.4s .7s ease-in-out 1; }
.welcome-burst { position: absolute; inset: 0; }
.welcome-burst i {
  position: absolute; top: 50%; left: 50%; width: 10px; height: 10px; margin: -5px; border-radius: 50%;
  background: var(--mango); opacity: 0;
  animation: burst .9s .25s ease-out both;
}
.welcome-burst i:nth-child(odd) { background: var(--indigo); width: 7px; height: 7px; margin: -3.5px; }
.welcome-burst i:nth-child(3n) { background: #7cc6d3; border-radius: 2px; }
.welcome-burst i:nth-child(1) { --a: 0deg; } .welcome-burst i:nth-child(2) { --a: 36deg; }
.welcome-burst i:nth-child(3) { --a: 72deg; } .welcome-burst i:nth-child(4) { --a: 108deg; }
.welcome-burst i:nth-child(5) { --a: 144deg; } .welcome-burst i:nth-child(6) { --a: 180deg; }
.welcome-burst i:nth-child(7) { --a: 216deg; } .welcome-burst i:nth-child(8) { --a: 252deg; }
.welcome-burst i:nth-child(9) { --a: 288deg; } .welcome-burst i:nth-child(10) { --a: 324deg; }
.welcome-view h1, .welcome-view .eyebrow, .welcome-line, .welcome-next { animation: settle .5s ease-out both; }
.welcome-view .eyebrow { animation-delay: .3s; }
.welcome-view h1 { animation-delay: .4s; }
.welcome-line { animation-delay: .55s; }
.welcome-next { animation-delay: .7s; }

@keyframes stamp { from { opacity: 0; transform: scale(.3) rotate(-30deg); } to { opacity: 1; transform: scale(1) rotate(-6deg); } }
@keyframes wave { 0%, 100% { transform: rotate(-6deg); } 20%, 60% { transform: rotate(10deg); } 40%, 80% { transform: rotate(-14deg); } }
@keyframes burst {
  0% { opacity: 1; transform: rotate(var(--a)) translateX(0) scale(.4); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--a)) translateX(92px) scale(1); }
}

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

.trophy-line { margin: -8px 0 16px; color: var(--indigo); font-size: .9rem; font-weight: 700; }
.trophy-news { padding: 14px 18px; border-radius: 16px; color: var(--indigo); background: var(--sky); font-weight: 750; }
.result-view p.trophy-news { margin: 0 0 18px; color: var(--indigo); font-size: 1rem; }
.result-view .board-open { display: block; margin-top: 18px; }
.board-list { display: grid; gap: 10px; margin: 0 0 28px; padding: 0; list-style: none; }
.board-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 14px 18px; border-radius: 16px; background: var(--white); box-shadow: 0 6px 18px rgb(41 36 92 / 8%); }
.board-list li.is-you { outline: 2px solid var(--mango); }
.board-name { overflow-wrap: anywhere; font-weight: 750; }
.board-count { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
#board-view .consent-card { margin-bottom: 24px; }

#sentence-dialog {
  width: min(100% - 24px, 650px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: clamp(22px, 5vw, 40px);
  border: 0;
  border-radius: 24px;
  color: var(--ink);
  background: var(--white);
  box-shadow: var(--shadow);
}
#sentence-dialog::backdrop { background: rgb(23 22 41 / 55%); }
#sentence-dialog h2 { margin: 0 0 16px; color: var(--indigo); font-size: 1.8rem; }
#sentence-dialog p { line-height: 1.5; }
#sentence-dialog textarea {
  width: 100%; resize: vertical; padding: 12px;
  border: 1px solid #cfccdc; border-radius: 12px;
  color: var(--ink); background: var(--paper);
}
#sentence-devanagari { font-family: "Kohinoor Devanagari", "Noto Sans Devanagari", sans-serif; font-size: 1.3rem; }
.sentence-recording-label { margin-top: 24px; }
#sentence-dialog .record-stage { margin-top: 24px; }
#sentence-back { display: block; margin-top: 24px; }

.progress-row { align-items: baseline; gap: 12px; min-height: 1.4em; }
.progress-row .trophy-line { margin: 0; }
.flash { margin: 0 0 0 auto; color: var(--indigo); font-weight: 800; }
.level-meter { width: 160px; height: 8px; margin-top: 16px; overflow: hidden; border-radius: 999px; background: #e5e2ed; }
.level-meter span { display: block; height: 100%; border-radius: inherit; background: var(--danger); transform: scaleX(0); transform-origin: left; transition: transform .08s linear; }
.take-warning { margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; color: #6b3d00; background: #fff1d6; font-weight: 650; line-height: 1.45; }

#report-dialog {
  width: min(100% - 24px, 520px);
  padding: clamp(22px, 5vw, 36px);
  border: 0;
  border-radius: 24px;
  color: var(--ink);
  background: var(--white);
  box-shadow: var(--shadow);
}
#report-dialog::backdrop { background: rgb(23 22 41 / 55%); }
#report-dialog h2 { margin: 0 0 10px; color: var(--indigo); font-size: 1.6rem; }
#report-dialog p { margin: 0 0 18px; color: var(--muted); line-height: 1.5; }
.report-choices { display: grid; gap: 8px; margin: 0 0 18px; padding: 0; border: 0; }
.report-choices label { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--paper); font-weight: 650; cursor: pointer; }
.report-choices label:has(input:checked) { outline: 2px solid var(--indigo); background: #ebe9f4; }
.report-choices input { width: 18px; height: 18px; accent-color: var(--indigo); }
.report-note { display: grid; gap: 8px; font-weight: 750; }
.report-note small { color: var(--muted); font-weight: 500; }
#report-note { width: 100%; resize: vertical; padding: 12px; border: 1px solid #cfccdc; border-radius: 12px; color: var(--ink); background: var(--paper); }
@media (max-width: 540px) {
  .progress-row { flex-direction: column; gap: 4px; }
  .flash { margin-left: 0; }
}
