:root {
  --radius: 14px;
  --font-serif: 'Songti SC', 'Noto Serif SC', 'Source Han Serif SC', 'SimSun', Georgia, serif;
  --font-sans: 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', system-ui, sans-serif;

  /* 兜底：与「纸墨」一致，避免缺 data-theme 时没有颜色 */
  --bg: #f7f3ea;
  --surface: #fffdf7;
  --surface-2: #f2ece0;
  --ink: #1f1b16;
  --ink-soft: #6a6157;
  --line: #e4dbc9;
  --accent: #8b3a25;
  --accent-ink: #fffdf7;
  --accent-soft: rgba(139, 58, 37, 0.1);
  --shadow: 0 24px 60px -40px rgba(40, 30, 20, 0.55);
  color-scheme: light;
}

/* ---------- 主题 ---------- */

html[data-theme='auto'] {
  --bg: #f7f3ea;
  --surface: #fffdf7;
  --surface-2: #f2ece0;
  --ink: #1f1b16;
  --ink-soft: #6a6157;
  --line: #e4dbc9;
  --accent: #8b3a25;
  --accent-ink: #fffdf7;
  --accent-soft: rgba(139, 58, 37, 0.1);
  --shadow: 0 24px 60px -40px rgba(40, 30, 20, 0.55);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  html[data-theme='auto'] {
    --bg: #14110d;
    --surface: #1c1813;
    --surface-2: #241f19;
    --ink: #ece4d6;
    --ink-soft: #a89c8c;
    --line: #332b22;
    --accent: #d98a63;
    --accent-ink: #1a1512;
    --accent-soft: rgba(217, 138, 99, 0.14);
    --shadow: 0 24px 60px -40px rgba(0, 0, 0, 0.9);
    color-scheme: dark;
  }
}

html[data-theme='paper'] {
  --bg: #f7f3ea;
  --surface: #fffdf7;
  --surface-2: #f2ece0;
  --ink: #1f1b16;
  --ink-soft: #6a6157;
  --line: #e4dbc9;
  --accent: #8b3a25;
  --accent-ink: #fffdf7;
  --accent-soft: rgba(139, 58, 37, 0.1);
  --shadow: 0 24px 60px -40px rgba(40, 30, 20, 0.55);
  color-scheme: light;
}

html[data-theme='sepia'] {
  --bg: #f1e6d0;
  --surface: #faf1de;
  --surface-2: #e9dcc2;
  --ink: #3b2e1e;
  --ink-soft: #7b6749;
  --line: #d9c9a8;
  --accent: #9a5a1e;
  --accent-ink: #fff9ec;
  --accent-soft: rgba(154, 90, 30, 0.12);
  --shadow: 0 24px 60px -40px rgba(70, 50, 20, 0.5);
  color-scheme: light;
}

html[data-theme='celadon'] {
  --bg: #eef3f0;
  --surface: #fbfdfb;
  --surface-2: #e3ece7;
  --ink: #1a2622;
  --ink-soft: #566a62;
  --line: #cfded7;
  --accent: #2f6b58;
  --accent-ink: #f6fffa;
  --accent-soft: rgba(47, 107, 88, 0.1);
  --shadow: 0 24px 60px -40px rgba(20, 60, 45, 0.45);
  color-scheme: light;
}

html[data-theme='night'] {
  --bg: #14110d;
  --surface: #1c1813;
  --surface-2: #241f19;
  --ink: #ece4d6;
  --ink-soft: #a89c8c;
  --line: #332b22;
  --accent: #d98a63;
  --accent-ink: #1a1512;
  --accent-soft: rgba(217, 138, 99, 0.14);
  --shadow: 0 24px 60px -40px rgba(0, 0, 0, 0.9);
  color-scheme: dark;
}

html[data-theme='midnight'] {
  --bg: #0e1422;
  --surface: #151d2f;
  --surface-2: #1c2740;
  --ink: #e2e9f7;
  --ink-soft: #94a2bf;
  --line: #28344d;
  --accent: #7aa2f7;
  --accent-ink: #0b1120;
  --accent-soft: rgba(122, 162, 247, 0.16);
  --shadow: 0 24px 60px -40px rgba(0, 0, 0, 0.9);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--surface) 0%, transparent 62%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

form {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  text-wrap: balance;
}

a {
  color: var(--accent);
}

code {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 0.92em;
  padding: 0.1em 0.35em;
  border-radius: 5px;
  background: var(--surface-2);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- 通用控件 ---------- */

.brand {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
}

.ghost {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease;
}

.ghost:hover {
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}

.primary {
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition:
    filter 0.18s ease,
    transform 0.12s ease;
}

.primary:hover {
  filter: brightness(1.07);
}

.primary:active {
  transform: translateY(1px);
}

.primary:focus-visible,
.ghost:focus-visible,
.nav-link:focus-visible,
.brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.alert {
  margin: 0;
  padding: 8px 0 8px 12px;
  border-left: 3px solid var(--accent);
  border-radius: 2px;
  color: var(--accent);
  font-size: 13px;
  line-height: 1.6;
}

.switch {
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  text-align: center;
}

.switch a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.switch a:hover {
  border-bottom-color: var(--accent);
}

/* ---------- 登录 / 注册 ---------- */

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 32px 20px;
}

.auth-card {
  width: min(100%, 420px);
  padding: 40px 36px 32px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card .brand {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
}

.auth-card h1 {
  margin: 14px 0 0;
  font-size: 30px;
  letter-spacing: 0.02em;
}

.auth-card .sub {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.8;
}

.auth-form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.field {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 0.02em;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.field input::placeholder {
  color: var(--ink-soft);
  opacity: 0.55;
  letter-spacing: normal;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- 顶部导航 ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 22px;
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 28px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: auto;
}

.nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 13.5px;
  text-decoration: none;
  transition:
    background 0.18s ease,
    color 0.18s ease;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.whoami {
  max-width: 14ch;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 主题切换 ---------- */

.theme-picker {
  position: relative;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
}

.theme-dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 14%, transparent);
}

.theme-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  min-width: 152px;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 50px -30px rgba(0, 0, 0, 0.45);
}

.theme-menu[hidden] {
  display: none;
}

.theme-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.theme-menu button:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.theme-menu button[aria-selected='true'] {
  background: var(--accent-soft);
  color: var(--accent);
}

.theme-swatch {
  width: 12px;
  height: 12px;
  flex: none;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 30%, transparent);
}

/* ---------- 主页 ---------- */

.shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 52px 28px 64px;
}

.primary.compact {
  padding: 8px 16px;
  border-radius: 9px;
  font-size: 13px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-head h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.01em;
}

.work-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.work-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.work-row:hover {
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
  box-shadow: 0 16px 36px -34px rgba(40, 30, 20, 0.6);
}

.work-row:hover .work-title {
  color: var(--accent);
}

.work-title {
  flex: 1;
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.work-meta {
  flex: none;
  color: var(--ink-soft);
  font-size: 12px;
  white-space: nowrap;
}

.work-arrow {
  flex: none;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1;
}

/* ---------- 作品详情 ---------- */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 12.5px;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  opacity: 0.45;
}

.work-head {
  margin-top: 22px;
}

.work-head h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 36px);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.work-head h1:hover {
  text-decoration: underline dotted color-mix(in srgb, var(--ink-soft) 55%, transparent);
  text-underline-offset: 6px;
  cursor: text;
}

.work-title-input {
  width: 100%;
  padding: 2px 8px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.work-head .work-meta {
  margin-top: 10px;
}

.work-hint {
  margin-left: 8px;
  color: var(--ink-soft);
  font-size: 12px;
  opacity: 0.7;
}

.work-hint[hidden] {
  display: none;
}

.work-error {
  margin: 10px 0 0;
  color: var(--accent);
  font-size: 13px;
}

.work-error[hidden] {
  display: none;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-top: 30px;
  border-bottom: 1px solid var(--line);
}

.tab {
  margin-bottom: -1px;
  padding: 10px 16px;
  border-bottom: 2px solid transparent;
  color: var(--ink-soft);
  font-size: 14px;
  text-decoration: none;
  transition:
    color 0.18s ease,
    border-color 0.18s ease;
}

.tab:hover {
  color: var(--ink);
}

.tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab-panel {
  margin-top: 26px;
}

.tab-panel .todo {
  margin-top: 0;
}

.todo {
  margin-top: 40px;
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}

.todo-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
}

.todo-note {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.8;
}

.empty {
  margin: 20px 0 0;
  padding: 30px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-size: 13.5px;
  text-align: center;
}

.footnote {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 20px;
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
}

@media (max-width: 620px) {
  .auth-card {
    padding: 32px 24px 26px;
  }

  .header-inner {
    gap: 14px;
    padding: 12px 20px;
  }

  .brand {
    font-size: 14px;
  }

  .whoami {
    display: none;
  }

  .theme-label {
    display: none;
  }

  .theme-toggle {
    padding: 8px 10px;
  }

  .shell {
    padding: 38px 20px 48px;
  }

  .section-head h1 {
    font-size: 21px;
  }

  .work-row {
    gap: 10px;
    padding: 16px 18px;
  }

  .todo {
    padding: 22px;
  }
}
