:root {
  --paper: #f7f2e9;
  --ink: #171a18;
  --muted: #676b66;
  --line: rgba(23, 26, 24, 0.16);
  --teal: #266f6a;
  --teal-soft: rgba(38, 111, 106, 0.12);
  --amber: #c98b2c;
  --amber-soft: rgba(201, 139, 44, 0.16);
  --panel: rgba(255, 252, 246, 0.84);
  --mono: "SFMono-Regular", "Cascadia Mono", "Liberation Mono", Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  --serif: "Songti SC", "Noto Serif SC", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  background:
    linear-gradient(rgba(23, 26, 24, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 26, 24, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px, 32px 32px, auto;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button,
.admin-link,
.save-button,
.wide-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

button:hover,
.admin-link:hover,
.save-button:hover,
.wide-button:hover {
  border-color: rgba(23, 26, 24, 0.42);
}

.debug-banner {
  display: flex;
  justify-content: center;
  padding: 9px 16px;
  border-bottom: 1px solid rgba(23, 26, 24, 0.2);
  background: #171a18;
  color: var(--paper);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 242, 233, 0.88);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 210px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-weight: 720;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.top-nav button,
.admin-link,
.save-button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 14px;
}

.top-nav button.active {
  background: var(--ink);
  color: var(--paper);
}

.admin-link,
.save-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: clamp(28px, 5vw, 76px);
  padding: clamp(40px, 7vw, 92px) clamp(18px, 4vw, 54px) 36px;
  border-bottom: 1px solid var(--line);
}

.kicker,
.section-title p {
  margin: 0 0 12px;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 920px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(42px, 8vw, 104px);
  font-weight: 650;
  line-height: 0.98;
}

.lead {
  max-width: 720px;
  margin: 24px 0 0;
  color: #3f443f;
  font-size: clamp(17px, 2.1vw, 22px);
  line-height: 1.75;
}

.hero-index {
  align-self: stretch;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 360px;
  padding: 24px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, transparent 0 48%, rgba(38, 111, 106, 0.1) 48% 52%, transparent 52%),
    var(--panel);
}

.index-number {
  align-self: start;
  font-family: var(--mono);
  font-size: clamp(120px, 20vw, 240px);
  line-height: 0.8;
}

.index-lines {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.index-lines span {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.control-strip {
  position: sticky;
  top: 72px;
  z-index: 15;
  display: grid;
  grid-template-columns: minmax(260px, 620px) auto;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(18px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 242, 233, 0.9);
  backdrop-filter: blur(12px);
}

.search-box {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
}

.search-box span,
.view-note {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
}

.search-box input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  outline: none;
}

.search-box input:focus {
  border-color: var(--teal);
}

.view-note {
  justify-self: end;
  display: flex;
  gap: 6px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.module-card {
  display: grid;
  grid-template-rows: 180px auto;
  min-height: 420px;
  border-right: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.38);
}

.module-card:last-child {
  border-right: 0;
}

.module-card img,
.article-cover,
.reader-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.92) contrast(0.98);
}

.module-card img {
  border-bottom: 1px solid var(--line);
}

.module-body {
  display: grid;
  align-content: space-between;
  gap: 28px;
  padding: 22px;
}

.module-code,
.article-issue,
.article-meta,
.status-pill {
  font-family: var(--mono);
  font-size: 12px;
}

.module-code {
  color: var(--amber);
}

.module-body h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1.1;
}

.module-body p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.timeline-section {
  padding: clamp(36px, 6vw, 76px) clamp(18px, 4vw, 54px);
}

.section-title {
  display: grid;
  grid-template-columns: minmax(0, 0.44fr) minmax(0, 1fr);
  gap: 28px;
  align-items: end;
  margin-bottom: 28px;
}

.section-title h2,
.principles h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1.05;
}

.article-timeline {
  display: grid;
  border-top: 1px solid var(--ink);
}

.article-row {
  display: grid;
  grid-template-columns: 130px minmax(220px, 0.6fr) minmax(0, 1.1fr) 140px;
  gap: 24px;
  align-items: stretch;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.article-row:hover .article-title {
  color: var(--teal);
}

.article-issue {
  color: var(--teal);
}

.article-date,
.article-meta {
  color: var(--muted);
}

.article-title {
  margin: 0;
  font-size: clamp(22px, 3vw, 38px);
  line-height: 1.12;
}

.article-summary {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.tag-list span {
  border: 1px solid var(--line);
  padding: 5px 8px;
  color: #444943;
  font-family: var(--mono);
  font-size: 11px;
  background: var(--panel);
}

.article-thumb {
  min-height: 96px;
  border: 1px solid var(--line);
  overflow: hidden;
}

.draft-label {
  color: var(--amber);
}

.principles {
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(300px, 0.72fr);
  gap: clamp(26px, 5vw, 70px);
  padding: clamp(36px, 6vw, 76px) clamp(18px, 4vw, 54px);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.46);
}

.principle-list {
  display: grid;
  gap: 14px;
}

.principle-list p {
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: #3f443f;
  line-height: 1.75;
}

.site-footer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  padding: 28px clamp(18px, 4vw, 54px);
  color: var(--muted);
}

.site-footer strong {
  color: var(--ink);
}

.site-footer p {
  margin: 6px 0 0;
}

.footer-links {
  display: flex;
  gap: 16px;
  align-items: center;
}

.footer-links a {
  border-bottom: 1px solid currentColor;
}

.reader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  background: rgba(23, 26, 24, 0.32);
}

.reader.open {
  display: block;
}

.reader-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(920px, 100%);
  height: 100%;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--paper);
}

.reader-close {
  position: sticky;
  top: 14px;
  z-index: 2;
  float: right;
  margin: 14px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
}

.reader-hero {
  display: grid;
  gap: 24px;
  padding: 74px clamp(20px, 5vw, 58px) 28px;
}

.reader-cover-wrap {
  height: min(50vw, 360px);
  border: 1px solid var(--line);
  overflow: hidden;
}

.reader h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(34px, 6vw, 72px);
  line-height: 1.02;
}

.reader .article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
}

.reader-section {
  padding: 30px clamp(20px, 5vw, 58px);
  border-top: 1px solid var(--line);
}

.reader-section h2 {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: clamp(26px, 4vw, 42px);
}

.reader-section p {
  margin: 0;
  color: #313631;
  font-size: 17px;
  line-height: 1.9;
}

.reader-figure {
  margin: 22px 0 0;
}

.reader-figure img {
  width: 100%;
  border: 1px solid var(--line);
}

.reader-figure figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.reader-video {
  margin-top: 20px;
  border: 1px solid var(--line);
  padding: 16px;
  background: var(--panel);
}

.reader-video a {
  border-bottom: 1px solid currentColor;
}

.admin-body {
  background: #f4efe5;
}

.admin-lock {
  display: grid;
  min-height: calc(100vh - 32px);
  place-items: center;
  padding: clamp(22px, 5vw, 60px);
}

.admin-lock-panel {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.admin-lock-panel h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 42px;
  line-height: 1;
}

.admin-lock-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.hint-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.hint-box button {
  min-height: 34px;
  padding: 0 12px;
}

.hint-box span {
  color: var(--teal);
  font-family: var(--mono);
  font-size: 13px;
}

.lock-error {
  min-height: 22px;
  color: #9b2c2c;
}

.admin-locked .admin-shell {
  display: none;
}

.admin-main {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 0;
  width: min(1500px, 100%);
  min-height: calc(100vh - 72px);
  border-bottom: 1px solid var(--line);
}

.admin-sidebar {
  border-right: 1px solid var(--line);
  padding: 24px;
}

.section-title.compact {
  display: block;
  margin-bottom: 18px;
}

.section-title.compact h1,
.section-title.compact h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 34px;
}

.wide-button {
  width: 100%;
  min-height: 42px;
  margin-bottom: 18px;
}

.admin-list {
  display: grid;
  gap: 8px;
}

.admin-item {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 12px;
  text-align: left;
  background: var(--panel);
}

.admin-item.active {
  border-color: var(--ink);
  background: #fffaf0;
}

.admin-item strong {
  font-size: 14px;
}

.admin-item span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.editor {
  padding: 24px clamp(18px, 4vw, 48px) 72px;
}

.editor-toolbar,
.section-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.editor-toolbar h2,
.section-editor-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 34px;
}

.status-pill {
  padding: 7px 10px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel);
}

.article-form,
.site-settings {
  display: grid;
  gap: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.76);
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 10px 12px;
  line-height: 1.65;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
}

.span-2 {
  grid-column: span 2;
}

.sections-editor {
  display: grid;
  gap: 14px;
}

.section-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.section-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.section-card-head button,
.section-editor-head button {
  min-height: 34px;
  padding: 0 12px;
}

.site-settings {
  margin-top: 38px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

@media (max-width: 1040px) {
  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .module-card:nth-child(2) {
    border-right: 0;
  }

  .article-row {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .article-thumb,
  .article-meta {
    grid-column: 2;
  }

  .admin-main {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .site-header {
    grid-template-columns: 1fr;
    position: static;
  }

  .brand {
    min-width: 0;
  }

  .top-nav {
    justify-content: start;
  }

  .hero,
  .principles,
  .section-title {
    grid-template-columns: 1fr;
  }

  .hero-index {
    min-height: 240px;
  }

  .control-strip {
    position: static;
    grid-template-columns: 1fr;
  }

  .view-note {
    justify-self: start;
  }

  .module-grid {
    grid-template-columns: 1fr;
  }

  .module-card {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .article-row {
    grid-template-columns: 1fr;
  }

  .article-thumb,
  .article-meta {
    grid-column: auto;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }
}
