:root {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --ink: #111111;
  --muted: #6f6f6b;
  --line: #deded9;
  --soft: #ecece8;
  --black: #0c0c0c;
  --radius: 18px;
  --shadow: 0 18px 60px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.shell { width: min(1180px, calc(100% - 48px)); margin-inline: auto; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  height: 76px; padding: 0 max(24px, calc((100vw - 1180px)/2));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(17,17,17,.08);
}
.brand { font-weight: 700; letter-spacing: -0.04em; font-size: 20px; }
.brand span { color: #777; }
.topbar nav { display: flex; gap: 28px; font-size: 13px; font-weight: 600; }
.topbar nav a { color: #555; }
.topbar nav a:hover { color: #000; }

.hero { padding: 110px 0 105px; border-bottom: 1px solid var(--line); }
.eyebrow, .kicker, .sidebar-label { font-size: 10px; letter-spacing: .18em; font-weight: 700; color: var(--muted); }
.hero h1 { margin: 18px 0 24px; font: 700 clamp(54px, 8vw, 108px)/.88 Libre Franklin, Inter, sans-serif; letter-spacing: -.075em; }
.hero h1 span { color: #a3a39f; }
.hero p { max-width: 650px; margin: 0; font-size: 18px; line-height: 1.7; color: #555; }
.hero-meta { display: flex; align-items: center; gap: 12px; margin-top: 42px; font-size: 12px; font-weight: 600; color: #666; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: #aaa; }

.content-section { padding: 88px 0 110px; }
.section-heading, .admin-header, .admin-list-head, .field-label-row {
  display: flex; justify-content: space-between; align-items: end;
}
.section-heading h2, .about h2, .admin-header h1 { margin: 8px 0 0; font: 700 42px/1 Libre Franklin, sans-serif; letter-spacing: -.055em; }
.view-actions { display: flex; gap: 6px; }
.icon-btn { width: 38px; height: 38px; border: 1px solid var(--line); background: transparent; border-radius: 10px; color: #777; }
.icon-btn.active, .icon-btn:hover { color: #fff; background: #111; border-color: #111; }

.toolbar { display: grid; grid-template-columns: 1fr 230px; gap: 12px; margin: 34px 0 14px; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box span { position: absolute; left: 16px; font-size: 24px; color: #777; transform: translateY(-2px); }
input, textarea, select {
  width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 12px; outline: none; transition: .18s ease;
}
input, select { height: 48px; padding: 0 14px; }
.search-box input { padding-left: 45px; }
textarea { padding: 14px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: #111; box-shadow: 0 0 0 3px rgba(0,0,0,.05); }

.tag-filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 28px; }
.filter-chip, .tag {
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; font-size: 11px; font-weight: 600; background: transparent; color: #666;
}
.filter-chip.active, .filter-chip:hover { background: #111; color: #fff; border-color: #111; }

.cards-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.cards-grid.list { grid-template-columns: 1fr; }
.content-card {
  min-height: 285px; display: flex; flex-direction: column; padding: 22px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.content-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: #c7c7c2; }
.content-card .card-top { display: flex; justify-content: space-between; gap: 12px; }
.category-badge { font-size: 10px; font-weight: 700; letter-spacing: .12em; color: #555; }
.card-index { font: 500 11px/1 monospace; color: #aaa; }
.content-card h3 { margin: 48px 0 12px; font-size: 22px; line-height: 1.2; letter-spacing: -.035em; }
.content-card p { margin: 0; color: #6d6d68; font-size: 13px; line-height: 1.65; }
.card-bottom { display: flex; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 24px; border-top: 1px solid var(--soft); }
.card-bottom span { font-size: 10px; color: #858580; }
.card-bottom b { font-size: 13px; }
.cards-grid.list .content-card { min-height: 0; display: grid; grid-template-columns: 170px 1fr auto; gap: 28px; align-items: center; }
.cards-grid.list .content-card h3 { margin: 8px 0; }
.cards-grid.list .content-card .card-bottom { border: 0; padding: 0; align-items: center; }

.empty-state { padding: 90px 20px; text-align: center; border: 1px dashed #ccc; border-radius: var(--radius); }
.empty-state span { font: 700 64px/1 Libre Franklin; color: #ddd; }
.empty-state h3 { margin-bottom: 8px; }
.empty-state p { margin: 0; color: #777; }

.about { padding: 90px 0 120px; border-top: 1px solid var(--line); }
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 80px; margin-top: 28px; }
.about h2 { font-size: 46px; line-height: 1.05; }
.about p { margin: 0; max-width: 500px; color: #5d5d59; font-size: 16px; line-height: 1.8; }
footer { min-height: 92px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); color: #777; font-size: 11px; }

.reader { position: fixed; inset: 0; z-index: 50; }
.reader-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.42); backdrop-filter: blur(6px); }
.reader-panel { position: absolute; top: 0; right: 0; width: min(850px, 94vw); height: 100%; overflow-y: auto; background: #fff; padding: 78px clamp(28px, 7vw, 86px); box-shadow: -20px 0 70px rgba(0,0,0,.16); }
.reader-close { position: fixed; right: 28px; top: 24px; z-index: 2; width: 42px; height: 42px; border: 1px solid #ddd; background: white; border-radius: 50%; font-size: 25px; }
.reader-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 34px; }
.reader-title { margin: 0 0 16px; font: 700 clamp(36px, 5vw, 64px)/.98 Libre Franklin; letter-spacing: -.055em; }
.reader-excerpt { font-size: 17px; line-height: 1.7; color: #666; margin-bottom: 54px; }
.article-content { color: #272724; font-size: 15px; line-height: 1.78; }
.article-content h1 { font-size: 34px; letter-spacing: -.04em; margin: 50px 0 20px; }
.article-content h2 { font-size: 24px; letter-spacing: -.035em; margin: 42px 0 12px; }
.article-content h3 { font-size: 18px; margin: 28px 0 8px; }
.article-content p { margin: 0 0 16px; }
.article-content ul { padding-left: 22px; }
.article-content strong { color: #000; }
.article-content code { background: #f0f0ed; padding: 2px 6px; border-radius: 5px; }
.article-content blockquote { margin: 24px 0; padding: 3px 0 3px 18px; border-left: 3px solid #111; color: #666; }

/* Admin */
.admin-body { background: #efefec; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: #0b0b0b; }
.login-card { width: min(470px, 100%); background: #fff; border-radius: 22px; padding: 42px; }
.login-card .brand { margin-bottom: 60px; }
.login-card h1 { margin: 10px 0 14px; font: 700 48px/.95 Libre Franklin; letter-spacing: -.06em; }
.login-card p { color: #777; line-height: 1.6; margin-bottom: 34px; }
.login-card label { display: grid; gap: 8px; font-size: 12px; font-weight: 600; }
.login-card .primary-btn { width: 100%; margin-top: 12px; }
#loginError { color: #b00020; display: block; margin-top: 10px; min-height: 18px; }

.admin-layout { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.admin-sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; display: flex; flex-direction: column; padding: 28px 18px; background: #101010; color: white; }
.admin-sidebar .brand { padding: 4px 10px; margin-bottom: 48px; }
.sidebar-label { color: #666; padding: 0 10px 9px; }
.admin-sidebar nav { display: grid; gap: 5px; }
.side-link { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 10px; border: 0; border-radius: 10px; color: #a8a8a8; background: transparent; text-align: left; font-size: 13px; }
.side-link:hover, .side-link.active { color: white; background: #232323; }
.side-link span { width: 18px; text-align: center; }
.sidebar-bottom { margin-top: auto; }
.admin-main { grid-column: 2; padding: 46px clamp(26px, 4vw, 64px) 80px; }
.admin-header { margin-bottom: 34px; }
.admin-header h1 { font-size: 44px; }
.primary-btn, .danger-btn, .text-btn { border: 0; border-radius: 11px; font-weight: 600; }
.primary-btn { min-height: 44px; padding: 0 17px; background: #111; color: #fff; }
.primary-btn:hover { background: #292929; }
.danger-btn { min-height: 44px; padding: 0 16px; color: #9e1b1b; background: #f8e7e7; }
.text-btn { padding: 0; margin: 0 0 22px; background: none; color: #777; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-card, .admin-list-card, .editor-form, .preview-panel { background: #fff; border: 1px solid #dfdfda; border-radius: 16px; }
.stat-card { padding: 23px; }
.stat-card span { display: block; color: #777; font-size: 9px; font-weight: 700; letter-spacing: .15em; }
.stat-card strong { display: block; margin: 18px 0 3px; font: 700 38px/1 Libre Franklin; letter-spacing: -.05em; }
.stat-card small { color: #999; }
.admin-list-card { overflow: hidden; }
.admin-list-head { padding: 22px; border-bottom: 1px solid var(--line); }
.admin-list-head h2 { font-size: 19px; margin: 5px 0 0; }
.admin-list-head input { width: 240px; height: 40px; }
.admin-summary-item { display: grid; grid-template-columns: 1fr 150px 105px 80px; gap: 18px; align-items: center; padding: 17px 22px; border-bottom: 1px solid #eeeeea; }
.admin-summary-item:last-child { border-bottom: 0; }
.admin-summary-item:hover { background: #fafaf8; }
.summary-main strong { display: block; font-size: 13px; margin-bottom: 5px; }
.summary-main span, .summary-meta { color: #888; font-size: 11px; }
.status-pill { width: fit-content; padding: 6px 9px; border-radius: 99px; font-size: 10px; font-weight: 700; background: #ededeb; color: #555; }
.status-pill.published { background: #111; color: white; }
.edit-btn { border: 1px solid #ddd; background: white; border-radius: 8px; padding: 7px 10px; font-size: 11px; }
.empty-admin { padding: 50px; text-align: center; color: #888; }

.editor-header { align-items: flex-end; }
.editor-actions { display: flex; gap: 8px; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 18px; align-items: start; }
.editor-form { padding: 24px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-group { display: grid; gap: 8px; margin-bottom: 17px; }
.field-group label { font-size: 11px; font-weight: 700; }
.field-label-row span { color: #999; font-size: 10px; }
.content-editor { min-height: 520px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.65; }
.switch-row { display: flex; align-items: center; gap: 12px; padding-top: 7px; cursor: pointer; }
.switch-row input { display: none; }
.switch { position: relative; width: 42px; height: 24px; border-radius: 99px; background: #ccc; transition: .2s; }
.switch::after { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: .2s; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.switch-row input:checked + .switch { background: #111; }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row strong, .switch-row small { display: block; }
.switch-row small { color: #888; margin-top: 2px; }
.preview-panel { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; }
.preview-top { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; padding: 14px 17px; background: rgba(255,255,255,.95); backdrop-filter: blur(10px); border-bottom: 1px solid #eee; color: #888; font-size: 9px; font-weight: 700; letter-spacing: .12em; }
.preview-panel .article-content { padding: 25px; font-size: 13px; }
.preview-panel .article-content h1 { font-size: 27px; margin-top: 8px; }
.preview-panel .article-content h2 { font-size: 20px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; transform: translateY(30px); opacity: 0; pointer-events: none; padding: 12px 16px; border-radius: 10px; background: #111; color: white; font-size: 12px; transition: .25s; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .cards-grid { grid-template-columns: 1fr 1fr; }
  .admin-layout { display: block; }
  .admin-sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; gap: 16px; }
  .admin-sidebar .brand { margin: 0 auto 0 0; }
  .admin-sidebar nav { display: flex; }
  .sidebar-label, .sidebar-bottom { display: none; }
  .admin-main { padding: 30px 22px 70px; }
  .editor-grid { grid-template-columns: 1fr; }
  .preview-panel { position: static; max-height: none; }
}

@media (max-width: 640px) {
  .shell { width: min(100% - 30px, 1180px); }
  .topbar { height: 65px; padding: 0 15px; }
  .topbar nav { gap: 15px; }
  .hero { padding: 75px 0; }
  .hero h1 { font-size: 54px; }
  .hero p { font-size: 15px; }
  .content-section { padding: 65px 0; }
  .toolbar, .about-grid, .field-row { grid-template-columns: 1fr; }
  .cards-grid { grid-template-columns: 1fr; }
  .cards-grid.list .content-card { display: flex; }
  .about-grid { gap: 25px; }
  .stats-grid { grid-template-columns: 1fr; }
  .admin-header, .admin-list-head { align-items: stretch; gap: 16px; flex-direction: column; }
  .admin-list-head input { width: 100%; }
  .admin-summary-item { grid-template-columns: 1fr auto; }
  .admin-summary-item .summary-meta:nth-of-type(1), .admin-summary-item .summary-meta:nth-of-type(2) { display: none; }
  .admin-sidebar { overflow-x: auto; }
  .admin-sidebar nav { min-width: max-content; }
  .side-link { white-space: nowrap; }
  .reader-panel { width: 100%; padding: 70px 24px; }
  footer { flex-direction: column; justify-content: center; gap: 8px; }
}
