:root {
  color-scheme: light;
  --ink: #1e2722;
  --muted: #65716c;
  --paper: #fbfaf6;
  --panel: #ffffff;
  --line: #ddd8cd;
  --red: #a9302a;
  --red-dark: #7d231f;
  --jade: #1e6c5b;
  --brass: #a9782a;
  --blue: #224f66;
  --shadow: 0 18px 50px rgba(30, 39, 34, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(251, 250, 246, 0.96), rgba(242, 246, 244, 0.98)),
    var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

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

img {
  display: block;
  max-width: 100%;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 56px);
  background: rgba(251, 250, 246, 0.88);
  border-bottom: 1px solid rgba(221, 216, 205, 0.82);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: var(--red);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  white-space: nowrap;
}

.brand strong {
  font-size: 0.98rem;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.site-nav a {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 650;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--ink);
  background: rgba(30, 108, 91, 0.1);
  outline: none;
}

.story-desk {
  position: relative;
  display: grid;
  grid-template-columns: minmax(330px, 440px) minmax(0, 1fr);
  gap: 32px;
  min-height: calc(100vh - 72px);
  padding: 54px clamp(18px, 4vw, 56px);
  overflow: hidden;
  isolation: isolate;
}

.desk-image-stack,
.story-desk::after {
  position: absolute;
  inset: 0;
}

.desk-image-stack {
  z-index: -2;
  overflow: hidden;
}

.desk-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.desk-image.is-secondary {
  opacity: 0;
  animation: heroCrossfade 14s ease-in-out infinite;
  will-change: opacity;
}

.story-desk::after {
  z-index: -1;
  content: "";
  background:
    linear-gradient(90deg, rgba(20, 28, 24, 0.84), rgba(20, 28, 24, 0.54) 45%, rgba(20, 28, 24, 0.26)),
    linear-gradient(180deg, rgba(20, 28, 24, 0.32), rgba(20, 28, 24, 0.72));
}

@keyframes heroCrossfade {
  0%,
  38% {
    opacity: 0;
  }

  50%,
  88% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

.desk-copy {
  align-self: end;
  justify-self: end;
  max-width: 780px;
  padding-bottom: 18px;
  color: #fff;
}

.desk-copy h1 {
  max-width: none;
}

.kicker {
  margin: 0 0 10px;
  color: var(--brass);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.desk-copy .kicker {
  color: #f4c973;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.08;
}

h1 {
  max-width: 12ch;
  font-size: 4.25rem;
  font-weight: 860;
}

.lede {
  max-width: 640px;
  margin: 22px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 1.08rem;
}

.metric-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.metric-row span {
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
}

.metric-row strong {
  color: #fff;
}

.capture-panel,
.timeline-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.capture-panel {
  align-self: center;
  justify-self: start;
  width: 100%;
  padding: 24px;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading h2,
.section-head h2 {
  font-size: 1.55rem;
}

.story-form {
  display: grid;
  gap: 14px;
}

.story-form label,
.search-box,
.sort-box {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 12px;
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cfc8ba;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  font-size: 0.96rem;
}

textarea {
  min-height: 138px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--jade);
  box-shadow: 0 0 0 4px rgba(30, 108, 91, 0.14);
  outline: none;
}

.form-actions,
.archive-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-action,
.ghost-action,
.small-action,
.filter-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-action {
  flex: 1 1 160px;
  color: #fff;
  background: var(--red);
}

.primary-action:hover,
.primary-action:focus-visible {
  background: var(--red-dark);
}

.ghost-action,
.small-action {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.ghost-action:hover,
.small-action:hover,
.ghost-action:focus-visible,
.small-action:focus-visible {
  border-color: var(--jade);
  color: var(--jade);
  outline: none;
}

.small-action.soft {
  color: var(--blue);
  background: rgba(34, 79, 102, 0.08);
}

.archive-band,
.prompts-band,
.timeline-band {
  padding: 56px clamp(18px, 4vw, 56px);
}

.archive-band,
.timeline-band {
  background: #fbfaf6;
}

.prompts-band {
  background: #eef5f1;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.tool-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px);
  gap: 14px;
  margin-bottom: 16px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.filter-button {
  min-height: 40px;
  color: var(--muted);
  background: #fff;
  border-color: var(--line);
}

.filter-button.is-active {
  color: #fff;
  background: var(--jade);
  border-color: var(--jade);
}

.archive-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}

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

.story-card {
  display: grid;
  gap: 14px;
  min-height: 250px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(30, 39, 34, 0.06);
}

.story-card:hover {
  border-color: rgba(30, 108, 91, 0.48);
}

.story-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--red-dark);
  background: rgba(169, 48, 42, 0.1);
  font-weight: 780;
}

.story-card h3 {
  color: var(--ink);
  font-size: 1.24rem;
}

.story-card p {
  margin: 0;
  color: #4a544f;
}

.read-action {
  justify-self: start;
  min-height: 38px;
  border: 0;
  border-bottom: 2px solid var(--jade);
  padding: 4px 0;
  color: var(--jade);
  background: transparent;
  font-weight: 850;
}

.empty-state {
  margin: 22px 0 0;
  padding: 18px;
  border: 1px dashed #c9c2b5;
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
}

.timeline-panel {
  position: sticky;
  top: 92px;
  padding: 22px;
}

.timeline-panel-wide {
  position: static;
  width: min(760px, 100%);
  margin: 0 auto;
}

.timeline-list {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-list li {
  position: relative;
  padding-left: 24px;
}

.timeline-list li::before {
  position: absolute;
  left: 0;
  top: 8px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--jade);
  border-radius: 50%;
  background: #fff;
  content: "";
}

.timeline-year {
  display: block;
  color: var(--jade);
  font-size: 0.86rem;
  font-weight: 860;
}

.timeline-title {
  display: block;
  margin-top: 2px;
  font-weight: 780;
}

.timeline-author {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.prompt-card {
  display: grid;
  gap: 14px;
  min-height: 170px;
  padding: 20px;
  text-align: left;
  border: 1px solid rgba(30, 108, 91, 0.24);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.prompt-card:hover,
.prompt-card:focus-visible {
  border-color: var(--jade);
  box-shadow: 0 10px 26px rgba(30, 108, 91, 0.12);
  outline: none;
}

.prompt-card span {
  color: var(--brass);
  font-size: 0.82rem;
  font-weight: 850;
}

.prompt-card strong {
  font-size: 1.08rem;
  line-height: 1.35;
}

.story-dialog {
  width: min(720px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: transparent;
}

.story-dialog::backdrop {
  background: rgba(30, 39, 34, 0.62);
}

.story-dialog article {
  position: relative;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.icon-action {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: #fff;
  font-size: 1.4rem;
  line-height: 1;
}

.dialog-meta {
  margin: 0 0 12px;
  color: var(--jade);
  font-weight: 820;
}

.story-dialog h2 {
  margin-right: 32px;
  font-size: 1.8rem;
}

.story-dialog p:last-child {
  margin-bottom: 0;
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(360px, calc(100% - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--jade);
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .desk-image.is-secondary {
    animation: none;
  }
}

@media (max-width: 1080px) {
  h1 {
    max-width: 14ch;
    font-size: 3.35rem;
  }

  .story-desk {
    grid-template-columns: minmax(0, 1fr);
    min-height: auto;
  }

  .desk-copy {
    align-self: start;
    padding-bottom: 0;
  }

  .capture-panel {
    max-width: 680px;
  }

  .archive-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .timeline-panel {
    position: static;
  }

  .prompt-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .site-nav {
    justify-content: flex-start;
  }

  .brand strong,
  .brand small {
    white-space: normal;
  }

  .story-desk {
    min-height: auto;
    padding-top: 38px;
  }

  h1 {
    max-width: none;
    font-size: 2.35rem;
  }

  .lede {
    font-size: 1rem;
  }

  .field-grid,
  .tool-row,
  .story-list,
  .prompt-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .archive-actions,
  .form-actions {
    width: 100%;
  }

  .small-action,
  .ghost-action,
  .primary-action {
    flex: 1 1 140px;
  }
}

@media (max-width: 430px) {
  .site-header,
  .story-desk,
  .archive-band,
  .prompts-band,
  .timeline-band {
    padding-left: 14px;
    padding-right: 14px;
  }

  .capture-panel,
  .story-card,
  .timeline-panel,
  .prompt-card {
    padding: 16px;
  }

  h1 {
    font-size: 2rem;
  }

  .story-dialog article {
    padding: 24px;
  }
}
