@font-face {
  font-family: "AceBrush";
  src: url("/assets/fonts/MaShanZheng-AceSubset.v1.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 400;
}

@font-face {
  font-family: "AceDigits";
  src: url("/assets/fonts/Oxanium-Variable.v1.ttf") format("truetype");
  font-display: swap;
  font-style: normal;
  font-weight: 200 800;
}

:root {
  color-scheme: light;
  --page: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f8f4ff;
  --surface-blue: #edf6ff;
  --ink: #190c38;
  --muted: #594a78;
  --line: #cbbcf0;
  --line-strong: #8b64e8;
  --purple: #6c22e6;
  --purple-dark: #3d087f;
  --magenta: #ee087d;
  --magenta-dark: #9b0757;
  --blue: #006ff2;
  --blue-dark: #06429e;
  --yellow: #ffd72e;
  --green: #008f73;
  --danger-soft: #ffe5f2;
  --warning-soft: #fff3bf;
  --shadow: 0 16px 34px rgb(75 24 159 / 0.14);
  --radius: 14px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --page: #120622;
  --surface: #1f0d3e;
  --surface-soft: #2a1450;
  --surface-blue: #102b59;
  --ink: #fff9ff;
  --muted: #d6c8eb;
  --line: #694aa0;
  --line-strong: #a47cff;
  --purple: #a876ff;
  --purple-dark: #5524a7;
  --magenta: #ff52ad;
  --magenta-dark: #d72f8a;
  --blue: #55a8ff;
  --blue-dark: #1566c9;
  --yellow: #ffe35a;
  --green: #58d7bc;
  --danger-soft: #50133c;
  --warning-soft: #59451a;
  --shadow: 0 18px 38px rgb(3 0 12 / 0.38);
}

* { box-sizing: border-box; }

html {
  min-width: 280px;
  background: var(--page);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

body {
  min-width: 280px;
  min-height: 100dvh;
  margin: 0;
  background-color: var(--page);
  background-image: linear-gradient(rgb(255 255 255 / 0.87), rgb(255 255 255 / 0.95)), url("/assets/ace28-body-bright-v1.png");
  background-position: center top;
  background-size: 1660px auto;
  background-repeat: repeat-y;
  background-attachment: fixed;
}

[data-theme="dark"] body {
  background-image: linear-gradient(rgb(18 6 34 / 0.88), rgb(18 6 34 / 0.96)), url("/assets/ace28-body-bright-v1.png");
}

button, a, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; }

:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

.site-header {
  position: relative;
  z-index: 5;
  width: min(1220px, calc(100% - 28px));
  min-height: 66px;
  margin: 10px auto 0;
  padding: 8px 10px 8px 12px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 0.94);
  box-shadow: 0 10px 26px rgb(64 18 140 / 0.12);
  backdrop-filter: blur(12px);
}

[data-theme="dark"] .site-header { background: rgb(31 13 62 / 0.94); }

.brand {
  min-width: 150px;
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
}

.brand img { width: 42px; height: 42px; }
.brand span { display: grid; line-height: 1; }
.brand strong {
  font-family: "AceBrush", "STKaiti", "KaiTi", sans-serif;
  font-size: 1.65rem;
  font-weight: 400;
  color: var(--purple-dark);
}
[data-theme="dark"] .brand strong { color: #f7ecff; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 0.62rem; white-space: nowrap; }

.nav-deck {
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
}

.nav-group, .nav-group > div { display: contents; }
.nav-group > span { display: none; }

.nav-deck a {
  min-height: 40px;
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.nav-deck a::before, .quick-link::before, .icon-inline {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  content: "";
  background: currentColor;
  -webkit-mask: center / contain no-repeat;
  mask: center / contain no-repeat;
}

.nav-deck a[href="/"]::before { -webkit-mask-image: url("/assets/icons/home-2.svg"); mask-image: url("/assets/icons/home-2.svg"); }
.nav-deck a[href="/scratch/"]::before { -webkit-mask-image: url("/assets/icons/cards.svg"); mask-image: url("/assets/icons/cards.svg"); }
.nav-deck a[href="/practice/"]::before { -webkit-mask-image: url("/assets/icons/player-play.svg"); mask-image: url("/assets/icons/player-play.svg"); }
.nav-deck a[href="/rules/"]::before { -webkit-mask-image: url("/assets/icons/book-2.svg"); mask-image: url("/assets/icons/book-2.svg"); }
.nav-deck a[href="/chat/"]::before { -webkit-mask-image: url("/assets/icons/message-circle.svg"); mask-image: url("/assets/icons/message-circle.svg"); }

.nav-deck a:hover { border-color: var(--line); background: var(--surface-soft); color: var(--purple); }
.nav-deck a[aria-current="page"] { border-color: var(--purple); background: var(--purple); color: #ffffff; }

.theme-toggle {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: var(--blue);
  color: #ffffff;
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / 0.14);
}

.theme-toggle span { width: 21px; height: 21px; overflow: hidden; color: transparent; background: #ffffff; -webkit-mask: url("/assets/icons/moon-stars.svg") center / contain no-repeat; mask: url("/assets/icons/moon-stars.svg") center / contain no-repeat; }
[data-theme="dark"] .theme-toggle span { -webkit-mask-image: url("/assets/icons/sun.svg"); mask-image: url("/assets/icons/sun.svg"); }

main {
  width: min(1160px, calc(100% - 28px));
  margin: 0 auto;
  padding: 14px 0 52px;
}

.draw-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(300px, 0.72fr);
  gap: 12px;
}

.live-strip {
  position: relative;
  min-width: 0;
  min-height: 260px;
  overflow: hidden;
  padding: 20px 22px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  gap: 8px 20px;
  border: 1px solid #4d1bb0;
  border-radius: var(--radius);
  background: linear-gradient(122deg, #3a0787 0%, #6c22e6 47%, #005fdd 100%);
  color: #ffffff;
  box-shadow: var(--shadow);
}

.live-strip::before {
  position: absolute;
  inset: 0 0 0 auto;
  width: 48%;
  height: 100%;
  background-image:
    linear-gradient(118deg, #6424d8 0%, #0759cd 100%),
    url("/assets/ace28-body-bright-v1.png");
  background-position: center, right bottom;
  background-repeat: no-repeat;
  background-size: 100% 100%, 710px auto;
  background-blend-mode: multiply;
  opacity: 0.92;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgb(0 0 0 / 0.72) 28%, #000000 52%);
  mask-image: linear-gradient(90deg, transparent 0%, rgb(0 0 0 / 0.72) 28%, #000000 52%);
  content: "";
  pointer-events: none;
}

.live-strip::after {
  position: absolute;
  left: -48px;
  top: -62px;
  width: 130px;
  height: 130px;
  border: 26px solid rgb(255 14 141 / 0.52);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.live-meta, .live-countdown, .equation, .live-status { position: relative; z-index: 1; }
.live-meta { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 5px 12px; }
.live-title { grid-column: 1 / -1; margin: 0; color: var(--yellow); font-family: "AceBrush", "STKaiti", cursive; font-size: 1.12rem; font-weight: 400; letter-spacing: 0.035em; }
.live-meta time { color: #e7ddff; font-size: 0.78rem; }
.live-meta > span:not(.kicker) { font-size: 0.92rem; }
.live-meta [data-live-issue] { font-family: "AceDigits", monospace; font-size: 1.05rem; letter-spacing: 0.035em; }

.kicker {
  color: var(--purple);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.live-strip .kicker { color: var(--yellow); }

.equation, .question-digits, .fixed-sample {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.equation { grid-column: 1 / -1; align-self: center; }
.equation b, .question-digits span, .fixed-sample span {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 3px solid #d6c4ff;
  border-radius: 50%;
  background: #ffffff;
  color: #4d12a5;
  font-family: "AceDigits", monospace;
  font-size: 1.7rem;
  font-weight: 800;
  box-shadow: 0 7px 0 rgb(26 4 73 / 0.25);
}

.equation b:nth-of-type(2), .question-digits span:nth-of-type(2), .fixed-sample span:nth-of-type(2) { border-color: #a9d6ff; color: #0054be; }
.equation b:nth-of-type(3), .question-digits span:nth-of-type(3), .fixed-sample span:nth-of-type(3) { border-color: #ffb4d6; color: #c80068; }
.equation i, .question-digits i, .fixed-sample i { color: inherit; font-family: "AceDigits", monospace; font-style: normal; font-weight: 700; }
.equation em, .question-digits strong, .fixed-sample strong {
  min-width: 64px;
  height: 58px;
  padding: 0 10px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  background: var(--magenta);
  color: #ffffff;
  font-family: "AceDigits", monospace;
  font-size: 1.75rem;
  font-style: normal;
  font-weight: 800;
  box-shadow: inset 0 -5px 0 rgb(92 0 48 / 0.22);
}
[data-theme="dark"] .equation em, [data-theme="dark"] .question-digits strong, [data-theme="dark"] .fixed-sample strong { background: #b71567; }

.live-countdown { display: grid; justify-items: end; gap: 1px; text-align: right; }
.live-countdown span { color: #e8e1ff; font-size: 0.74rem; }
.live-countdown strong { font-family: "AceDigits", monospace; font-size: 1.75rem; font-weight: 760; line-height: 1; }
.live-countdown button {
  min-height: 30px;
  padding: 2px 8px;
  border: 1px solid rgb(255 255 255 / 0.44);
  border-radius: 8px;
  background: rgb(255 255 255 / 0.1);
  color: #ffffff;
  font-size: 0.74rem;
}
.live-countdown button::before { display: inline-block; width: 13px; height: 13px; margin-right: 4px; vertical-align: -2px; content: ""; background: currentColor; -webkit-mask: url("/assets/icons/refresh.svg") center / contain no-repeat; mask: url("/assets/icons/refresh.svg") center / contain no-repeat; }

.live-status {
  min-height: 30px;
  margin: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: #ffffff;
  font-size: 0.8rem;
}

.live-status span { padding: 4px 9px; border: 1px solid rgb(255 255 255 / 0.45); border-radius: 8px; background: rgb(255 255 255 / 0.13); font-weight: 780; }
.live-status[data-state="waiting"] { color: #fff2af; }
.live-status[data-state="conflict"] { color: #ffe1ef; }

.recent-card, .practice-panel, .progress-card, .boundary-table, .chat-shell, .scratch-shell, .content-card, .page-heading {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.recent-card { min-width: 0; min-height: 260px; overflow: hidden; }
.recent-card .section-heading {
  min-height: 72px;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(115deg, var(--magenta), var(--purple));
  color: #ffffff;
}
.section-heading h2 { margin: 1px 0 0; font-family: "AceBrush", "STKaiti", cursive; font-size: 1.45rem; font-weight: 400; }
.section-heading .kicker { color: #ffffff; opacity: 0.86; }
.section-heading a { font-size: 0.75rem; font-weight: 750; text-decoration: none; }

.recent-list { margin: 0; padding: 8px 10px 10px; display: grid; list-style: none; }
.recent-list li {
  min-width: 0;
  min-height: 57px;
  padding: 8px 5px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}
.recent-list li:last-child { border-bottom: 0; }
.recent-list span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.77rem; font-weight: 720; }
.recent-list small { color: var(--muted); font-size: 0.68rem; }
.recent-list strong { color: var(--magenta-dark); font-family: "AceDigits", monospace; font-size: 1.06rem; white-space: nowrap; }
[data-theme="dark"] .recent-list strong { color: #ff93ca; }

.quick-actions {
  margin: 12px 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.quick-link {
  min-height: 54px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--purple-dark);
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 7px 18px rgb(72 22 156 / 0.08);
}
[data-theme="dark"] .quick-link { color: #f5ecff; }
.quick-link:nth-child(2) { background: var(--surface-blue); color: var(--blue-dark); }
[data-theme="dark"] .quick-link:nth-child(2) { border-color: #477fc3; background: #143f77; color: #e8f4ff; }
.quick-link:nth-child(3) { background: #fff0f8; color: var(--magenta-dark); }
[data-theme="dark"] .quick-link:nth-child(3) { background: #461230; color: #ffadd6; }
.quick-link:nth-child(4) { background: var(--warning-soft); color: #6d4700; }
[data-theme="dark"] .quick-link:nth-child(4) { color: #ffe88a; }
.quick-link[href="/practice/"]::before { -webkit-mask-image: url("/assets/icons/player-play.svg"); mask-image: url("/assets/icons/player-play.svg"); }
.quick-link[href="/scratch/"]::before { -webkit-mask-image: url("/assets/icons/cards.svg"); mask-image: url("/assets/icons/cards.svg"); }
.quick-link[href="/chat/"]::before { -webkit-mask-image: url("/assets/icons/message-circle.svg"); mask-image: url("/assets/icons/message-circle.svg"); }
.quick-link[href="/rules/"]::before { -webkit-mask-image: url("/assets/icons/book-2.svg"); mask-image: url("/assets/icons/book-2.svg"); }

.practice-panel { padding: 20px; border-top: 7px solid var(--blue); }
.practice-header { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.practice-header h2, .progress-card h2 { margin: 2px 0; }
.practice-header h2 { font-family: "AceBrush", "STKaiti", cursive; font-size: 1.55rem; font-weight: 400; }
.progress-mini { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 0.76rem; }
.progress-mini b { color: var(--magenta-dark); font-family: "AceDigits", monospace; }

.feed-status { margin: 10px 0; padding: 7px 10px; border-left: 4px solid var(--blue); background: var(--surface-blue); color: var(--muted); font-size: 0.78rem; }
.feed-status[data-state="conflict"] { border-color: var(--magenta); background: var(--danger-soft); color: var(--magenta-dark); }
.feed-status[data-state="waiting"] { border-color: #e5a800; background: var(--warning-soft); color: #694400; }
[data-theme="dark"] .feed-status[data-state="waiting"] { color: #ffe798; }
.question-loading { padding: 28px 14px; color: var(--muted); text-align: center; }
.question-card { margin-top: 14px; }
.question-source { color: var(--muted); font-size: 0.78rem; }
.question-card h3 { margin: 8px 0 12px; font-size: 1.35rem; }
.question-digits { justify-content: flex-start; margin: 12px 0 18px; }
.question-digits span, .fixed-sample span { width: 48px; height: 48px; font-size: 1.35rem; box-shadow: 0 5px 0 rgb(52 8 117 / 0.16); }
.question-digits strong, .fixed-sample strong { min-width: 54px; height: 50px; font-size: 1.4rem; }
.answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.answer { min-height: 48px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-weight: 800; }
.answer:hover:not(:disabled), .answer:focus-visible { border-color: var(--purple); box-shadow: inset 0 0 0 2px rgb(108 34 230 / 0.14); }
.answer.correct { border-color: var(--green); background: color-mix(in srgb, var(--green), transparent 86%); }
.answer.wrong { border-color: var(--magenta); background: var(--danger-soft); }
.explanation { margin-top: 14px; padding: 15px; border-left: 5px solid var(--purple); background: var(--surface-soft); }
.explanation p, .explanation li { color: var(--muted); line-height: 1.55; }
.question-actions { margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.button {
  min-height: 42px;
  padding: 9px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 800;
  text-decoration: none;
}
.button.primary { border-color: transparent; background: linear-gradient(115deg, var(--purple), var(--blue)); color: #ffffff; box-shadow: inset 0 -4px 0 rgb(0 0 0 / 0.15); }
.button.ghost { background: var(--surface); color: var(--purple); }
.button:disabled { cursor: not-allowed; opacity: 0.48; }

.practice-page { max-width: 1120px; }
.practice-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 12px; }
.progress-card { padding: 18px; background: linear-gradient(145deg, #3a0787, #0756bd); color: #ffffff; }
.progress-card .kicker { color: var(--yellow); }
.progress-card dl { margin-bottom: 12px; display: grid; }
.progress-card dl div { padding: 8px 0; display: flex; justify-content: space-between; border-bottom: 1px solid rgb(255 255 255 / 0.25); }
.progress-card dd { margin: 0; color: #ffd1e7; font-family: "AceDigits", monospace; font-weight: 800; }
.storage-note { color: #e9e0ff; font-size: 0.75rem; line-height: 1.5; }
.text-button { padding: 0; border: 0; background: none; color: #ffffff; text-decoration: underline; }

.page-heading { margin-bottom: 12px; padding: 18px 22px; border-left: 8px solid var(--magenta); background: rgb(255 255 255 / 0.94); }
[data-theme="dark"] .page-heading { background: rgb(31 13 62 / 0.94); }
.page-heading h1, .chat-heading h1, .not-found h1 { margin: 2px 0; font-family: "AceBrush", "STKaiti", cursive; font-size: clamp(2rem, 4vw, 3.2rem); font-weight: 400; line-height: 1.1; }
.page-heading p { max-width: 70ch; margin: 6px 0 0; color: var(--muted); line-height: 1.6; }

.topic-picker { margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.topic-picker button { min-height: 39px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); font-weight: 800; }
.topic-picker button.active { border-color: var(--magenta); background: var(--magenta); color: #ffffff; }

.rule-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.rule-grid article { padding: 19px; border: 1px solid var(--line); border-left: 6px solid var(--purple); border-radius: var(--radius); background: var(--surface); }
.rule-grid article:nth-child(2n) { border-left-color: var(--blue); }
.rule-grid article:nth-child(3n) { border-left-color: var(--magenta); }
.rule-grid article:last-child { grid-column: 1 / -1; }
.rule-grid article > b { color: var(--magenta-dark); font-family: "AceDigits", monospace; }
.rule-grid h2 { margin: 2px 0 6px; }
.rule-grid p { margin: 0; color: var(--muted); line-height: 1.65; }
.boundary-table { margin-top: 12px; padding: 20px; background: linear-gradient(125deg, #3a0787, #0756bd); color: #ffffff; }
.boundary-table p { color: #e9e3ff; }
.fixed-sample { justify-content: flex-start; margin: 14px 0; }

.content-stack { display: grid; gap: 10px; }
.content-card { padding: 20px; border-left: 6px solid var(--purple); }
.content-card:nth-child(2n) { border-left-color: var(--blue); }
.content-card:nth-child(3n) { border-left-color: var(--magenta); }
.content-card h2 { margin: 0 0 7px; }
.content-card p, .content-card li { color: var(--muted); line-height: 1.65; }

.scratch-page, .chat-page { max-width: 900px; }
.scratch-shell, .chat-shell { padding: 18px; }
.scratch-shell { border-top: 7px solid var(--magenta); }
.scratch-ticket { position: relative; min-height: 330px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: url("/assets/ace28-scratch-study-v1.png") center / cover; }
.scratch-meta { padding: 18px; display: flex; justify-content: space-between; color: #321064; font-weight: 850; }
.scratch-result { min-height: 248px; padding: 18px; display: grid; place-items: center; }
.scratch-result .question-digits { justify-content: center; }
.scratch-result p { color: #321064; font-weight: 850; }
.scratch-ticket canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.scratch-controls { margin-top: 14px; display: flex; justify-content: center; gap: 8px; }
.scratch-help { color: var(--muted); font-size: 0.8rem; text-align: center; }

.chat-heading { margin-bottom: 12px; display: flex; align-items: center; gap: 14px; }
.chat-shell { border-top: 7px solid var(--blue); }
.chat-profile { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.chat-profile img { border: 3px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.chat-profile label, .chat-form label { display: block; color: var(--muted); font-size: 0.74rem; }
.chat-profile input { padding: 4px 0; border: 0; background: transparent; color: var(--ink); font-weight: 850; }
.chat-profile input:disabled { opacity: 1; }
.chat-profile small { display: block; color: var(--muted); }
.connection-pill { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--danger-soft); color: var(--magenta-dark); font-size: 0.75rem; font-weight: 800; }
.chat-announcement { margin: 12px 0; padding: 10px 12px; border-left: 5px solid var(--purple); background: var(--surface-soft); color: var(--muted); }
.messages { min-height: 190px; max-height: 460px; overflow: auto; padding: 12px; display: grid; align-content: start; gap: 9px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.messages .empty { margin: auto; padding: 14px; color: var(--muted); text-align: center; }
.message { max-width: 88%; display: grid; grid-template-columns: 36px 1fr; gap: 8px; }
.message.self { justify-self: end; grid-template-columns: 1fr 36px; }
.message img { width: 36px; height: 36px; border-radius: 10px; }
.message-body { padding: 9px 11px; border-radius: 10px; background: #dfeeff; color: #1a1232; }
.message.self .message-body { order: -1; background: #f3ddff; }
.message-meta { margin-bottom: 2px; display: flex; gap: 7px; color: #5f5672; font-size: 0.68rem; }
.message p { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-form { margin-top: 12px; display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.chat-form label, .chat-form-status { grid-column: 1 / -1; }
.chat-form textarea { min-height: 72px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); resize: vertical; }
.chat-form-status { margin: 0; color: var(--muted); font-size: 0.75rem; }

.site-footer {
  width: min(1160px, calc(100% - 28px));
  margin: 0 auto 16px;
  padding: 13px 4px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 12px; }
.not-found { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 9px; text-align: center; }
.not-found p { color: var(--muted); }

@media (hover: hover) {
  .button, .quick-link, .nav-deck a, .theme-toggle { transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease; }
  .button:hover, .quick-link:hover, .theme-toggle:hover { transform: translateY(-2px); }
}

@media (min-width: 821px) {
  .equation { gap: 12px; }
  .equation b {
    width: 76px;
    height: 76px;
    border-width: 4px;
    font-size: 2.28rem;
    box-shadow: 0 9px 0 rgb(26 4 73 / 0.25);
  }
  .equation i { font-size: 1.28rem; }
  .equation em {
    min-width: 86px;
    height: 78px;
    padding: 0 14px;
    border-radius: 14px;
    font-size: 2.36rem;
  }
}

@media (max-width: 820px) {
  .site-header { grid-template-columns: 1fr auto; gap: 6px 10px; }
  .brand { grid-column: 1; grid-row: 1; }
  .theme-toggle { grid-column: 2; grid-row: 1; }
  .nav-deck { grid-column: 1 / -1; grid-row: 2; justify-content: stretch; }
  .nav-deck a { flex: 1 1 0; justify-content: center; }
  .draw-stage, .practice-layout { grid-template-columns: 1fr; }
  .live-strip { min-height: 240px; }
  .live-strip::before { width: 46%; opacity: 0.68; background-size: 100% 100%, 620px auto; }
  .recent-card { min-height: 0; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
  .rule-grid { grid-template-columns: 1fr; }
  .rule-grid article:last-child { grid-column: auto; }
  .progress-card { order: -1; }
}

@media (max-width: 560px) {
  .site-header { width: calc(100% - 16px); margin-top: 7px; padding: 7px; }
  .brand { min-width: 0; }
  .brand img { width: 38px; height: 38px; }
  .brand strong { font-size: 1.45rem; }
  .brand small { display: none; }
  .nav-deck { gap: 2px; }
  .nav-deck a { min-width: 0; min-height: 36px; padding: 6px 4px; flex-direction: column; gap: 1px; font-size: 0.65rem; line-height: 1; }
  .nav-deck a::before { width: 17px; height: 17px; flex-basis: 17px; }
  .theme-toggle { width: 38px; height: 38px; }
  main { width: calc(100% - 16px); padding-top: 8px; }
  .draw-stage { gap: 8px; }
  .live-strip { min-height: 232px; padding: 14px; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; }
  .live-meta { gap: 3px 8px; }
  .live-meta time { font-size: 0.7rem; }
  .equation { gap: 5px; }
  .equation b { width: 45px; height: 45px; border-width: 2px; font-size: 1.42rem; }
  .equation em { min-width: 51px; height: 47px; font-size: 1.5rem; }
  .live-countdown strong { font-size: 1.48rem; }
  .live-status { font-size: 0.73rem; }
  .live-status span { padding: 3px 7px; }
  .recent-card .section-heading { min-height: 54px; padding: 8px 11px; }
  .section-heading h2 { font-size: 1.24rem; }
  .recent-list { padding: 3px 8px 6px; }
  .recent-list li { min-height: 47px; padding: 5px 2px; }
  .recent-list strong { font-size: 0.95rem; }
  .quick-actions { margin: 8px 0; gap: 6px; }
  .quick-link { min-height: 46px; padding: 6px; font-size: 0.78rem; }
  .practice-panel { padding: 14px; }
  .practice-header { display: grid; }
  .progress-mini { gap: 7px; }
  .answers { grid-template-columns: 1fr; }
  .question-digits { gap: 5px; }
  .question-digits span, .fixed-sample span { width: 43px; height: 43px; }
  .page-heading { padding: 14px 16px; }
  .page-heading h1 { font-size: 2rem; }
  .content-card, .rule-grid article, .boundary-table { padding: 16px; }
  .chat-profile { grid-template-columns: auto 1fr; }
  .connection-pill { grid-column: 1 / -1; justify-self: start; }
  .chat-form { grid-template-columns: 1fr; }
  .chat-form label, .chat-form-status { grid-column: auto; }
  .scratch-shell, .chat-shell { padding: 12px; }
  .scratch-ticket { min-height: 292px; }
  .scratch-result { min-height: 214px; }
  .site-footer { width: calc(100% - 16px); flex-direction: column; }
}

@media (max-width: 350px) {
  .nav-deck a { font-size: 0.59rem; }
  .live-strip { padding: 11px; }
  .equation { gap: 3px; }
  .equation b { width: 39px; height: 39px; font-size: 1.24rem; }
  .equation em { min-width: 44px; height: 42px; padding: 0 6px; font-size: 1.3rem; }
  .live-status span { padding: 3px 5px; }
  .recent-list strong { font-size: 0.84rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
.daily-data-brief{margin:1.5rem auto;padding:clamp(1rem,2.5vw,1.5rem);border:2px solid var(--line,#d3c6e8);border-radius:1rem;background:var(--card,#fff);box-shadow:0 10px 28px rgba(55,31,87,.08)}
.daily-data-brief h2{margin:.15rem 0 .75rem;font-size:clamp(1.35rem,3vw,1.8rem)}
.daily-data-brief .daily-facts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.75rem;margin:1rem 0;padding:0;list-style:none}
.daily-data-brief .daily-facts li{padding:.8rem;border-radius:.75rem;background:rgba(117,76,178,.09)}
.daily-data-brief details{margin-top:.65rem;padding:.75rem;border:1px solid var(--line,#d3c6e8);border-radius:.75rem}
.daily-data-brief .daily-links{display:flex;flex-wrap:wrap;gap:.8rem;margin-top:1rem}
@media(max-width:640px){.daily-data-brief .daily-facts{grid-template-columns:1fr}}
