:root {
  --bg: #24121f;
  --surface: #33192d;
  --surface-2: #402038;
  --line: #52304a;
  --text: #f8ecf0;
  --muted: #c4a8b8;
  --accent: #eba3a6;
  --gold: #ecc290;
  --grad: linear-gradient(90deg, #e6929b 0%, #efb39a 55%, #ebc78f 100%);
  --ok: #8fd6a8;
  --danger: #ff8a8a;
  --radius: 16px;
  --tap: 48px;
  --tabbar-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: linear-gradient(color-mix(in srgb, var(--bg) 88%, transparent), color-mix(in srgb, var(--bg) 88%, transparent)), url(/img/pattern.webp) 0 0 / 420px repeat fixed, var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

a { color: inherit; text-decoration: none; }

button { font: inherit; color: inherit; }

h1, h2 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }

.muted { color: var(--muted); }
.error { color: var(--danger); }
.empty { color: var(--muted); text-align: center; padding: 32px 0; }

#app { max-width: 720px; margin: 0 auto; }

.screen {
  padding: max(12px, env(safe-area-inset-top)) 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
}
.topbar h1 { flex: 1; }

.avatar {
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  object-fit: cover;
  background: var(--grad);
  color: #3a1830;
  font-weight: 700;
  flex: none;
}

.back {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-size: 30px;
  line-height: 1;
  color: var(--accent);
  flex: none;
}
.back:active { background: var(--surface-2); }

.progress {
  height: 8px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--grad);
  border-radius: inherit;
  min-width: 0;
  transition: width 0.25s ease;
}

.diamonds { color: var(--gold); white-space: nowrap; }
.free { color: var(--muted); }

.overall {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.overall-row { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; }

.search {
  width: 100%;
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px;
  padding: 2px 16px;
}
.chips::-webkit-scrollbar { display: none; }
.chips.dragging { cursor: grabbing; user-select: none; }
@media (hover: hover) and (pointer: fine) {
  .chips { scrollbar-width: thin; scrollbar-color: var(--line) transparent; padding-bottom: 6px; }
  .chips::-webkit-scrollbar { display: block; height: 6px; }
  .chips::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
}
.chip {
  flex: none;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.chip.active {
  background: var(--grad);
  color: #3a1830;
  border-color: transparent;
  font-weight: 600;
}

.story-list { display: flex; flex-direction: column; gap: 10px; }

.story-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.story-card:active { background: var(--surface-2); }
.story-card-head { display: flex; align-items: center; gap: 10px; }
.story-num {
  flex: none;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--gold);
  font-weight: 700;
  font-size: 14px;
}
.story-title { flex: 1; font-weight: 600; line-height: 1.25; }
.story-card-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--muted); }

.status { flex: none; font-size: 12px; padding: 3px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.status-ongoing { color: var(--accent); }
.status-paused { color: #c9a8ff; }
.status-done { color: var(--ok); }

.mini-stats { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.mini-stats:empty { display: none; }

.story { padding-top: 0; }

.sticky-summary {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 -16px;
  padding: max(8px, env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sticky-top { display: flex; align-items: center; gap: 6px; margin-left: -8px; }
.topbar-avatar { flex: none; margin-left: auto; border-radius: 50%; display: grid; }
.topbar-avatar:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sticky-title { flex: 1; min-width: 0; font-size: 18px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sticky-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.summary-line { display: flex; gap: 10px; font-size: 14px; align-items: baseline; }
.summary-count { font-weight: 600; }
.summary-pct { color: var(--muted); }
.summary-diamonds { color: var(--gold); }

.sticky-inner { display: flex; flex-direction: column; gap: 8px; }

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

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.segmented button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.segmented button.active { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }

.tag-sub { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }

.season[hidden] { display: none; }

.hide-done {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  min-height: 40px;
}
.hide-done input { width: 20px; height: 20px; accent-color: var(--accent); }

.groups { display: flex; flex-direction: column; gap: 12px; }

.season {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.season-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: var(--tap);
  padding: 0 14px;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.season-head::-webkit-details-marker { display: none; }
.season-head::after { content: "›"; color: var(--muted); transform: rotate(90deg); transition: transform 0.2s; margin-left: 10px; }
details:not([open]) > .season-head::after { transform: none; }
.season-head.static { cursor: default; }
.season-head.static::after { content: none; }
.season-count { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 14px; }

.item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  min-height: 60px;
}
.item[hidden] { display: none; }
.item-body { flex: 1; min-width: 0; cursor: pointer; display: flex; flex-direction: column; gap: 4px; padding-top: 4px; }
.item.series .item-body { cursor: default; }
.item-name { font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.item.done .item-name { color: var(--muted); }
.item-meta { display: flex; gap: 12px; font-size: 13px; color: var(--muted); }
.item.preset { opacity: 0.6; }
.tag { margin-left: 8px; font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); vertical-align: 2px; }

.check {
  flex: none;
  width: 36px;
  height: 36px;
  margin-top: 2px;
  border-radius: 11px;
  border: 2px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s, border-color 0.15s;
}
.check::after {
  content: "";
  width: 14px;
  height: 8px;
  border: solid #3a1830;
  border-width: 0 0 3px 3px;
  transform: rotate(-45deg) translate(1px, -1px);
  opacity: 0;
}
.check.on { background: var(--grad); border-color: transparent; }
.check.on::after { opacity: 1; }
.check.partial { border-color: var(--accent); }
.check.partial::after { opacity: 1; width: 14px; height: 0; border-width: 0 0 3px; border-color: var(--accent); transform: none; }
.check:disabled { cursor: default; }
.check:focus-visible, .variant:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.variants { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.variant {
  min-height: 34px;
  min-width: 52px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.variant small { color: var(--gold); }
.variant .chip-price { margin-left: 4px; font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 6px; background: color-mix(in srgb, var(--gold) 18%, transparent); }
.variant .chip-free { color: var(--muted); font-weight: 600; background: color-mix(in srgb, var(--muted) 14%, transparent); }
.variant .chip-sub { margin-left: 4px; font-size: 11px; font-weight: 600; padding: 1px 5px; border-radius: 6px; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.variant .chip-ep { margin-left: 4px; font-size: 11px; color: var(--muted); }
.appearance { font-size: 13px; }
.appearance summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; min-height: 30px; }
.appearance summary::-webkit-details-marker { display: none; }
.appearance summary::after { content: "›"; color: var(--muted); transform: rotate(90deg); margin-left: auto; }
.appearance[open] summary::after { transform: rotate(-90deg); }
.appearance-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--grad); color: #3a1830; text-transform: uppercase; letter-spacing: 0.03em; }
.appearance-hint { margin: 4px 0 8px; font-size: 12px; }
.appearance-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.appearance-row { display: flex; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); }
.appearance-row { border: 0; font: inherit; color: var(--text); cursor: pointer; text-align: left; align-items: center; }
.appearance-row.best { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 60%, transparent); }
.appearance-row.chosen { background: color-mix(in srgb, var(--accent) 24%, var(--surface-2)); box-shadow: inset 0 0 0 2px var(--accent); font-weight: 650; }
.appearance-best { color: var(--gold); font-weight: 600; }
.appearance-mine { font-weight: 650; }
.summary-appearance { color: var(--muted); font-size: 12px; }
.variant.on { background: color-mix(in srgb, var(--accent) 22%, var(--surface-2)); border-color: var(--accent); color: var(--text); }
.variant.on::before { content: "✓ "; color: var(--accent); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 20px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}
.button.primary { background: var(--grad); color: #3a1830; border-color: transparent; }
.button.ghost { background: transparent; color: var(--muted); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}
.panel p { margin: 0; }
.import-status { width: 100%; }
.import-report p { margin: 4px 0; }
.unmatched summary { cursor: pointer; color: var(--accent); min-height: 36px; display: flex; align-items: center; }
.unmatched ul { margin: 6px 0; padding-left: 18px; font-size: 13px; color: var(--muted); max-height: 320px; overflow: auto; }

.profile-card { display: flex; align-items: center; gap: 14px; }
.profile-name { font-size: 20px; font-weight: 650; }

.login {
  min-height: 100dvh;
  padding: 0 24px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}
.login-hero {
  display: block;
  width: calc(100% + 48px);
  margin: 0 -24px;
  -webkit-mask-image: linear-gradient(#000 60%, transparent);
  mask-image: linear-gradient(#000 60%, transparent);
}
.login-hero img { display: block; width: 100%; height: auto; max-height: 46dvh; object-fit: cover; }
.login-logo { margin-top: -64px; border-radius: 50%; box-shadow: 0 8px 32px #0008; }
.login h1 {
  font-size: 32px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login p { max-width: 320px; margin: 0; }
.login .button { min-width: 240px; }
.button.telegram { gap: 10px; background: #2aabee; color: #fff; border-color: transparent; }
.button.telegram svg { width: 22px; height: 22px; }

.loading { min-height: 60dvh; display: grid; place-items: center; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-screen { align-items: center; text-align: center; padding-top: 30dvh; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom));
  transform: translate(-50%, 40px);
  opacity: 0;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 8px env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  min-height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  -webkit-user-select: none;
  user-select: none;
}
.tab.active { color: var(--accent); }
.tab:active { background: var(--surface); border-radius: 14px; }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: 14px; }

.placeholder {
  min-height: 50dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  color: var(--muted);
}
.placeholder-icon {
  width: 104px;
  height: 104px;
  border-radius: 32px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--accent);
}
.placeholder p { max-width: 260px; margin: 0; font-size: 17px; }

.overall-big { display: flex; flex-direction: column; gap: 2px; }
.overall-big .diamonds { font-size: 28px; font-weight: 700; }
.overall-big .muted { font-size: 13px; }

.guide-groups, .guide-list { display: flex; flex-direction: column; gap: 14px; }
.guide-group { display: flex; flex-direction: column; gap: 10px; }
.guide-group-title { font-size: 17px; padding: 6px 2px 0; }
.guide-group-title a { color: var(--text); }
.guide-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.guide-source { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.guide-source time { margin-left: auto; }
.guide-source-name { color: var(--text); font-weight: 600; }
.guide-badge { font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 6px; background: var(--surface-2); color: var(--gold); }
.guide-badge.guide-tg { background: #2aabee22; color: #6cc6f5; }
.guide-title { margin: 0; font-size: 16px; line-height: 1.3; }
.guide-topics, .guide-preview { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.4; }
.guide-embed:empty { display: none; }
.guide-embed iframe { display: block; width: 100% !important; min-width: 0 !important; border-radius: 12px; }
.guide-card.embedded .guide-fallback { display: none; }
.guide-open { align-self: flex-start; min-height: 42px; font-size: 14px; }
.guide-open-tg { background: #2aabee; color: #fff; border-color: transparent; }

.story-card.has-cover { display: grid; grid-template-columns: 64px 1fr; column-gap: 12px; row-gap: 10px; }
.story-card.has-cover > :not(.story-cover) { grid-column: 2; }
.story-cover { grid-row: 1 / span 4; width: 64px; height: 91px; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.story-hero { flex: none; padding: 0; border: 0; background: none; border-radius: 6px; overflow: hidden; display: grid; cursor: zoom-in; }
.story-hero img { width: 34px; height: 48px; object-fit: cover; display: block; }

.item-head { display: flex; align-items: flex-start; gap: 10px; }
.thumb { flex: none; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-card { border-radius: 7px; box-shadow: 0 2px 8px #0005; }
.thumb-card img { object-position: center top; }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #0d070cf0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.viewer img { max-width: 100%; max-height: 80dvh; object-fit: contain; border-radius: 12px; }
.viewer-caption { margin: 0; color: var(--text); text-align: center; }
.viewer-close { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--text); font-size: 26px; line-height: 1; }

.card-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.card-reward { color: var(--gold); }
.card-credit { flex-basis: 100%; font-size: 11px; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.card-quote { flex-basis: 100%; margin: 2px 0 0; font-size: 13px; font-style: italic; color: var(--muted); line-height: 1.35; }

.catalog-switch { display: flex; }
.catalog-switch a { flex: 1; min-height: 40px; display: grid; place-items: center; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 15px; }
.catalog-switch a.active { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }

.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.deck-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.deck-card:active { background: var(--surface-2); }
.deck-card.complete { border-color: var(--gold); }
.deck-cover { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; object-position: center top; border-radius: 12px; background: var(--surface-2); box-shadow: 0 4px 14px #0006; }
.deck-cover-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; font-size: 40px; border: 1px dashed var(--line); box-shadow: none; }
.deck-cover-icon { opacity: 0.5; }
.soon-badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--gold); letter-spacing: 0.02em; }
.deck-card.pending { opacity: 0.75; cursor: default; }
.deck-missing { color: var(--gold); }
.thumb-soon { display: grid; place-items: center; flex: none; border: 1px dashed var(--line); background: var(--surface-2); color: var(--muted); font-size: 10px; font-weight: 600; text-align: center; box-shadow: none; }
.deck-name { font-weight: 650; }
.deck-sub { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.deck-pencil { position: absolute; top: 6px; right: 6px; background: var(--surface); }
.sticky-top .deck-pencil { position: static; }
.ed-cover { border-radius: 4px; object-fit: cover; }
.deck-count { font-size: 13px; color: var(--muted); }
.card-story { color: var(--accent); }

.tag-new { background: color-mix(in srgb, var(--gold) 22%, transparent); color: var(--gold); }
.whats-new-banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--line)); background: color-mix(in srgb, var(--gold) 10%, var(--surface)); font-size: 14px; }
.whats-new-spark { font-size: 24px; }
.whats-new-arrow { margin-left: auto; font-size: 24px; color: var(--gold); }
.news-import { display: flex; flex-direction: column; gap: 10px; }
.news-date { font-size: 17px; }
.news-story { display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.news-cover { width: 48px; height: 68px; object-fit: cover; border-radius: 8px; flex: none; }
.news-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.news-title { font-weight: 650; }
.news-items { margin: 0; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.admin-imports { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.admin-imports li { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.admin-report { width: 100%; max-height: 360px; overflow: auto; font-size: 12px; white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: 10px; margin: 0; }

.milestones { display: flex; gap: 6px; flex-wrap: wrap; }
.milestone { display: inline-flex; gap: 6px; align-items: center; min-height: 32px; padding: 0 10px; border-radius: 99px; border: 1px solid color-mix(in srgb, var(--gold) 55%, var(--line)); background: color-mix(in srgb, var(--gold) 12%, var(--surface)); color: var(--text); font-size: 13px; cursor: pointer; }
.milestone span { color: var(--gold); }
.share-sheet { position: fixed; inset: 0; z-index: 60; background: #0d070ccc; display: flex; align-items: flex-end; justify-content: center; }
.share-panel { width: 100%; max-width: 520px; max-height: 94dvh; overflow: auto; background: var(--surface); border-radius: 22px 22px 0 0; border: 1px solid var(--line); padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.share-congrats { margin: 0; color: var(--gold); font-weight: 700; }
.share-preview { width: min(100%, 360px); height: auto; aspect-ratio: 4 / 5; border-radius: 14px; background: var(--surface-2); box-shadow: 0 10px 30px #0008; }
.share-actions { display: flex; gap: 10px; width: 100%; justify-content: center; }

@media (min-width: 560px) {
  .story-list { display: grid; grid-template-columns: 1fr 1fr; }
}

.ed-pencil { flex: none; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--gold); font-size: 17px; cursor: pointer; }
.ed-pencil:focus-visible, .ed-add:focus-visible, .ed-pin:focus-visible, .ed-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ed-row-tools { flex: none; display: flex; align-items: center; gap: 6px; padding-top: 2px; }
.ed-select { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.ed-group-tools { display: flex; gap: 6px; align-items: center; margin-left: 10px; }
.ed-add { min-height: 32px; padding: 0 10px; border-radius: 10px; border: 1px dashed var(--line); background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; }
.ed-chip { border-style: dashed; color: var(--muted); }
.ed-pin-dot { margin-left: 6px; font-size: 12px; color: var(--gold); vertical-align: 1px; }
.tag-hidden { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.item.ed-hidden .item-body, .variant.ed-hidden { opacity: 0.45; }
.variant.ed-hidden { text-decoration: line-through; }
.sticky-top .ed-pencil { margin-left: auto; }
.story.editing .sticky-summary { box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--gold) 45%, transparent); }

.ed-panel { text-align: left; align-items: stretch; gap: 14px; }
.ed-head { display: flex; align-items: center; gap: 10px; }
.ed-head h2 { flex: 1; font-size: 17px; overflow-wrap: anywhere; }
.ed-close { width: 40px; height: 40px; border: none; border-radius: 12px; background: var(--surface-2); font-size: 22px; cursor: pointer; }
.ed-form { display: flex; flex-direction: column; gap: 12px; }
.ed-field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.ed-field.ed-check { flex-direction: row; align-items: center; gap: 10px; min-height: 36px; }
.ed-check input { width: 22px; height: 22px; accent-color: var(--accent); }
.ed-label { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.ed-field input[type="text"], .ed-field input[type="number"], .ed-field select, .ed-field textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; font-size: 16px;
}
.ed-field textarea { resize: vertical; }
.ed-group { display: flex; flex-direction: column; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; }
.ed-pin { border: none; background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--gold); border-radius: 8px; min-width: 28px; min-height: 26px; cursor: pointer; font-size: 14px; }
.ed-image { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ed-image img { border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.button.small { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.button.danger { color: var(--danger); }
.ed-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ed-actions .button { flex: 1 1 auto; }
.link-button { align-self: flex-start; border: none; background: none; color: var(--accent); padding: 6px 0; cursor: pointer; font-size: 14px; }
.small { font-size: 13px; }
.ed-variants { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ed-variants li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.ed-variants li > span:nth-child(2) { flex: 1; font-size: 12px; }
.ed-variants li.ed-hidden { opacity: 0.5; }
.ed-merge-bar { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom)); z-index: 40; display: flex; gap: 8px; justify-content: center; padding: 0 16px; }
.ed-merge-bar[hidden] { display: none; }
.ed-merge-bar .button { box-shadow: 0 8px 24px #0009; }

.ed-mode { display: flex; flex-direction: column; gap: 12px; }
.ed-toggle { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.ed-toggle input { width: 24px; height: 24px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.ed-toggle > span { display: flex; flex-direction: column; gap: 4px; }
.ed-links { display: flex; flex-wrap: wrap; gap: 8px; }
.ed-links .button { flex: 1 1 auto; }

.ed-journal { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ed-journal li { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.ed-journal li.reverted { opacity: 0.55; }
.ed-j-head { display: flex; gap: 10px; font-size: 13px; flex-wrap: wrap; }
.ed-j-action { font-size: 12px; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.ed-j-action.revert { color: var(--gold); }
.ed-j-action.delete { color: var(--danger); }
.ed-j-label { font-size: 14px; overflow-wrap: anywhere; }
.ed-j-diff { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.ed-history { min-height: 80px; }

.ed-new-story { margin-left: auto; margin-right: 8px; }
.story-new { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 96px; border-style: dashed; color: var(--gold); font: inherit; cursor: pointer; }
.story-new-plus { font-size: 34px; line-height: 1; }
.author-link { display: inline-flex; align-items: center; gap: 6px; align-self: center; margin: 4px auto 8px; padding: 8px 12px; border-radius: 999px; color: var(--muted); font-size: 14px; text-decoration: none; }
.author-link svg { width: 16px; height: 16px; }
.author-link:hover, .author-link:focus-visible { color: var(--text); background: var(--surface); }
.author-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.branch-switch { display: flex; margin: 0 0 8px; }
.branch-switch button { flex: 1; }
.branch-switch button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.branch-progress { color: var(--muted); font-size: 12px; font-weight: 400; }
.tag-shared { cursor: help; }
.howto { margin-top: 2px; font-size: 13px; color: var(--muted); }
.howto summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 4px; padding: 2px 0; }
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after { content: '›'; transition: transform .2s; }
.howto[open] summary::after { transform: rotate(90deg); }
.howto p { margin: 4px 0 2px; color: var(--text); line-height: 1.45; white-space: pre-line; }
.howto a { color: var(--accent); font-size: 12px; }

@property --gem-angle { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes gem-turn { to { --gem-angle: 360deg; } }
.story-card.collected, .sticky-inner.collected { position: relative; border-color: transparent; }
.sticky-inner.collected { border: 1px solid transparent; border-radius: var(--radius); padding: 8px 10px; margin: 0 -10px; }
.story-card.collected::before, .sticky-inner.collected::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 2px;
  background: conic-gradient(from var(--gem-angle), #ecc290, #f3a6c0, #a8d8f0, #fff1d6, #ecc290 50%, #f3a6c0, #a8d8f0, #ecc290);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: gem-turn 9s linear infinite;
  pointer-events: none;
}
.story-card.collected { box-shadow: 0 0 18px -6px color-mix(in srgb, var(--gold) 55%, transparent); }
.collected-badge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 99px; font-size: 11px; font-weight: 700; vertical-align: middle; color: #3a1830; background: linear-gradient(90deg, #ecc290, #f3c6d2, #ecc290); white-space: nowrap; }
.mini-stats .closed { color: var(--gold); font-weight: 600; }
@keyframes stat-flash { 0% { text-shadow: none; transform: scale(1); } 35% { text-shadow: 0 0 10px var(--gold), 0 0 2px #fff; transform: scale(1.18); } 100% { text-shadow: none; transform: scale(1); } }
.mini-stats .flash { display: inline-block; animation: stat-flash .7s ease-out; }

@keyframes check-pop { 0% { transform: scale(.72); } 55% { transform: scale(1.14); } 100% { transform: scale(1); } }
@keyframes spark-fly { 0% { opacity: 0; transform: translate(0, 0) scale(.4) rotate(0deg); } 25% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--sx, 10px), var(--sy, -18px)) scale(1) rotate(45deg); } }
.check { position: relative; }
.check.pop { animation: check-pop .28s cubic-bezier(.3, 1.5, .5, 1); }
.check.pop::before, .variant.pop::after {
  content: "✦";
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 11px;
  color: var(--gold);
  pointer-events: none;
  animation: spark-fly .32s ease-out forwards;
}
.variant { position: relative; }
.variant.pop { animation: check-pop .26s cubic-bezier(.3, 1.5, .5, 1); }
.variant.pop::after { --sx: 8px; --sy: -14px; }

.progress-fill { transition: width .45s cubic-bezier(.25, .8, .3, 1); }

@keyframes burst { 0% { opacity: 0; transform: translate(0, 0) scale(.3); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1); } }
.spark-layer { position: absolute; left: 50%; top: 40%; width: 0; height: 0; pointer-events: none; z-index: 2; }
.spark-layer i { position: absolute; width: 6px; height: 6px; margin: -3px; border-radius: 1px; transform: rotate(45deg); background: linear-gradient(135deg, #fff1d6, #ecc290 60%, #f3a6c0); box-shadow: 0 0 6px #ecc290; animation: burst .9s cubic-bezier(.2, .7, .3, 1) var(--d) both; }
.story-card { position: relative; }

.ms-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom));
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(360px, calc(100vw - 32px));
  padding: 10px 16px 10px 10px;
  border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--line));
  border-radius: 14px;
  background: linear-gradient(180deg, #3d1f37, #2c1527);
  box-shadow: 0 10px 30px -8px #000c, inset 0 1px 0 #ffffff14;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transform: translate(-50%, calc(100% + var(--tabbar-h) + 40px));
  animation: toast-in .62s cubic-bezier(.22, 1.35, .42, 1) forwards;
}
.ms-toast.out { animation: toast-out .42s cubic-bezier(.55, 0, .75, .2) forwards; }
@keyframes toast-in { from { transform: translate(-50%, calc(100% + var(--tabbar-h) + 40px)); } to { transform: translate(-50%, 0); } }
@keyframes toast-out { from { transform: translate(-50%, 0); } to { transform: translate(-50%, calc(100% + var(--tabbar-h) + 40px)); } }
.ms-emblem { flex: none; width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-size: 21px; background: radial-gradient(circle at 35% 30%, #5a2c50, #2a1326); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 50%, transparent); }
.ms-body { display: flex; flex-direction: column; min-width: 0; }
.ms-body small { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--gold); }
.ms-text { font-size: 14px; font-weight: 600; line-height: 1.3; }
.ms-toast.grand { border-color: transparent; }
.ms-toast.grand::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1.5px;
  background: conic-gradient(from var(--gem-angle), #ecc290, #f3a6c0, #a8d8f0, #ecc290);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: gem-turn 4s linear infinite;
  pointer-events: none;
}
.ms-toast.grand .ms-emblem { background: radial-gradient(circle at 35% 30%, #7a4a3a, #3a1830); }

@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.share-sheet { animation: fade-in .2s ease-out; }
.share-panel { animation: sheet-up .32s cubic-bezier(.22, 1, .36, 1); }
.viewer { animation: fade-in .2s ease-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .story-card.collected::before, .sticky-inner.collected::before, .ms-toast.grand::before { background: var(--gold); }
  .ms-toast { transform: translate(-50%, 0); }
  .ms-toast.out { display: none; }
}
.collected-row { display: flex; }
.collected-row .collected-badge { margin-left: 0; }
