/* =========================================================================
   DaysCycle Fans — design tokens, v3
   Concept: a proper reference wiki (Fandom-style), not a scrapbook.
   Clean sans typography, bordered headings, a right-hand "infobox" on
   character pages, flat cards with a light hover lift, blue reference
   links. Dark mode reads like a wiki's night-reading mode, not a diary.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Noto+Sans+SC:wght@400;500;600;700;800&display=swap');

:root, [data-theme="dark"] {
  --bg: #14171a;
  --bg-vignette: #181c20;
  --panel: #1c2024;
  --panel-2: #262b31;
  --panel-3: #2e343b;
  --line: #33393f;
  --line-strong: #454c54;
  --ink: #e7e9ec;
  --ink-dim: #9aa1a9;
  --accent: #5aa9ff;
  --accent-strong: #82c0ff;
  --accent-ink: #0b1520;
  --ok: #4fbf82;
  --danger: #f0796b;
  --shadow-color: rgba(0, 0, 0, 0.5);
  --header-bg: #101317;
  --header-ink: #eef0f2;
  --header-ink-dim: #90979f;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #eef0f2;
  --bg-vignette: #eef0f2;
  --panel: #ffffff;
  --panel-2: #f3f4f6;
  --panel-3: #e9ebee;
  --line: #dde0e4;
  --line-strong: #c3c8ce;
  --ink: #1c2024;
  --ink-dim: #656c74;
  --accent: #1268c3;
  --accent-strong: #0d4f99;
  --accent-ink: #ffffff;
  --ok: #1f8a52;
  --danger: #c23b2c;
  --shadow-color: rgba(20, 25, 35, 0.1);
  --header-bg: #14181d;
  --header-ink: #f2f3f5;
  --header-ink-dim: #9298a0;
  color-scheme: light;
}

:root {
  --font-ui: "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --radius: 6px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

h1, h2, h3 {
  font-family: var(--font-ui);
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 12px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
h1 {
  font-size: 26px;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line-strong);
}
h2 { font-size: 19px; }
h3 { font-size: 16px; }

p { margin: 0 0 12px; max-width: 68ch; color: var(--ink); }

.container {
  max-width: 900px;
  margin: 16px auto 60px;
  padding: 26px 24px 40px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px var(--shadow-color);
}
.container.narrow { max-width: 480px; }
@media (max-width: 640px) {
  .container { margin: 0; border-left: none; border-right: none; border-radius: 0; padding: 20px 16px 40px; }
}

/* ---- header ---- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: var(--header-bg);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.site-header-inner {
  max-width: 900px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 20px; gap: 10px;
}
.brand-mark {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 17px; letter-spacing: -0.01em;
  color: var(--header-ink); cursor: pointer;
  display: flex; align-items: center;
}
.brand-mark .dot { font-size: 0; }
.brand-mark .dot::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin: 0 8px; }
.header-actions { display: flex; align-items: center; gap: 10px; }

.nav-strip {
  max-width: 900px; margin: 0 auto;
  display: flex; gap: 4px; overflow-x: auto;
  padding: 0 14px 10px;
  scrollbar-width: none;
}
.nav-strip::-webkit-scrollbar { display: none; }
.nav-strip a {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 13px;
  color: var(--header-ink-dim);
  border: none;
  border-radius: 4px;
  padding: 6px 10px;
  white-space: nowrap;
}
.nav-strip a:hover { color: var(--header-ink); text-decoration: none; background: rgba(255,255,255,0.06); }
.nav-strip a.active { color: var(--accent-strong); background: rgba(90,169,255,0.14); }

/* ---- buttons / inputs ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-ui); font-weight: 600; font-size: 13.5px;
  padding: 9px 16px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2); color: var(--ink);
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.btn-danger { border-color: var(--line-strong); color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.05); color: var(--header-ink);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 13px;
}
.icon-btn:hover { border-color: var(--accent-strong); color: var(--accent-strong); }

.field { margin-bottom: 17px; }
.field label {
  display: block; font-family: var(--font-ui); font-weight: 600;
  font-size: 12.5px; color: var(--ink-dim); margin-bottom: 6px;
}
.input, .textarea, select.input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 4px;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 14.5px;
}
.textarea { resize: vertical; min-height: 90px; }
.input:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); outline: none; }
.hint { font-size: 12.5px; color: var(--ink-dim); margin-top: 6px; }

/* ---- choice chips: multi-select checkbox groups (associated chapters/characters) ---- */
.choice-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--ink-dim);
  font-family: var(--font-ui); font-size: 12.5px; font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.choice-chip input { accent-color: var(--accent); margin: 0; }
.choice-chip:hover { border-color: var(--accent); color: var(--ink); }
.choice-chip.is-checked,
.choice-chip:has(input:checked) {
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
  border-color: var(--accent);
  color: var(--ink);
  font-weight: 700;
}
.choice-empty { font-size: 12.5px; color: var(--ink-dim); font-style: italic; }

/* ---- panels ---- */
.panel {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
}

.section-title {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 8px;
  margin: 30px 0 14px;
}

/* ---- grids ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  padding-top: 4px;
}
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

/* ---- flat reference cards ---- */
.chapter-card, .character-card, .work-card {
  position: relative;
  display: block;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  overflow: hidden;
  box-shadow: 0 1px 2px var(--shadow-color);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.grid > a:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 18px -6px var(--shadow-color);
  border-color: var(--accent);
  text-decoration: none;
  z-index: 2;
}

.chapter-card .cover {
  height: 104px; background: var(--panel-3) center/cover no-repeat;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.chapter-card .order-tag {
  position: absolute; bottom: 7px; left: 8px;
  font-family: var(--font-ui); font-weight: 700; font-size: 11px; color: #fff;
  background: rgba(10, 14, 20, 0.62);
  border-radius: 3px;
  padding: 2px 7px;
}
.chapter-card .body { padding: 12px 14px; }
.chapter-card h3 { margin-bottom: 4px; font-size: 15px; }
.chapter-card p {
  font-family: var(--font-body); font-size: 12.5px; margin-bottom: 0; color: var(--ink-dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.character-card { text-align: center; padding: 16px 10px 14px; }
.character-card .avatar {
  width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 10px;
  background: var(--panel-3) center/cover no-repeat;
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-weight: 700; font-size: 19px; color: var(--ink-dim);
}
.character-card .name { font-family: var(--font-ui); font-weight: 600; font-size: 13.5px; }
.character-card .alias { font-family: var(--font-body); font-size: 11.5px; color: var(--ink-dim); margin-top: 3px; }
.character-card .chapters { font-family: var(--font-body); font-size: 11px; color: var(--ink-dim); margin-top: 4px; }

.work-card .thumb { height: 140px; background: var(--panel-3) center/cover no-repeat; border-bottom: 1px solid var(--line); }
.work-card .body { padding: 11px 13px; }
.work-card .title {
  font-family: var(--font-ui); font-weight: 600; font-size: 13px; margin-bottom: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.work-card .meta { font-family: var(--font-body); font-size: 11.5px; color: var(--ink-dim); display: flex; justify-content: space-between; gap: 6px; }
.work-card-meta-right { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.like-count-mini { color: var(--danger); font-weight: 600; }

/* ---- tag / relation chips (chapters a character belongs to, characters a work depicts) ---- */
.chapter-badge, .character-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-ui); font-weight: 600; font-size: 12px;
  color: var(--ink);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 4px 10px;
  margin: 0 6px 6px 0;
}
.chapter-badge:hover, .character-badge:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.chip-row { display: flex; flex-wrap: wrap; gap: 0; }

/* ---- wiki article layout: main column + infobox ---- */
.wiki-layout { display: flex; gap: 28px; align-items: flex-start; }
.wiki-main { flex: 1 1 380px; min-width: 0; }
.wiki-main h1 { margin-bottom: 4px; border-bottom: none; padding-bottom: 0; }
.wiki-main .subtitle { color: var(--ink-dim); font-style: italic; margin-bottom: 18px; font-size: 13.5px; }
.wiki-main .subtitle + .section-title { margin-top: 20px; }

.infobox {
  flex: 0 0 240px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.infobox-title {
  background: var(--header-bg);
  color: var(--header-ink);
  font-family: var(--font-ui); font-weight: 800; font-size: 14.5px;
  text-align: center;
  padding: 10px 12px;
}
.infobox-image {
  width: 100%; aspect-ratio: 1 / 1.05;
  background: var(--panel-3) center/cover no-repeat;
  border-bottom: 1px solid var(--line);
}
.infobox-image--empty {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-weight: 700; font-size: 38px; color: var(--ink-dim);
}
.infobox-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.infobox-table th, .infobox-table td {
  text-align: left; vertical-align: top;
  padding: 9px 12px;
  border-top: 1px solid var(--line);
}
.infobox-table th {
  width: 34%;
  font-family: var(--font-ui); font-weight: 600; color: var(--ink-dim);
}
.infobox-table td { font-family: var(--font-body); color: var(--ink); }
.infobox-table tr:first-child th, .infobox-table tr:first-child td { border-top: none; }

@media (max-width: 720px) {
  .wiki-layout { flex-direction: column; }
  .infobox { flex: 1 1 auto; width: 100%; order: -1; max-width: 320px; }
}

/* ---- article figures (full art / work images) ---- */
.full-art, .work-detail img, .work-detail video {
  width: 100%; max-height: 65vh; object-fit: contain;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
  display: block;
}

.work-detail .meta {
  display: flex; flex-wrap: wrap; gap: 4px 16px;
  font-family: var(--font-ui); font-size: 12.5px; color: var(--ink-dim);
  margin-bottom: 6px;
}

/* ---- 点赞 ---- */
.interaction-bar { display: flex; align-items: center; gap: 12px; margin: 4px 0 20px; }
.like-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-ui); font-size: 13.5px; font-weight: 600;
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink-dim);
  cursor: pointer; transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.like-btn:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
.like-btn .like-icon { font-size: 15px; line-height: 1; }
.like-btn.is-liked { border-color: var(--danger); color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.like-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.interaction-bar .hint { font-size: 12.5px; color: var(--ink-dim); }

/* ---- 短评 ---- */
.comment-section { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 4px; }
.comment-section-title {
  font-family: var(--font-ui); font-weight: 700; font-size: 14px; color: var(--ink);
  margin-bottom: 12px;
}
.comment-form { display: flex; gap: 8px; margin-bottom: 14px; }
.comment-form .input { flex: 1; }
.comment-list { display: flex; flex-direction: column; }
.comment-row { padding: 11px 0; border-bottom: 1px solid var(--line); }
.comment-row:last-child { border-bottom: none; }
.comment-row-meta {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-ui); font-size: 12px; color: var(--ink-dim); margin-bottom: 3px;
}
.comment-row-meta [data-author-slot] { font-weight: 600; color: var(--ink); }
.comment-row-time { flex: 1; }
.comment-delete {
  border: none; background: none; cursor: pointer;
  font-family: var(--font-ui); font-size: 11.5px; color: var(--ink-dim);
  padding: 0; text-decoration: underline;
}
.comment-delete:hover { color: var(--danger); }
.comment-row-text { font-family: var(--font-body); font-size: 13.5px; color: var(--ink); word-break: break-word; }

/* ---- status badges ---- */
.stamp {
  font-family: var(--font-ui); font-weight: 700;
  font-size: 11.5px;
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
}
.stamp.pending { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.stamp.approved { color: var(--ok); background: color-mix(in srgb, var(--ok) 18%, transparent); }
.stamp.rejected { color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, transparent); }

/* ---- submission / data rows ---- */
.submission-row, .data-row {
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.submission-row { display: flex; align-items: center; gap: 12px; }
.submission-row:last-child, .data-row:last-child { border-bottom: none; }
.submission-row .meta, .data-row .top .meta { flex: 1; min-width: 0; font-family: var(--font-body); }
.submission-row .title { font-family: var(--font-ui); font-weight: 600; font-size: 14px; }
.submission-row .sub { font-size: 12.5px; color: var(--ink-dim); }
.submission-row .reason { font-size: 12.5px; color: var(--danger); margin-top: 4px; }

.data-row .top { display: flex; align-items: center; gap: 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

/* ---- states ---- */
.empty-state, .error-state, .loading-state {
  font-family: var(--font-body);
  text-align: left; padding: 24px 0; color: var(--ink-dim); font-size: 14px;
}
.error-state { color: var(--danger); }
.error-text { color: var(--danger); font-size: 12.5px; margin-top: 8px; min-height: 1em; }
.success-text { color: var(--ok); font-size: 12.5px; margin-top: 8px; min-height: 1em; }

/* ---- gate: a clean access notice ---- */
.gate {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 22px 22px;
  text-align: left;
}
.gate p { font-family: var(--font-body); margin-bottom: 14px; }
.gate h2 { border-bottom: none; padding-bottom: 0; }

.copyright-notice {
  margin-top: 4px;
  padding: 10px 14px;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink-dim);
}

/* ---- copyright notice ---- */
.copyright-notice {
  font-family: var(--font-body); font-size: 12.5px; color: var(--ink-dim);
  background: var(--panel-2);
  border-left: 3px solid var(--line-strong);
  border-radius: 0 4px 4px 0;
  padding: 10px 14px;
  margin: 4px 0 16px;
}

/* ---- character image gallery (public) ---- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.gallery-thumb {
  display: block; aspect-ratio: 1 / 1;
  background: var(--panel-3) center/cover no-repeat;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.gallery-thumb:hover { border-color: var(--accent); }

/* ---- admin: gallery manager ---- */
.gallery-editor {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-bottom: 10px;
}
.gallery-editor:empty { display: none; }
.gallery-editor-item { position: relative; width: 74px; height: 74px; }
.gallery-editor-item img {
  width: 100%; height: 100%; object-fit: cover;
  border: 1px solid var(--line); border-radius: 4px; display: block;
}
.gallery-editor-item button {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: var(--danger); color: #fff;
  font-size: 12px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
}

/* ---- admin: repeatable custom section rows ---- */
.extra-section-row {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--panel);
}
.extra-section-row .input { margin-bottom: 8px; }
.extra-section-row .textarea { margin-bottom: 8px; min-height: 70px; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 4px; margin-bottom: 18px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tab-btn {
  font-family: var(--font-ui); font-weight: 600; font-size: 13px;
  padding: 8px 12px;
  border: none; border-bottom: 2px solid transparent;
  background: transparent; color: var(--ink-dim); cursor: pointer;
  border-radius: 4px 4px 0 0;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--ink); background: var(--panel-2); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

@media (max-width: 480px) {
  h1 { font-size: 22px; }
  .grid { gap: 12px; }
  .infobox { max-width: none; }
}
