:root {
  /* Полосатый фон (как референс): золотистый + приглушённый голубо-серый */
  --stripe-gold: #c4b896;
  --stripe-blue: #b8c9d4;
  --stripe-warm: #d4c4a0;
  --cream: #fdf5e6;
  --cream-panel: rgba(253, 246, 234, 0.98);
  --surface: #fffdf7;
  --ink: #5c3d2e;
  --muted: #7d6a58;
  --muted-strong: #6e5d4d;
  --text-soft: #8d7a68;
  --line: rgba(92, 61, 46, 0.11);
  /* Акценты: «ржавый» коричневый вместо шалфея */
  --rust: #8b4513;
  --rust-hover: #6d3410;
  --rust-soft: #f0e6d4;
  --accent: #a0522d;
  --accent-hover: #8b4513;
  --accent-soft: #ede4d8;
  --ok: #5a6b42;
  --bad: #a94444;
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-display: "Caveat", cursive;
  /* Совместимость со старыми именами переменных */
  --bg: var(--cream);
  --sage: var(--accent);
  --sage-hover: var(--accent-hover);
  --sage-soft: var(--rust-soft);
  --wood: var(--rust);
  /* Только типографика ×1.25; отступы и размеры блоков без zoom */
  --text-scale: 1.25;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  /* Фон на корне: тянется на всю высоту документа (в т.ч. длинная коллекция в модалке) */
  min-height: 100%;
  background-color: var(--stripe-gold);
  background-image: repeating-linear-gradient(
    90deg,
    var(--stripe-gold) 0,
    var(--stripe-gold) 38px,
    var(--stripe-blue) 38px,
    var(--stripe-blue) 44px,
    var(--stripe-warm) 44px,
    var(--stripe-warm) 84px
  );
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  background: transparent;
  overflow-x: hidden;
}

body.app-auth-required .top-bar,
body.app-auth-required .phrase-bubbles,
body.app-auth-required #global-err,
body.app-auth-required .stage-root,
body.app-auth-required #modal-add,
body.app-auth-required #modal-card-peek {
  display: none !important;
}

code {
  font-size: calc(0.85em * var(--text-scale));
  opacity: 0.85;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.auth-gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: var(--cream);
}

.auth-gate-card {
  width: min(94vw, 440px);
  background: var(--surface);
  border: 1px solid rgba(139, 69, 19, 0.2);
  border-radius: 14px;
  box-shadow: 0 14px 40px rgba(40, 28, 20, 0.14);
  padding: 1.2rem 1.1rem 1.3rem;
  text-align: center;
}

.auth-gate-card.auth-gate-card--pending {
  width: min(94vw, 760px);
  min-height: 18rem;
  padding: 1.6rem 1.8rem 1.55rem;
  text-align: left;
}

.auth-gate-card.auth-gate-card--pending .auth-gate-title,
.auth-gate-card.auth-gate-card--pending .auth-gate-sub,
.auth-gate-card.auth-gate-card--pending .google-signin-btn-gate,
.auth-gate-card.auth-gate-card--pending .auth-gate-divider,
.auth-gate-card.auth-gate-card--pending .auth-email-form {
  display: none !important;
}

.auth-gate-title {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-size: calc(1.45rem * var(--text-scale));
  color: var(--rust);
}

.auth-gate-sub {
  margin: 0 0 0.85rem;
  font-size: calc(0.82rem * var(--text-scale));
  color: var(--muted);
}

.google-signin-btn-gate {
  min-height: 42px;
  display: flex;
  justify-content: center;
}

.auth-gate-divider {
  margin: 0.72rem 0 0.68rem;
  font-size: calc(0.72rem * var(--text-scale));
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.auth-email-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.auth-email-input {
  width: 100%;
  border: 1px solid rgba(92, 61, 46, 0.22);
  border-radius: 10px;
  background: #fffdf8;
  color: var(--ink);
  font-family: var(--font);
  font-size: calc(0.78rem * var(--text-scale));
  line-height: 1.2;
  padding: 0.56rem 0.65rem;
}

.auth-email-input:focus {
  outline: 2px solid rgba(160, 82, 45, 0.45);
  outline-offset: 1px;
}

.auth-email-submit {
  margin-top: 0.1rem;
}

.auth-email-switch,
.auth-email-link-btn {
  border: none;
  background: transparent;
  color: var(--rust);
  font-family: var(--font);
  font-size: calc(0.72rem * var(--text-scale));
  text-decoration: underline;
  cursor: pointer;
  padding: 0.12rem 0.2rem;
}

.auth-email-switch:hover,
.auth-email-link-btn:hover {
  color: var(--rust-hover);
}

.auth-email-link-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  text-decoration: none;
}

.auth-email-pending {
  text-align: left;
  border-top: 1px solid rgba(92, 61, 46, 0.12);
  margin-top: 0.66rem;
  padding-top: 0.7rem;
}

.auth-gate-card.auth-gate-card--pending .auth-email-pending {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
}

.auth-email-pending-title {
  margin: 0 0 0.62rem;
  font-weight: 600;
  color: var(--ink);
  font-size: clamp(calc(1.08rem * var(--text-scale)), 3.4vw, calc(1.46rem * var(--text-scale)));
  line-height: 1.1;
  letter-spacing: 0.005em;
}

.auth-email-pending-line {
  margin: 0 0 0.35rem;
  color: var(--ink);
  font-size: calc(0.74rem * var(--text-scale));
  line-height: 1.35;
}

.auth-gate-card.auth-gate-card--pending .auth-email-pending-line {
  font-size: clamp(calc(0.9rem * var(--text-scale)), 2.6vw, calc(1.06rem * var(--text-scale)));
  line-height: 1.28;
  margin-bottom: 0.52rem;
}

.auth-email-pending-muted {
  color: var(--muted);
}

.auth-email-pending-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  margin-top: 0.55rem;
}

.auth-gate-card.auth-gate-card--pending .auth-email-link-btn {
  font-size: calc(0.84rem * var(--text-scale));
  padding: 0;
}

.auth-gate-card.auth-gate-card--pending #auth-email-resend {
  min-width: 16.5rem;
  min-height: 2.55rem;
  border-radius: 999px;
  border: 1px solid rgba(139, 69, 19, 0.32);
  background: linear-gradient(180deg, #b06b46 0%, #9b5531 100%);
  color: #fffef8;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.35rem 1rem;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 8px 18px rgba(85, 48, 30, 0.22);
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.2s ease;
}

.auth-gate-card.auth-gate-card--pending #auth-email-resend:hover {
  background: linear-gradient(180deg, #b7754f 0%, #a15e39 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 10px 20px rgba(85, 48, 30, 0.25);
}

.auth-gate-card.auth-gate-card--pending #auth-email-resend:active {
  transform: translateY(1px);
}

.auth-gate-card.auth-gate-card--pending #auth-email-resend:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
}

.auth-gate-card.auth-gate-card--pending #auth-email-new-account {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  font-weight: 500;
}

.auth-gate-card.auth-gate-card--pending #auth-email-new-account:hover {
  color: var(--accent-hover);
}

@media (max-width: 720px) {
  .auth-gate-card.auth-gate-card--pending {
    padding: 1.2rem 1.1rem 1.2rem;
  }

  .auth-email-pending-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .auth-gate-card.auth-gate-card--pending #auth-email-resend {
    min-width: 14.25rem;
  }
}

/* —— Top —— */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem clamp(1rem, 4vw, 2.5rem);
  background: linear-gradient(
    180deg,
    rgba(253, 246, 233, 0.96) 0%,
    rgba(249, 238, 219, 0.92) 100%
  );
  border-bottom: 1px solid rgba(92, 61, 46, 0.14);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.75) inset,
    0 8px 24px rgba(55, 37, 25, 0.05);
  position: relative;
  z-index: 10;
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(
    calc(1.65rem * var(--text-scale)),
    4vw,
    calc(2rem * var(--text-scale))
  );
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  color: var(--rust);
  line-height: 1;
}

.global-err {
  margin: 0;
  padding: 0.5rem 1rem;
  text-align: center;
  font-size: calc(0.8rem * var(--text-scale));
  color: var(--bad);
  background: rgba(253, 245, 230, 0.95);
  border-bottom: 1px solid rgba(168, 68, 68, 0.2);
}

.top-bar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  max-width: min(92vw, 540px);
  z-index: 11;
}

.top-bar-center > * {
  max-width: 100%;
}

.timer-strip {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.25rem;
}

.timer-btn {
  font: inherit;
  font-size: calc(0.64rem * var(--text-scale));
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: none;
  color: var(--rust);
  background: linear-gradient(180deg, #f7ecdc 0%, #f4e5d2 100%);
  border: 2px solid rgba(139, 69, 19, 0.28);
  border-radius: 999px;
  padding: 0 0.82rem;
  cursor: pointer;
  width: auto;
  min-width: 6.05rem;
  height: 2.24rem;
  line-height: 1.05;
  text-align: center;
  white-space: nowrap;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.78) inset,
    0 3px 10px rgba(80, 50, 30, 0.08);
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    transform 0.12s ease,
    box-shadow 0.15s ease;
}

.timer-btn:hover {
  background: linear-gradient(180deg, #f8eee1 0%, #f1e1cc 100%);
  border-color: rgba(139, 69, 19, 0.38);
  color: var(--rust);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.82) inset,
    0 5px 14px rgba(80, 50, 30, 0.12);
}

.timer-btn:active {
  transform: translateY(1px);
}

.timer-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.timer-btn.is-active {
  background: linear-gradient(180deg, #f1dbc9 0%, #edd2bc 100%);
  border-color: rgba(160, 82, 45, 0.45);
  color: var(--rust);
  font-weight: 600;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 5px 14px rgba(106, 56, 32, 0.14);
}

.timer-icon {
  font-size: 1.15em;
  line-height: 1;
  vertical-align: -0.04em;
  opacity: 0.88;
}

.timer-plan {
  font-size: calc(0.58rem * var(--text-scale));
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: left;
  line-height: 1.25;
  max-width: 100%;
}

.timer-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 11rem;
  padding: 0.65rem 0.75rem 0.75rem;
  background: var(--surface);
  border: 1px solid rgba(139, 69, 19, 0.2);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(40, 28, 20, 0.18);
  z-index: 30;
}

.timer-popover-hint {
  margin: 0 0 0.45rem;
  font-size: calc(0.58rem * var(--text-scale));
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.timer-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
}

.timer-presets button {
  font: inherit;
  font-size: calc(0.72rem * var(--text-scale));
  font-weight: 600;
  padding: 0.4rem 0.35rem;
  border-radius: 8px;
  border: 1px solid rgba(139, 69, 19, 0.2);
  background: var(--cream);
  color: var(--rust);
  cursor: pointer;
}

.timer-presets button:hover {
  background: rgba(139, 69, 19, 0.08);
}

.timer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.timer-action-btn {
  font: inherit;
  font-size: calc(0.62rem * var(--text-scale));
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.45rem 0.35rem;
  border-radius: 8px;
  border: 1px solid rgba(139, 69, 19, 0.25);
  background: transparent;
  color: var(--rust);
  cursor: pointer;
}

.timer-action-btn:hover {
  background: rgba(139, 69, 19, 0.08);
}

/* Пауза включена — кнопка темнее; таймер идёт — светлее (базовый .timer-action-btn) */
.timer-action-btn.is-paused-active {
  background: rgba(139, 69, 19, 0.12);
  border-color: rgba(139, 69, 19, 0.35);
  color: var(--rust);
}

.timer-action-btn.is-paused-active:hover {
  background: rgba(139, 69, 19, 0.18);
}

.timer-action-btn--reset {
  border-color: rgba(168, 68, 68, 0.35);
  background: transparent;
  color: var(--bad);
}

.timer-action-btn--reset:hover {
  background: rgba(168, 68, 68, 0.08);
  color: #a33;
}

.timer-btn.is-paused {
  opacity: 0.92;
  font-style: italic;
}

.top-meta {
  font-size: calc(0.66rem * var(--text-scale));
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-soft);
  font-weight: 500;
}

.top-meta-btn {
  font: inherit;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.35rem 0.65rem;
  margin: 0;
  border-radius: 6px;
  max-width: calc(100vw - 8rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-meta-btn:hover {
  color: var(--rust);
  background: rgba(139, 69, 19, 0.06);
}

.top-meta-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.phrase-count-btn {
  min-width: 0;
  width: fit-content;
  font-family: var(--font-display);
  font-size: clamp(calc(1.22rem * var(--text-scale)), 3.2vw, calc(1.52rem * var(--text-scale)));
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  text-transform: none;
  color: var(--rust);
  line-height: 1.15;
}

.btn-plus {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: 2px solid rgba(139, 69, 19, 0.35);
  background: var(--accent);
  color: #fffef8;
  font-size: calc(1.15rem * var(--text-scale));
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.15s ease;
  box-shadow: 0 2px 8px rgba(90, 50, 30, 0.2);
}

.btn-plus:hover {
  background: var(--accent-hover);
}

.btn-plus:active {
  transform: scale(0.96);
}

.add-menu-wrap {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.add-menu-wrap--center {
  gap: 0;
}

.auth-box {
  position: relative;
  display: flex;
  align-items: center;
}

.google-signin-btn {
  min-height: 38px;
}

.auth-avatar-wrap {
  position: relative;
}

.auth-avatar-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(139, 69, 19, 0.25);
  background: var(--surface);
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(50, 35, 25, 0.12);
}

.auth-avatar-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.auth-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.auth-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: min(100vw - 1.5rem, 15rem);
  background: var(--surface);
  border: 1px solid rgba(139, 69, 19, 0.2);
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(40, 28, 20, 0.16);
  padding: 0.25rem 0;
  z-index: 40;
}

.auth-menu-email {
  margin: 0;
  padding: 0.5rem 0.75rem 0.35rem;
  font-size: calc(0.62rem * var(--text-scale));
  line-height: 1.35;
  color: var(--muted);
  border-bottom: 1px solid rgba(139, 69, 19, 0.12);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-menu-item {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  font: inherit;
  font-size: calc(0.78rem * var(--text-scale));
  color: var(--ink);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

.auth-menu-item:hover {
  background: rgba(139, 69, 19, 0.08);
}

/* Как блок выбора аватара: белая подложка под раскрывающимся заголовком */
.auth-menu-contacts-panel {
  padding: 0.5rem 0.65rem 0.45rem;
  border-top: 1px solid rgba(139, 69, 19, 0.12);
  background: #fff;
}

/* Как email пользователя в шапке меню (.auth-menu-email) */
.auth-menu-contact-link {
  display: block;
  font-family: var(--font);
  font-size: calc(0.62rem * var(--text-scale));
  font-weight: 400;
  line-height: 1.35;
  color: var(--muted);
  text-decoration: none;
  word-break: normal;
  overflow-wrap: anywhere;
}

.auth-menu-contact-label {
  color: var(--rust);
}

.auth-menu-contact-link + .auth-menu-contact-link {
  margin-top: 0.35rem;
}

.auth-menu-contact-link:hover {
  color: var(--rust);
  text-decoration: underline;
}

.auth-menu-item--logout {
  border-top: 1px solid rgba(139, 69, 19, 0.12);
  margin-top: 0.15rem;
}

.auth-avatar-chooser {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem;
  padding: 0.5rem 0.65rem 0.45rem;
  border-top: 1px solid rgba(139, 69, 19, 0.12);
}

.auth-avatar-choice {
  width: 100%;
  border: 2px solid rgba(139, 69, 19, 0.18);
  border-radius: 10px;
  background: #fff;
  padding: 0.15rem;
  cursor: pointer;
}

.auth-avatar-choice.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(160, 82, 45, 0.2);
}

.auth-avatar-choice img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  border-radius: 7px;
}

.add-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 12.5rem;
  padding: 0.35rem 0;
  background: var(--surface);
  border: 1px solid rgba(139, 69, 19, 0.18);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(40, 28, 20, 0.15);
}

.add-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: calc(0.85rem * var(--text-scale));
  padding: 0.55rem 1rem;
  border: none;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.add-menu-item:hover {
  background: rgba(139, 69, 19, 0.06);
}

.add-menu-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* —— Center stage —— */
.stage-root {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.5rem, 2vh, 1rem) 1.5rem clamp(0.5rem, 2vh, 1rem);
  min-height: 0;
}

.stage {
  width: min(100%, 420px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stage.stage-idle {
  width: min(100%, 1560px);
  min-height: 0;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* Случайные фразы — одна линия пузырьков (сколько влезло по ширине); в каждом пузырьке фраза в одну строку, без …; лишнее — горизонтальный скролл */
.phrase-bubbles {
  position: relative;
  z-index: 9;
  width: 100%;
  margin: 0;
  min-height: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.42rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  padding: 0.48rem clamp(1rem, 4vw, 2.5rem);
  background: var(--cream);
  border: none;
  border-bottom: 1px solid rgba(92, 61, 46, 0.1);
  box-shadow: none;
}

/* Не display:none — сохраняем разметку для пустой коллекции */
.phrase-bubbles:empty {
  visibility: hidden;
  pointer-events: none;
  height: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: none;
  overflow: hidden;
}

.idle-center {
  --stats-col-width: clamp(140px, 12vw, 175px);
  display: grid;
  grid-template-columns: var(--stats-col-width) minmax(0, 920px) var(--stats-col-width);
  justify-content: center;
  align-items: start;
  column-gap: clamp(0.85rem, 2vw, 1.4rem);
  width: 100%;
  min-height: 0;
  flex: 0 0 auto;
}

.idle-main {
  grid-column: 2;
  --text-scale: 1.42;
  min-width: 0;
  min-height: clamp(26rem, 48vh, 38rem);
  width: 100%;
  max-width: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1.05rem;
  padding: 1.55rem 1.85rem 1.65rem;
  background: var(--cream-panel);
  border-radius: 24px;
  border: 1px solid rgba(92, 61, 46, 0.1);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.82) inset,
    0 22px 50px rgba(40, 27, 18, 0.14);
}

.stats-today-panel {
  grid-column: 3;
  width: var(--stats-col-width);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.stats-today-card {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 16px;
  border: 1px solid rgba(92, 61, 46, 0.11);
  padding: 1rem 1rem 1.05rem;
  background: linear-gradient(180deg, #fffaf1 0%, #f5ecdc 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.74) inset,
    0 10px 24px rgba(58, 40, 28, 0.11);
}

.stats-today-title {
  margin: 0 0 0.35rem;
  font-size: calc(0.58rem * var(--text-scale));
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats-today-value {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(calc(1.8rem * var(--text-scale)), 4vw, calc(2.4rem * var(--text-scale)));
  line-height: 1;
  color: var(--accent);
}

.stats-today-sub {
  margin: 0;
  font-size: calc(0.78rem * var(--text-scale));
  color: var(--wood);
}

@media (max-width: 1080px) {
  .idle-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    --stats-col-width: min(680px, 96vw);
  }

  .idle-main {
    margin-top: 0.9rem;
    min-height: 0;
  }

  .stats-today-panel {
    order: -1;
    width: min(680px, 96vw);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chip-panel-head {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    row-gap: 0.4rem;
  }

  .chip-panel-title-wrap {
    grid-row: 1;
    max-width: 100%;
    justify-content: center;
  }

  .answer-mode-toggle {
    grid-row: 2;
    position: static;
    right: auto;
    top: auto;
    transform: none;
    order: 2;
    width: auto;
    justify-content: center;
  }
}

.phrase-bubble {
  display: block;
  flex: 0 0 auto;
  width: max-content;
  max-width: none;
  min-width: 2.4rem;
  padding: 0.32rem 0.56rem;
  margin: 0;
  background: var(--surface);
  border: 1px solid rgba(92, 61, 46, 0.12);
  border-radius: 9px;
  font-family: var(--font);
  font-size: calc(0.78rem * var(--text-scale));
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--muted-strong);
  box-shadow: 0 1px 2px rgba(60, 40, 30, 0.03);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-appearance: none;
  appearance: none;
}

@media (max-width: 640px) {
  .stage-root {
    padding-left: clamp(1.35rem, 6vw, 2.25rem);
    padding-right: clamp(1.35rem, 6vw, 2.25rem);
  }

  .phrase-bubbles {
    padding: 0.48rem clamp(1rem, 4vw, 2.5rem);
    gap: 0.4rem;
  }

  .idle-main {
    width: 100%;
    max-width: min(580px, calc(100% - 0.5rem));
    justify-content: flex-start;
    margin-top: 0;
  }

  .stats-today-panel {
    order: -1;
    width: 100%;
    max-width: min(580px, calc(100% - 0.5rem));
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 1.05rem;
    column-gap: 0.6rem;
  }

  .stats-today-card {
    min-height: 88px;
    padding: 0.72rem 0.72rem 0.76rem;
    border-radius: 14px;
  }

  .stats-today-title {
    margin: 0 0 0.24rem;
    font-size: calc(0.52rem * var(--text-scale));
  }

  .stats-today-value {
    font-size: clamp(calc(1.45rem * var(--text-scale)), 6.2vw, calc(1.8rem * var(--text-scale)));
  }

  .chip-panel-head {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    row-gap: 0.45rem;
    align-items: center;
  }

  .chip-panel-title-wrap {
    grid-row: 1;
    width: 100%;
    justify-content: center;
  }

  .answer-mode-toggle {
    grid-row: 2;
    position: static;
    right: auto;
    top: auto;
    transform: none;
    order: 2;
    width: 100%;
    justify-content: center;
  }

  .chip-row--task-basic,
  .chip-row--task-ai {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.42rem;
    max-width: min(21rem, 100%);
    margin: 0 auto;
    overflow: visible;
    padding-bottom: 0;
  }

  .chip-row--task-basic .chip,
  .chip-row--task-ai .chip {
    width: 100%;
    justify-content: center;
  }

  .phrase-bubble {
    font-size: calc(0.88rem * var(--text-scale));
    padding: 0.34rem 0.5rem;
  }
}

@media (max-width: 900px) {
  .top-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand right"
      "center center";
    row-gap: 0.55rem;
    align-items: center;
  }

  .brand {
    grid-area: brand;
  }

  .top-bar > .add-menu-wrap {
    grid-area: right;
    justify-self: end;
  }

  .top-bar-center {
    grid-area: center;
    position: static;
    left: auto;
    transform: none;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    gap: 0.45rem;
  }

  .stats-today-panel {
    margin-bottom: 1rem;
  }

  .stats-today-card {
    min-height: 94px;
    padding: 0.8rem 0.8rem 0.84rem;
    border-radius: 15px;
  }

  .stats-today-title {
    margin: 0 0 0.28rem;
    font-size: calc(0.54rem * var(--text-scale));
  }

  .stats-today-value {
    font-size: clamp(calc(1.56rem * var(--text-scale)), 5.2vw, calc(1.95rem * var(--text-scale)));
  }

  .chip-panel-head {
    min-height: 0;
    flex-direction: column;
    row-gap: 0.45rem;
    justify-content: center;
    align-items: center;
  }

  .answer-mode-toggle {
    position: static;
    transform: none;
    order: 2;
    width: 100%;
    justify-content: center;
  }

  .answer-mode-text {
    width: auto;
  }
}

.hidden {
  display: none !important;
}

/* Wheel: .wheel-ring прижат к центру (inset), толщина цветной полосы = inset у ::after (не менять вместе с внешним inset) */
.wheel-frame {
  position: relative;
  width: min(76vw, 300px);
  height: min(76vw, 300px);
  margin: 0 auto;
}

.wheel-ring {
  position: absolute;
  /* Кольцо ближе к кнопке: меньше общий диаметр градиента, толщина полосы по-прежнему из ::after */
  inset: clamp(16px, 5.5vw, 28px);
  border-radius: 50%;
  background: conic-gradient(
    from -90deg,
    #c4a574 0deg,
    var(--stripe-blue) 51deg,
    #d4c4a0 102deg,
    #b8956a 153deg,
    #c2ced6 204deg,
    #c9b896 255deg,
    #b0bec8 306deg,
    #d4c4a0 360deg
  );
  border: 1px solid rgba(139, 69, 19, 0.12);
  box-shadow: 0 12px 36px rgba(80, 50, 35, 0.15);
}

.wheel-ring::after {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: inset 0 0 0 1px rgba(139, 69, 19, 0.08);
}

.wheel-blur {
  filter: saturate(1.05);
}

.wheel-ring.is-animating {
  animation: wheel-dramatic 1.65s cubic-bezier(0.12, 0.85, 0.15, 1) forwards;
}

@keyframes wheel-dramatic {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(1980deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .wheel-ring.is-animating {
    animation: none;
    transform: rotate(72deg);
  }
}

.hub-spin {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  width: clamp(112px, 32vw, 152px);
  height: clamp(112px, 32vw, 152px);
  border-radius: 50%;
  border: 2px solid rgba(120, 74, 44, 0.24);
  background: linear-gradient(180deg, #b06b46 0%, #9d5632 100%);
  color: #fffef8;
  font-family: var(--font-display);
  font-size: calc(0.88rem * var(--text-scale));
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.22) inset,
    0 10px 24px rgba(95, 53, 33, 0.28);
  transition: background 0.2s ease, transform 0.15s ease;
}

.hub-spin:hover {
  background: var(--accent-hover);
}

.hub-spin:active {
  transform: translate(-50%, -50%) scale(0.97);
}

.hub-spin:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.stage-hint {
  margin: 0;
  font-family: var(--font);
  font-size: calc(0.8rem * var(--text-scale));
  letter-spacing: 0.02em;
  color: var(--muted-strong);
  font-weight: 500;
  max-width: 28ch;
}

.idle-main .stage-hint {
  font-size: calc(0.88rem * var(--text-scale));
  max-width: 34ch;
}

/* Task type chips (Pinterest-style pills) */
.chip-panel {
  width: 100%;
  margin-bottom: 1.5rem;
}

.idle-main .chip-panel {
  margin-bottom: 0;
}

.chip-panel-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  margin-bottom: 0.5rem;
}

.chip-panel-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  margin: 0 auto;
}

.chip-panel-info-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 1.65rem;
  height: 1.65rem;
  margin-left: 0.12rem;
}

.answer-mode-toggle {
  position: absolute;
  right: -1.35rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  cursor: pointer;
  user-select: none;
  width: 11.2rem;
  justify-content: flex-start;
}

.answer-mode-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.answer-mode-track {
  width: 2rem;
  height: 1.14rem;
  border-radius: 999px;
  border: 1px solid rgba(90, 140, 190, 0.55);
  background: rgba(184, 201, 212, 0.55);
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.answer-mode-thumb {
  position: absolute;
  top: 50%;
  left: 2px;
  width: 0.86rem;
  height: 0.86rem;
  border-radius: 50%;
  background: #fffdf8;
  border: 1px solid rgba(90, 140, 190, 0.4);
  transform: translateY(-50%);
  transition: transform 0.16s ease;
}

.answer-mode-text {
  display: inline-block;
  width: 8.6rem;
  font-family: var(--font);
  font-size: calc(0.64rem * var(--text-scale));
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-strong);
  white-space: nowrap;
  text-align: left;
}

.answer-mode-toggle input:checked + .answer-mode-track {
  background: rgba(132, 178, 122, 0.6);
  border-color: rgba(90, 132, 80, 0.78);
}

.answer-mode-toggle input:checked + .answer-mode-track .answer-mode-thumb {
  transform: translate(0.84rem, -50%);
  border-color: rgba(98, 142, 88, 0.62);
}

.answer-mode-toggle input:focus-visible + .answer-mode-track {
  box-shadow: 0 0 0 2px var(--cream), 0 0 0 4px rgba(90, 160, 220, 0.55);
}

.chip-panel-info-btn {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  border: 1px solid rgba(139, 69, 19, 0.22);
  background: var(--surface);
  color: var(--muted);
  font-size: calc(0.82rem * var(--text-scale));
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition:
    border-color 0.15s ease,
    color 0.15s ease,
    background 0.15s ease;
}

.chip-panel-info-btn:hover {
  border-color: var(--sage);
  color: var(--sage-hover);
}

.chip-panel-info-btn[aria-expanded="true"] {
  border-color: var(--sage);
  background: var(--sage-soft);
  color: var(--ink);
}

.task-types-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 25;
  width: min(calc(100vw - 2.5rem), 22rem);
  max-height: min(70vh, 24rem);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.75rem 0.85rem 0.85rem;
  text-align: left;
  background: var(--surface);
  border: 1px solid rgba(139, 69, 19, 0.2);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(40, 28, 20, 0.2);
  -webkit-overflow-scrolling: touch;
}

.task-types-popover-title {
  margin: 0 0 0.55rem;
  font-size: calc(0.62rem * var(--text-scale));
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.task-types-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-types-list li {
  margin-bottom: 0.85rem;
}

.task-types-list li:last-child {
  margin-bottom: 0;
}

.task-types-name {
  display: block;
  font-size: calc(0.72rem * var(--text-scale));
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--rust);
  margin-bottom: 0.28rem;
}

.task-types-desc {
  margin: 0;
  font-size: calc(0.78rem * var(--text-scale));
  line-height: 1.45;
  color: var(--muted);
  font-weight: 400;
}

.chip-panel-label {
  margin: 0 0 0.65rem;
  font-family: var(--font-display);
  font-size: calc(1.22rem * var(--text-scale));
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: none;
  color: var(--rust);
  text-align: center;
}

.chip-panel-head .chip-panel-label {
  margin: 0;
  flex: 0 0 auto;
  min-width: auto;
}

.idle-main .chip-panel-label {
  margin: 0 0 0.5rem;
  font-size: calc(1.3rem * var(--text-scale));
}

.idle-main .chip-panel-head .chip-panel-label {
  margin: 0;
}

.task-chips-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.62rem;
  width: 100%;
}

.idle-main .task-chips-wrap {
  gap: 0.58rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
}

.chip-row--task-basic,
.chip-row--task-ai {
  width: 100%;
}

/* Три базовых режима — одна строка (без переноса 2+1) */
.chip-row--task-basic {
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: clamp(0.22rem, 1.5vw, 0.4rem);
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 0.15rem;
}

.chip-row--task-basic .chip {
  flex: 0 0 auto;
}

.chip-row--task-basic .chip-text,
.chip-row--task-ai .chip-text {
  white-space: nowrap;
}

.idle-main .chip-row {
  gap: 0.45rem;
}

/* Один размер чипов в обоих рядах (в т.ч. заблокированные ИИ) */
.idle-main .task-chips-wrap .chip {
  padding: 0.48rem 0.66rem;
  font-size: calc(0.68rem * var(--text-scale));
}

.idle-main .task-chips-wrap .chip-icon {
  font-size: calc(0.88rem * var(--text-scale));
}

/* Тёплый фон = выбрано в spin, светлая плашка = выкл. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.56rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.88);
  background: var(--surface);
  color: var(--muted-strong);
  font-family: var(--font);
  font-size: calc(0.78rem * var(--text-scale));
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease,
    box-shadow 0.18s ease;
  box-shadow: 0 1px 2px rgba(60, 40, 30, 0.035);
}

.chip:hover {
  border-color: rgba(255, 255, 255, 0.95);
}

.chip:not(.is-selected):not(.chip--locked) {
  border-color: transparent;
  box-shadow: none;
}

.chip:not(.is-selected):not(.chip--locked):hover {
  border-color: transparent;
  box-shadow: none;
}

.chip:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--cream), 0 0 0 4px var(--accent);
}

.chip.is-selected {
  background: linear-gradient(180deg, #f3e8d7 0%, #ede0cc 100%);
  border-color: rgba(139, 69, 19, 0.32);
  color: var(--muted-strong);
  box-shadow: 0 2px 6px rgba(90, 50, 30, 0.08);
}

.chip.chip--locked {
  position: relative;
  cursor: not-allowed;
  opacity: 1;
}

.chip.chip--locked:disabled {
  opacity: 1;
}

.chip-lock-shade {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(35, 24, 18, 0.42);
  pointer-events: none;
  z-index: 1;
}

.chip-lock-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  color: #fffef8;
  line-height: 0;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.chip-lock-icon svg {
  display: block;
  width: 1.2em;
  height: 1.2em;
}

.chip-icon {
  font-size: calc(0.95rem * var(--text-scale));
  line-height: 1;
}

.hub-spin--blocked {
  opacity: 0.4;
  cursor: not-allowed;
}

.rotate-label {
  margin: 0;
  font-size: calc(0.75rem * var(--text-scale));
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Loading */
.stage-load .load-line {
  width: 48px;
  height: 2px;
  background: var(--line);
  margin: 0 auto 1rem;
  position: relative;
  overflow: hidden;
}

.stage-load .load-line::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 40%;
  background: var(--sage);
  animation: load-sweep 0.8s ease-in-out infinite;
}

@keyframes load-sweep {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}

.load-text {
  margin: 0;
  font-size: calc(0.65rem * var(--text-scale));
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Task: плотная «карточка» поверх полосатого фона — нормальный контраст для текста */
.stage.stage-task {
  align-items: stretch;
  text-align: left;
  width: min(100%, 560px);
  max-width: 560px;
  padding: 0 1rem;
  box-sizing: border-box;
  /* Центруем блок задания в рамках экрана */
  align-self: center;
}

.task-panel {
  width: 100%;
  background: #fffef8;
  background: linear-gradient(180deg, #fffcf7 0%, #fff9f0 100%);
  border: 1px solid rgba(139, 69, 19, 0.12);
  border-radius: 16px;
  padding: 1.35rem 1.35rem 1.5rem;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.7) inset,
    0 12px 40px rgba(35, 24, 18, 0.12);
}

.task-kind-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.task-kind-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.task-edit-card {
  width: 2rem;
  height: 2rem;
}

.task-close {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: calc(1.45rem * var(--text-scale));
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    color 0.15s ease,
    background 0.15s ease;
}

.task-close:hover {
  color: var(--ink);
  background: rgba(139, 69, 19, 0.08);
}

.task-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.task-kind {
  font-size: calc(0.58rem * var(--text-scale));
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin: 0;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.task-def-info {
  flex-shrink: 0;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  border: 1px solid rgba(139, 69, 19, 0.22);
  background: var(--surface);
  color: var(--muted);
  font-size: calc(0.82rem * var(--text-scale));
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition:
    border-color 0.15s ease,
    color 0.15s ease,
    background 0.15s ease;
}

.task-def-info:hover {
  border-color: var(--sage);
  color: var(--sage-hover);
}

.task-def-info[aria-expanded="true"] {
  border-color: var(--sage);
  background: var(--sage-soft);
  color: var(--ink);
}

.task-def-reveal {
  font-size: calc(0.84rem * var(--text-scale));
  line-height: 1.5;
  color: var(--wood);
  margin: 0 0 1rem;
  padding: 0.75rem 0.85rem;
  background: var(--sage-soft);
  border-radius: 8px;
  border: 1px solid var(--line);
  white-space: pre-wrap;
  word-break: break-word;
}

.task-prompt {
  font-size: clamp(
    calc(1.05rem * var(--text-scale)),
    2.8vw,
    calc(1.25rem * var(--text-scale))
  );
  font-weight: 500;
  line-height: 1.55;
  color: var(--ink);
  margin: 0 0 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(139, 69, 19, 0.12);
  white-space: pre-wrap;
}

.task-flip-card {
  width: 100%;
  min-height: clamp(11rem, 34vh, 15.5rem);
  border: 1px solid rgba(139, 69, 19, 0.2);
  border-radius: 12px;
  padding: 1.2rem 1.35rem;
  margin: 0 0 1.5rem;
  background: linear-gradient(180deg, #fffdf8 0%, #f7f0e5 100%);
  color: var(--rust);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(72, 46, 28, 0.08);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.task-flip-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(72, 46, 28, 0.13);
}

.task-flip-card-face {
  display: block;
  font-size: clamp(
    calc(1.02rem * var(--text-scale)),
    2.5vw,
    calc(1.18rem * var(--text-scale))
  );
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.task-flip-card-face--back {
  display: none;
}

.task-flip-card.is-flipped .task-flip-card-face--front {
  display: none;
}

.task-flip-card.is-flipped .task-flip-card-face--back {
  display: block;
}

.task-input {
  width: 100%;
  font: inherit;
  font-size: calc(1rem * var(--text-scale));
  line-height: 1.5;
  padding: 0.75rem 0.85rem;
  min-height: 7.5rem;
  border: 1px solid rgba(139, 69, 19, 0.18);
  background: #fff;
  color: var(--muted-strong);
  margin-bottom: 1.5rem;
  border-radius: 8px;
  resize: vertical;
  box-sizing: border-box;
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

.task-input::placeholder {
  color: rgba(107, 107, 107, 0.55);
}

.task-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(160, 82, 45, 0.2);
}

.task-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
}

.task-row-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn-ghost.task-give-up {
  margin-left: auto;
  text-transform: none;
}

.srs-rate-row {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.srs-rate-btn {
  font: inherit;
  font-size: calc(0.62rem * var(--text-scale));
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid rgba(139, 69, 19, 0.28);
  border-radius: 8px;
  background: transparent;
  color: var(--wood);
  padding: 0.42rem 0.3rem;
  cursor: pointer;
}

.srs-rate-btn:hover {
  background: rgba(139, 69, 19, 0.08);
}

#btn-srs-easy {
  color: #4f6b4b;
  border-color: rgba(79, 107, 75, 0.42);
  background: rgba(116, 145, 110, 0.14);
}

#btn-srs-easy:hover {
  background: rgba(116, 145, 110, 0.22);
}

#btn-srs-mid {
  color: #8e7b4e;
  border-color: rgba(142, 123, 78, 0.42);
  background: rgba(196, 176, 124, 0.17);
}

#btn-srs-mid:hover {
  background: rgba(196, 176, 124, 0.25);
}

#btn-srs-difficult {
  color: #7a5b42;
  border-color: rgba(122, 91, 66, 0.44);
  background: rgba(154, 120, 92, 0.15);
}

#btn-srs-difficult:hover {
  background: rgba(154, 120, 92, 0.24);
}

.btn-sage {
  font: inherit;
  cursor: pointer;
  border: 2px solid rgba(139, 69, 19, 0.25);
  background: var(--accent);
  color: #fffef8;
  padding: 0.65rem 1.4rem;
  font-size: calc(0.66rem * var(--text-scale));
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-radius: 6px;
  transition: background 0.2s ease;
  box-shadow: 0 2px 10px rgba(90, 50, 30, 0.2);
}

.btn-sage:hover {
  background: var(--sage-hover);
}

.btn-sage.btn-sage--next {
  background: var(--ok);
  border-color: rgba(90, 107, 66, 0.45);
  box-shadow: 0 2px 10px rgba(70, 90, 50, 0.28);
}

.btn-sage.btn-sage--next:hover {
  background: #4d5c38;
  border-color: rgba(90, 107, 66, 0.55);
}

.btn-sage.btn-sage--almost {
  background: #a3872b;
  border-color: rgba(149, 116, 28, 0.52);
  box-shadow: 0 2px 10px rgba(127, 98, 24, 0.28);
}

.btn-sage.btn-sage--almost:hover {
  background: #937723;
  border-color: rgba(133, 104, 24, 0.62);
}

/* Режим «Оценить»: подсказка к кнопкам SRS, сам клик не отправляет ответ */
.btn-sage.btn-sage--rate {
  cursor: default;
}

.btn-wide {
  width: 100%;
  margin-top: 0.25rem;
}

.btn-ghost {
  font: inherit;
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: calc(0.68rem * var(--text-scale));
  letter-spacing: 0.08em;
  text-transform: lowercase;
  padding: 0.5rem 0;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.btn-ghost:hover {
  color: var(--ink);
}

.feedback {
  margin-top: 1rem;
  font-size: calc(0.88rem * var(--text-scale));
  font-weight: 500;
}

.feedback.ok {
  color: var(--ok);
}

.feedback.bad {
  color: #9a5a5a;
}

/* Сообщение об ошибке прямо на фоне карточки (без отдельной белой плашки) */
.task-panel .feedback.bad {
  background: transparent;
  border-radius: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
}

.feedback.info {
  color: #7b6a5d;
  font-weight: 400;
}

.feedback.almost {
  color: #9b7a1d;
}

.reveal-answer {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--sage-soft);
  text-align: left;
}

.reveal-answer-line {
  margin: 0;
  font-size: calc(0.9rem * var(--text-scale));
  line-height: 1.45;
  color: var(--muted-strong);
}

.reveal-answer-label {
  font-size: calc(0.65rem * var(--text-scale));
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 0.35rem;
}

.reveal-answer-value {
  font-weight: 500;
  color: var(--ink);
}

.err {
  margin-top: 0.75rem;
  font-size: calc(0.85rem * var(--text-scale));
  color: var(--bad);
}

/* —— Modal —— */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1rem, 4vh, 2rem);
  overflow-y: auto;
}

/* Окно одной карточки (поверх остального) */
.modal-card-peek-wrap {
  z-index: 110;
}

/* Окончание таймера сессии — поверх задания и остальных модалок */
.modal-timer-end {
  z-index: 115;
  align-items: center;
  justify-content: center;
}

.modal-panel--timer-end {
  position: relative;
  width: min(100%, 380px);
  margin-top: 0;
  text-align: center;
  padding-top: 2.35rem;
}

.modal-timer-end-close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 2;
}

.modal-timer-end-title {
  margin: 0 0 1.15rem;
  width: 100%;
  text-align: center;
  padding: 0 1.75rem;
  box-sizing: border-box;
}

.modal-panel--peek {
  width: min(100%, 400px);
  margin-top: 6vh;
}

.modal-head--peek {
  justify-content: flex-end;
  margin-bottom: 0.85rem;
}

.modal-head--peek .modal-head-actions {
  margin-left: auto;
}

.card-peek-block {
  margin: 0;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.card-peek-block:last-child {
  border-bottom: none;
}

.card-peek-main {
  font-size: calc(1.15rem * var(--text-scale));
  font-weight: 600;
  color: var(--ink);
  padding-top: 0;
}

.card-peek-sub {
  font-size: calc(0.88rem * var(--text-scale));
  color: var(--muted);
}

.card-peek-ru {
  font-size: calc(0.88rem * var(--text-scale));
  color: var(--wood);
}

.card-peek-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.modal-scrim {
  /* fixed: затемнение на весь экран при любой прокрутке длинного списка */
  position: fixed;
  inset: 0;
  z-index: 0;
  border: none;
  background: rgba(45, 32, 24, 0.35);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 92vw, 760px);
  background: var(--cream);
  border: 1px solid rgba(139, 69, 19, 0.18);
  padding: 1.35rem 1.5rem 1.75rem;
  margin-top: 2vh;
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(40, 28, 20, 0.18);
}

.modal-panel.modal-panel--peek {
  width: min(100%, 400px);
}

/* Полноэкранный просмотр коллекции и проверка импорта — одна геометрия «листа» */
.modal.modal--collection,
.modal.modal--sheet {
  /* flex-start: панель по высоте = контент (не растягиваем на 100vh — иначе фон обрезается) */
  align-items: flex-start;
  justify-content: flex-start;
  padding: 0;
}

.modal.modal--collection .modal-panel,
.modal.modal--sheet .modal-panel {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  margin-top: 0;
  min-height: 100vh;
  min-height: 100dvh;
  border-radius: 0;
  border-width: 0 1px;
  padding: clamp(1rem, 3vh, 1.5rem) clamp(1rem, 4vw, 2rem) 2rem;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.modal.modal--collection .modal-head,
.modal.modal--sheet .modal-head {
  margin-bottom: 1rem;
}

.modal.modal--collection .phrase-list,
.modal.modal--sheet .phrase-list--import-preview {
  /* Список задаёт высоту панели; flex:1 + stretch родителя давали обрезку фона */
  flex: none;
  min-height: 0;
  max-height: none;
  overflow: visible;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-shrink: 0;
}

.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.modal-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(
    calc(1.35rem * var(--text-scale)),
    3vw,
    calc(1.65rem * var(--text-scale))
  );
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: none;
  color: var(--rust);
}

.btn-close {
  background: none;
  border: none;
  font-size: calc(1.35rem * var(--text-scale));
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 0.25rem;
}

.btn-close:hover {
  color: var(--ink);
}

.modal-form .field {
  margin-bottom: 1rem;
}

.modal-form label {
  display: block;
  font-size: calc(0.58rem * var(--text-scale));
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.modal-form input,
.modal-form textarea {
  width: 100%;
  font: inherit;
  padding: 0.55rem 0;
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
  background: transparent;
  border-radius: 0;
  resize: vertical;
}

/* Многострочные определения: без лишней «пустой» высоты при rows=1–2 */
.modal-form textarea {
  line-height: 1.35;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  min-height: 2.25em;
  max-height: 10rem;
}

/* Редактирование карточки (peek): высота под текст (JS), без обрезки из‑за max-height формы */
#card-peek-edit textarea {
  min-height: 2.75em;
  max-height: min(75dvh, 28rem);
  overflow-y: hidden;
  box-sizing: border-box;
  resize: vertical;
}

.modal-form input:focus,
.modal-form textarea:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

.modal-subheading {
  margin: 0 0 0.85rem;
  font-size: calc(0.58rem * var(--text-scale));
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.bulk-import {
  margin-bottom: 0.25rem;
}

.bulk-hint {
  margin: 0 0 0.75rem;
  font-size: calc(0.68rem * var(--text-scale));
  line-height: 1.45;
  color: var(--wood);
}

.bulk-hint-k {
  color: var(--ink);
  font-weight: 500;
}

.bulk-textarea {
  width: 100%;
  min-height: 10rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: calc(0.72rem * var(--text-scale));
  line-height: 1.4;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.65rem;
  border: 1px solid rgba(139, 69, 19, 0.2);
  border-radius: 8px;
  background: var(--surface);
  resize: vertical;
  box-sizing: border-box;
}

.bulk-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.bulk-status {
  margin: 0.5rem 0 0;
  min-height: 1.2em;
  font-size: calc(0.68rem * var(--text-scale));
  color: var(--muted);
}

.import-preview-step {
  margin-bottom: 0.25rem;
}

.import-preview-hint {
  margin: 0 0 0.75rem;
  font-size: calc(0.72rem * var(--text-scale));
  line-height: 1.45;
  color: var(--wood);
}

/* Импорт: тот же список и карточки, что в коллекции (.phrase-list-item + .card-edit) */
.phrase-list--import-preview {
  max-height: min(52vh, 32rem);
  margin: 0 0 0.75rem;
  padding-right: 0.25rem;
}

.import-preview-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  align-items: stretch;
}

.add-form-status {
  margin: 0 0 0.5rem;
  min-height: 1.2em;
  font-size: calc(0.68rem * var(--text-scale));
  color: var(--bad);
}

.modal-divider {
  height: 1px;
  background: var(--line);
  margin: 1.5rem 0;
}

.list-heading {
  margin: 0 0 0.75rem;
  font-size: calc(0.58rem * var(--text-scale));
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.phrase-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(40vh, 280px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.phrase-list-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  font-size: calc(0.88rem * var(--text-scale));
}

.phrase-list-item:last-child {
  border-bottom: none;
}

.phrase-list-row {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
}

.phrase-list-item .card-view {
  flex: 1;
  min-width: 0;
}

.phrase-list-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  flex-shrink: 0;
  padding-top: 0.1rem;
}

.btn-edit-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--rust);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-edit-card:hover {
  background: rgba(139, 69, 19, 0.08);
  border-color: rgba(139, 69, 19, 0.28);
  color: var(--accent-hover);
}

.btn-edit-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-edit-card svg {
  display: block;
}

.card-edit {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card-edit-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.card-edit-label {
  font-size: calc(0.58rem * var(--text-scale));
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-edit-input {
  width: 100%;
  font: inherit;
  font-size: calc(0.82rem * var(--text-scale));
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  box-sizing: border-box;
  resize: vertical;
  min-height: 2.25rem;
}

textarea.card-edit-input {
  line-height: 1.35;
  min-height: 2.75rem;
  max-height: 12rem;
}

.card-edit-input:focus {
  outline: none;
  border-color: var(--sage);
}

.card-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  margin-top: 0.25rem;
}

.btn-edit-save {
  padding: 0.45rem 1rem;
  font-size: calc(0.68rem * var(--text-scale));
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.btn-edit-cancel {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: calc(0.65rem * var(--text-scale));
}

.phrase-list .p-main {
  font-weight: 500;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.phrase-list .p-sub {
  font-size: calc(0.78rem * var(--text-scale));
  color: var(--muted);
  margin-top: 0.2rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.phrase-list .p-ru {
  font-size: calc(0.78rem * var(--text-scale));
  color: var(--wood);
  margin-top: 0.35rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 520px) {
  .phrase-list-row {
    flex-direction: row;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .phrase-list-actions {
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-start;
    width: auto;
  }
}

.btn-danger {
  background: none;
  border: none;
  color: var(--bad);
  font-size: calc(0.65rem * var(--text-scale));
  letter-spacing: 0.08em;
  cursor: pointer;
  text-transform: uppercase;
  flex-shrink: 0;
  padding: 0.2rem 0;
}

.btn-danger:hover {
  text-decoration: underline;
}

.empty-hint {
  font-size: calc(0.82rem * var(--text-scale));
  color: var(--muted);
  margin: 0;
}

.empty-hint.hidden {
  display: none;
}

/* ——— Страница коллекции (/collection.html) ——— */
/* Явная высота viewport, иначе flex-ребёнок с flex:1 не растягивается на всю страницу */
html.collection-page-root {
  height: 100%;
  min-height: 100dvh;
}

html.collection-page-root,
html.collection-page-root body.collection-body {
  box-sizing: border-box;
}

.collection-body {
  /* Как на главной: полосатый «болотный» фон с html, body прозрачный */
  background: transparent;
  min-height: 100%;
  min-height: 100dvh;
  margin: 0;
}

.collection-body #collection-app {
  width: 100%;
  max-width: none;
}

.collection-top-bar {
  padding: 0.85rem clamp(1rem, 4vw, 1.75rem);
  background: var(--cream-panel);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.collection-top-bar .collection-back-link {
  flex: 0 0 auto;
  align-self: center;
  font-size: calc(0.88rem * var(--text-scale));
  font-weight: 500;
  color: var(--rust);
  text-decoration: none;
  letter-spacing: 0.02em;
  max-width: min(40vw, 12rem);
  white-space: nowrap;
}

.collection-back-link:hover {
  text-decoration: underline;
}

/* Явно колонка: базовый .top-bar-center — row, иначе заголовок и «+» ломают выравнивание */
.collection-top-bar .top-bar-center.collection-top-center {
  flex-direction: column;
  align-items: center;
}

.collection-top-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  text-align: center;
  max-width: min(78vw, 22rem);
}

.collection-title-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  /* Одна «визуальная» высота строки: как у .btn-plus (2.1rem) */
  min-height: 2.1rem;
}

.collection-plus-near-title {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  align-self: center;
  height: 2.1rem;
}

.collection-plus-near-title .add-menu-dropdown {
  left: auto;
  right: 0;
}

.collection-top-bar .collection-page-title {
  margin: 0;
  padding: 0;
  line-height: 1.05;
  font-family: var(--font-display);
  font-size: clamp(calc(1.35rem * var(--text-scale)), 3.5vw, calc(1.85rem * var(--text-scale)));
  font-weight: 600;
  color: var(--rust);
  flex-shrink: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  align-self: center;
  min-height: 2.1rem;
}

.collection-top-bar .collection-total {
  font-size: calc(0.72rem * var(--text-scale));
  color: var(--muted);
  white-space: nowrap;
}

.collection-header-trailing {
  flex: 0 1 auto;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  min-width: 0;
}

@media (max-width: 720px) {
  .collection-top-bar {
    flex-wrap: wrap;
    row-gap: 0.65rem;
  }

  .collection-top-bar .top-bar-center.collection-top-center {
    position: static;
    transform: none;
    order: 3;
    flex: 1 1 100%;
    max-width: none;
  }

  .collection-header-trailing {
    flex: 1 1 auto;
    justify-content: flex-end;
  }
}

@media (max-width: 560px) {
  .collection-top-bar .collection-back-link {
    max-width: none;
  }
}

.collection-page {
  /* Тот же молочный, что шапка; уже по ширине — полоски сзади */
  align-self: center;
  width: 100%;
  max-width: min(52rem, calc(100% - clamp(2rem, 10vw, 5rem)));
  margin: 0.65rem auto 1.1rem;
  box-sizing: border-box;
  padding: clamp(1rem, 3vw, 1.5rem) clamp(1rem, 3.5vw, 1.75rem) clamp(1rem, 3vw, 1.35rem);
  min-height: auto;
  display: block;
  background: var(--cream-panel);
  border: 1px solid rgba(139, 69, 19, 0.12);
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(40, 28, 20, 0.06);
}

.collection-toolbar {
  margin-bottom: 1rem;
}

.collection-list-wrap {
  overflow: visible;
}

.collection-empty-msg:not(.hidden) {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 0;
  padding: 2rem 0.5rem;
  min-height: 8rem;
}

.collection-search {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid rgba(139, 69, 19, 0.22);
  border-radius: 10px;
  font: inherit;
  font-size: calc(0.95rem * var(--text-scale));
  background: var(--surface);
  color: var(--ink);
}

.collection-search:focus {
  outline: 2px solid rgba(160, 82, 45, 0.35);
  outline-offset: 1px;
}

/* Общий .phrase-list выше — max-height ~40vh для модалки; на полной странице скролл у .collection-list-wrap */
.collection-page ul.phrase-list.collection-phrase-list {
  max-height: none;
  overflow: visible;
}

.collection-phrase-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.collection-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.collection-pager.hidden {
  display: none;
}

.collection-pager-info {
  font-size: calc(0.82rem * var(--text-scale));
  color: var(--muted);
  min-width: 8.5rem;
  text-align: center;
}

.collection-pager-btn {
  font-size: calc(0.85rem * var(--text-scale));
}

.collection-gate-link {
  margin-top: 0.75rem;
  display: inline-flex;
  justify-content: center;
}

/* Final mobile overrides for spin filters layout */
@media (max-width: 900px) {
  .stats-today-panel {
    margin-bottom: 1rem;
  }

  .chip-panel-head {
    position: static;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.42rem;
    min-height: 0;
  }

  .chip-panel-title-wrap {
    order: 1;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.34rem;
  }

  .chip-panel-label {
    margin: 0;
    white-space: nowrap;
  }

  .answer-mode-toggle {
    order: 2;
    position: static;
    right: auto;
    top: auto;
    transform: none;
    width: 100%;
    justify-content: center;
  }

  .task-chips-wrap {
    margin-top: 0.2rem;
  }

  .task-types-popover {
    position: fixed;
    left: 50%;
    top: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    width: min(92vw, 26rem);
    max-height: min(68vh, 30rem);
    z-index: 1200;
    padding: 0.8rem 0.9rem 0.95rem;
  }
}

@media (max-width: 640px) {
  .chip-panel-label {
    font-size: calc(1.02rem * var(--text-scale));
  }

  .stats-today-card {
    min-height: 86px;
    padding: 0.68rem 0.7rem 0.72rem;
  }

  .task-types-popover {
    width: min(94vw, 24rem);
    max-height: 66vh;
  }
}
