:root {
  color-scheme: light;
  --paper: #f6f7f5;
  --surface: #ffffff;
  --surface-strong: #fafbf8;
  --ink: #1c211f;
  --muted: #68716c;
  --line: #dde4df;
  --line-strong: #c8d3cd;
  --teal: #176f66;
  --teal-soft: #e8f3ef;
  --red: #b94a43;
  --red-soft: #f8e3df;
  --gold: #b97918;
  --gold-soft: #fbefd4;
  --shadow: 0 16px 38px rgba(35, 47, 43, 0.1);
  --shadow-soft: 0 6px 18px rgba(35, 47, 43, 0.07);
  --focus-ring: 0 0 0 3px rgba(23, 111, 102, 0.18);
  --font-ui:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Apple SD Gothic Neo",
    "Noto Sans KR",
    "Segoe UI",
    sans-serif;
  --font-jp-sans:
    "Hiragino Sans",
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    "YuGothic",
    "Meiryo",
    "Noto Sans CJK JP",
    sans-serif;
  --font-jp-serif:
    "Hiragino Mincho ProN",
    "Yu Mincho",
    "YuMincho",
    "Noto Serif CJK JP",
    serif;
  --font-mono:
    "Geist Mono",
    "SF Mono",
    Menlo,
    Consolas,
    ui-monospace,
    monospace;
  font-family: var(--font-ui);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

body.dialog-open {
  overflow: hidden;
}

body.auth-mode .bottom-nav {
  display: none;
}

body.shell-mode .bottom-nav {
  display: none;
}

body.study-mode .bottom-nav {
  display: none;
}

body.study-mode .app-header {
  display: none;
}

body.auth-mode .app-shell {
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}

body.study-mode .app-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}

body.study-mode {
  overflow: hidden;
}

body.study-mode .app-shell > main,
body.study-mode #view-study.view.active {
  display: grid;
  min-height: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.is-pending:disabled {
  opacity: 0.72;
}

button.is-pending .icon {
  animation: pending-pulse 900ms ease-in-out infinite;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  flex-shrink: 0;
}

.button-content {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  gap: 6px;
  line-height: 1.15;
}

.button-content span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 12px;
  row-gap: 7px;
  margin-bottom: 16px;
  padding: 6px 2px 8px;
  color: var(--ink);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  justify-self: end;
  max-width: min(54vw, 210px);
  flex-shrink: 0;
}

.header-brand {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
}

.app-header .eyebrow {
  color: var(--teal);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.72rem;
  line-height: 1.12;
}

.app-header h1 {
  color: var(--ink);
  font-size: 1.75rem;
  font-weight: 800;
}

.header-context {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 780;
  line-height: 1.3;
}

.header-greeting {
  display: grid;
  gap: 5px;
  grid-column: 1 / -1;
  min-width: 0;
  margin: -2px 0 0;
  color: var(--teal);
  font-size: 0.84rem;
  font-weight: 850;
  line-height: 1.35;
}

.header-greeting[hidden] {
  display: none;
}

.dday-badge {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(23, 111, 102, 0.22);
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 0.74rem;
  font-weight: 950;
  white-space: nowrap;
}

h2 {
  margin-bottom: 12px;
  font-size: 1.22rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.header-user {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
  flex-shrink: 0;
}

.header-user[hidden] {
  display: none;
}

.header-user .small-button {
  min-height: 44px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.8rem;
  box-shadow: var(--shadow-soft);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view h2[tabindex="-1"]:focus {
  outline: none;
}

.panel {
  min-width: 0;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.compact-panel {
  padding: 13px;
}

.stack {
  display: grid;
  gap: 12px;
}

.auth-panel {
  margin-top: 18px;
}

.auth-mascot-card {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 138px;
  padding: 12px;
  border: 1px solid rgba(23, 111, 102, 0.2);
  border-radius: 8px;
  background: var(--teal-soft);
}

.auth-mascot {
  display: block;
  width: 120px;
  height: 120px;
  object-fit: contain;
}

.auth-mascot-card strong {
  display: block;
  color: var(--teal);
  font-size: 1.02rem;
  line-height: 1.32;
}

.auth-heading {
  display: grid;
  gap: 6px;
}

.auth-heading h2 {
  margin-bottom: 0;
}

.auth-note,
.auth-error,
.backup-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.42;
}

.auth-error,
.backup-error {
  border-color: rgba(185, 74, 67, 0.28);
  background: var(--red-soft);
  color: var(--red);
  font-weight: 800;
}

.connection-banner {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: 50%;
  z-index: 45;
  width: min(calc(100% - 24px), 536px);
  padding: 10px 12px;
  border: 1px solid rgba(185, 121, 24, 0.32);
  border-radius: 8px;
  background: var(--gold-soft);
  box-shadow: 0 14px 30px rgba(21, 31, 28, 0.14);
  color: #5f4312;
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.42;
  transform: translateX(-50%);
}

.connection-banner[hidden] {
  display: none;
}

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

.help-disclosure {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.help-disclosure summary {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  margin: -8px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.help-disclosure summary::before {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  content: "";
}

.help-disclosure summary .icon {
  position: relative;
  width: 16px;
  height: 16px;
  z-index: 1;
}

.help-disclosure summary:hover::before {
  background: var(--surface-strong);
}

.help-disclosure summary:hover {
  color: var(--muted);
}

.help-disclosure summary::-webkit-details-marker {
  display: none;
}

.help-disclosure summary:focus-visible {
  outline: none;
}

.help-disclosure summary:focus-visible::before {
  box-shadow: 0 0 0 3px rgba(23, 111, 102, 0.18);
}

.help-disclosure[open] summary::before {
  background: var(--teal-soft);
}

.help-disclosure[open] summary {
  color: var(--teal);
}

.help-disclosure p {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  width: min(280px, calc(100vw - 40px));
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 38px rgba(35, 47, 43, 0.1);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.45;
}

.orientation-note {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin: -4px 0 2px;
  padding: 7px 8px 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.38;
}

.orientation-note.has-visible-note {
  grid-template-columns: 1fr;
  gap: 3px;
}

.orientation-note span {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 850;
}

.orientation-note.has-visible-note > p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.42;
}

.orientation-note .help-disclosure {
  justify-self: end;
}

.orientation-note .help-disclosure p {
  right: 0;
  left: auto;
}

.shell-state-panel {
  margin-top: 18px;
}

.shell-state-panel .button-row {
  margin-top: 2px;
}

.loading-lines {
  display: grid;
  gap: 8px;
  padding-top: 2px;
}

.loading-lines span {
  display: block;
  height: 12px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-strong), var(--teal-soft), var(--surface-strong));
  background-size: 220% 100%;
  animation: loading-sheen 1.4s ease-in-out infinite;
}

.loading-lines span:nth-child(2) {
  width: 82%;
  animation-delay: 0.12s;
}

.loading-lines span:nth-child(3) {
  width: 58%;
  animation-delay: 0.24s;
}

@keyframes loading-sheen {
  0% {
    background-position: 120% 0;
  }

  100% {
    background-position: -120% 0;
  }
}

@keyframes pending-pulse {
  0%,
  100% {
    opacity: 0.42;
  }

  50% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .loading-lines span,
  .study-card,
  button.is-pending .icon {
    animation: none !important;
  }

  .primary-button:not(:disabled):hover,
  .secondary-button:not(:disabled):hover,
  .danger-button:not(:disabled):hover,
  .ghost-button:not(:disabled):hover,
  .segment:not(:disabled):hover,
  .order-option:not(:disabled):hover,
  button:active,
  .today-action-card:active,
  .study-start-panel:active,
  .group-item:active,
  .round-item-button:active {
    transform: none;
  }
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.row > h3 {
  margin-bottom: 0;
}

.meta {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.jp-text {
  font-family: var(--font-jp-sans);
  font-feature-settings: "palt" 1;
  line-height: 1.42;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  min-height: 72px;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.stat strong {
  display: block;
  color: var(--ink);
  font-size: 1.18rem;
  font-weight: 950;
}

.stat span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.stats-page {
  gap: 12px;
}

.stats-today-panel {
  gap: 12px;
}

.stats-filter-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.stats-filter-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  line-height: 1.35;
}

.stats-range-options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stats-range-options .segment {
  min-height: 44px;
  font-size: 0.8rem;
}

.stats-recommend-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(23, 111, 102, 0.26);
  border-radius: 8px;
  background: var(--teal-soft);
}

.stats-recommend-card.danger {
  border-color: rgba(185, 74, 67, 0.26);
  background: var(--red-soft);
}

.stats-recommend-card.good {
  border-color: rgba(23, 111, 102, 0.22);
  background: var(--surface-strong);
}

.stats-recommend-card.quiet {
  border-color: var(--line);
  background: var(--surface-strong);
}

.stats-recommend-card > div {
  min-width: 0;
}

.stats-recommend-card > div > span,
.stats-status-item > span {
  display: block;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 900;
}

.stats-recommend-card.danger > div > span {
  color: var(--red);
}

.stats-recommend-card strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 1.06rem;
  font-weight: 950;
  line-height: 1.32;
}

.stats-recommend-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 720;
  line-height: 1.42;
}

.stats-recommend-card .full {
  width: auto;
  min-width: 116px;
}

.stats-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stats-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stats-metric-card,
.stats-status-item,
.stats-insight,
.stats-insight-strip > div,
.stats-collection-item,
.stats-focus-item,
.stats-healthy-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.stats-metric-card,
.stats-status-item {
  min-height: 104px;
  padding: 12px;
}

.stats-metric-card span,
.stats-status-item span,
.stats-insight span,
.stats-insight-strip span,
.stats-progress-row span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.stats-metric-card strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 1.42rem;
  font-weight: 950;
  line-height: 1.08;
}

.stats-status-item strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 1.3rem;
  font-weight: 950;
  line-height: 1.08;
}

.stats-metric-card p,
.stats-status-item p,
.stats-insight p,
.stats-insight-strip p,
.stats-item-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
  line-height: 1.42;
}

.stats-progress {
  height: 7px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.stats-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.stats-progress.empty span {
  width: 0;
}

.stats-progress-row.danger .stats-progress span {
  background: var(--red);
}

.stats-status-item.good .stats-progress span {
  background: var(--teal);
}

.stats-status-item.danger .stats-progress span {
  background: var(--red);
}

.stats-insight {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.stats-insight > div {
  padding: 12px;
  border-top: 1px solid var(--line);
}

.stats-insight > div:first-child {
  border-top: 0;
}

.stats-insight strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.35;
}

.stats-insight-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stats-insight-strip > div {
  padding: 12px;
}

.stats-insight-strip strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 900;
  line-height: 1.34;
}

.stats-healthy-note {
  display: grid;
  padding: 14px;
  border-color: rgba(23, 111, 102, 0.22);
  background: var(--teal-soft);
}

.stats-healthy-note.has-mascot {
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.stats-healthy-mascot {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: contain;
}

.stats-healthy-note span {
  display: block;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 900;
}

.stats-healthy-note strong {
  display: block;
  margin-top: 5px;
  color: var(--teal);
  font-size: 1rem;
  font-weight: 950;
  line-height: 1.35;
}

.stats-healthy-note p {
  margin: 5px 0 0;
  color: var(--teal);
  font-size: 0.84rem;
  font-weight: 760;
  line-height: 1.42;
}

.stats-collection-list,
.stats-focus-list,
.stats-round-list {
  display: grid;
  gap: 10px;
}

.stats-collection-item,
.stats-focus-item {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.stats-focus-item {
  border-left: 4px solid rgba(185, 74, 67, 0.34);
}

.stats-item-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.stats-item-heading > div {
  min-width: 0;
}

.stats-item-heading strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.35;
}

.stats-item-heading .small-button {
  flex-shrink: 0;
}

.stats-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stats-chip-row span {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.stats-progress-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.stats-progress-row .stats-progress {
  margin-top: 0;
}

.stats-progress-row strong {
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
}

.stats-round-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  text-align: left;
}

.stats-round-item span,
.stats-round-item em {
  min-width: 0;
  font-style: normal;
}

.stats-round-item strong {
  display: block;
  font-size: 0.96rem;
  font-weight: 900;
  line-height: 1.3;
}

.stats-round-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
  line-height: 1.35;
}

.stats-round-item em {
  text-align: right;
}

.stats-round-item em strong {
  color: var(--teal);
}

.stats-round-item i {
  display: inline-flex;
  color: var(--muted);
  font-style: normal;
}

.study-readiness {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.study-readiness.done {
  border-color: rgba(15, 117, 108, 0.34);
  background: var(--teal-soft);
}

.study-readiness p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.study-readiness strong {
  flex-shrink: 0;
  color: var(--teal);
  font-size: 1.05rem;
}

.study-start-panel {
  display: grid;
  gap: 13px;
  padding: 16px;
  border: 1px solid rgba(23, 111, 102, 0.22);
  border-radius: 8px;
  background: var(--teal-soft);
  box-shadow: var(--shadow-soft);
}

.study-start-panel strong {
  display: block;
  color: var(--teal);
  font-size: 1.32rem;
  line-height: 1.15;
}

.study-start-panel p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.38;
}

.study-start-panel .today-action-label {
  color: var(--teal);
}

.study-start-panel .primary-button {
  background: var(--teal);
  color: white;
  box-shadow: var(--shadow-soft);
}

.study-start-panel .ghost-button {
  border-color: rgba(23, 111, 102, 0.18);
  background: white;
  color: var(--ink);
}

.study-start-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 8px;
}

.study-options-panel {
  display: grid;
  gap: 10px;
}

.study-options-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.study-options-toggle span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.study-options-toggle strong {
  font-size: 0.95rem;
}

.study-options-toggle small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 780;
  line-height: 1.35;
}

.study-options-toggle em {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(23, 111, 102, 0.2);
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  font-style: normal;
}

.study-options-toggle em .icon {
  width: 18px;
  height: 18px;
  stroke-width: 2.4;
}

.study-options-body {
  display: grid;
  gap: 12px;
}

.today-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 900;
}

.today-badge.done {
  background: var(--surface);
  color: var(--teal);
}

.today-badge.pending {
  background: var(--surface-strong);
  color: var(--muted);
}

.study-option-block {
  display: grid;
  gap: 8px;
}

.order-options {
  display: grid;
  gap: 8px;
}

.order-options.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.order-option {
  display: grid;
  gap: 4px;
  min-height: 66px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.order-option.active {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.order-option span {
  font-weight: 900;
}

.order-option small {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field label,
.fieldset-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.field-label {
  display: block;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 850;
}

.section-heading-with-help,
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  min-width: 0;
}

.section-heading-with-help > span,
.field-label-row > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.field-label-row {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.section-heading-with-help .help-disclosure,
.field-label-row .help-disclosure {
  flex: 0 0 auto;
}

.form-hint {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.42;
}

.duplicate-warning {
  margin: -4px 0 0;
  padding: 9px 10px;
  border: 1px solid rgba(178, 70, 62, 0.24);
  border-radius: 8px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.4;
}

.duplicate-warning.inline {
  margin-top: 8px;
}

.pending-note {
  margin: 0;
  padding: 9px 10px;
  border: 1px solid rgba(15, 117, 108, 0.2);
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 820;
  line-height: 1.4;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.input,
.select {
  padding: 0 12px;
}

.search-field {
  position: relative;
  display: block;
}

.card-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.card-filter-summary,
.card-location-panel {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.bulk-mode-note {
  display: grid;
  gap: 3px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.bulk-mode-note strong {
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.35;
}

.bulk-mode-note span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 760;
  line-height: 1.4;
}

.card-filter-summary span,
.card-location-panel > div > span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.card-filter-summary strong,
.card-location-panel > div > strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.32;
}

.card-filter-summary p,
.card-location-panel p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
  line-height: 1.4;
}

.search-field .input {
  padding-right: 52px;
  padding-left: 42px;
}

.search-field .input::-webkit-search-cancel-button,
.search-field .input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 13px;
  z-index: 1;
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 3px;
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  transform: translateY(-50%);
}

.search-clear .icon {
  width: 16px;
  height: 16px;
}

.textarea {
  min-height: 88px;
  padding: 12px;
  resize: vertical;
}

input[name="front"],
textarea[name="example_japanese"] {
  font-family: var(--font-jp-sans);
  font-feature-settings: "palt" 1;
  line-height: 1.5;
}

.bulk-textarea,
.backup-textarea {
  min-height: 150px;
  line-height: 1.5;
}

.bulk-textarea,
.backup-textarea {
  font-family: var(--font-mono);
  font-size: 0.86rem;
}

.bulk-textarea {
  max-height: min(42vh, 360px);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--teal);
  box-shadow: var(--focus-ring);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.segmented.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.study-sort-options {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.segment {
  min-height: 44px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.segment.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button {
  min-height: 46px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 850;
}

.primary-button {
  background: var(--teal);
  color: white;
  box-shadow: var(--shadow-soft);
}

.secondary-button {
  border: 1px solid rgba(15, 117, 108, 0.22);
  background: var(--teal-soft);
  color: var(--teal);
}

.danger-button {
  background: var(--red-soft);
  color: var(--red);
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

button:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.danger-button:focus-visible,
.ghost-button:focus-visible,
.segment:focus-visible,
.order-option:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.primary-button:not(:disabled):hover,
.secondary-button:not(:disabled):hover,
.danger-button:not(:disabled):hover,
.ghost-button:not(:disabled):hover,
.segment:not(:disabled):hover,
.order-option:not(:disabled):hover {
  transform: translateY(-1px);
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.segment,
.order-option,
.today-action-card,
.study-start-panel,
.study-options-toggle,
.group-item,
.study-card {
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

button:active,
.today-action-card:active,
.study-start-panel:active,
.group-item:active,
.study-card:active {
  transform: translateY(1px);
}

.study-card:active {
  transform: none;
}

.small-button {
  min-height: 44px;
  padding: 0 12px;
  white-space: nowrap;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.full {
  width: 100%;
}

.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.group-list,
.card-list,
.round-list {
  display: grid;
  gap: 10px;
}

.list-footer {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.list-footer p,
.list-performance-note,
.bulk-preview-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 760;
  line-height: 1.42;
}

.scroll-list {
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.recent-round-scroll {
  max-height: min(44vh, 420px);
}

.study-group-scroll {
  display: grid;
  max-height: min(58vh, 520px);
  gap: 10px;
  overflow-y: auto;
  padding: 3px 4px 3px 0;
  overscroll-behavior: contain;
}

.study-group-tools {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 8px;
  padding: 4px 0 8px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.today-study-panel,
.group-browser-block {
  display: grid;
  gap: 10px;
}

.study-subgroup-panel {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.study-subgroup-list {
  display: grid;
  gap: 10px;
}

.study-subgroup-note {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 760;
  line-height: 1.42;
}

.quick-practice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.quick-practice-grid .ghost-button {
  min-height: 44px;
  padding: 0 8px;
  font-size: 0.78rem;
}

.quick-practice-grid .preset-button.active {
  border-color: rgba(15, 117, 108, 0.3);
  background: var(--teal-soft);
  color: var(--teal);
  box-shadow: inset 0 0 0 1px rgba(15, 117, 108, 0.16);
}

.study-subgroup-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.study-subgroup-option.active {
  border-color: rgba(15, 117, 108, 0.3);
  background: var(--teal-soft);
}

.study-subgroup-option.disabled {
  border-style: dashed;
  background: var(--surface-strong);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 1;
}

.study-subgroup-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.study-subgroup-option.disabled input {
  opacity: 0.58;
}

.study-subgroup-option strong,
.study-subgroup-option small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.study-subgroup-option small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  line-height: 1.35;
}

.today-action-grid,
.today-secondary-grid {
  display: grid;
  gap: 10px;
}

.today-action-card {
  display: grid;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.today-primary-card {
  gap: 14px;
  padding: 17px;
}

.today-primary-card strong {
  font-size: 1.28rem;
}

.today-action-card.primary {
  border-color: rgba(23, 111, 102, 0.24);
  background: var(--surface-mint, var(--teal-soft));
  color: var(--ink);
}

.today-action-card.weak {
  border-color: var(--line);
  background: var(--surface);
}

.today-action-card.weak.has-weak {
  border-color: rgba(185, 74, 67, 0.22);
  background: #fff8f6;
}

.today-action-card.weak.quiet {
  background: var(--surface-strong);
}

.today-action-card.has-mascot {
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
}

.today-action-card.has-mascot .today-card-actions {
  grid-column: 1 / -1;
}

.today-card-mascot {
  display: block;
  width: 76px;
  height: 76px;
  object-fit: contain;
}

.today-action-label {
  display: block;
  margin-bottom: 5px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 900;
}

.today-action-card strong {
  display: block;
  font-size: 1.12rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.today-action-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
  line-height: 1.4;
}

.today-action-card.primary strong,
.today-action-card.primary p {
  color: var(--teal);
}

.today-action-card.primary .today-action-label {
  color: var(--teal);
}

.today-action-card.primary .primary-button {
  background: var(--teal);
  color: white;
  box-shadow: var(--shadow-soft);
}

.today-action-card.weak .today-action-label,
.today-action-card.weak.has-weak strong {
  color: var(--red);
}

.today-action-card.weak.quiet .today-action-label,
.today-action-card.weak.quiet strong {
  color: var(--muted);
}

.today-action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.today-card-actions {
  display: grid;
  gap: 8px;
}

.recent-study-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(15, 117, 108, 0.28);
  border-radius: 8px;
  background: var(--teal-soft);
}

.recent-study-callout strong {
  display: block;
  margin-top: 2px;
  font-size: 1.02rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.recent-study-callout span {
  display: block;
  margin-top: 4px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.35;
}

.recent-study-callout .small-button {
  flex-shrink: 0;
}

.weak-card-panel {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid rgba(185, 74, 67, 0.2);
  border-radius: 8px;
  background: #fff8f6;
}

.weak-card-panel h3 {
  margin-bottom: 0;
}

.weak-card-list {
  display: grid;
  max-height: min(40vh, 360px);
  gap: 8px;
  overflow-y: auto;
  padding-right: 3px;
  overscroll-behavior: contain;
}

.weak-card-item {
  overflow: hidden;
  border: 1px solid rgba(185, 74, 67, 0.16);
  border-radius: 8px;
  background: var(--surface);
}

.weak-card-item.open {
  border-color: rgba(185, 74, 67, 0.3);
}

.weak-card-main {
  display: grid;
  width: 100%;
  gap: 8px;
  padding: 12px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.weak-card-main p {
  margin: 0;
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.weak-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.35;
}

.weak-card-detail {
  display: grid;
  gap: 9px;
  padding: 0 12px 12px;
}

.group-item,
.card-item,
.round-item {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.card-item {
  display: grid;
  gap: 10px;
}

.card-item-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.card-path {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card-front {
  display: block;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.card-back {
  margin: 0;
  color: var(--ink);
  font-size: 0.93rem;
  font-weight: 760;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.card-meta-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.card-meta-strip span {
  min-height: 24px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
}

.quiet-actions {
  margin-top: 0;
}

.quiet-actions .ghost-button,
.quiet-actions .danger-button {
  min-height: 44px;
}

.round-item-button {
  display: block;
  width: 100%;
  color: var(--ink);
  text-align: left;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.round-item-button:hover,
.round-item-button:focus-visible {
  border-color: rgba(15, 117, 108, 0.28);
  background: var(--surface-strong);
}

.round-item-button:active {
  transform: translateY(1px);
}

.round-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.round-detail-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
}

.round-detail-indicator .icon {
  width: 16px;
  height: 16px;
}

.round-time-grid {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.round-time-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.round-time-item span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.round-time-item strong {
  min-width: 0;
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.round-time-item.duration {
  border-color: rgba(15, 117, 108, 0.3);
  background: var(--teal-soft);
}

.round-time-item.duration span,
.round-time-item.duration strong {
  color: var(--teal);
}

.group-item {
  width: 100%;
  color: var(--ink);
  text-align: left;
}

.groups-page-header,
.collection-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.collection-detail-header {
  justify-content: flex-start;
}

.collection-detail-header .ghost-button {
  flex: 0 0 auto;
}

.groups-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.collection-list-main {
  display: block;
  width: 100%;
  padding: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.collection-list-main:focus-visible {
  outline: 3px solid rgba(23, 111, 102, 0.18);
  outline-offset: 3px;
}

.collection-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.collection-card-heading div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.collection-card-heading span:first-child {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 860;
}

.collection-card-heading strong {
  min-width: 0;
  color: var(--ink);
  font-size: 1.04rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.collection-description,
.collection-list-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 760;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.collection-metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 11px 0 9px;
}

.collection-metric-strip span {
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 820;
  text-align: center;
}

.collection-metric-strip strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.1;
}

.collection-detail-summary,
.group-form-context {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.collection-detail-summary p,
.collection-detail-summary small {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 760;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.group-form-context {
  gap: 3px;
  background: var(--teal-soft);
  border-color: rgba(15, 117, 108, 0.22);
}

.group-form-context span {
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 860;
}

.group-form-context strong {
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.subgroup-item-main {
  display: grid;
  gap: 6px;
}

.subgroup-primary-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}

.group-item.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  box-shadow: var(--shadow-soft);
}

.group-choice {
  position: relative;
  min-height: 106px;
  overflow: hidden;
  padding: 0;
}

.group-choice.active::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4px;
  background: var(--teal);
  content: "";
}

.group-choice.empty {
  background: var(--surface-strong);
}

.group-choice-main {
  display: block;
  width: 100%;
  padding: 14px 86px 14px 14px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.group-choice-main:focus-visible,
.group-choice-empty-action:focus-visible {
  outline: 3px solid rgba(23, 111, 102, 0.18);
  outline-offset: -3px;
}

.group-choice-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  line-height: 1.35;
}

.group-choice-footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.group-status-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.status-pill.done {
  border-color: rgba(23, 111, 102, 0.22);
  background: var(--teal-soft);
  color: var(--teal);
}

.status-pill.bad {
  border-color: rgba(185, 74, 67, 0.2);
  background: #fff8f6;
  color: var(--red);
}

.status-pill.muted {
  background: var(--surface-strong);
  color: var(--muted);
}

.status-pill.review {
  border-color: rgba(185, 121, 24, 0.28);
  background: var(--gold-soft);
  color: var(--gold);
}

.subgroup-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.subgroup-metric {
  min-width: 0;
  padding: 9px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.subgroup-metric.accuracy.good {
  border-color: rgba(23, 111, 102, 0.2);
  background: var(--teal-soft);
}

.subgroup-metric.accuracy.warn {
  border-color: rgba(185, 121, 24, 0.22);
  background: var(--gold-soft);
}

.subgroup-metric.accuracy.bad {
  border-color: rgba(185, 74, 67, 0.2);
  background: #fff8f6;
}

.subgroup-metric.accuracy.good strong,
.subgroup-metric.accuracy.good span {
  color: var(--teal);
}

.subgroup-metric.accuracy.warn strong,
.subgroup-metric.accuracy.warn span {
  color: var(--gold);
}

.subgroup-metric.accuracy.bad strong,
.subgroup-metric.accuracy.bad span {
  color: var(--red);
}

.subgroup-metrics strong,
.subgroup-metrics span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.subgroup-metrics strong {
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 950;
  line-height: 1.08;
}

.subgroup-metrics span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 820;
  line-height: 1.25;
}

.subgroup-choice .meta:last-child,
.subgroup-management-item > .meta:last-of-type {
  margin-top: 9px;
}

.subgroup-management-item.empty {
  background: var(--surface-strong);
}

.subgroup-management-item .add-card-button {
  margin-top: 10px;
}

.subgroup-danger-actions {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.group-choice-empty-action {
  width: calc(100% - 28px);
  margin: 0 14px 14px;
}

.group-choice-card-count {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
}

.user-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.user-strip span {
  overflow-wrap: anywhere;
  font-weight: 850;
}

.item-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.item-title strong {
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.pill.good {
  background: var(--teal-soft);
  color: var(--teal);
}

.pill.bad {
  background: var(--red-soft);
  color: var(--red);
}

.group-card-count {
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid transparent;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.group-card-count:hover,
.group-card-count:focus-visible {
  border-color: rgba(23, 111, 102, 0.24);
  background: var(--teal-soft);
  color: var(--teal);
}

.timer-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-size: 0.78rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.reset-history-button {
  margin-top: 10px;
}

.danger-zone {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(209, 68, 68, 0.22);
  border-radius: 8px;
  background: var(--red-soft);
}

.danger-zone.compact {
  margin-top: 10px;
  padding: 0;
  overflow: hidden;
  background: var(--surface-strong);
}

.danger-zone strong,
.danger-zone summary {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 860;
}

.danger-zone p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  line-height: 1.42;
}

.danger-zone summary {
  min-height: 44px;
  padding: 11px 12px;
  cursor: pointer;
  list-style-position: inside;
}

.danger-zone-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.danger-zone.compact .danger-zone-actions {
  padding: 0 12px 12px;
}

.completion-panel {
  gap: 14px;
  padding-bottom: 158px;
}

.completion-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.completion-title-row h2 {
  margin-bottom: 0;
}

.completion-record-note {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(23, 111, 102, 0.2);
  border-radius: 8px;
  background: var(--teal-soft);
}

.completion-record-note.practice {
  border-color: var(--line);
  background: var(--surface-strong);
}

.completion-record-note.review {
  border-color: rgba(185, 121, 24, 0.28);
  background: var(--gold-soft);
}

.completion-record-note strong {
  color: var(--ink);
  font-size: 0.94rem;
}

.completion-record-note p {
  margin: 0;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 760;
  line-height: 1.45;
}

.completion-celebration {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 146px;
  padding: 12px;
  border: 1px solid rgba(23, 111, 102, 0.2);
  border-radius: 8px;
  background: var(--teal-soft);
}

.completion-mascot {
  display: block;
  width: 120px;
  height: 120px;
  object-fit: contain;
}

.completion-celebration strong {
  display: block;
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.32;
}

.completion-celebration p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
  line-height: 1.4;
}

#completion-summary,
#wrong-review,
#correct-review {
  scroll-margin-top: 10px;
}

.completion-scoreboard {
  display: grid;
  gap: 10px;
}

.completion-main-score {
  padding: 16px;
  border: 1px solid rgba(23, 111, 102, 0.24);
  border-radius: 8px;
  background: var(--teal-soft);
}

.completion-scoreboard.practice .completion-main-score {
  border-color: var(--line);
  background: var(--surface-strong);
}

.completion-scoreboard.review .completion-main-score {
  border-color: rgba(185, 121, 24, 0.28);
  background: var(--gold-soft);
}

.completion-main-score strong {
  display: block;
  color: var(--teal);
  font-size: 2rem;
  line-height: 1;
}

.completion-main-score span {
  display: block;
  color: var(--teal);
  font-size: 0.86rem;
  font-weight: 850;
}

.completion-main-score p {
  margin: 7px 0 0;
  color: var(--teal);
  font-size: 0.84rem;
  font-weight: 760;
  line-height: 1.38;
}

.completion-scoreboard.practice .completion-main-score strong,
.completion-scoreboard.practice .completion-main-score span,
.completion-scoreboard.practice .completion-main-score p {
  color: var(--ink);
}

.completion-scoreboard.review .completion-main-score strong,
.completion-scoreboard.review .completion-main-score span,
.completion-scoreboard.review .completion-main-score p {
  color: var(--gold);
}

.completion-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.completion-metric-grid div {
  min-height: 72px;
  padding: 11px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.completion-metric-grid strong {
  display: block;
  font-size: 1.14rem;
}

.completion-metric-grid span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.duration-comparison {
  display: grid;
  gap: 5px;
  padding: 13px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.duration-comparison.faster {
  border-left-color: var(--teal);
}

.duration-comparison.slower {
  border-left-color: var(--gold);
}

.duration-comparison span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.duration-comparison strong {
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.35;
}

.duration-comparison p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 760;
  line-height: 1.4;
}

.completion-details {
  display: grid;
  gap: 12px;
}

.completion-focus {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.completion-focus.good {
  border-left: 4px solid var(--teal);
}

.completion-focus.bad {
  border-left: 4px solid var(--red);
}

.completion-focus h3 {
  margin-bottom: 6px;
}

.completion-focus p {
  margin-bottom: 6px;
  line-height: 1.42;
}

.completion-section {
  display: grid;
  gap: 8px;
}

.completion-section-copy {
  margin: 0;
}

.completion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.completion-header h3 {
  margin-bottom: 0;
}

.completion-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.result-list {
  display: grid;
  gap: 8px;
}

.completion-collapsed-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(15, 117, 108, 0.28);
  border-radius: 8px;
  background: var(--teal-soft);
}

.completion-collapsed-summary > div {
  min-width: 0;
}

.completion-collapsed-summary strong {
  display: block;
  color: var(--teal);
  font-size: 0.98rem;
  line-height: 1.3;
}

.completion-collapsed-summary p {
  margin: 4px 0 0;
  color: var(--teal);
  font-size: 0.8rem;
  font-weight: 760;
  line-height: 1.35;
}

.completion-collapsed-summary .small-button {
  flex-shrink: 0;
}

.wrong-review-list {
  display: grid;
  gap: 10px;
}

.wrong-review-card {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-left: 4px solid rgba(185, 74, 67, 0.34);
  border-radius: 8px;
  background: var(--surface);
}

.wrong-review-block {
  display: grid;
  gap: 7px;
}

.wrong-review-meaning {
  margin: 0;
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 850;
  line-height: 1.42;
}

.attempt-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attempt-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 850;
}

.attempt-chip.good {
  background: var(--teal-soft);
  color: var(--teal);
}

.attempt-chip.bad {
  background: var(--red-soft);
  color: var(--red);
}

.review-examples {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-examples li {
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 3px solid rgba(23, 111, 102, 0.28);
  border-radius: 8px;
  background: var(--surface-strong);
}

.bulk-preview {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.bulk-preview-list {
  display: grid;
  max-height: min(34vh, 360px);
  gap: 8px;
  overflow-y: auto;
  padding-right: 3px;
  overscroll-behavior: contain;
}

.bulk-preview-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.bulk-preview-item.warn {
  border-left: 4px solid var(--red);
}

.bulk-preview .completion-header h3 {
  margin-bottom: 2px;
}

.bulk-row-issues {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  padding: 9px 10px;
  border: 1px solid rgba(185, 74, 67, 0.24);
  border-radius: 8px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.4;
}

.bulk-row-issues p {
  margin: 0;
}

.bulk-issues {
  display: grid;
  max-height: min(28vh, 220px);
  gap: 4px;
  overflow-y: auto;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.4;
  overscroll-behavior: contain;
}

.bulk-issues p {
  margin: 0;
}

.bulk-issues.bad {
  border: 1px solid rgba(178, 70, 62, 0.24);
  background: var(--red-soft);
  color: var(--red);
}

.bulk-issues.warn {
  border: 1px solid rgba(185, 121, 24, 0.28);
  background: var(--gold-soft);
  color: var(--gold);
}

.card-preview-example {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-strong);
}

.card-preview-example.compact {
  margin: 0;
}

.result-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.result-item.bad {
  border-left: 4px solid var(--red);
}

.result-item.good {
  border-left: 4px solid var(--teal);
}

.result-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.42;
}

.completion-sticky-actions {
  position: fixed;
  left: 50%;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 18;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(calc(100% - 32px), 528px);
  transform: translateX(-50%);
  gap: 6px;
  padding: 6px;
  border: 1px solid rgba(214, 224, 219, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.completion-sticky-actions .full {
  min-height: 44px;
  padding-right: 6px;
  padding-left: 6px;
  font-size: 0.82rem;
}

.completion-sticky-actions .primary-button {
  grid-column: 1 / -1;
  order: 2;
  min-height: 48px;
}

.completion-sticky-actions .secondary-button,
.completion-sticky-actions .ghost-button {
  order: 1;
}

.completion-sticky-actions .button-content {
  gap: 4px;
  white-space: normal;
}

.completion-sticky-actions .button-content span {
  overflow-wrap: anywhere;
  white-space: normal;
}

.completion-sticky-actions .icon {
  width: 16px;
  height: 16px;
}

.study-session-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}

.study-session-controls .small-button {
  min-height: 44px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--muted);
}

.study-session-controls .pill,
.study-session-controls .timer-pill {
  min-height: 28px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--muted);
  box-shadow: none;
}

.study-shell {
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  min-height: 0;
  height: 100%;
  padding-bottom: 0;
}

.study-quick-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.study-card {
  position: relative;
  display: grid;
  align-content: center;
  min-height: 0;
  height: 100%;
  width: 100%;
  padding: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(22, 34, 31, 0.12);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
  -webkit-overflow-scrolling: touch;
  animation: study-card-enter 180ms ease;
}

.study-card.front {
  min-height: 300px;
  align-content: center;
  border-top: 4px solid var(--teal);
}

.study-card.back {
  align-content: start;
  border-top: 4px solid var(--teal);
  text-align: left;
}

.study-card[role="button"] {
  cursor: pointer;
}

.study-card.answer-feedback-correct {
  border-color: rgba(22, 107, 98, 0.62);
  box-shadow: var(--shadow);
}

.study-card.answer-feedback-wrong {
  border-color: rgba(178, 70, 62, 0.64);
  box-shadow: var(--shadow);
}

.answer-feedback-label {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  color: white;
  font-size: 0.82rem;
  font-weight: 900;
  box-shadow: var(--shadow-soft);
}

.answer-feedback-label.answer-feedback-correct {
  background: var(--teal);
}

.answer-feedback-label.answer-feedback-wrong {
  background: var(--red);
}

.study-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.study-front-content,
.study-back-content {
  display: grid;
  min-width: 0;
  width: 100%;
}

.study-front-content {
  justify-items: center;
  gap: 13px;
}

.study-back-content {
  gap: 16px;
}

.study-card-meta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.study-card.back .study-card-meta {
  justify-content: flex-start;
}

.study-card-meta .meta {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.study-weak-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(178, 70, 62, 0.2);
  border-radius: 999px;
  background: rgba(246, 222, 217, 0.52);
  color: var(--red);
  font-size: 0.73rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.study-weak-badge .icon {
  width: 13px;
  height: 13px;
  stroke-width: 2.3;
}

.grammar {
  margin: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 2.22rem;
  line-height: 1.25;
}

.grammar.script-jp {
  font-family: var(--font-jp-serif);
  font-weight: 760;
}

.grammar.script-cjk {
  font-family: var(--font-jp-sans);
  font-weight: 780;
}

.grammar.script-latin,
.grammar.script-generic {
  font-family: var(--font-ui);
  font-weight: 850;
}

.grammar.density-medium {
  font-size: 1.72rem;
  line-height: 1.34;
}

.grammar.density-long {
  justify-self: stretch;
  font-size: 1.28rem;
  line-height: 1.48;
  text-align: left;
}

.study-back-section {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.study-section-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1.2;
}

.meaning-section {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.meaning {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 1.34rem;
  font-weight: 850;
  line-height: 1.42;
}

.study-note {
  margin: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf9;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.42;
}

.example-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.examples {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.example-toggle {
  margin-top: 10px;
}

.example {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid rgba(23, 111, 102, 0.28);
  border-radius: 8px;
  background: var(--surface-strong);
}

.example-jp {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-jp-sans);
  font-feature-settings: "palt" 1;
  font-size: 0.98rem;
  font-weight: 520;
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.example-ko {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid rgba(214, 224, 219, 0.8);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.grammar-mark {
  padding: 0 0.1em 0.07em;
  border-radius: 4px;
  background: var(--gold-soft);
  box-shadow: inset 0 -0.28em rgba(185, 121, 24, 0.12);
  color: inherit;
  font-weight: 760;
}

.progress {
  overflow: hidden;
  height: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  transition: width 180ms ease;
}

.study-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-height: 58px;
}

.study-action-bar {
  position: relative;
  bottom: auto;
  z-index: 15;
  display: grid;
  align-items: center;
  min-height: 76px;
  padding: 8px;
  border: 1px solid rgba(214, 224, 219, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.study-action-bar.answer-feedback-correct {
  border-color: rgba(22, 107, 98, 0.5);
}

.study-action-bar.answer-feedback-wrong {
  border-color: rgba(178, 70, 62, 0.5);
}

.reveal-button {
  min-height: 58px;
}

.answer-wrong,
.answer-correct {
  min-height: 58px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 900;
}

.answer-wrong {
  background: var(--red);
  color: white;
}

.answer-correct {
  background: var(--teal);
  color: white;
}

.answer-wrong:disabled,
.answer-correct:disabled {
  cursor: default;
  opacity: 0.58;
}

.study-action-bar.answer-feedback-wrong .answer-wrong,
.study-action-bar.answer-feedback-correct .answer-correct {
  opacity: 1;
  box-shadow: var(--shadow-soft);
}

@keyframes study-card-enter {
  from {
    opacity: 0.76;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-height: 620px) {
  body.study-mode .app-shell {
    padding-top: calc(10px + env(safe-area-inset-top));
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .study-shell {
    gap: 8px;
  }

  .study-card {
    padding: 18px;
  }

  .study-card.front {
    min-height: 0;
  }

  .study-action-bar {
    min-height: 68px;
    padding: 6px;
  }

  .reveal-button,
  .answer-wrong,
  .answer-correct {
    min-height: 54px;
  }
}

@media (max-height: 480px) {
  .study-shell {
    gap: 7px;
  }

  .study-card {
    padding: 14px;
  }

  .study-quick-stats {
    display: none;
  }

  .grammar {
    font-size: 1.86rem;
  }

  .grammar.density-medium {
    font-size: 1.42rem;
  }

  .grammar.density-long {
    font-size: 1.08rem;
  }
}

.empty-state {
  padding: 20px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  line-height: 1.55;
  text-align: center;
}

.empty-state.action-empty {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.empty-state-mascot {
  display: block;
  width: 92px;
  height: 92px;
  object-fit: contain;
  margin-bottom: -2px;
}

.empty-state.action-empty strong {
  color: var(--ink);
  font-size: 0.94rem;
}

.empty-state.action-empty p {
  max-width: 32rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 760;
  line-height: 1.45;
}

.disabled-reason {
  margin: -2px 0 0;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 760;
  line-height: 1.4;
}

.example-editor-list {
  display: grid;
  max-height: min(44vh, 420px);
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.example-row {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.example-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.example-row-header strong {
  font-size: 0.9rem;
}

.example-row-body {
  display: grid;
  gap: 8px;
}

.example-row.collapsed .example-row-body {
  display: none;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.settings-summary {
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid rgba(23, 111, 102, 0.24);
  border-radius: 8px;
  background: var(--teal-soft);
}

.settings-summary.empty {
  border-color: var(--line);
  background: var(--surface-strong);
}

.settings-summary.empty span,
.settings-summary.empty p {
  color: var(--muted);
}

.settings-summary span {
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 850;
}

.settings-summary strong {
  color: var(--teal);
  font-size: 1.45rem;
  line-height: 1.1;
}

.settings-summary.empty strong {
  color: var(--ink);
  font-size: 1.08rem;
}

.settings-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.settings-subsection {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

#settings-form .field,
#settings-form .number-setting,
#card-form .field,
#card-form .example-row,
#card-form .duplicate-warning {
  scroll-margin-top: 16px;
  scroll-margin-bottom: calc(112px + env(safe-area-inset-bottom));
}

.settings-form-actions,
.card-form-actions {
  position: sticky;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 12;
  margin-top: 2px;
  padding: 6px;
  border: 1px solid rgba(214, 224, 219, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.data-safety-panel h2 {
  margin-bottom: 0;
}

.safety-note-grid {
  display: grid;
  gap: 9px;
}

.safety-note,
.data-safety-summary,
.weak-rule-preview {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.safety-note.compact {
  padding: 8px 10px;
}

.safety-note strong,
.data-safety-summary strong {
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.35;
}

.safety-note p,
.data-safety-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
  line-height: 1.45;
}

.data-safety-summary {
  border-color: rgba(185, 74, 67, 0.24);
  background: var(--red-soft);
}

.weak-rule-preview {
  grid-template-columns: 1fr;
  border-color: rgba(23, 111, 102, 0.2);
  background: var(--teal-soft);
}

.weak-rule-preview span {
  color: var(--teal);
  font-size: 0.8rem;
  font-weight: 850;
  line-height: 1.35;
}

.number-setting {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.number-setting span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
  white-space: nowrap;
}

.weak-rule-grid {
  display: grid;
  gap: 8px;
}

.weak-rule-setting {
  grid-template-columns: auto minmax(72px, 1fr) auto;
  min-height: 44px;
}

.weak-rule-setting.total {
  grid-template-columns: minmax(0, 1fr) minmax(72px, 0.7fr) auto;
}

.date-select-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(0, 0.91fr) minmax(0, 0.91fr);
  gap: 8px;
}

.date-select-grid .select {
  min-width: 0;
  padding-right: 8px;
  padding-left: 10px;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(20, 31, 28, 0.12);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(18px);
}

.nav-button {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  min-height: 56px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.nav-button.active {
  background: var(--teal-soft);
  color: var(--teal);
  box-shadow: none;
}

.nav-button.active .nav-icon {
  color: var(--teal);
}

.nav-icon {
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
}

.nav-icon .icon {
  width: 21px;
  height: 21px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  left: 16px;
  z-index: 40;
  display: none;
  width: min(480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 750;
  line-height: 1.4;
  box-shadow: var(--shadow);
}

.toast.show {
  display: block;
}

body.study-mode .toast {
  bottom: calc(112px + env(safe-area-inset-bottom));
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  align-items: end;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: rgba(20, 31, 28, 0.42);
  backdrop-filter: blur(8px);
}

.dialog-panel {
  width: min(100%, 488px);
  max-height: min(86vh, 760px);
  margin: 0 auto;
  overflow-y: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
}

.dialog-panel h2 {
  margin-bottom: 8px;
  font-size: 1.18rem;
}

.dialog-panel .button-row {
  margin-top: 16px;
}

.preview-dialog {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 12px;
  overflow: hidden;
}

.collection-study-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(86vh, 760px);
  gap: 12px;
  overflow: hidden;
}

.collection-study-body {
  display: grid;
  align-content: start;
  grid-auto-rows: max-content;
  min-height: 0;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.collection-study-note {
  margin: 0;
}

.collection-study-dialog .study-subgroup-panel {
  min-height: 0;
}

.collection-study-dialog .study-subgroup-list {
  max-height: min(36vh, 340px);
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.collection-study-dialog .button-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.collection-study-dialog .quick-practice-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.collection-study-dialog .quick-practice-grid .ghost-button {
  padding-right: 6px;
  padding-left: 6px;
  font-size: 0.74rem;
}

.collection-study-dialog .practice-summary {
  gap: 8px;
  padding: 10px;
  box-shadow: none;
}

.collection-study-dialog .practice-summary .today-action-label {
  margin-bottom: 3px;
}

.collection-study-dialog .practice-summary strong {
  font-size: 1.02rem;
  line-height: 1.25;
}

.collection-study-dialog .practice-summary p {
  margin-top: 4px;
  font-size: 0.78rem;
  line-height: 1.3;
}

.collection-study-dialog .practice-summary .study-start-actions {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 8px;
}

.collection-study-dialog .practice-summary .primary-button,
.collection-study-dialog .practice-summary .ghost-button {
  min-height: 44px;
  padding-right: 8px;
  padding-left: 8px;
}

.round-detail-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: min(86vh, 760px);
  max-height: min(86vh, 760px);
  gap: 12px;
  overflow: hidden;
}

.round-detail-body {
  display: grid;
  min-height: 0;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.round-detail-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.round-detail-metrics div {
  min-height: 68px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.round-detail-metrics strong {
  display: block;
  font-size: 1.1rem;
}

.round-detail-metrics span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
}

.round-detail-section {
  display: grid;
  gap: 8px;
}

.round-detail-list {
  display: grid;
  min-height: 0;
  gap: 8px;
}

.round-detail-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.round-detail-card.good {
  border-left-color: var(--teal);
}

.round-detail-card.bad {
  border-left-color: var(--red);
}

.round-detail-card p {
  margin: 0 0 9px;
  color: var(--teal);
  font-size: 0.95rem;
  font-weight: 850;
  line-height: 1.36;
}

.round-detail-card .attempt-timeline {
  margin-bottom: 0;
}

.preview-list {
  display: grid;
  min-height: 0;
  max-height: min(52vh, 460px);
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.preview-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.preview-card p {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 1rem;
  font-weight: 850;
  line-height: 1.35;
}

.preview-card .meta {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

@media (min-width: 521px) {
  .app-shell {
    padding-right: 18px;
    padding-left: 18px;
  }
}

@media (max-width: 480px) {
  #settings-form .help-disclosure p,
  .data-safety-panel .help-disclosure p,
  #bulk-card-form .help-disclosure p {
    position: fixed;
    top: auto;
    right: 16px;
    bottom: calc(86px + env(safe-area-inset-bottom));
    left: 16px;
    width: auto;
    max-height: min(42vh, 220px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .card-location-grid {
    grid-template-columns: 1fr;
  }

  .bulk-textarea {
    min-height: 124px;
    max-height: min(30vh, 260px);
  }

  .bulk-preview {
    gap: 8px;
    padding: 10px;
  }

  .bulk-preview-list {
    max-height: min(30vh, 260px);
  }

  .bulk-issues {
    max-height: min(24vh, 180px);
  }

  .subgroup-danger-actions,
  .danger-zone.compact .danger-zone-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .order-options.two {
    grid-template-columns: 1fr;
  }

  .button-row,
  .form-actions,
  .card-filter-grid,
  .collection-metric-strip,
  .danger-zone-actions,
  .study-start-actions,
  .today-action-buttons,
  .quick-practice-grid {
    grid-template-columns: 1fr;
  }

  .groups-page-header,
  .collection-card-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .groups-header-actions {
    justify-content: flex-start;
  }

  .study-card {
    padding: 18px;
  }

  .date-select-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.82fr) minmax(0, 0.82fr);
    gap: 6px;
  }

  .date-select-grid .select {
    padding-right: 6px;
    padding-left: 8px;
  }

  .settings-form-actions .primary-button,
  .card-form-actions .primary-button {
    order: -1;
  }

  .stats-recommend-card {
    grid-template-columns: 1fr;
  }

  .stats-recommend-card .full {
    width: 100%;
  }

  .stats-overview,
  .stats-insight-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-status-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats-status-item {
    min-height: 98px;
    padding: 10px 8px;
  }

  .stats-status-item strong {
    font-size: 1.18rem;
  }

  .stats-item-heading {
    display: grid;
  }

  .stats-item-heading .small-button {
    width: 100%;
  }

  .stats-round-item {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .stats-round-item em {
    text-align: left;
  }

  .stats-round-item i {
    display: none;
  }

  .completion-sticky-actions {
    grid-template-columns: 1fr;
  }

  .completion-panel {
    padding-bottom: 190px;
  }
}
