/* HSKMax — feuille de style unique, écrite pour ce projet.
   Deux registres : l'interface (sobre, moderne) et la copie d'examen
   (papier, sérif, mise en page fidèle au 样卷 officiel). */

:root {
  --red: #c1272d;
  --red-bright: #df1f25;
  --red-dark: #8f1d21;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --paper: #fffdf8;
  --desk: #e9e6df;
  --gold: #d89a2b;
  --line: #d8d2c4;
  --ok: #2e9e4f;
  --ok-bg: #e6f6ea;
  --ko: #d33;
  --ko-bg: #fdecec;
  --focus: #2b6cb0;
  --radius: 10px;
  --sheet-w: 880px;
  --serif: 'Noto Serif SC', Georgia, serif;
  --sans: 'Noto Sans SC', 'Segoe UI', system-ui, sans-serif;
  --latin: 'Noto Sans', 'Segoe UI', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(circle at 0 28%, rgba(193, 39, 45, .10) 0 1px, transparent 2px),
    radial-gradient(circle at 100% 38%, rgba(216, 154, 43, .12) 0 1px, transparent 2px),
    linear-gradient(180deg, #fffaf1 0%, #f4efe4 58%, #ebe7df 100%);
  background-size: 42px 42px, 54px 54px, auto;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
}

img { max-width: 100%; height: auto; }

/* Le pinyin doit utiliser une police latine : les fontes CJK rendent mal
   les macrons et les carons. */
.py { font-family: var(--latin); }

a { color: var(--red); }

/* ---------------------------------------------------------------- accueil */

.site-header {
  position: relative;
  min-height: 64px;
  background:
    radial-gradient(circle at 4% 50%, rgba(255, 255, 255, .11) 0 1px, transparent 2px),
    radial-gradient(circle at 78% 20%, rgba(255, 255, 255, .08), transparent 28%),
    linear-gradient(135deg, #9d0005 0%, var(--red) 52%, #db1f25 100%);
  background-size: 22px 22px, auto, auto;
  color: #fff;
  padding: 7px 22px;
  display: flex;
  align-items: center;
  border-radius: 0 0 18px 18px;
  box-shadow: 0 10px 28px rgba(112, 15, 18, .20);
}
.site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  background: linear-gradient(90deg, transparent, rgba(255, 226, 161, .95), transparent);
}
.site-brand {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
}
.service-button {
  margin-left: 0;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 50%;
  background: linear-gradient(135deg, #d71920 0%, #aa0509 100%);
  color: #fff;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .22),
    0 8px 18px rgba(70, 0, 0, .18);
}
.ai-button {
  position: relative;
  margin-left: auto;
  overflow: visible;
  color: #fff4c9;
  background: linear-gradient(135deg, #b8090e 0%, #860005 100%);
}
.ai-button span {
  position: absolute;
  right: -3px;
  bottom: -3px;
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 3px;
  border: 2px solid #c91f25;
  border-radius: 999px;
  color: #8d0005;
  background: #fff4d2;
  font: 900 8px/1 var(--sans);
  letter-spacing: 0;
  box-shadow: 0 3px 8px rgba(60, 0, 0, .25);
}
.service-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}
.service-button svg {
  width: 23px;
  height: 23px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.profile-button {
  text-decoration: none;
  margin-left: 0;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, .82);
  background: #d8dde4 url('../img/default-profile-avatar.png') center / cover no-repeat;
  color: transparent;
  border-radius: 50%;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .72),
    0 8px 18px rgba(70, 0, 0, .16);
}
.profile-button:hover {
  transform: translateY(-1px);
  background: #d8dde4 url('../img/default-profile-avatar.png') center / cover no-repeat;
  filter: brightness(1.04);
}
.profile-button.has-photo {
  background-position: center;
  background-size: cover;
}
.profile-button.has-photo:hover {
  filter: brightness(1.04);
}
.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 8px 18px rgba(70, 0, 0, .24);
}
.site-brand strong {
  display: block;
  font-family: var(--serif);
  font-size: clamp(1.25rem, 3vw, 1.58rem);
  letter-spacing: .08em;
  line-height: 1;
}
.site-brand small {
  display: block;
  margin-top: 3px;
  font-family: var(--serif);
  font-size: .66rem;
  letter-spacing: .22em;
  opacity: .92;
}

.wrap {
  position: relative;
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 17px 38px;
}
.wrap::before,
.wrap::after {
  content: "";
  position: fixed;
  pointer-events: none;
  opacity: .24;
  z-index: -1;
}
.wrap::before {
  left: -24px;
  top: 170px;
  width: 190px;
  height: 360px;
  background:
    radial-gradient(circle at 16% 12%, #d23 0 2px, transparent 3px),
    linear-gradient(135deg, transparent 18%, rgba(120, 120, 120, .25) 19% 20%, transparent 21%),
    radial-gradient(ellipse at 55% 78%, rgba(90, 90, 90, .24), transparent 56%);
  border-radius: 50%;
}
.wrap::after {
  right: -90px;
  top: 190px;
  width: 220px;
  height: 220px;
  border: 12px solid rgba(216, 154, 43, .16);
  border-radius: 50%;
}

.credit-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(22, 16, 14, .58);
  backdrop-filter: blur(8px);
}
.credit-dialog {
  position: relative;
  width: min(460px, 100%);
  background: #fffdf8;
  border: 1px solid rgba(216, 154, 43, .45);
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
}
.credit-dialog h2 {
  margin: 0 34px 14px 0;
  font-family: var(--serif);
  font-size: 1.7rem;
  color: var(--red);
  line-height: 1.15;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
}
.modal-message { margin: 0 0 12px; }
.modal-note {
  color: var(--muted);
  font-size: .92rem;
  margin: 10px 0 16px;
}
.modal-note.success { color: var(--ok); font-weight: 700; }
.modal-note.error { color: var(--ko); font-weight: 700; }
.credit-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 12px 14px;
  font: inherit;
  outline: none;
}
.credit-input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, .14);
}
.code-input {
  text-transform: uppercase;
  letter-spacing: .16em;
  font-weight: 800;
}
.modal-main-action {
  width: 100%;
  justify-content: center;
  padding: 12px 16px;
}
.modal-actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.generator-actions {
  grid-template-columns: 1fr 1fr;
}
.secondary-action,
.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 9px;
  padding: 9px 14px;
  text-decoration: none;
  font-weight: 800;
}
.secondary-action {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--red);
}
.primary-link {
  background: var(--red);
  color: #fff;
}
.wallet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}
.wallet-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.wallet-card span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
}
.wallet-card b {
  display: block;
  margin-top: 4px;
  color: var(--red);
  font-size: 1.45rem;
  line-height: 1;
}
.wallet-card.total {
  background: #fff6e4;
  border-color: rgba(216, 154, 43, .45);
}
.profile-email {
  margin: -4px 0 10px;
  color: var(--muted);
  word-break: break-word;
}
.code-stock-output {
  width: 100%;
  min-height: 220px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  resize: vertical;
  font: 700 .78rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #211816;
  white-space: pre;
}
body.modal-open { overflow: hidden; }
body.profile-route .site-header {
  display: none;
}
body.profile-route {
  background: var(--desk);
}
body.profile-route .wrap {
  min-height: 100vh;
  padding-top: 18px;
}
body.level-route {
  background: var(--desk);
}
body.level-route .wrap {
  min-height: calc(100vh - 76px);
}
body.install-welcome-route {
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 12%, rgba(255,255,255,.18), transparent 26%),
    linear-gradient(135deg, #970006 0%, #c1272d 54%, #e32228 100%);
}
body.install-welcome-route .site-header {
  display: none;
}
body.install-welcome-route .wrap {
  min-height: 100vh;
  padding: 0;
  max-width: none;
}

.profile-page {
  display: grid;
  gap: 16px;
  max-width: 860px;
  margin: 0 auto;
}
.profile-topbar {
  position: relative;
  display: block;
  min-height: 66px;
  margin: -18px calc(50% - 50vw) 0;
  padding: 12px max(18px, calc((100vw - 860px) / 2 + 18px));
  overflow: hidden;
  background:
    radial-gradient(circle at 4% 50%, rgba(255, 255, 255, .11) 0 1px, transparent 2px),
    radial-gradient(circle at 78% 20%, rgba(255, 255, 255, .08), transparent 28%),
    linear-gradient(135deg, #9d0005 0%, var(--red) 52%, #db1f25 100%);
  background-size: 22px 22px, auto, auto;
  color: #fff;
  border-radius: 0 0 18px 18px;
  box-shadow: 0 10px 28px rgba(112, 15, 18, .20);
}
.profile-topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  background: linear-gradient(90deg, transparent, rgba(255, 226, 161, .95), transparent);
}
.profile-topbar h1 {
  margin: 0;
  color: #fff;
  font-family: var(--serif);
  font-size: clamp(1.45rem, 4vw, 2rem);
  line-height: 1;
}
.profile-topbar-center {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: min(48vw, 320px);
  transform: translate(-50%, -50%);
  text-align: center;
  min-width: 0;
  pointer-events: none;
}
.profile-topbar-center p {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, .84);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .04em;
}
.profile-exit {
  position: absolute;
  left: max(18px, calc((100vw - 860px) / 2 + 18px));
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  z-index: 1;
  min-height: 40px;
  padding: 8px 13px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .48);
  color: #fff;
  text-decoration: none;
  font-weight: 900;
  box-shadow: 0 8px 22px rgba(70, 0, 0, .14);
}
.profile-topbar .logout-button {
  position: absolute;
  right: max(18px, calc((100vw - 860px) / 2 + 18px));
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .48);
  color: #fff;
  font-size: 0;
}
.profile-topbar .logout-button::before {
  content: none;
}
.profile-topbar-actions {
  position: absolute;
  right: max(18px, calc((100vw - 860px) / 2 + 18px));
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.profile-topbar-actions .logout-button,
.profile-topbar-actions .profile-service-button {
  position: static;
  transform: none;
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .48);
  color: #fff;
  border-radius: 50%;
  font-size: 0;
}
.profile-topbar-actions .logout-button svg,
.profile-topbar-actions .profile-service-button svg {
  width: 22px;
  height: 22px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.profile-topbar-actions .logout-button:hover,
.profile-topbar-actions .profile-service-button:hover {
  background: rgba(255, 255, 255, .20);
}
.profile-topbar-spacer {
  justify-self: end;
  width: 1px;
}
.profile-hero {
  position: relative;
  min-height: 130px;
  display: grid;
  place-items: center stretch;
  text-align: left;
  padding: 22px 116px 22px 92px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 18% 20%, rgba(193, 39, 45, .12), transparent 28%),
    radial-gradient(circle at 86% 10%, rgba(216, 154, 43, .18), transparent 26%),
    linear-gradient(135deg, #fffdf8 0%, #fff6e7 100%);
  border: 1px solid rgba(216, 154, 43, .35);
  box-shadow: 0 18px 48px rgba(82, 62, 32, .12);
}
.profile-hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.75rem, 4vw, 2.55rem);
  color: var(--red);
  line-height: 1.05;
}
.profile-hero p {
  margin: 5px 0 0;
  color: var(--muted);
}
.profile-kicker {
  margin: 0 0 8px !important;
  color: var(--gold) !important;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: .78rem;
}
.profile-back {
  top: 14px;
  left: 14px;
}
.profile-panel {
  background: rgba(255, 253, 248, .92);
  border: 1px solid rgba(216, 210, 196, .88);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 12px 34px rgba(82, 62, 32, .09);
}
.profile-panel h2 {
  margin: 0;
  font-family: var(--serif);
  color: var(--red);
  font-size: 1.45rem;
  line-height: 1.15;
}
.profile-page:not(.admin-page) .profile-panel h2 {
  color: var(--ink);
  font-family: var(--latin);
  font-size: .96rem;
  font-weight: 900;
}
.profile-empty {
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  gap: 14px;
}
.profile-title-row {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
  text-align: left;
}
.profile-title-row > div {
  width: 100%;
}
.profile-email.large {
  font-size: .98rem;
  margin: 4px 0 0;
}
.profile-user-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 15px;
  padding-right: 58px;
}
.profile-user-info {
  min-width: 0;
}
.profile-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink) !important;
  font-size: clamp(1.35rem, 4vw, 1.9rem) !important;
}
.profile-name-edit {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-family: var(--serif);
  font-size: clamp(1.35rem, 4vw, 1.9rem);
  font-weight: 900;
  line-height: 1.12;
  cursor: pointer;
}
.profile-name-edit span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
}
.edit-pencil {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #fff3d8;
  border: 1px solid rgba(216, 154, 43, .42);
  color: var(--red);
  font-family: var(--latin);
  font-size: .95rem;
  line-height: 1;
}
.profile-card-edit {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  background: rgba(17, 24, 39, .06);
  border: 1px solid rgba(17, 24, 39, .12);
  color: #111827;
  font-family: var(--latin);
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
}
.profile-card-edit:hover {
  background: rgba(17, 24, 39, .10);
}
.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.profile-identity {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 18px;
  width: 100%;
}
.profile-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: #d8dde4 url('../img/default-profile-avatar.png') center / cover no-repeat;
  color: transparent;
  font-family: var(--latin);
  font-weight: 900;
  letter-spacing: .06em;
  border: 3px solid rgba(255, 255, 255, .94);
  box-shadow: 0 10px 24px rgba(31, 41, 55, .16);
}
.profile-avatar.large {
  width: 82px;
  height: 82px;
  font-size: 1.38rem;
}
.profile-avatar-button {
  cursor: pointer;
  background-position: center;
  background-size: cover;
}
.profile-avatar-button:hover {
  transform: translateY(-1px);
  filter: saturate(1.05);
}
.profile-avatar.has-photo {
  color: transparent;
  background-position: center;
  background-size: cover;
}
.profile-photo-wrap {
  position: relative;
  display: grid;
  place-items: center;
}
.profile-photo-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.logout-button {
  position: absolute;
  top: 14px;
  right: 14px;
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .78);
  color: var(--red);
  font-weight: 800;
}
.profile-wallet-summary {
  position: relative;
  overflow: hidden;
  display: block;
  border-radius: 18px;
  padding: 16px;
  background:
    radial-gradient(circle at 92% 18%, rgba(216, 154, 43, .18), transparent 28%),
    linear-gradient(135deg, #fff 0%, #fff8eb 100%);
  border: 1px solid rgba(216, 154, 43, .34);
}
.profile-wallet-summary::after {
  content: "";
  position: absolute;
  right: -34px;
  bottom: -34px;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: rgba(193, 39, 45, .08);
}
.wallet-total-line {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
}
.wallet-total-line span {
  color: var(--muted);
  font-weight: 900;
}
.wallet-total-line b {
  color: var(--red);
  font-size: clamp(1.8rem, 5vw, 2.45rem);
  line-height: 1;
}
.wallet-breakdown {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid rgba(216, 154, 43, .22);
}
.wallet-pill {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 39px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .78);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: clamp(.76rem, 2.8vw, .92rem);
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
  padding: 8px 10px;
}
.wallet-pill.free { color: #217a3d; }
.wallet-pill.paid { color: #a66b14; }
.profile-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  margin-top: 12px;
}
.history-list {
  display: grid;
  gap: 8px;
}
.history-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  text-align: left;
}
.history-row:hover { background: #fff8eb; }
.history-main {
  min-width: 0;
}
.history-main b,
.history-main time {
  display: block;
}
.history-main b {
  overflow: hidden;
  color: var(--ink);
  font-size: .95rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-main time {
  margin-top: 3px;
  color: var(--muted);
  font-size: .78rem;
}
.history-amount {
  min-width: 92px;
  border-radius: 999px;
  padding: 4px 9px;
  text-align: center;
  font-weight: 900;
  font-size: .88rem;
}
.history-amount.positive {
  background: var(--ok-bg);
  color: var(--ok);
}
.history-amount.negative {
  background: var(--ko-bg);
  color: var(--ko);
}
.history-empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, .58);
}
.bottom-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  align-items: end;
  background: rgba(22, 16, 14, .58);
  backdrop-filter: blur(7px);
}
.bottom-sheet {
  width: min(720px, calc(100% - 20px));
  max-height: min(78vh, 620px);
  overflow: auto;
  margin: 0 auto 10px;
  padding: 10px 18px 18px;
  border: 1px solid rgba(216, 154, 43, .36);
  border-radius: 24px 24px 18px 18px;
  background: #fffdf8;
  box-shadow: 0 -18px 60px rgba(0, 0, 0, .26);
}
.sheet-handle {
  width: 52px;
  height: 5px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: #d8d2c4;
}
.sheet-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: start;
}
.sheet-head h2 {
  margin: 0;
  color: var(--red);
  font-family: var(--serif);
  font-size: 1.55rem;
  line-height: 1.15;
}
.sheet-close {
  position: static;
}
.sheet-amount {
  display: inline-flex;
  margin: 14px 0;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 900;
}
.sheet-amount.positive {
  background: var(--ok-bg);
  color: var(--ok);
}
.sheet-amount.negative {
  background: var(--ko-bg);
  color: var(--ko);
}
.sheet-detail-list {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}
.sheet-detail-row {
  display: grid;
  grid-template-columns: minmax(120px, .8fr) 1.2fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.sheet-detail-row span {
  color: var(--muted);
}
.sheet-detail-row b {
  text-align: right;
}
.admin-hero {
  background:
    radial-gradient(circle at 16% 22%, rgba(255, 255, 255, .18), transparent 26%),
    linear-gradient(135deg, #8f1d21 0%, #c1272d 60%, #df1f25 100%);
}
.admin-hero h1,
.admin-hero p,
.admin-hero .profile-kicker {
  color: #fff !important;
}
.admin-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  border: 1px solid rgba(216, 154, 43, .34);
  border-radius: 18px;
  padding: 18px;
  background: #fff;
}
.admin-card b,
.admin-card span {
  display: block;
}
.admin-card b {
  color: var(--red);
  font-size: 1.1rem;
}
.admin-card span {
  color: var(--muted);
  margin-top: 4px;
}
.admin-stats-auth {
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}
.admin-stats-auth .primary {
  min-height: 48px;
  white-space: nowrap;
}
.admin-stats-content {
  margin-top: 18px;
}
.admin-stats-empty {
  margin: 0;
  padding: 22px;
  border: 1px dashed rgba(193, 39, 45, .28);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
  background: rgba(193, 39, 45, .025);
}
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.admin-stat-card {
  min-height: 118px;
  padding: 18px;
  border: 1px solid rgba(216, 154, 43, .3);
  border-radius: 16px;
  background: linear-gradient(145deg, #fff, #fffaf1);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.admin-stat-card strong {
  color: var(--red);
  font: 700 2rem/1.05 "Noto Serif SC", serif;
}
.admin-stat-card span {
  margin-top: 8px;
  color: var(--muted);
  font-size: .9rem;
}
.admin-daily {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.admin-daily h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}
.admin-daily-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(90px, .7fr) minmax(110px, .8fr);
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.admin-daily-row span {
  color: var(--muted);
  text-align: right;
}
.admin-tracking-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: .88rem;
}
.whatsapp-admin-page {
  max-width: 1180px;
}
.whatsapp-auth-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 360px);
  gap: 10px 18px;
  align-items: center;
}
.whatsapp-auth-panel .admin-stats-auth {
  margin: 0;
}
.whatsapp-auth-panel .modal-note {
  grid-column: 1;
  margin: 0;
}
.whatsapp-search {
  grid-column: 2;
  grid-row: 1 / span 2;
  margin: 0;
}
.whatsapp-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  min-height: 520px;
}
.whatsapp-column {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(216, 154, 43, .32);
  border-radius: 20px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 14px 38px rgba(87, 54, 22, .08);
}
.whatsapp-column > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #fff8ea, #fff);
}
.whatsapp-column.done > header {
  background: linear-gradient(135deg, #edf9f0, #fff);
}
.whatsapp-column h2 {
  margin: 0;
  color: #202020;
  font-size: 1.15rem;
}
.whatsapp-column-count {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  min-height: 34px;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
  background: var(--red);
  font-weight: 900;
}
.whatsapp-column-count.done {
  background: #21844a;
}
.whatsapp-contact-list {
  max-height: min(65vh, 680px);
  overflow-y: auto;
  padding: 8px;
  scrollbar-gutter: stable;
}
.whatsapp-contact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 8px;
  align-items: center;
  min-height: 50px;
  margin: 4px 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #fffaf3;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.whatsapp-contact-row:hover {
  transform: translateY(-1px);
  border-color: rgba(193, 39, 45, .28);
  background: #fff;
}
.whatsapp-contact-row.contacted {
  background: #f3faf5;
}
.whatsapp-phone-link {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 48px;
  padding: 8px 6px 8px 12px;
  color: #222;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}
.whatsapp-phone-link::before {
  content: "";
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  margin-right: 10px;
  border-radius: 50%;
  background: #25d366;
  box-shadow: 0 0 0 4px rgba(37, 211, 102, .13);
}
.whatsapp-open-mark,
.whatsapp-undo {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  color: var(--red);
  background: rgba(193, 39, 45, .08);
  font-size: 1.2rem;
  font-weight: 900;
}
.whatsapp-undo {
  cursor: pointer;
  color: #1d7741;
  background: rgba(33, 132, 74, .10);
}
.whatsapp-undo:hover {
  background: rgba(33, 132, 74, .20);
}
.whatsapp-empty {
  margin: 20px 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 860px) {
  .profile-button {
    width: 36px;
    height: 36px;
  }
  .wallet-grid {
    grid-template-columns: 1fr;
  }
  .generator-actions {
    grid-template-columns: 1fr;
  }
  .profile-page {
    gap: 16px;
  }
  .profile-topbar {
    min-height: 66px;
  }
  .profile-topbar-center {
    width: min(54vw, 230px);
  }
  .profile-topbar h1 {
    font-size: 1.55rem;
  }
  .profile-topbar-center p {
    font-size: .68rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .profile-exit {
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    justify-content: center;
    width: 38px;
    min-height: 36px;
    padding: 0;
    border-radius: 12px;
    font-size: 0;
  }
  .profile-exit::before {
    content: "‹";
    font-size: 1.5rem;
    line-height: 1;
  }
  .profile-hero {
    min-height: 136px;
    padding: 58px 16px 18px;
    text-align: left;
    place-items: center;
  }
  .profile-panel {
    padding: 14px;
    border-radius: 16px;
  }
  .profile-identity {
    grid-template-columns: auto 1fr;
    justify-items: stretch;
    gap: 12px;
  }
  .profile-user-card {
    gap: 12px;
    padding-right: 50px;
  }
  .profile-avatar.large {
    width: 70px;
    height: 70px;
    font-size: 1.12rem;
  }
  .logout-button {
    width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    font-size: 0;
  }
  .profile-topbar .logout-button {
    right: 18px;
  }
  .profile-topbar-actions {
    right: 18px;
    gap: 7px;
  }
  .profile-topbar-actions .logout-button,
  .profile-topbar-actions .profile-service-button {
    width: 38px;
    height: 38px;
    min-height: 38px;
  }
  .profile-topbar .logout-button::before {
    content: none;
  }
  .profile-title-row,
  .profile-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .profile-wallet-summary {
    padding: 14px;
  }
  .wallet-total-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
  .wallet-breakdown {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .wallet-pill {
    min-height: 34px;
    font-size: .72rem;
    padding: 6px 6px;
  }
  .history-row {
    grid-template-columns: 1fr auto;
  }
  .bottom-sheet {
    width: 100%;
    margin-bottom: 0;
    border-radius: 22px 22px 0 0;
  }
  .sheet-detail-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .sheet-detail-row b {
    text-align: left;
  }
  .admin-card {
    grid-template-columns: 1fr;
  }
  .admin-stats-auth,
  .admin-daily-row {
    grid-template-columns: 1fr;
  }
  .admin-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .admin-daily-row span {
    text-align: left;
  }
  .whatsapp-auth-panel {
    grid-template-columns: 1fr;
  }
  .whatsapp-auth-panel .modal-note,
  .whatsapp-search {
    grid-column: 1;
    grid-row: auto;
  }
  .whatsapp-board {
    gap: 10px;
    min-height: 440px;
  }
  .whatsapp-column > header {
    min-height: 58px;
    padding: 10px 12px;
  }
  .whatsapp-column h2 {
    font-size: .98rem;
  }
  .whatsapp-column-count {
    min-width: 34px;
    min-height: 30px;
    padding: 3px 8px;
    font-size: .82rem;
  }
  .whatsapp-contact-list {
    max-height: 58vh;
    padding: 5px;
  }
  .whatsapp-contact-row {
    grid-template-columns: minmax(0, 1fr) 30px;
    gap: 2px;
  }
  .whatsapp-phone-link {
    padding-left: 8px;
    font-size: .78rem;
  }
  .whatsapp-phone-link::before {
    flex-basis: 7px;
    width: 7px;
    height: 7px;
    margin-right: 7px;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, .13);
  }
  .whatsapp-open-mark,
  .whatsapp-undo {
    width: 27px;
    height: 27px;
    font-size: 1rem;
  }
}

.levels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 21px;
  margin-top: 0;
}

.home-levels {
  max-width: 735px;
  margin: 8px auto 0;
  gap: 20px;
}
.install-banner {
  grid-column: 1 / -1;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  display: block;
  padding: 10px 14px max(10px, env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid rgba(216, 210, 196, .95);
  box-shadow: 0 -10px 28px rgba(42, 28, 18, .16);
}
body.has-install-footer .wrap {
  padding-bottom: 92px;
}
.install-banner-main {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  background: var(--red);
  color: #fff;
  font-weight: 900;
  font-size: .98rem;
  cursor: pointer;
}
.install-banner-main:hover {
  background: var(--red-dark);
  color: #fff;
}
.home-wallet-card {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 13px;
  padding: 14px 15px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 92% 18%, rgba(216, 154, 43, .20), transparent 28%),
    linear-gradient(135deg, #fff 0%, #fff8ec 100%);
  border: 1px solid rgba(216, 154, 43, .34);
  box-shadow: 0 14px 34px rgba(82, 62, 32, .12);
}
.home-wallet-buy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(193, 39, 45, .10);
  color: var(--red);
  text-decoration: none;
  font-size: .72rem;
  font-weight: 900;
  border: 1px solid rgba(193, 39, 45, .18);
  white-space: nowrap;
}
.home-wallet-buy:hover {
  background: var(--red);
  color: #fff;
}
.home-wallet-main {
  min-width: 0;
  width: 100%;
  display: grid;
  gap: 3px;
}
.home-wallet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.home-wallet-buy {
  margin-left: auto;
}
.home-wallet-label {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.home-wallet-main strong {
  color: var(--red);
  font-size: clamp(1.42rem, 4vw, 2rem);
  line-height: 1;
}
.home-wallet-main small {
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.home-wallet-action {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  min-width: 0;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  text-decoration: none;
  font-weight: 900;
  cursor: pointer;
}

@media (min-width: 861px) {
  .home-wallet-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px 18px;
    padding: 18px 20px;
  }

  .home-wallet-head {
    grid-column: 1 / -1;
  }

  .home-wallet-main {
    grid-column: 1;
    grid-row: 2;
  }

  .home-wallet-action {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    width: auto;
    min-width: 250px;
    min-height: 46px;
    padding: 0 34px;
    font-size: 1.04rem;
  }

  .home-wallet-card.guest .home-wallet-action {
    min-width: 170px;
  }
}
.home-wallet-action:hover {
  background: var(--red-dark);
  color: #fff;
  filter: brightness(1.04);
}
.home-wallet-action:focus-visible {
  background: var(--red-dark);
  color: #fff;
}

.home-level-square {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border-radius: 28px;
  color: #fff;
  text-decoration: none;
  font-family: var(--serif);
  font-size: clamp(2rem, 4.4vw, 3.1rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: .02em;
  border: 1px solid rgba(255, 255, 255, .48);
  box-shadow:
    0 18px 42px rgba(82, 62, 32, .18),
    inset 0 1px 0 rgba(255, 255, 255, .34);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}

.home-level-square:hover {
  transform: translateY(-4px);
  filter: saturate(1.06);
  box-shadow:
    0 24px 52px rgba(82, 62, 32, .24),
    inset 0 1px 0 rgba(255, 255, 255, .34);
}

.home-level-square.level-1 { background: linear-gradient(135deg, #d71920, #f25b3f); }
.home-level-square.level-2 { background: linear-gradient(135deg, #d78312, #f0b43d); }
.home-level-square.level-3 { background: linear-gradient(135deg, #16834b, #36b66a); }
.home-level-square.level-4 { background: linear-gradient(135deg, #1769aa, #35a0df); }
.home-level-square.level-5 { background: linear-gradient(135deg, #6b3bbd, #9a6ee8); }
.home-level-square.level-6 { background: linear-gradient(135deg, #2d2d35, #676875); }

.install-welcome-page {
  min-height: 100vh;
}
.install-hero {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto auto 1fr auto;
  gap: 18px;
  padding: max(28px, env(safe-area-inset-top)) 22px max(22px, env(safe-area-inset-bottom));
  color: #fff;
  overflow: hidden;
}
.install-hero::selection {
  background: rgba(255,255,255,.28);
}
.install-hero::before,
.install-hero::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
}
.install-hero::before {
  width: 240px;
  height: 240px;
  top: -80px;
  right: -90px;
  background: rgba(255,255,255,.16);
}
.install-hero::after {
  width: 220px;
  height: 220px;
  left: -100px;
  bottom: 112px;
  border: 22px solid rgba(255, 226, 161, .18);
}
.install-graffiti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.install-graffiti span {
  position: absolute;
  font-family: var(--serif);
  font-weight: 900;
  line-height: 1;
  color: rgba(255, 255, 255, .105);
  text-shadow:
    0 0 1px rgba(255, 226, 161, .26),
    0 12px 30px rgba(80, 0, 0, .12);
  transform: rotate(var(--r));
  user-select: none;
}
.install-graffiti .g1 { --r: -16deg; top: 10%; left: -3%; font-size: 7.8rem; }
.install-graffiti .g2 { --r: 13deg; top: 17%; right: 4%; font-size: 5.8rem; color: rgba(255, 226, 161, .12); }
.install-graffiti .g3 { --r: -9deg; top: 47%; left: 7%; font-size: 4.8rem; }
.install-graffiti .g4 { --r: 18deg; bottom: 21%; right: -2%; font-size: 8.2rem; color: rgba(255, 226, 161, .10); }
.install-graffiti .g5 { --r: -22deg; bottom: 10%; left: 16%; font-size: 3.9rem; opacity: .65; }
.install-hero-logo {
  position: relative;
  z-index: 1;
  align-self: end;
  justify-self: center;
  width: 112px;
  height: 112px;
  border-radius: 22px;
  object-fit: cover;
  box-shadow: 0 18px 44px rgba(50, 0, 0, .28);
}
.install-hero-copy {
  position: relative;
  z-index: 1;
  align-self: start;
  text-align: center;
}
.install-kicker {
  margin: 0 0 8px;
  color: rgba(255,255,255,.78);
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.install-hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.35rem, 11vw, 3.6rem);
  line-height: .95;
  letter-spacing: .045em;
}
.install-subtitle {
  max-width: 34rem;
  margin: 18px auto 0;
  color: rgba(255,255,255,.90);
  font-size: 1.04rem;
  line-height: 1.55;
}
.install-bottom-actions {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
}
.install-primary,
.install-later {
  width: 100%;
  min-height: 54px;
  border-radius: 999px;
  font-weight: 900;
  cursor: pointer;
}
.install-primary {
  border: 0;
  background: #fff;
  color: var(--red);
  box-shadow: 0 14px 30px rgba(64, 0, 0, .20);
}
.install-primary:hover {
  background: #fff7e6;
}
.install-later {
  border: 1px solid rgba(255,255,255,.36);
  background: rgba(255,255,255,.10);
  color: #fff;
}
.install-later:hover {
  background: rgba(255,255,255,.16);
}
.language-choice-page .install-hero {
  grid-template-rows: auto auto 1fr auto;
  gap: 14px;
  padding-top: max(18px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.language-hero .install-hero-copy {
  align-self: center;
}
.language-hero .install-hero-copy h1 {
  font-size: clamp(1.75rem, 7.5vw, 2.55rem);
}
.language-hero .install-subtitle {
  margin-top: 8px;
  font-size: .9rem;
  line-height: 1.35;
}
.language-hero .install-hero-logo {
  width: 78px;
  height: 78px;
  align-self: end;
}
.language-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 460px);
  margin: 0 auto;
  align-self: center;
}
.language-option {
  min-height: 54px;
  border: 1px solid rgba(255, 255, 255, .30);
  border-radius: 17px;
  background: rgba(255, 255, 255, .13);
  color: #fff;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 3px;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(60, 0, 0, .12);
}
.language-option:hover {
  background: rgba(255, 255, 255, .22);
}
.language-option.is-selected {
  background: rgba(255, 255, 255, .92);
  color: var(--red);
  border-color: rgba(255, 226, 161, .85);
}
.language-native {
  font-family: var(--serif);
  font-size: .98rem;
  font-weight: 900;
}
.language-option small {
  color: rgba(255, 255, 255, .76);
  font-weight: 800;
}
.language-option.is-disabled {
  opacity: .38;
  cursor: not-allowed;
  filter: grayscale(.2);
}
.language-option.is-disabled:hover {
  background: rgba(255, 255, 255, .13);
}
.language-actions {
  width: min(100%, 460px);
  margin: 0 auto;
  gap: 8px;
}
.language-actions .install-primary,
.language-actions .install-later {
  min-height: 48px;
}
.install-steps {
  margin: 0 0 12px 1.2rem;
  padding: 0;
  color: var(--ink);
  line-height: 1.65;
}

.level-page {
  display: block;
}

.level-page-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 0 0 18px;
}

.level-page-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  color: var(--red);
}

.level-page-head p { margin: 0; color: var(--muted); }

.back-levels {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--red);
  text-decoration: none;
  font-weight: 800;
  box-shadow: 0 3px 14px rgba(0, 0, 0, .06);
}

.exam-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.exam-grid .level-card {
  min-height: 168px;
  gap: 8px;
}
.exam-grid .level-card .lv {
  font-family: var(--serif);
  font-size: 1.65rem;
  color: var(--red);
}
.exam-grid .progress-ring { display: none; }
.exam-grid .card-stats { padding-right: 0; }

@media (max-width: 860px) {
  .levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .exam-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-levels {
    width: min(100%, 94%);
    gap: 15px;
  }
}

@media (max-width: 860px) {
  .level-page-head { align-items: stretch; flex-direction: column; }
  .levels { grid-template-columns: 1fr; }
  .home-levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-level-square { border-radius: 22px; font-size: 2.15rem; }
  .exam-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .site-header { min-height: 58px; border-radius: 0 0 14px 14px; padding: 6px 12px; }
  .brand-logo { width: 42px; height: 42px; border-radius: 11px; }
  .service-button {
    width: 36px;
    height: 36px;
    min-height: 36px;
  }
  .home-wallet-card {
    padding: 12px;
    border-radius: 18px;
  }
  .home-wallet-action {
    min-height: 36px;
    min-width: 0;
    padding: 0 11px;
    font-size: .82rem;
  }
  .progress-ring { width: 66px; height: 66px; top: 44px; right: 20px; }
  .card-stats { padding-right: 70px; }
}

@media (max-width: 430px) {
  .site-brand {
    gap: 7px;
  }
  .site-brand > span {
    min-width: 0;
  }
  .site-brand strong {
    font-size: 1.14rem;
    letter-spacing: .055em;
    white-space: nowrap;
  }
  .site-brand small {
    overflow: hidden;
    font-size: .58rem;
    letter-spacing: .15em;
    white-space: nowrap;
  }
  .home-wallet-card {
    flex-direction: column;
    align-items: stretch;
  }
  .home-wallet-action {
    width: 100%;
  }
}

.level-card {
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(216, 210, 196, .95);
  border-radius: 14px;
  padding: 24px 24px 20px;
  min-height: 218px;
  box-shadow: 0 12px 30px rgba(82, 62, 32, .12);
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-decoration: none;
  color: inherit;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.home-levels .level-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,.98), rgba(255,255,255,.94)),
    radial-gradient(circle at 86% 26%, rgba(193, 39, 45, .08), transparent 28%);
}
.home-levels .level-card::before,
.exam-grid .level-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--red), var(--red-bright));
}
a.level-card:hover {
  transform: translateY(-4px);
  border-color: rgba(193, 39, 45, .30);
  box-shadow: 0 18px 38px rgba(82, 62, 32, .18);
}
.level-card .lv {
  font-family: var(--latin);
  font-size: clamp(2rem, 4vw, 2.55rem);
  font-weight: 900;
  color: #101922;
  line-height: 1;
}
.home-levels .level-card .lv em {
  margin-left: 4px;
  font-family: var(--serif);
  font-style: normal;
  color: var(--red);
  font-size: 1.22em;
  font-weight: 900;
}
.progress-ring {
  position: absolute;
  top: 48px;
  right: 24px;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    conic-gradient(var(--red-bright) var(--progress), #eee9e1 0),
    #f6f2ec;
  box-shadow: inset 0 0 0 1px rgba(216, 210, 196, .55);
}
.progress-ring::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .06);
}
.progress-ring span {
  position: relative;
  z-index: 1;
  color: #17202a;
  font-family: var(--latin);
  font-weight: 900;
  font-size: 1rem;
}
.level-card .hz { font-family: var(--serif); font-size: 1.05rem; }
.level-card .meta { color: var(--muted); font-size: .9rem; }
.level-card.is-draft { opacity: .62; cursor: default; }
.card-corner {
  position: absolute;
  top: 12px;
  right: 16px;
  color: rgba(216, 154, 43, .48);
  font-size: 1.45rem;
  line-height: 1;
}
.card-stats {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 10px;
  padding-right: 80px;
}
.card-stats span {
  display: inline-grid;
  grid-template-columns: auto auto;
  column-gap: 7px;
  align-items: center;
  color: #1b2229;
  font-weight: 700;
}
.card-stats b {
  grid-row: span 2;
  color: var(--red-bright);
  font-size: 1.15rem;
}
.card-stats small {
  grid-column: 2;
  display: block;
  margin-top: -2px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 500;
}
.audio-badge {
  align-self: flex-end;
  margin-top: auto;
  margin-bottom: -2px;
  padding: 5px 12px;
  border-radius: 999px;
  background: #fff1f1;
  color: var(--red);
  font-size: .78rem;
  font-weight: 700;
}
.audio-badge::before { content: "♫ "; }

.tag {
  align-self: flex-start;
  margin-top: 6px;
  font-size: .74rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
}
.tag.ready { background: var(--ok-bg); color: #1c6b35; }
.tag.draft { background: #f0ede6; color: #6b6b6b; }
.tag.action {
  align-self: stretch;
  margin-top: 0;
  padding: 10px 14px;
  border-radius: 9px;
  text-align: center;
  color: #fff;
  background: linear-gradient(180deg, var(--red-bright), #bd070d);
  box-shadow: 0 8px 16px rgba(193, 39, 45, .22);
  font-size: .92rem;
  text-transform: none;
  letter-spacing: 0;
}
.tag.action.draft { background: #aaa; box-shadow: none; }

/* ----------------------------------------------------- pages de niveau */

.level-page-head {
  position: relative;
  min-height: 148px;
  margin: -8px -10px 24px;
  padding: 10px 18px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-align: center;
  background:
    radial-gradient(circle at 4% 74%, rgba(88, 111, 70, .14) 0 1px, transparent 2px),
    radial-gradient(circle at 84% 28%, rgba(70, 60, 48, .08), transparent 26%),
    linear-gradient(180deg, rgba(255, 250, 241, .84), rgba(255, 250, 241, .34));
}
.level-profile-button {
  display: none;
}
.level-page-head::before,
.level-page-head::after {
  content: "";
  position: absolute;
  pointer-events: none;
  opacity: .28;
}
.level-page-head::before {
  left: -56px;
  bottom: -20px;
  width: 220px;
  height: 118px;
  border-left: 2px solid rgba(83, 96, 65, .38);
  border-radius: 50%;
  transform: rotate(-13deg);
  box-shadow:
    38px -18px 0 -36px rgba(83, 96, 65, .8),
    72px -40px 0 -34px rgba(83, 96, 65, .7),
    108px -22px 0 -35px rgba(83, 96, 65, .75);
}
.level-page-head::after {
  right: -44px;
  top: 0;
  width: 260px;
  height: 130px;
  background:
    radial-gradient(ellipse at 72% 86%, rgba(86, 82, 74, .20), transparent 52%),
    radial-gradient(ellipse at 36% 92%, rgba(86, 82, 74, .13), transparent 45%);
}
.level-title-wrap {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
}
.level-page-head h2 {
  margin: 0;
  color: #151515;
  font-family: var(--serif);
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: .02em;
  text-shadow: 0 2px 0 rgba(216, 154, 43, .16);
}
.title-rule {
  position: relative;
  width: min(290px, 70%);
  height: 1px;
  margin: 12px auto 10px;
  background: linear-gradient(90deg, transparent, rgba(216, 154, 43, .9), transparent);
}
.title-rule::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  border: 1px solid var(--gold);
  background: #fff8eb;
  transform: translate(-50%, -50%) rotate(45deg);
}
.level-subtitle {
  margin: 0;
  color: #252525;
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.7vw, 1.55rem);
}
.level-count {
  margin: 2px 0 0;
  color: #9f5f12;
  font-family: var(--serif);
  font-size: .98rem;
}
.back-levels {
  position: absolute;
  left: 18px;
  top: 12px;
  z-index: 2;
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--red);
  font-family: var(--serif);
  font-weight: 800;
  font-size: 1rem;
  text-decoration: none;
}
.back-levels:hover { color: var(--red-dark); }

.exam-grid {
  gap: 22px;
}

.exam-square {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border-radius: 20px;
  color: #fff;
  text-decoration: none;
  font-family: var(--serif);
  font-size: clamp(1.55rem, 3.5vw, 2.25rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: .02em;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, .48);
  box-shadow:
    0 16px 34px rgba(82, 62, 32, .16),
    inset 0 1px 0 rgba(255, 255, 255, .32);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}

@media (min-width: 861px) {
  .level-page .exam-grid {
    max-width: 735px;
    margin: 0 auto;
    gap: 21px;
  }
}

a.exam-square:hover {
  transform: translateY(-4px);
  filter: saturate(1.06);
  box-shadow:
    0 22px 44px rgba(82, 62, 32, .22),
    inset 0 1px 0 rgba(255, 255, 255, .32);
}

.exam-square.level-1 { background: linear-gradient(135deg, #d71920, #f25b3f); }
.exam-square.level-2 { background: linear-gradient(135deg, #d78312, #f0b43d); }
.exam-square.level-3 { background: linear-gradient(135deg, #16834b, #36b66a); }
.exam-square.level-4 { background: linear-gradient(135deg, #1769aa, #35a0df); }
.exam-square.level-5 { background: linear-gradient(135deg, #6b3bbd, #9a6ee8); }
.exam-square.level-6 { background: linear-gradient(135deg, #2d2d35, #676875); }
.exam-square.is-draft {
  opacity: .45;
  filter: grayscale(.25);
}

.exam-grid .exam-card {
  min-height: 188px;
  padding: 24px 24px 18px;
  gap: 12px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.99), rgba(255,255,255,.96)),
    radial-gradient(circle at 92% 14%, rgba(216,154,43,.07), transparent 28%);
}
.exam-grid .exam-card::before {
  height: 4px;
  background: linear-gradient(90deg, #a70008, #e01820);
}
.exam-grid .exam-card .lv {
  font-family: var(--serif);
  font-size: clamp(1.65rem, 3vw, 2rem);
  font-weight: 900;
  color: var(--red);
  letter-spacing: .02em;
  padding-right: 90px;
}
.exam-progress-ring {
  position: absolute;
  top: 22px;
  right: 22px;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    conic-gradient(var(--red-bright) var(--progress), #eee9e1 0),
    #f7f3eb;
  box-shadow: inset 0 0 0 1px rgba(216, 210, 196, .72);
}
.exam-progress-ring::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .06);
}
.exam-progress-ring span {
  position: relative;
  z-index: 1;
  color: #17202a;
  font-family: var(--latin);
  font-size: 1rem;
  font-weight: 900;
}
.exam-card-info {
  display: grid;
  gap: 8px;
  margin: 2px 0 4px;
  color: #252525;
  font-family: var(--latin);
  font-size: .9rem;
}
.exam-card-info span {
  display: flex;
  align-items: center;
  gap: 10px;
}
.exam-card-info b { font-weight: 500; }
.info-icon {
  position: relative;
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  color: var(--gold);
}
.info-icon.doc {
  border: 1.8px solid currentColor;
  border-radius: 2px;
}
.info-icon.doc::after {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  top: 4px;
  height: 1px;
  background: currentColor;
  box-shadow: 0 4px 0 currentColor;
}
.info-icon.audio::before {
  content: "♪";
  position: absolute;
  inset: -6px 0 0 -1px;
  color: var(--red-bright);
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
}
.info-icon.progress {
  border: 2px solid rgba(216, 154, 43, .70);
  border-radius: 50%;
}
.info-icon.progress::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 2px;
  height: 6px;
  background: var(--gold);
  border-radius: 2px;
  transform-origin: 50% 5px;
  transform: rotate(45deg);
}
.info-icon.check {
  border-radius: 50% 50% 45% 45%;
  background: var(--ok);
}
.info-icon.check::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 6px;
  height: 3px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg);
}
.compose-btn {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 5px;
  background: linear-gradient(180deg, var(--red-bright), #bd070d);
  color: #fff;
  font-family: var(--latin);
  font-size: .9rem;
  font-weight: 700;
  box-shadow: 0 8px 14px rgba(193, 39, 45, .18);
}
.exam-card.is-draft .compose-btn {
  background: #aaa;
  box-shadow: none;
}

@media (max-width: 860px) {
  .level-page-head { margin-left: 0; margin-right: 0; }
  .exam-grid { gap: 18px; }
}

@media (max-width: 560px) {
  body.level-route .site-header {
    display: none;
  }
  body.level-route .wrap {
    padding-top: 0;
  }
  .level-page-head {
    min-height: 74px;
    margin: 0 calc(50% - 50vw) 18px;
    padding: 10px 18px 14px;
    display: block;
    overflow: hidden;
    background:
      radial-gradient(circle at 4% 50%, rgba(255, 255, 255, .11) 0 1px, transparent 2px),
      radial-gradient(circle at 78% 20%, rgba(255, 255, 255, .08), transparent 28%),
      linear-gradient(135deg, #9d0005 0%, var(--red) 52%, #db1f25 100%);
    background-size: 22px 22px, auto, auto;
    color: #fff;
    border-radius: 0 0 18px 18px;
    box-shadow: 0 10px 28px rgba(112, 15, 18, .20);
  }
  .level-page-head::before,
  .level-page-head::after {
    display: block;
  }
  .level-page-head::before {
    inset: auto 0 0;
    left: 0;
    width: 100%;
    height: 5px;
    border: 0;
    border-radius: 0;
    transform: none;
    opacity: 1;
    background: linear-gradient(90deg, transparent, rgba(255, 226, 161, .95), transparent);
    box-shadow: none;
  }
  .level-page-head::after {
    display: none;
  }
  .level-title-wrap {
    position: absolute;
    left: 50%;
    width: min(54vw, 240px);
    min-width: 0;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
  }
  .level-page-head h2 {
    font-size: 1.75rem;
    line-height: 1;
    color: #fff;
    text-shadow: none;
  }
  .level-subtitle {
    display: none;
  }
  .level-page-head .level-count {
    margin-top: 4px;
    font-family: var(--latin);
    font-size: .75rem;
    color: rgba(255, 255, 255, .86);
    white-space: nowrap;
  }
  .back-levels {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    min-height: 38px;
    padding: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .48);
    color: #fff;
    box-shadow: 0 8px 20px rgba(70, 0, 0, .14);
    font-family: var(--latin);
    font-size: 0;
  }
  .back-levels::before {
    content: "‹";
    font-size: 1.5rem;
    line-height: 1;
  }
  .level-profile-button {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    display: block;
    margin-left: 0;
    width: 38px;
    height: 38px;
  }
  .level-profile-button:hover {
    transform: translateY(-50%);
  }
  .title-rule { display: none; }
  .exam-grid {
    width: min(100%, 94%);
    margin-left: auto;
    margin-right: auto;
  }
  .exam-grid .exam-card { min-height: 157px; padding: 20px 18px 16px; }
}

.notice {
  margin: 34px 0 0;
  padding: 16px 18px;
  background: #fff8e8;
  border: 1px solid #e8d9a8;
  border-left: 4px solid #d3a52b;
  border-radius: 6px;
  font-size: .95rem;
}

/* ------------------------------------------------------------ barre haute */

.navbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
}
.navbar a.back {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, .45);
  white-space: nowrap;
}
.navbar a.back:hover { background: rgba(255, 255, 255, .14); }
.navbar .crumb { font-weight: 700; line-height: 1.2; }
.navbar .crumb small { display: block; font-weight: 400; opacity: .85; font-size: .78rem; }
.timer-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 116px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .50);
  background: rgba(255, 255, 255, .13);
  color: #fff;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18);
}
.timer-toggle[hidden] { display: none; }
.timer-toggle:hover { background: rgba(255, 255, 255, .20); }
.timer-toggle.is-paused {
  background: #fff;
  color: var(--red);
}
.timer-toggle.is-expired {
  background: var(--red-dark);
  color: #fff;
}
.timer-toggle.is-finished {
  opacity: .72;
  cursor: default;
}
.timer-icon {
  width: 1.2em;
  text-align: center;
  line-height: 1;
}
.timer-text { min-width: 48px; text-align: right; }

.pause-overlay {
  position: fixed;
  inset: 0;
  z-index: 26;
  display: grid;
  place-items: center;
  padding: 96px 18px 28px;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, .30), transparent 24%),
    rgba(20, 16, 14, .76);
  backdrop-filter: blur(12px);
}
.pause-overlay[hidden] { display: none; }
.pause-card {
  width: min(420px, 100%);
  text-align: center;
  background: #fffdf8;
  border: 1px solid rgba(216, 154, 43, .44);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
}
.pause-title {
  font-family: var(--serif);
  font-size: 1.65rem;
  font-weight: 900;
  color: var(--red);
}
.pause-card p {
  margin: 8px 0 20px;
  color: var(--muted);
}
body.exam-paused {
  overflow: hidden;
}

@media (max-width: 620px) {
  .navbar {
    gap: 8px;
    padding: 8px 10px;
  }
  .navbar a.back {
    padding: 6px 8px;
  }
  .timer-toggle {
    min-width: 92px;
    padding: 7px 10px;
    gap: 5px;
  }
  .timer-text { min-width: 42px; }
}

.toolbar {
  position: sticky;
  top: 46px;
  z-index: 29;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
}
button {
  font: inherit;
  cursor: pointer;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px 14px;
  transition: background .12s ease;
}
button:hover { background: #f4f1ea; }
button.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--red-dark); }
button:focus-visible, .selectable:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.score {
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: #f4f1ea;
  border-radius: 999px;
  padding: 6px 16px;
}
.score.done { background: var(--ok-bg); color: #1c6b35; }

/* ------------------------------------------------------------- la « copie » */

.sheet {
  max-width: var(--sheet-w);
  margin: 26px auto;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 4px 22px rgba(0, 0, 0, .16);
  padding: 38px 44px;
}
@media (max-width: 620px) { .sheet { padding: 22px 16px; margin: 16px 8px; } }

/* ----------------------------------------------------------- HSK Master */
.hsk-master-modal {
  z-index: 120;
  padding: 14px;
  background: rgba(30, 20, 18, .48);
  backdrop-filter: blur(10px);
}
.hsk-master-dialog {
  width: min(480px, 100%);
  height: min(790px, calc(100dvh - 28px));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(136, 47, 31, .18);
  border-radius: 26px;
  background: #fffaf6;
  box-shadow: 0 28px 90px rgba(31, 16, 11, .32);
}
.hsk-master-head {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 44px 56px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 88px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(136, 47, 31, .14);
  background: rgba(255, 253, 250, .96);
}
.hsk-master-avatar {
  display: block;
  width: 56px;
  height: 56px;
  border-radius: 17px;
  object-fit: cover;
  object-position: 50% 38%;
  border: 2px solid #fff;
  background: #ead8cc;
  box-shadow: 0 8px 20px rgba(72, 31, 20, .18), 0 0 0 1px rgba(136, 47, 31, .12);
}
.hsk-master-identity {
  min-width: 0;
}
.hsk-master-head h2 {
  margin: 0;
  overflow: hidden;
  color: #201815;
  font: 900 1.28rem/1.2 var(--sans);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hsk-master-head p {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 4px 0 0;
  color: #73816e;
  font-size: .92rem;
}
.hsk-master-online-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #52b788;
  box-shadow: 0 0 0 3px rgba(82, 183, 136, .14);
}
.hsk-master-head-actions {
  display: flex;
  gap: 8px;
}
.hsk-master-head-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(136, 47, 31, .18);
  border-radius: 15px;
  color: #713023;
  background: #fff;
  cursor: pointer;
}
.hsk-master-head-button:hover,
.hsk-master-head-button:focus-visible {
  background: #fff4ee;
}
.hsk-master-head-button svg,
.hsk-master-settings svg,
.hsk-ai-header-menu svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hsk-master-back svg {
  width: 24px;
  height: 24px;
}
.hsk-ai-header-menu {
  position: absolute;
  z-index: 5;
  top: calc(100% - 5px);
  right: 16px;
  width: min(240px, calc(100vw - 32px));
  overflow: hidden;
  padding: 6px;
  border: 1px solid rgba(136, 47, 31, .16);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(58, 26, 17, .2);
}
.hsk-ai-header-menu[hidden] {
  display: none;
}
.hsk-ai-header-menu button {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: 11px;
  color: #432d27;
  background: transparent;
  font: 750 .88rem/1.2 var(--sans);
  text-align: left;
  cursor: pointer;
}
.hsk-ai-header-menu button:hover,
.hsk-ai-header-menu button:focus-visible {
  background: #fff3ed;
}
.hsk-master-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0 0 3px;
  border: 1px solid rgba(136, 47, 31, .18);
  border-radius: 15px;
  color: #7c2c1e;
  background: #fff;
  font: 400 1.7rem/1 var(--sans);
  cursor: pointer;
}
.hsk-master-close:hover {
  background: #fff4ee;
}
.hsk-master-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 26px 20px 30px;
  background:
    radial-gradient(circle at 15% 18%, rgba(193, 39, 45, .035) 0 1px, transparent 2px),
    linear-gradient(180deg, #fffdfb, #fff9f4);
  background-size: 30px 30px, auto;
}
.hsk-master-date {
  align-self: center;
  margin: 4px 0 10px;
  color: #9b8a83;
  font-size: .82rem;
  font-weight: 800;
  text-transform: capitalize;
}
.hsk-master-message {
  position: relative;
  max-width: calc(100% - 52px);
  padding: 16px 18px;
  border-radius: 25px 25px 25px 8px;
  font-size: 1rem;
  line-height: 1.55;
  box-shadow: 0 12px 30px rgba(84, 45, 32, .07);
}
.hsk-master-message strong {
  display: block;
  margin-bottom: 7px;
  color: #211916;
  font-size: 1.08rem;
}
.hsk-master-message p {
  margin: 0;
}
.hsk-master-message.bot {
  align-self: flex-start;
  margin-left: 50px;
  border: 1px solid rgba(136, 47, 31, .17);
  color: #352925;
  background: #fff;
}
.hsk-master-message.bot::before {
  content: "";
  position: absolute;
  left: -51px;
  top: 0;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 2px solid #fff;
  background: #ead8cc url('/assets/hsk-ai-profile.webp') center 38% / cover no-repeat;
  box-shadow: 0 5px 14px rgba(72, 31, 20, .15), 0 0 0 1px rgba(136, 47, 31, .12);
}
.hsk-master-message.user {
  align-self: flex-end;
  border-radius: 25px 25px 8px 25px;
  color: #fff;
  background: linear-gradient(145deg, #d62b31, #a9060b);
  box-shadow: 0 12px 30px rgba(157, 0, 6, .17);
}
.hsk-master-message.user.voice {
  width: min(270px, calc(100% - 40px));
  padding: 8px 10px;
}
.hsk-master-message.user.voice audio {
  display: block;
  width: 100%;
  height: 38px;
}
.hsk-ai-reply-audio {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}
.hsk-ai-reply-audio audio {
  display: block;
  width: min(280px, 100%);
  height: 38px;
}
.hsk-ai-reply-audio small {
  color: #7b6f69;
  font-size: 11px;
  line-height: 1.2;
}
.hsk-master-composer {
  flex: 0 0 auto;
  border-top: 1px solid rgba(136, 47, 31, .13);
  padding: 12px 14px 14px;
  background: #f8eee8;
}
.hsk-master-selection {
  display: grid;
  gap: 12px;
}
.hsk-master-level-group > b {
  display: block;
  margin: 0 0 7px 2px;
  color: #493833;
  font-size: .85rem;
}
.hsk-master-levels {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 1px 1px 4px;
  scrollbar-width: none;
}
.hsk-master-levels::-webkit-scrollbar {
  display: none;
}
.hsk-master-level {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid rgba(136, 47, 31, .22);
  border-radius: 999px;
  color: #6d4036;
  background: #fff;
  font: 800 .8rem/1 var(--sans);
  cursor: pointer;
}
.hsk-master-level.selected {
  border-color: var(--red);
  color: #fff;
  background: var(--red);
  box-shadow: 0 7px 16px rgba(193, 39, 45, .2);
}
.hsk-master-feedback {
  min-height: 18px;
  margin: 0;
  color: var(--red);
  font-size: .78rem;
}
.hsk-master-next {
  min-height: 46px;
  justify-content: center;
  border-radius: 14px;
  font-size: .94rem;
}
.hsk-master-input-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px auto;
  gap: 8px;
  align-items: center;
  min-height: 58px;
  padding: 7px 8px;
  border: 1px solid rgba(136, 47, 31, .2);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 9px 24px rgba(84, 45, 32, .08);
}
.hsk-master-settings {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  color: #815448;
  background: #fff4ee;
  cursor: pointer;
}
.hsk-master-settings:hover,
.hsk-master-settings:focus-visible {
  color: #fff;
  background: var(--red);
}
.hsk-master-microphone {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #7a4c42;
  background: #fff4ee;
  cursor: pointer;
}
.hsk-master-microphone svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hsk-master-microphone:hover,
.hsk-master-microphone:focus-visible {
  color: #fff;
  background: var(--red);
}
.hsk-master-microphone.recording {
  color: #fff;
  background: #d4000a;
  animation: hsk-ai-recording-pulse 1.15s ease-in-out infinite;
}
.hsk-master-microphone:disabled,
.hsk-master-send:disabled,
.hsk-master-settings:disabled {
  cursor: wait;
  opacity: .55;
}
@keyframes hsk-ai-recording-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 0, 10, .25); }
  50% { box-shadow: 0 0 0 7px rgba(212, 0, 10, 0); }
}
.hsk-master-input {
  min-width: 0;
  border: 0;
  outline: 0;
  color: #332825;
  background: transparent;
  font: inherit;
}
.hsk-master-input::placeholder {
  color: #b09f97;
}
.hsk-master-send {
  min-height: 44px;
  padding: 9px 16px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(145deg, #d62b31, #b5090f);
  font-weight: 900;
  cursor: pointer;
}

@media (max-width: 560px) {
  .hsk-master-modal {
    padding: 0;
    align-items: stretch;
    overscroll-behavior: none;
  }
  .hsk-master-dialog {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
    overscroll-behavior: contain;
  }
  .hsk-master-head {
    grid-template-columns: 36px 44px minmax(0, 1fr) auto;
    gap: 8px;
    min-height: 66px;
    padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  }
  .hsk-master-avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }
  .hsk-master-head h2 {
    font-size: 1.08rem;
  }
  .hsk-master-head p {
    margin-top: 2px;
    font-size: .8rem;
  }
  .hsk-master-close {
    width: 40px;
    height: 40px;
    border-radius: 13px;
  }
  .hsk-master-head-actions {
    gap: 6px;
  }
  .hsk-master-head-button {
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }
  .hsk-master-head-button svg {
    width: 19px;
    height: 19px;
  }
  .hsk-master-back svg {
    width: 22px;
    height: 22px;
  }
  .hsk-ai-header-menu {
    top: calc(100% - 3px);
    right: 10px;
  }
  .hsk-master-messages {
    gap: 11px;
    padding: 14px 12px 18px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .hsk-master-message {
    max-width: calc(100% - 40px);
    padding: 12px 13px;
    border-radius: 20px 20px 20px 7px;
    font-size: .92rem;
    line-height: 1.45;
  }
  .hsk-master-message.bot {
    margin-left: 40px;
  }
  .hsk-master-message.bot::before {
    left: -40px;
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }
  .hsk-master-composer {
    max-height: 48dvh;
    overflow-y: auto;
    padding: 9px 10px max(9px, env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
  }
  .hsk-master-selection {
    gap: 9px;
  }
  .hsk-master-levels {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    overflow: visible;
    padding: 0;
  }
  .hsk-master-level {
    min-width: 0;
    min-height: 34px;
    padding: 7px 4px;
    font-size: .74rem;
    text-align: center;
  }
  .hsk-master-next {
    min-height: 42px;
  }
  .hsk-master-input-row {
    grid-template-columns: 30px minmax(0, 1fr) 30px auto;
    gap: 5px;
    min-height: 52px;
    padding: 5px 6px;
    border-radius: 17px;
  }
  .hsk-master-settings {
    width: 30px;
    height: 30px;
  }
  .hsk-master-settings svg {
    width: 18px;
    height: 18px;
  }
  .hsk-master-microphone {
    width: 30px;
    height: 30px;
  }
  .hsk-master-microphone svg {
    width: 18px;
    height: 18px;
  }
  .hsk-master-input {
    width: 100%;
    font-size: 16px;
  }
  .hsk-master-send {
    min-height: 40px;
    max-width: 112px;
    padding: 8px 12px;
    overflow: hidden;
    font-size: .84rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 360px) {
  .hsk-master-levels {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .hsk-master-send {
    max-width: 92px;
    padding-inline: 9px;
  }
}

.cover { text-align: center; border: 3px double var(--ink); }
.cover img.logo {
  display: block;
  width: min(100%, 420px);
  height: auto;
  object-fit: contain;
  margin: 0 auto 16px;
}
.cover h1 {
  font-family: var(--serif); font-weight: 900;
  font-size: 2.4em; letter-spacing: .15em; margin: .3em 0 .1em;
}
.cover h2 { font-family: var(--serif); font-weight: 700; font-size: 1.6em; margin: .2em 0 1em; }
.cover .note-title { font-weight: 700; font-size: 1.12em; margin: 1.3em 0 .5em; }
.cover .rules { text-align: left; max-width: 560px; margin: 0 auto; line-height: 2; }
.cover .rules p { margin: .3em 0; }

.section-title {
  font-family: var(--serif); font-weight: 900; font-size: 1.5em;
  text-align: center; letter-spacing: .3em;
  border-bottom: 2px solid var(--ink); padding-bottom: .3em; margin: 0 0 1em;
}
.part-title { font-family: var(--serif); font-size: 1.2em; margin: 1.6em 0 .2em; }
.range-title { color: #555; margin: 0 0 1em; }

/* — vrai / faux — */
.vx-row {
  display: grid; grid-template-columns: 42px 1fr 120px;
  align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px dashed var(--line);
}
.vx-num { font-weight: 700; text-align: center; }
.vx-img img { max-height: 120px; }
.vx-choice { display: flex; gap: 8px; justify-content: center; }

.selectable {
  border: 1.5px solid var(--ink); border-radius: 7px;
  padding: 6px 12px; cursor: pointer; background: #fff;
  user-select: none; transition: background .12s ease, border-color .12s ease;
}
.selectable:hover { background: #f2efe7; }
.selectable[aria-pressed="true"] { background: var(--ink); color: #fff; }
.selectable.correct { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.selectable.wrong { background: var(--ko-bg); border-color: var(--ko); color: var(--ko); }
.selectable.reveal { border-style: dashed; border-color: var(--ok); color: var(--ok); }

.fixed { border: 1.5px solid var(--ok); color: var(--ok); border-radius: 7px; padding: 6px 12px; }

/* — trois images — */
.abc-row {
  display: grid; grid-template-columns: 42px repeat(3, 1fr);
  gap: 10px; align-items: stretch;
  padding: 12px 0; border-bottom: 1px dashed var(--line);
}
.abc-num { font-weight: 700; align-self: center; text-align: center; }
.abc-cell {
  border: 1.5px solid var(--ink); border-radius: 8px; padding: 8px;
  text-align: center; cursor: pointer; background: #fff;
}
.abc-cell:hover { background: #f2efe7; }
.abc-cell[aria-pressed="true"] { border-width: 3px; background: #f0ece2; }
.abc-cell.correct { background: var(--ok-bg); border-color: var(--ok); }
.abc-cell.wrong { background: var(--ko-bg); border-color: var(--ko); }
.abc-cell.reveal { border-style: dashed; border-color: var(--ok); }
.abc-cell .letter { font-weight: 700; margin-top: 4px; }

/* — banque A–F — */
.bank {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; border: 1.5px solid var(--ink); border-radius: 8px;
  padding: 12px; margin-bottom: 16px; background: #fff;
}
.bank .cell { text-align: center; }
.bank .cell img { max-height: 100px; }
.bank .cell .letter { font-weight: 700; }
.bank .cell .py { display: block; font-size: .82em; color: #666; }
.bank .cell .hz { font-family: var(--serif); }

/* — appariement / texte à trou — */
.q-row {
  display: grid; grid-template-columns: 48px 1fr auto;
  gap: 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px dashed var(--line);
}
@media (max-width: 620px) {
  .q-row { grid-template-columns: 40px 1fr; }
  .q-row .picker { grid-column: 2; }
  .abc-row { grid-template-columns: 34px repeat(3, 1fr); }
  .vx-row { grid-template-columns: 34px 1fr 104px; }
}
.q-num { font-weight: 700; text-align: center; }
.q-body .py { display: block; font-size: .86em; color: #666; }
.q-body .hz { font-family: var(--serif); font-size: 1.08em; }
.picker { display: flex; gap: 6px; flex-wrap: wrap; }
.picker .selectable { min-width: 38px; text-align: center; font-weight: 700; padding: 6px 9px; }

.blank {
  display: inline-block; min-width: 62px; text-align: center;
  border-bottom: 2px solid var(--ink); font-weight: 700;
  padding: 0 6px; margin: 0 3px;
}
.blank.filled { color: var(--red); }

/* — options textuelles — */
.opts { display: flex; gap: 10px; flex-wrap: wrap; }
.opts .selectable { flex: 1 1 150px; text-align: center; }
.opts .py { display: block; font-size: .82em; color: #666; }
.opts .hz { font-family: var(--serif); }
.text-options.text-abc .opts {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
}
.text-options.text-abc .opts .selectable {
  flex: 1 0 30%;
  min-width: 92px;
}
.script {
  background: #f6f3ea; border-left: 3px solid var(--line);
  padding: 10px 14px; margin: 10px 0; font-family: var(--serif);
}

.example-flag {
  display: inline-block; font-size: .78rem; font-weight: 700;
  background: #eef3fb; color: #2b6cb0; border-radius: 999px;
  padding: 2px 9px; margin-right: 8px;
}
.example { opacity: .8; }

.audio-note {
  background: #fff8e8; border: 1px solid #e8d9a8; border-left: 4px solid #d3a52b;
  border-radius: 6px; padding: 14px 16px; margin: 0 0 18px; font-size: .94rem;
}

.audio-sheet { padding: 18px 22px; }
.audio-player {
  display: grid;
  gap: 10px;
}
.audio-title {
  color: var(--muted);
  font-size: .94rem;
}
.audio-player audio {
  width: 100%;
}

.submit-zone {
  max-width: var(--sheet-w);
  margin: 28px auto 70px;
  padding: 0 18px;
  display: flex;
  justify-content: center;
}
.submit-zone .primary {
  min-width: min(100%, 320px);
  padding: 14px 22px;
  font-size: 1.05rem;
  box-shadow: 0 10px 22px rgba(197, 31, 39, .18);
}

.result-panel {
  position: sticky; bottom: 0; z-index: 28;
  background: #fff; border-top: 2px solid var(--red);
  padding: 14px 18px; box-shadow: 0 -3px 14px rgba(0, 0, 0, .1);
  display: none;
}
.result-panel.show { display: block; }
.result-panel .big { font-size: 1.3rem; font-weight: 800; }
.certificate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 12px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(197, 31, 39, .18);
}
.certificate-btn:hover {
  background: var(--red-dark);
}
.certificate-btn:disabled {
  cursor: wait;
  opacity: .78;
}
.certificate-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 13, 8, .62);
}
.certificate-preview-sheet {
  width: min(100%, 760px);
  max-height: min(92vh, 980px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-radius: 22px;
  background: #fffaf0;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .28);
  overflow: hidden;
}
.certificate-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  background: var(--red);
  color: #fff;
}
.certificate-preview-head strong {
  font-size: 1rem;
}
.certificate-preview-close {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  cursor: pointer;
}
.certificate-preview-close svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}
.certificate-preview-image-wrap {
  min-height: 0;
  overflow: auto;
  padding: 18px;
  background: #ead9bd;
}
.certificate-preview-image {
  display: block;
  width: min(100%, 520px);
  margin: 0 auto;
  border-radius: 3px;
  box-shadow: 0 16px 40px rgba(64, 36, 10, .24);
}
.certificate-preview-actions {
  padding: 14px 16px 16px;
  display: flex;
  justify-content: center;
  background: #fffaf0;
}
.certificate-preview-download {
  min-width: min(100%, 280px);
  min-height: 44px;
  border-radius: 999px;
}

.site-footer {
  text-align: center; color: #6b6b6b; font-size: .86rem;
  padding: 26px 18px 40px;
}

/* mot à valider, au 阅读 第一部分 : à côté de l'image, comme sur l'original */
.vx-img { display: flex; align-items: center; gap: 26px; }
.vx-mot { text-align: center; }
.vx-mot .py { display: block; font-size: .85em; color: #666; }
.vx-mot .hz { font-family: var(--serif); font-size: 1.25em; }

/* affirmation à juger, niveau 2 阅读 第三部分 */
.texte-vx .q-body { line-height: 1.75; }
.texte-vx .claim {
  display: flex; gap: 8px; align-items: baseline;
  margin-top: 10px; padding: 8px 12px;
  background: #f6f3ea; border-left: 3px solid var(--red); border-radius: 4px;
}
.texte-vx .claim .star { color: var(--red); font-size: 1.05em; }

/* partie écriture : fragments à remettre en ordre, et saisie libre */
.ecriture .jetons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.ecriture .jeton {
  font-family: var(--serif); font-size: 1.1em;
  border: 1.5px solid var(--ink); border-radius: 6px; padding: 4px 12px;
  background: #fff;
}
.ecriture .indice { display: block; color: #666; font-size: .86em; }
.saisie {
  display: block; margin-top: 10px; width: 100%;
  font: inherit; font-family: var(--serif); font-size: 1.05em;
  padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 7px;
  background: #fff;
}
.saisie:focus { outline: 3px solid var(--focus); outline-offset: 1px; }
.saisie.correct { border-color: var(--ok); background: var(--ok-bg); }
.saisie.wrong { border-color: var(--ko); background: var(--ko-bg); }
.texte-vx .opts { margin-top: 10px; }

/* remise en ordre de trois segments, et phrase à partir d'une image */
.ordre3 .segs { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.ordre3 .seg { display: flex; gap: 10px; align-items: baseline; }
.ordre3 .seg b { color: var(--red); min-width: 1.2em; }
.ordre3 .seg .hz { font-family: var(--serif); }
.picker.ordres .selectable { letter-spacing: .12em; }
.mot-image { display: flex; align-items: center; gap: 20px; }
.mot-image img { max-height: 130px; border: 1px solid var(--line); border-radius: 6px; }
.mot-image .mot .hz { font-family: var(--serif); font-size: 1.4em; }
.mot-image .mot .py { display: block; font-size: .85em; color: #666; }

/* sujet de rédaction */
.redaction .consigne { font-family: var(--serif); display: block; }
.redaction .illus { max-height: 220px; margin: 12px 0; border: 1px solid var(--line); border-radius: 6px; }
.redaction textarea.saisie { resize: vertical; min-height: 6em; }
.note-libre { color: #6b6b6b; font-size: .86rem; margin: 8px 0 0; }

/* code officiel de l'épreuve, sous son intitulé */
.level-card .ref {
  font-family: var(--latin); font-size: .82rem; letter-spacing: .04em;
  color: var(--red); font-weight: 600;
}

/* ---- niveau 6 ------------------------------------------------------- */

/* Les quatre jeux de mots occupent chacun une ligne entière : mis côte à
   côte, ils passaient à la ligne au milieu d'un mot. */
.opts.jeux { flex-direction: column; gap: 6px; }
.opts.jeux .selectable { flex: 1 1 auto; text-align: left; display: flex; gap: 12px; }
.lettre { color: var(--red); font-weight: 700; min-width: 1.2em; }

/* La banque de phrases est une liste, pas une grille de vignettes. */
.bank.phrases {
  display: block; margin: 10px 0 12px; padding: 10px 14px;
}
.bank.phrases .cell {
  display: flex; gap: 12px; text-align: left; padding: 3px 0;
}

.regles { margin: 6px 0 14px; padding-left: 1.4em; color: #444; font-size: .92rem; }
.regles li { margin: 2px 0; }
.article {
  display: block; font-family: var(--serif); text-align: justify;
  line-height: 1.9; margin: 10px 0 14px;
}
