:root {
  --bg: #f7f7f4;
  --surface: #fff;
  --text: #22221f;
  --muted: #74746d;
  --line: #e4e4de;
  --accent: #2457d6;
  --soft: #eeeee9;
  --shadow: 0 24px 80px rgba(28, 28, 24, .12);
}

[data-theme="dark"] {
  --bg: #171816;
  --surface: #20211e;
  --text: #efefe9;
  --muted: #a2a29a;
  --line: #353630;
  --accent: #8aa7ff;
  --soft: #292a26;
  --shadow: 0 24px 80px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans SC", sans-serif;
  transition: color .2s, background .2s;
}
button, input { font: inherit; }
button { color: inherit; }
.shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }
.topbar { height: 80px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; font-weight: 720; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 29px; height: 29px; color: #fff; background: var(--text); border-radius: 8px; font-family: Georgia, serif; font-weight: 700; }
.brand-mark.large { width: 42px; height: 42px; margin-bottom: 22px; font-size: 20px; }
.nav { display: flex; gap: 8px; align-items: center; }
.nav button { border: 0; background: transparent; cursor: pointer; }
.nav-link { padding: 8px 11px; color: var(--muted); }
.nav-link:hover, .nav-link.active { color: var(--text); }
.icon-button { width: 37px; height: 37px; border-radius: 50% !important; font-size: 18px; }
.icon-button:hover { background: var(--soft); }
.login-button { padding: 9px 16px; margin-left: 4px; border: 1px solid var(--line) !important; border-radius: 9px; font-weight: 650; }
.login-button:hover { background: var(--surface); }
.hero { padding: 94px 0 78px; border-bottom: 1px solid var(--line); }
.eyebrow, .section-kicker, .side-title { margin: 0; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.hero h1 { margin: 17px 0 22px; font-family: ui-serif, Georgia, "Noto Serif SC", serif; font-size: clamp(44px, 6.5vw, 78px); line-height: 1.08; letter-spacing: -.055em; font-weight: 520; }
.hero h1 span { color: var(--muted); }
.intro { max-width: 600px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.8; }
.search-box { display: flex; align-items: center; gap: 12px; width: min(570px, 100%); height: 54px; margin-top: 40px; padding: 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 30px rgba(30, 30, 25, .04); }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 13%, transparent); }
.search-box svg { width: 19px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.search-box input { min-width: 0; flex: 1; color: var(--text); background: transparent; border: 0; outline: 0; }
.search-box kbd { color: var(--muted); background: var(--soft); border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px; }
.content-grid { display: grid; grid-template-columns: 210px 1fr; gap: 70px; padding: 70px 0 110px; }
.side-section + .side-section { margin-top: 38px; }
.side-title { margin-bottom: 14px; }
.side-link { display: flex; width: 100%; justify-content: space-between; padding: 9px 10px; margin-left: -10px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; color: var(--muted); text-align: left; }
.side-link:hover, .side-link.selected { color: var(--text); background: var(--soft); }
.side-link em { font-style: normal; font-size: 12px; color: var(--muted); }
.tags div { display: flex; flex-wrap: wrap; gap: 7px; }
.tags button { padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; }
.tags button:hover { color: var(--text); border-color: var(--muted); }
.admin-card { margin-top: 38px; padding: 16px; background: var(--text); color: var(--bg); border-radius: 12px; }
.admin-card span, .admin-card strong { display: block; }
.admin-card span { opacity: .65; font-size: 11px; }
.admin-card strong { margin-top: 7px; font-size: 14px; }
.admin-card button { padding: 0; margin-top: 17px; border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 22px; }
.section-head h2 { margin: 7px 0 0; font-family: ui-serif, Georgia, serif; font-size: 29px; font-weight: 520; letter-spacing: -.025em; }
.new-note { border: 0; padding: 9px 13px; background: var(--text); color: var(--bg); border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 650; }
.note-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.note { min-width: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 44%, transparent); }
.note.featured { grid-column: 1 / -1; }
.note-link { display: flex; flex-direction: column; width: 100%; min-height: 246px; padding: 26px; text-align: left; border: 0; background: transparent; cursor: pointer; }
.featured .note-link { min-height: 270px; padding: 31px; }
.note:hover { background: var(--surface); }
.note-meta { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 11px; }
.category { color: var(--accent); font-weight: 700; }
.note h3 { margin: 22px 0 11px; font-family: ui-serif, Georgia, "Noto Serif SC", serif; font-size: 23px; line-height: 1.3; font-weight: 560; letter-spacing: -.02em; }
.featured h3 { font-size: 31px; }
.note p { max-width: 640px; margin: 0; color: var(--muted); line-height: 1.7; font-size: 14px; }
.note-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 25px; color: var(--muted); font-size: 11px; }
.arrow { font-size: 17px; transform: translate(-3px, 3px); transition: transform .2s; }
.note:hover .arrow { transform: translate(1px, -1px); }
.empty { padding: 70px 0; text-align: center; color: var(--muted); }
footer { display: flex; justify-content: space-between; padding: 27px 0 45px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
dialog { padding: 0; border: 0; border-radius: 16px; color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(15, 15, 13, .55); backdrop-filter: blur(5px); }
.login-panel { position: relative; width: min(420px, calc(100vw - 40px)); padding: 40px; }
.close { position: absolute; right: 18px; top: 14px; padding: 5px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 24px; }
.login-panel h2 { margin: 8px 0; font-family: ui-serif, Georgia, serif; font-size: 30px; }
.login-panel > p:not(.section-kicker) { margin: 0 0 27px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.login-panel label { display: block; margin-top: 15px; color: var(--muted); font-size: 12px; }
.login-panel input { width: 100%; margin-top: 7px; padding: 12px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; outline: none; }
.login-panel input:focus { border-color: var(--accent); }
.submit { width: 100%; margin-top: 22px; padding: 12px; border: 0; border-radius: 8px; color: var(--bg); background: var(--text); cursor: pointer; font-weight: 700; }
.reader-dialog { width: min(900px, calc(100vw - 32px)); max-height: calc(100vh - 32px); border-radius: 13px; }
.reader { width: min(680px, calc(100% - 40px)); margin: 0 auto; padding: 55px 0 90px; }
.reader-back { margin-bottom: 62px; padding: 0; color: var(--muted); border: 0; background: transparent; cursor: pointer; }
.reader-meta { color: var(--accent); font-size: 12px; }
.reader h1 { margin: 15px 0 20px; font-family: ui-serif, Georgia, serif; font-size: clamp(38px, 6vw, 55px); line-height: 1.15; letter-spacing: -.04em; }
.reader-lead { color: var(--muted); font-size: 18px; line-height: 1.8; }
.reader hr { margin: 44px 0; border: 0; border-top: 1px solid var(--line); }
.reader h2 { margin-top: 42px; font-family: ui-serif, Georgia, serif; font-size: 25px; }
.reader p { line-height: 1.9; }
.reader pre { overflow: auto; padding: 20px; color: #e5e7eb; background: #20211f; border-radius: 9px; line-height: 1.7; }
.reader blockquote { margin: 35px 0; padding-left: 20px; border-left: 3px solid var(--accent); color: var(--muted); font-family: ui-serif, Georgia, serif; font-size: 19px; }

@media (max-width: 760px) {
  .shell { width: min(100% - 28px, 1180px); }
  .topbar { height: 68px; }
  .nav-link { display: none; }
  .hero { padding: 65px 0 55px; }
  .hero h1 { font-size: 43px; }
  .intro { font-size: 15px; }
  .content-grid { grid-template-columns: 1fr; gap: 38px; padding: 48px 0 75px; }
  .sidebar { display: flex; overflow-x: auto; gap: 8px; padding-bottom: 5px; }
  .side-section { display: contents; }
  .side-title, .tags, .admin-card { display: none !important; }
  .side-link { flex: 0 0 auto; width: auto; gap: 9px; padding: 8px 11px; margin: 0; border: 1px solid var(--line); }
  .note-list { grid-template-columns: 1fr; }
  .note.featured { grid-column: auto; }
  .note-link, .featured .note-link { min-height: 230px; padding: 23px; }
  .note h3, .featured h3 { font-size: 23px; }
  footer { flex-direction: column; gap: 8px; }
}
