:root {
  --paper: #f6fbf8;
  --surface: #ffffff;
  --ink: #17333a;
  --muted: #5e747a;
  --line: #d9e7e4;
  --primary: #147b73;
  --primary-pressed: #0e625c;
  --primary-soft: #dff4ef;
  --chinese: #c64b43;
  --chinese-soft: #ffe9e6;
  --math: #167653;
  --math-soft: #dff7ea;
  --english: #3564b0;
  --english-soft: #e8efff;
  --shell: #f4c95d;
  --danger: #b33f3f;
  --shadow: 0 10px 28px rgba(23, 51, 58, 0.12);
  font-family: "Alibaba PuHuiTi", "HarmonyOS Sans SC", "Microsoft YaHei UI", sans-serif;
  color: var(--ink);
  background: #e4f0ed;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-height: 100%; background: #e4f0ed; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background: #e4f0ed;
  color: var(--ink);
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible {
  outline: 3px solid rgba(244, 201, 93, 0.9);
  outline-offset: 2px;
}

::selection { color: #fff; background: var(--primary); }

.app-shell {
  position: relative;
  width: min(100%, 480px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  overflow-x: clip;
}

.ocean-header {
  position: relative;
  min-height: 178px;
  padding: calc(22px + env(safe-area-inset-top)) 22px 24px;
  overflow: hidden;
  background: #dff3f2;
  border-bottom: 1px solid #cde5e1;
}

.ocean-header::after {
  content: "";
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: -28px;
  height: 54px;
  background: var(--paper);
  border-radius: 50% 50% 0 0;
}

.brand-block { position: relative; z-index: 2; max-width: 62%; }
.brand-name { margin: 0 0 8px; font-size: 14px; font-weight: 800; color: #0f6c65; }
.ocean-header h1 { margin: 0; font-size: 26px; line-height: 1.18; font-weight: 800; }
.header-subtitle { margin: 8px 0 0; color: #526d73; font-size: 14px; font-weight: 600; }

.guide-shark {
  position: absolute;
  z-index: 1;
  right: -22px;
  bottom: 2px;
  width: 205px;
  height: 162px;
  object-fit: cover;
  object-position: 48% 50%;
  border-radius: 42% 0 0 0;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.icon-button:hover { background: rgba(20, 123, 115, 0.09); }
.icon-button:active { background: rgba(20, 123, 115, 0.16); }
.icon-button svg { width: 22px; height: 22px; stroke-width: 2.2; }
.settings-button { position: absolute; z-index: 3; top: calc(18px + env(safe-area-inset-top)); right: 14px; background: rgba(255,255,255,0.72); }

main { padding: 4px 18px calc(106px + env(safe-area-inset-bottom)); }
.view { animation: view-in 180ms cubic-bezier(.2,.8,.2,1); }
.view[hidden] { display: none; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-heading-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 2px 14px;
}
.section-heading-row h2 { margin: 0 0 5px; font-size: 22px; line-height: 1.2; }
.muted { margin: 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.progress-copy { margin: 0 0 3px; color: var(--muted); font-size: 14px; font-weight: 700; white-space: nowrap; }
.progress-copy strong { color: var(--primary); font-size: 21px; }

.subject-list { display: grid; gap: 10px; }
.subject-block {
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface);
}
.subject-block[data-subject="chinese"] { background: var(--chinese-soft); }
.subject-block[data-subject="math"] { background: var(--math-soft); }
.subject-block[data-subject="english"] { background: var(--english-soft); }
.subject-summary {
  display: grid;
  grid-template-columns: 76px 1fr auto 28px;
  min-height: 104px;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 10px 8px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.subject-summary:hover { filter: saturate(1.06); }
.subject-art { width: 76px; height: 74px; object-fit: cover; border-radius: 8px; mix-blend-mode: multiply; }
.subject-card-art { position: relative; display: block; overflow: hidden; border: 2px solid rgba(255,255,255,.78); background: #dff3f2; mix-blend-mode: normal; }
.subject-card-art.is-rare { border-color: #d7b957; box-shadow: inset 0 0 0 2px #173f55; }
.subject-card-art .species-art { width: 100%; height: 100%; }
.subject-name { font-size: 20px; font-weight: 800; }
.grade-status {
  display: grid;
  min-width: 72px;
  height: 50px;
  padding: 0 14px;
  place-items: center;
  border-radius: 16px;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,0.7);
}
.grade-status.is-empty { color: var(--muted); font-size: 14px; }
.grade-status.is-no-homework { min-width: 78px; color: #45665f !important; background: rgba(255,255,255,.8) !important; font-size: 13px; }
.subject-block[data-subject="chinese"] .grade-status:not(.is-empty) { color: #fff; background: var(--chinese); }
.subject-block[data-subject="math"] .grade-status:not(.is-empty) { color: #fff; background: var(--math); }
.subject-block[data-subject="english"] .grade-status:not(.is-empty) { color: #fff; background: var(--english); }
.summary-chevron { display: grid; place-items: center; transition: transform 180ms ease; }
.subject-block.is-open .summary-chevron { transform: rotate(180deg); }
.summary-chevron svg { width: 20px; height: 20px; }

.grade-picker {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  padding: 0 10px 12px;
}
.grade-picker button {
  position: relative;
  min-width: 0;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(23,51,58,0.09);
  border-radius: 14px;
  background: rgba(255,255,255,0.72);
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.grade-picker button.is-selected { color: #fff; }
.grade-picker button[data-subject="chinese"].is-selected { background: var(--chinese); }
.grade-picker button[data-subject="math"].is-selected { background: var(--math); }
.grade-picker button[data-subject="english"].is-selected { background: var(--english); }
.grade-picker button.is-selected::after { content: ""; position: absolute; width: 5px; height: 5px; border-radius: 50%; right: 7px; top: 7px; background: #fff; }
.grade-picker .no-homework-option { grid-column: 1 / -1; height: 42px; color: #45665f; }
.grade-picker .no-homework-option.is-selected { color: #fff; background: #567e74 !important; }

.save-dock { margin-top: 16px; }
.reward-hint { min-height: 22px; margin: 0 4px 9px; color: #486b66; font-size: 13px; font-weight: 750; text-align: center; }
.primary-button, .secondary-button, .danger-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 16px;
  font-weight: 800;
  cursor: pointer;
}
.primary-button { width: 100%; border: 0; color: #fff; background: var(--primary); box-shadow: 0 7px 18px rgba(23,51,58,0.16); }
.primary-button:hover { background: #116f67; }
.primary-button:active { background: var(--primary-pressed); transform: translateY(1px); }
.primary-button:disabled { color: #78908f; background: #d9e6e2; box-shadow: none; cursor: not-allowed; }
.primary-button svg, .secondary-button svg { width: 19px; height: 19px; }
.secondary-button { border: 1px solid #a9cbc5; color: var(--primary); background: #fff; }
.secondary-button:hover { background: var(--primary-soft); }
.compact-button { min-height: 42px; padding: 0 14px; border-radius: 14px; }
.danger-button { width: 100%; border: 1px solid #e2b7b7; color: var(--danger); background: #fff5f5; }

.month-switcher {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  margin: 4px 0 12px;
  text-align: center;
}
.month-switcher strong { font-size: 18px; }
.month-switcher button:disabled { color: #aebdbb; cursor: not-allowed; }
.month-switcher button:disabled:hover { background: transparent; }
.history-calendar { margin-top: 4px; }
.calendar-panel {
  padding: 12px 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.calendar-weekdays, .calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.calendar-weekdays { margin-bottom: 6px; }
.calendar-weekdays span {
  display: grid;
  height: 28px;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.calendar-grid { gap: 4px 2px; }
.calendar-spacer { min-width: 0; height: 50px; }
.calendar-day {
  position: relative;
  display: grid;
  min-width: 0;
  height: 50px;
  padding: 6px 2px 5px;
  place-items: start center;
  align-content: space-between;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.calendar-day:hover { background: #f0f7f5; }
.calendar-day:active { background: #e2f1ed; }
.calendar-day.is-today { border-color: var(--primary); }
.calendar-day.has-record { background: var(--primary-soft); }
.calendar-day.is-complete { color: #fff; background: var(--primary); }
.calendar-day:disabled { color: #bcc7c5; background: transparent; cursor: not-allowed; }
.calendar-day:disabled:hover { background: transparent; }
.calendar-day-number { line-height: 1; font-variant-numeric: tabular-nums; }
.calendar-complete {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  width: 14px;
  height: 14px;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--primary);
}
.calendar-complete svg { width: 10px; height: 10px; stroke-width: 3; }
.record-dots { display: grid; grid-template-columns: repeat(3, 6px); gap: 3px; min-height: 6px; }
.record-dot { width: 6px; height: 6px; border-radius: 50%; background: #cbd8d5; }
.record-dot.chinese.is-filled { background: var(--chinese); }
.record-dot.math.is-filled { background: var(--math); }
.record-dot.english.is-filled { background: var(--english); }
.calendar-day.is-complete .record-dot { background: rgba(255,255,255,.9); }
.calendar-summary {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 16px 2px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.calendar-legend span { display: inline-flex; align-items: center; gap: 5px; }
.calendar-legend .record-dot { display: inline-block; }

.empty-state { padding: 44px 20px; text-align: center; }
.empty-state img { width: 154px; height: 100px; object-fit: cover; object-position: 50% 54%; border-radius: 50%; mix-blend-mode: multiply; }
.empty-state h3 { margin: 14px 0 6px; font-size: 18px; }
.empty-state p { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.6; }

.segmented-control { display: grid; grid-template-columns: repeat(3,1fr); padding: 4px; border-radius: 16px; background: #e9f1ef; }
.segmented-control button { min-height: 42px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-weight: 800; cursor: pointer; }
.segmented-control button.is-selected { color: #fff; background: var(--primary); }
.insight-strip { display: grid; grid-template-columns: 86px 1fr; align-items: center; gap: 8px; margin: 14px 0; padding: 8px 14px 8px 4px; border-radius: 8px; background: var(--primary-soft); }
.insight-strip img { width: 86px; height: 70px; object-fit: cover; border-radius: 8px; mix-blend-mode: multiply; }
.insight-strip p { margin: 0; font-size: 15px; line-height: 1.5; font-weight: 800; }
.chart-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.chart-section h3 { margin: 0 0 10px; font-size: 18px; }
.chart-wrap { overflow-x: auto; padding-bottom: 3px; }
.trend-chart { display: block; width: 100%; min-width: 340px; height: auto; }
.chart-grid { stroke: #dbe7e4; stroke-width: 1; stroke-dasharray: 3 4; }
.chart-axis-label { fill: #657a7f; font-size: 10px; font-weight: 700; }
.chart-line { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-point { stroke: #fff; stroke-width: 1.5; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.distribution { display: grid; gap: 13px; }
.distribution-row { display: grid; grid-template-columns: 38px 1fr; align-items: center; gap: 9px; }
.distribution-label { font-size: 13px; font-weight: 800; }
.stack { display: flex; height: 24px; overflow: hidden; border-radius: 8px; background: #edf3f1; }
.stack span { min-width: 2px; height: 100%; }
.distribution-note { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.bottom-nav {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 480px);
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,0.97);
  box-shadow: 0 -7px 22px rgba(23,51,58,0.08);
}
.bottom-nav button { display: grid; min-height: 58px; place-items: center; align-content: center; gap: 3px; border: 0; background: transparent; color: #718288; font-size: 12px; font-weight: 800; cursor: pointer; }
.bottom-nav button svg { width: 23px; height: 23px; stroke-width: 2.3; }
.bottom-nav button.is-selected { color: var(--primary); }
.bottom-nav button.is-selected::after { content: ""; width: 24px; height: 3px; border-radius: 999px; background: var(--primary); }
.nav-icon-wrap { position: relative; display: grid; place-items: center; }
.nav-icon-wrap b { position: absolute; top: -7px; right: -13px; display: grid; min-width: 18px; height: 18px; padding: 0 5px; place-items: center; border: 2px solid #fff; border-radius: 9px; color: #fff; background: var(--chinese); font-size: 10px; line-height: 1; }
.nav-icon-wrap b[hidden] { display: none; }

.bottom-sheet {
  width: min(100% - 18px, 462px);
  max-height: calc(100dvh - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
  margin: auto;
  padding: 12px 18px calc(22px + env(safe-area-inset-bottom));
  overflow-y: auto;
  border: 0;
  border-radius: 18px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 -12px 34px rgba(23,51,58,.18);
}
.bottom-sheet::backdrop { background: rgba(13, 34, 38, 0.42); }
.bottom-sheet[open] { animation: sheet-in 220ms cubic-bezier(.2,.8,.2,1); }
@keyframes sheet-in { from { transform: translateY(28px); opacity: .5; } to { transform: translateY(0); opacity: 1; } }
.sheet-handle { width: 42px; height: 4px; margin: 0 auto 16px; border-radius: 999px; background: #c5d4d1; }
.sheet-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-title-row h2 { margin: 0; font-size: 21px; }
.sheet-copy { margin: 5px 0 18px; color: var(--muted); font-size: 13px; }
.form-field { display: grid; gap: 7px; margin: 14px 0; }
.form-field label { font-size: 13px; font-weight: 800; }
.form-field input { min-height: 48px; width: 100%; padding: 0 13px; border: 1px solid #bfd1cd; border-radius: 12px; color: var(--ink); background: #fff; }
.editor-subject { margin: 14px 0; }
.editor-subject-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.editor-subject-head strong { font-size: 15px; }
.text-button { min-height: 36px; padding: 0 6px; border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; margin-top: 20px; }
.sheet-actions .secondary-button, .sheet-actions .primary-button { width: 100%; }
.settings-actions { display: grid; gap: 10px; margin-top: 24px; }

/* Record and collectible sheets use a compact, non-scrolling portrait layout. */
.bottom-sheet[data-sheet-mode="record"],
.bottom-sheet[data-sheet-mode="card"] {
  overflow-y: hidden;
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom));
}
.bottom-sheet[data-sheet-mode="record"] .sheet-handle,
.bottom-sheet[data-sheet-mode="card"] .sheet-handle { margin-bottom: 8px; }
.bottom-sheet[data-sheet-mode="record"] .sheet-title-row h2,
.bottom-sheet[data-sheet-mode="card"] .sheet-title-row h2 { font-size: 20px; }
.bottom-sheet[data-sheet-mode="record"] .sheet-copy { margin: 2px 0 8px; line-height: 1.35; }
.bottom-sheet[data-sheet-mode="record"] .form-field { grid-template-columns: 44px 1fr; align-items: center; gap: 8px; margin: 6px 0 8px; }
.bottom-sheet[data-sheet-mode="record"] .form-field input { min-height: 42px; }
.bottom-sheet[data-sheet-mode="record"] .editor-subject { margin: 7px 0; }
.bottom-sheet[data-sheet-mode="record"] .editor-subject-head { margin-bottom: 4px; }
.bottom-sheet[data-sheet-mode="record"] .grade-picker { gap: 5px; padding: 0 0 5px; }
.bottom-sheet[data-sheet-mode="record"] .grade-picker button { height: 42px; border-radius: 12px; }
.bottom-sheet[data-sheet-mode="record"] .grade-picker .no-homework-option { height: 36px; }
.bottom-sheet[data-sheet-mode="record"] .sheet-actions { margin-top: 8px; }
.bottom-sheet[data-sheet-mode="record"] .sheet-actions > button { min-height: 44px; }

.bottom-sheet[data-sheet-mode="card"] { --card-inset: max(16px, env(safe-area-inset-top), env(safe-area-inset-bottom)); inset: 0; width: min(100%, 480px); height: 100dvh; max-height: 100dvh; margin: 0 auto; padding: var(--card-inset) 16px; overflow: hidden; border-radius: 0; background: transparent; box-shadow: none; overscroll-behavior: contain; }
.bottom-sheet[data-sheet-mode="card"][open] { display: grid; place-items: center; }
.bottom-sheet[data-sheet-mode="card"]::-webkit-scrollbar { display: none; }
.bottom-sheet[data-sheet-mode="card"] #sheet-content { width: 100%; }
.bottom-sheet[data-sheet-mode="card"] .sheet-handle { display: none; }

.settings-row { display: flex; width: 100%; min-height: 62px; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; padding: 9px 4px; border: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.settings-row span { display: grid; gap: 3px; }
.settings-row strong { font-size: 15px; }
.settings-row small { color: var(--muted); font-size: 12px; }
.settings-row svg { width: 20px; }

/* Collection */
.collection-progress { margin: 4px 0 14px; padding: 3px 2px 14px; border-bottom: 1px solid var(--line); }
.progress-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.progress-title strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.progress-title span { color: var(--muted); font-size: 12px; font-weight: 700; }
.depth-track { position: relative; display: flex; height: 10px; align-items: center; justify-content: space-between; overflow: hidden; border-radius: 6px; background: #d9e9e8; }
.depth-track > span { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--primary); }
.depth-track i { position: relative; z-index: 1; width: 5px; height: 5px; border-radius: 50%; background: rgba(255,255,255,.9); }
.pending-strip { display: grid; grid-template-columns: 66px 1fr auto; min-height: 82px; align-items: center; gap: 10px; margin-bottom: 14px; padding: 7px 8px 7px 2px; border-radius: 8px; background: var(--primary-soft); }
.pending-strip img { width: 66px; height: 64px; object-fit: cover; border-radius: 8px; mix-blend-mode: multiply; }
.pending-strip div { display: grid; gap: 4px; min-width: 0; }
.pending-strip strong { font-size: 14px; line-height: 1.35; }
.pending-strip span { color: #52706b; font-size: 11px; }
.pending-strip button { min-height: 42px; padding: 0 12px; border: 0; border-radius: 14px; color: #fff; background: var(--primary); font-size: 12px; font-weight: 800; cursor: pointer; }
.collection-calm { display: flex; min-height: 72px; align-items: center; gap: 12px; margin-bottom: 14px; padding: 5px 12px 5px 2px; background: var(--primary-soft); border-radius: 8px; }
.collection-calm img { width: 74px; height: 62px; object-fit: cover; border-radius: 8px; mix-blend-mode: multiply; }
.collection-calm p { margin: 0; color: #486b66; font-size: 13px; font-weight: 750; line-height: 1.5; }
.collection-filters { display: flex; gap: 7px; margin: 0 -18px 14px; padding: 0 18px 3px; overflow-x: auto; scrollbar-width: none; }
.collection-filters::-webkit-scrollbar { display: none; }
.collection-filters button { flex: 0 0 auto; min-height: 42px; padding: 0 17px; border: 0; border-radius: 14px; color: #587176; background: #e9f1ef; font-size: 13px; font-weight: 800; cursor: pointer; }
.collection-filters button.is-selected { color: #fff; background: var(--primary); }
.collection-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.collection-card { position: relative; display: block; min-width: 0; aspect-ratio: 3 / 4; overflow: hidden; padding: 0; border: 1px solid #cddfdb; border-radius: 8px; background: #dff3f2; text-align: left; cursor: pointer; }
.collection-card.is-rare { border: 2px solid #d4b34e; background: #153f58; }
.collection-card.is-locked { color: #fff; background: #315e65; cursor: default; }
.collection-card.is-locked > .species-art { inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); transform: scale(1.06); filter: blur(6px) grayscale(.58) saturate(.72) brightness(.78); }
.locked-card-copy { position: absolute; z-index: 2; inset: 0; display: grid; place-items: center; align-content: center; gap: 12px; background: rgba(17, 58, 64, .28); }
.collection-card.is-locked strong { font-size: 13px; text-shadow: 0 2px 8px rgba(5, 31, 35, .55); }
.card-back-pattern { display: grid; width: 58px; height: 58px; place-items: center; border: 2px solid rgba(20,123,115,.3); border-radius: 50%; }
.card-back-pattern svg { width: 29px; }
.collection-card.is-locked .card-back-pattern { border-color: rgba(255,255,255,.68); background: rgba(12,55,61,.28); }
.species-art {
  display: block;
  width: 100%;
  height: 100%;
  background-image: var(--sprite);
  /* Slightly crop each sprite cell so the source sheet's divider lines stay outside the frame. */
  background-size: 408% 408%;
  background-position: var(--sprite-x) var(--sprite-y);
  background-repeat: no-repeat;
}
.collection-card > .species-art { position: absolute; inset: 0; }
.card-rarity, .reveal-rarity { position: absolute; z-index: 2; top: 9px; left: 9px; padding: 5px 9px; border-radius: 12px; color: #284b53; background: rgba(255,255,255,.9); font-size: 11px; font-weight: 850; }
.is-rare > .card-rarity, .is-rare .reveal-rarity { color: #fff0b1; background: #173e56; border: 1px solid #d4b34e; }
.tooth-badge { position: absolute; z-index: 3; top: 7px; right: 7px; display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid #e6cf7a; border-radius: 50%; color: #f5d86a; background: #173e56; }
.tooth-badge svg { width: 16px; }
.collection-card-foot { position: absolute; z-index: 2; right: 0; bottom: 0; left: 0; display: grid; gap: 2px; padding: 22px 10px 9px; color: var(--ink); background: linear-gradient(transparent, rgba(255,255,255,.96) 42%); }
.collection-card.is-rare .collection-card-foot { color: #fff; background: linear-gradient(transparent, rgba(9,38,57,.95) 48%); }
.collection-card-foot strong { font-size: 16px; }
.collection-card-foot small { overflow: hidden; font-size: 10px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.companion-mark { position: absolute; z-index: 4; right: 8px; bottom: 9px; display: grid; width: 25px; height: 25px; place-items: center; border-radius: 50%; color: #fff; background: var(--chinese); }
.companion-mark svg { width: 13px; fill: currentColor; }

/* Collectible card detail and companion picker */
.species-vitals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0 0 10px; overflow: hidden; border-radius: 8px; background: #c9dfdb; }
.species-vitals div { display: grid; min-width: 0; gap: 3px; padding: 9px 11px; background: #e8f4f1; }
.species-vitals dt { display: flex; align-items: center; justify-content: space-between; gap: 5px; color: #54716d; font-size: 11px; font-weight: 750; }
.species-vitals dd { margin: 0; color: var(--ink); font-size: 14px; font-weight: 850; font-variant-numeric: tabular-nums; }
.metric-rank { display: inline-flex; min-height: 19px; align-items: baseline; gap: 1px; padding: 2px 6px; border-radius: 9px; color: #0f625d; background: rgba(255,255,255,.72); font-size: 10px; font-weight: 850; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric-rank small { font-size: 8px; }
.metric-rank.is-unranked { color: #607a77; font-size: 8px; }
.species-facts { display: grid; gap: 7px; margin: 0; padding-left: 19px; color: #456168; font-size: 13px; line-height: 1.55; }
.species-facts li::marker { color: var(--primary); }
.detail-card-view { display: grid; width: min(100%, 430px); margin: 0 auto; justify-items: center; }
.detail-card-view.is-rare { color: #fff; }
.detail-card-stage { position: relative; width: 100%; }
.detail-collectible-card { position: relative; width: 100%; height: min(clamp(600px, 150vw, 688px), calc(100dvh - var(--card-inset) * 2)); overflow: hidden; border: 2px solid #c8dfda; border-radius: 16px; background: #fff; box-shadow: 0 12px 28px rgba(23,51,58,.18); perspective: 1200px; cursor: pointer; }
.detail-collectible-card:focus-visible { outline: 3px solid var(--shell); outline-offset: 3px; }
.detail-card-view.is-rare .detail-collectible-card { border: 2px solid #e0c15b; background: #123e57; box-shadow: 0 16px 34px rgba(9,47,69,.3); }
.detail-card-view .tooth-badge { display: none; }
.detail-close-button { position: absolute; z-index: 9; top: 16px; right: 16px; border: 1px solid rgba(20,123,115,.28); background: rgba(255,255,255,.94); box-shadow: 0 6px 18px rgba(13,58,62,.2); }
.detail-card-view.is-rare .detail-close-button { color: #f4d46f; border-color: rgba(244,201,93,.55); background: rgba(21,63,88,.94); }
.card-action-cluster { position: absolute; z-index: 9; right: 16px; bottom: 16px; display: flex; gap: 8px; }
.card-action-button { display: grid; width: 44px; height: 44px; place-items: center; padding: 0; border: 1px solid rgba(20,123,115,.28); border-radius: 50%; color: var(--primary); background: rgba(255,255,255,.94); box-shadow: 0 6px 18px rgba(13,58,62,.2); cursor: pointer; }
.card-action-button:active { background: var(--primary-soft); }
.card-action-button:focus-visible { outline: 3px solid var(--shell); outline-offset: 2px; }
.card-action-button svg { width: 22px; }
.card-action-button.companion-action.is-selected svg { fill: currentColor; }
.detail-card-view.is-rare .card-action-button { color: #f4d46f; border-color: rgba(244,201,93,.55); background: rgba(21,63,88,.94); }
.detail-card-view .card-flip-hint { display: none; }
.detail-card-view .species-art { background-size: 400% 400%; }
.detail-card-view .reveal-card-copy { padding-right: 168px; padding-bottom: 22px; }
.detail-card-view .info-facts { overflow: visible; padding: 0; scrollbar-width: none; }
.detail-card-view .reveal-info-page { grid-template-rows: auto auto auto auto auto; gap: 14px; padding: 24px 24px 82px; overflow-y: auto; overscroll-behavior: contain; }
.detail-card-view .info-page-head span { font-size: 15px; }
.detail-card-view .info-page-head strong { font-size: clamp(30px, 8vw, 36px); }
.detail-card-view .reveal-info-page .species-vitals div { padding: 12px; }
.detail-card-view .reveal-info-page .species-vitals dt { font-size: 15px; }
.detail-card-view .reveal-info-page .species-vitals dd { font-size: 19px; }
.detail-card-view .metric-rank { min-height: 24px; padding: 3px 8px; font-size: 13px; }
.detail-card-view .metric-rank small { font-size: 10px; }
.detail-card-view .info-regions { grid-template-columns: 22px 1fr; gap: 9px; }
.detail-card-view .info-regions svg { width: 21px; }
.detail-card-view .info-regions p { font-size: 16px; line-height: 1.5; }
.detail-card-view .info-regions strong { font-size: 15px; }
.detail-card-view .info-summary { font-size: 16px; line-height: 1.6; }
.detail-card-view .info-facts > strong { margin-bottom: 8px; font-size: 16px; }
.detail-card-view .info-facts .species-facts { gap: 8px; padding-left: 21px; font-size: 16px; line-height: 1.6; }
.companion-current { display: flex; align-items: center; gap: 7px; color: var(--chinese); font-size: 13px; font-weight: 800; }
.companion-current svg { width: 16px; fill: currentColor; }
.companion-picker { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.companion-picker button { display: grid; min-width: 0; padding: 8px 5px 10px; place-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 8px; background: #f7fbfa; cursor: pointer; }
.companion-picker button.is-selected { border-color: var(--primary); background: var(--primary-soft); }
.companion-picker .subject-art { width: 66px; height: 62px; }
.companion-picker strong { font-size: 14px; }
.companion-picker span:last-child { color: var(--muted); font-size: 10px; }
.reset-companions { width: 100%; margin-top: 14px; }
.companion-overview { display: grid; gap: 8px; }
.companion-overview > div { display: grid; grid-template-columns: 66px 1fr; align-items: center; gap: 12px; min-height: 72px; border-bottom: 1px solid var(--line); }
.companion-overview .subject-art { width: 62px; height: 60px; }
.companion-overview span { display: grid; gap: 3px; }
.companion-overview small { color: var(--muted); }

/* Discovery and authored flip */
.discovery-dialog { width: min(100%,480px); height: 100dvh; max-width: none; max-height: none; margin: 0 auto; padding: 0; border: 0; color: #fff; background: #0e465a; }
.discovery-dialog::backdrop { background: #0e465a; }
#discovery-content { min-height: 100%; }
.discovery-head { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 9px; padding: calc(14px + env(safe-area-inset-top)) 16px 10px; }
.discovery-head .icon-button, .reveal-close { color: #fff; }
.discovery-head strong { text-align: center; }
.discovery-head span { font-size: 12px; font-weight: 750; }
.discovery-signal { display: grid; place-items: center; gap: 9px; margin: 16px 0 28px; }
.discovery-signal i { width: 76px; height: 4px; border-radius: 2px; background: #f4c95d; }
.discovery-signal span { color: #d9eef2; font-size: 14px; font-weight: 750; }
.card-back-fan { position: relative; height: 430px; margin: 0 auto; perspective: 1000px; }
.discovery-back { position: absolute; top: 0; left: 50%; display: grid; width: 230px; aspect-ratio: 3 / 4; place-items: center; align-content: center; gap: 18px; transform: translateX(-50%); border: 2px solid #bce0df; border-radius: 16px; color: #dff7f4; background: #176878; box-shadow: 0 18px 38px rgba(3,31,44,.32); cursor: pointer; }
.count-2 .discovery-back:first-child { transform: translateX(-68%) rotate(-7deg); }
.count-2 .discovery-back:last-child { transform: translateX(-32%) rotate(7deg); }
.count-3 .discovery-back:first-child { transform: translateX(-82%) rotate(-11deg); }
.count-3 .discovery-back:nth-child(2) { z-index: 2; }
.count-3 .discovery-back:last-child { transform: translateX(-18%) rotate(11deg); }
.discovery-back:active { filter: brightness(1.12); }
.sonar-mark { display: grid; width: 92px; height: 92px; place-items: center; border: 3px solid rgba(255,255,255,.54); border-radius: 50%; }
.sonar-mark svg { width: 45px; }
.discovery-back small { font-size: 13px; font-weight: 800; }
.discovery-help { margin: 0 24px; color: #c4e2e7; font-size: 13px; line-height: 1.55; text-align: center; }
.reveal-scene { position: relative; display: grid; min-height: 100dvh; align-content: center; justify-items: center; padding: calc(58px + env(safe-area-inset-top)) 22px calc(24px + env(safe-area-inset-bottom)); overflow: hidden; background: #d9f0ed; color: var(--ink); }
.reveal-scene.is-rare { color: #fff; background: #092f45; }
.reveal-close { position: absolute; z-index: 6; top: calc(12px + env(safe-area-inset-top)); right: 12px; }
.flip-card { position: relative; z-index: 2; width: min(74vw,300px,calc((100dvh - 260px) * .75)); aspect-ratio: 3 / 4; perspective: 1200px; }
.flip-card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 760ms cubic-bezier(.16,1,.3,1); }
.is-revealed .flip-card-inner { transform: rotateY(180deg); }
.flip-card-back, .flip-card-front { position: absolute; inset: 0; overflow: hidden; border-radius: 16px; backface-visibility: hidden; }
.flip-card-back { display: grid; place-items: center; color: #e9fbf8; background: #176878; border: 2px solid #bce0df; }
.flip-card-front { transform: rotateY(180deg); border: 2px solid #c8dfda; background: #fff; }
.is-rare .flip-card-front { border: 2px solid #e0c15b; background: #123e57; box-shadow: 0 16px 42px rgba(0,0,0,.28); }
.reveal-card-pages { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 520ms cubic-bezier(.16,1,.3,1); }
.collectible-card-face.is-showing-info .reveal-card-pages { transform: rotateY(180deg); }
.reveal-image-page, .reveal-info-page { position: absolute; inset: 0; overflow: hidden; backface-visibility: hidden; }
.reveal-image-page { pointer-events: auto; }
.reveal-info-page { pointer-events: none; }
.collectible-card-face.is-showing-info .reveal-image-page { pointer-events: none; }
.collectible-card-face.is-showing-info .reveal-info-page { pointer-events: auto; }
.reveal-image-page > .species-art { position: absolute; inset: 0; }
.reveal-info-page { display: grid; grid-template-rows: auto auto auto auto minmax(0, 1fr); gap: 11px; padding: 18px 16px 15px; transform: rotateY(180deg); color: var(--ink); background: #f6fbf8; }
.is-rare .reveal-info-page { color: #fff; background: #103b50; }
.info-page-head { display: grid; gap: 2px; padding-right: 42px; }
.info-page-head span { color: #5b7775; font-size: 11px; font-weight: 800; }
.info-page-head strong { font-size: clamp(21px,5.5vw,26px); line-height: 1.1; }
.is-rare .info-page-head span { color: #d2e5e8; }
.reveal-info-page .species-vitals { margin: 0; }
.reveal-info-page .species-vitals div { gap: 5px; padding: 8px 9px; }
.reveal-info-page .species-vitals dd { font-size: 13px; }
.is-rare .reveal-info-page .species-vitals { background: #477381; }
.is-rare .reveal-info-page .species-vitals div { background: #194d60; }
.is-rare .reveal-info-page .species-vitals dt { color: #bbd4d8; }
.is-rare .reveal-info-page .species-vitals dd { color: #fff; }
.is-rare .metric-rank { color: #fff0b1; background: rgba(7,39,54,.55); }
.is-rare .metric-rank.is-unranked { color: #c2d8dc; }
.info-regions { display: grid; grid-template-columns: 17px 1fr; gap: 7px; align-items: start; }
.info-regions svg { width: 16px; margin-top: 2px; color: var(--primary); }
.is-rare .info-regions svg { color: #f4c95d; }
.info-regions p { display: grid; gap: 2px; margin: 0; color: #4c686b; font-size: 12px; line-height: 1.4; }
.info-regions strong { color: var(--ink); font-size: 11px; }
.is-rare .info-regions p { color: #d2e5e8; }
.is-rare .info-regions strong { color: #fff; }
.info-summary { margin: 0; color: #34565b; font-size: 12px; font-weight: 700; line-height: 1.5; }
.is-rare .info-summary { color: #edf6f7; }
.info-facts { min-height: 0; overflow-y: auto; padding-right: 4px; scrollbar-width: thin; }
.info-facts > strong { display: block; margin-bottom: 6px; font-size: 12px; }
.info-facts .species-facts { gap: 6px; padding-left: 17px; color: #3f5c61; font-size: 12px; line-height: 1.48; }
.is-rare .info-facts .species-facts { color: #e0edef; }
.is-rare .info-facts .species-facts li::marker { color: #f4c95d; }
.card-flip-hint { position: absolute; z-index: 5; right: 11px; bottom: 11px; display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid rgba(20,123,115,.25); border-radius: 50%; color: var(--primary); background: rgba(255,255,255,.94); box-shadow: 0 5px 16px rgba(13,58,62,.18); }
.card-flip-hint svg { width: 18px; }
.card-flip-hint.is-info { top: 12px; right: 12px; bottom: auto; }
.is-rare .card-flip-hint { color: #f4d46f; border-color: rgba(244,201,93,.55); background: #153f58; }
.reveal-card-copy { position: absolute; z-index: 3; right: 0; bottom: 0; left: 0; display: grid; gap: 3px; padding: 50px 16px 16px; background: linear-gradient(transparent, rgba(255,255,255,.97) 52%); }
.reveal-card-copy { padding-right: 66px; }
.is-rare .reveal-card-copy { background: linear-gradient(transparent, rgba(4,30,47,.96) 52%); }
.reveal-card-copy strong { font-size: 24px; }
.reveal-card-copy span { color: var(--muted); font-size: 12px; font-weight: 750; }
.is-rare .reveal-card-copy span { color: #d9eaf0; }
.reveal-copy { position: relative; z-index: 2; margin-top: 18px; text-align: center; }
.reveal-copy h2 { margin: 0 0 7px; font-size: 23px; }
.reveal-copy p { max-width: 360px; margin: 0; color: #4a676d; font-size: 13px; line-height: 1.6; }
.is-rare .reveal-copy p { color: #d3e5e9; }
.reveal-actions { position: relative; z-index: 2; display: grid; width: min(100%,360px); gap: 9px; margin-top: 18px; }
.reveal-actions .secondary-button { width: 100%; }
.sonar-rings { position: absolute; z-index: 1; top: 30%; left: 50%; width: 20px; height: 20px; transform: translate(-50%,-50%); }
.sonar-rings i { position: absolute; inset: 0; border: 2px solid rgba(244,201,93,.44); border-radius: 50%; opacity: 0; }
.is-revealed.is-rare .sonar-rings i { animation: sonar-wave 1.2s cubic-bezier(.16,1,.3,1) forwards; }
.is-revealed.is-rare .sonar-rings i:nth-child(2) { animation-delay: 120ms; }
.is-revealed.is-rare .sonar-rings i:nth-child(3) { animation-delay: 240ms; }
@keyframes sonar-wave { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(24); opacity: 0; } }
.reward-sheet { padding: 5px 2px 2px; text-align: center; }
.reward-sheet h2 { margin: 12px 0 5px; font-size: 23px; }
.reward-sheet p { margin: 0; color: var(--primary); font-size: 20px; font-weight: 850; }
.reward-sheet > span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.reward-shells { display: flex; height: 54px; align-items: flex-end; justify-content: center; gap: 8px; }
.reward-shells i { width: 39px; height: 34px; border-radius: 50% 50% 42% 42%; background: var(--shell); box-shadow: inset 0 -5px 0 rgba(181,132,24,.18); }

.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); max-width: calc(100% - 36px); padding: 11px 16px; transform: translate(-50%, 18px); border-radius: 12px; color: #fff; background: #17333a; opacity: 0; pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; font-size: 14px; font-weight: 700; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  body { padding: 22px 0; }
  .app-shell { min-height: calc(100vh - 44px); border-radius: 18px; box-shadow: 0 18px 60px rgba(23,51,58,.14); }
  .ocean-header { border-radius: 18px 18px 0 0; }
  .bottom-nav { bottom: 22px; border-radius: 0 0 18px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .flip-card-inner { transition: opacity 180ms ease !important; }
  .is-revealed .flip-card-inner { transform: rotateY(180deg); }
  .reveal-card-pages { transition: opacity 180ms ease !important; }
  .sonar-rings { display: none; }
}

@media (max-width: 370px) {
  main { padding-right: 13px; padding-left: 13px; }
  .collection-filters { margin-right: -13px; margin-left: -13px; padding-right: 13px; padding-left: 13px; }
  .pending-strip { grid-template-columns: 54px 1fr; }
  .pending-strip img { width: 54px; height: 54px; }
  .pending-strip button { grid-column: 1 / -1; }
  .card-back-fan { transform: scale(.88); transform-origin: top center; }
}

@media (max-height: 760px) and (orientation: portrait) {
  .bottom-sheet[data-sheet-mode="record"] { padding-top: 6px; }
  .bottom-sheet[data-sheet-mode="record"] .sheet-handle { margin-bottom: 5px; }
  .bottom-sheet[data-sheet-mode="record"] .sheet-copy { display: none; }
  .bottom-sheet[data-sheet-mode="record"] .form-field { margin: 3px 0 5px; }
  .bottom-sheet[data-sheet-mode="record"] .editor-subject { margin: 4px 0; }
  .bottom-sheet[data-sheet-mode="record"] .grade-picker button { height: 38px; }
  .bottom-sheet[data-sheet-mode="record"] .grade-picker .no-homework-option { height: 32px; }
  .bottom-sheet[data-sheet-mode="record"] .sheet-actions { margin-top: 4px; }
}

@media (max-height: 620px), (orientation: landscape) {
  .bottom-sheet[data-sheet-mode="record"] { overflow-y: auto; }
}
