:root {
  color-scheme: light;
  --ink: #172421;
  --muted: #65706b;
  --paper: #fffefd;
  --page: #f1f4f0;
  --line: #d7ddd7;
  --line-strong: #b8c2ba;
  --forest: #173b3a;
  --forest-light: #28645f;
  --coral: #db6048;
  --coral-dark: #b74231;
  --sun: #efb34f;
  --blue: #367c91;
  --success: #2f7656;
  --error: #a73a32;
  --radius: 8px;
  --radius-small: 5px;
  --shadow: 0 12px 34px rgba(23, 36, 33, 0.09);
  --content: 1220px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

i[data-lucide] {
  display: inline-grid;
  width: 1.15em;
  height: 1.15em;
  place-items: center;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-style: normal;
  line-height: 1;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 9px 13px;
  border-radius: var(--radius-small);
  background: var(--paper);
  color: var(--forest);
  font-weight: 700;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  background: var(--forest);
  color: #fff;
}

.site-header__inner {
  display: flex;
  min-height: 72px;
  max-width: var(--content);
  margin: 0 auto;
  padding: 10px 28px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand__mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: var(--coral);
}

.brand__mark svg,
.brand__mark i {
  width: 22px;
  height: 22px;
}

.brand strong,
.brand small {
  display: block;
  letter-spacing: 0;
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
  line-height: 1.2;
}

.brand small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.74rem;
  line-height: 1.2;
}

.service-state {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.78rem;
  font-weight: 650;
}

.service-state__dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
}

.service-state.is-online .service-state__dot {
  border-color: #9fe4bd;
  background: #58b982;
}

.service-state.is-offline .service-state__dot {
  border-color: #ffc2b8;
  background: var(--coral);
}

.page-shell {
  max-width: var(--content);
  margin: 0 auto;
  padding: 32px 28px 52px;
}

.reader-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.story-reader {
  min-width: 0;
  padding: 46px clamp(28px, 5vw, 72px) 60px;
  outline: none;
}

.story-header {
  max-width: 760px;
  margin: 0 auto;
}

.story-kicker {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--coral-dark);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.story-kicker__divider {
  width: 22px;
  height: 1px;
  background: var(--line-strong);
}

.story-kicker time {
  color: var(--muted);
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

#storyTitle {
  max-width: 760px;
  margin: 14px 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3.5rem;
  line-height: 1.05;
  letter-spacing: 0;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.story-dek {
  max-width: 670px;
  margin-bottom: 25px;
  color: #52615c;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.12rem;
  line-height: 1.55;
}

.story-toolbar {
  display: flex;
  min-height: 46px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.story-meta {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.story-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.story-meta svg,
.story-meta i {
  width: 15px;
  height: 15px;
  color: var(--forest-light);
}

.icon-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  place-items: center;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background-color 150ms ease;
}

.icon-button svg,
.icon-button i {
  width: 18px;
  height: 18px;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--coral);
  background: #fff7f3;
  color: var(--coral-dark);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.icon-button:focus-visible,
.text-button:focus-visible,
.archive-item__button:focus-visible,
.brand:focus-visible,
.run-details summary:focus-visible {
  outline: 3px solid rgba(54, 124, 145, 0.35);
  outline-offset: 2px;
}

.story-art {
  position: relative;
  width: 100%;
  max-width: 820px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  margin: 32px auto 40px;
  border-radius: var(--radius);
  background: #183f43;
}

.story-art img,
.story-art canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-art img[hidden],
.story-art canvas[hidden] {
  display: none;
}

.story-art figcaption {
  position: absolute;
  right: 12px;
  bottom: 12px;
  max-width: calc(100% - 24px);
  padding: 5px 8px;
  border-radius: 4px;
  background: rgba(23, 36, 33, 0.84);
  color: #fff;
  font-size: 0.7rem;
  line-height: 1.35;
}

.story-body {
  max-width: 680px;
  min-height: 300px;
  margin: 0 auto;
  color: #25312e;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.13rem;
  line-height: 1.86;
}

.story-body p {
  margin-bottom: 1.35em;
}

.story-body p:first-child::first-letter {
  float: left;
  margin: 0.1em 0.1em 0 0;
  color: var(--coral-dark);
  font-size: 3.55em;
  font-weight: 700;
  line-height: 0.75;
}

.gentle-thought {
  display: flex;
  max-width: 680px;
  margin: 38px auto 0;
  padding: 19px 20px;
  border-top: 2px solid var(--sun);
  border-bottom: 1px solid var(--line);
  gap: 14px;
  background: #fbfcf7;
}

.gentle-thought[hidden] {
  display: none;
}

.gentle-thought > svg,
.gentle-thought > i {
  width: 21px;
  height: 21px;
  flex: 0 0 21px;
  margin-top: 3px;
  color: var(--coral-dark);
}

.gentle-thought span {
  color: var(--coral-dark);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.gentle-thought p {
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
}

.reader-rail {
  display: flex;
  min-width: 0;
  border-left: 1px solid var(--line);
  background: #f7f9f6;
  flex-direction: column;
}

.agent-panel,
.archive-panel {
  padding: 28px 24px;
}

.agent-panel {
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h2 {
  margin: 2px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.section-label {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.run-state {
  flex: 0 0 auto;
  padding: 4px 7px;
  border: 1px solid #91bda6;
  border-radius: 4px;
  background: #edf8f1;
  color: var(--success);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.run-state.is-error {
  border-color: #e3aaa4;
  background: #fff1ef;
  color: var(--error);
}

.agent-summary {
  margin: 15px 0 19px;
  color: #54605b;
  font-size: 0.84rem;
  line-height: 1.55;
}

.evidence-list,
.run-details dl {
  margin: 0;
}

.evidence-list > div {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  padding: 9px 0;
  border-top: 1px solid var(--line);
  align-items: start;
  gap: 10px;
}

.evidence-list dt {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
}

.evidence-list dt svg,
.evidence-list dt i {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  color: var(--forest-light);
}

.evidence-list dd {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 750;
  text-align: right;
  overflow-wrap: anywhere;
}

.run-details {
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.run-details summary {
  padding: 12px 0 4px;
  color: var(--forest-light);
  font-size: 0.75rem;
  font-weight: 750;
  cursor: pointer;
}

.run-details dl > div {
  display: flex;
  padding-top: 7px;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.7rem;
}

.run-details dt {
  color: var(--muted);
}

.run-details dd {
  min-width: 0;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 650;
  text-align: right;
  overflow-wrap: anywhere;
}

.archive-panel {
  flex: 1 1 auto;
}

.section-heading--archive {
  align-items: center;
  margin-bottom: 16px;
}

.archive-count {
  display: grid;
  min-width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  place-items: center;
}

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

.archive-item__button {
  display: grid;
  width: 100%;
  min-height: 76px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.archive-item__button:hover {
  border-color: var(--coral);
  background: #fff8f5;
}

.archive-item__button[aria-current="true"] {
  border-color: var(--forest-light);
  background: #eff7f4;
}

.archive-date {
  display: grid;
  width: 42px;
  height: 50px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f8eee9;
  color: var(--coral-dark);
  place-content: center;
  text-align: center;
}

.archive-date strong,
.archive-date span {
  display: block;
  line-height: 1;
}

.archive-date strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.22rem;
}

.archive-date span {
  margin-top: 4px;
  font-size: 0.58rem;
  font-weight: 850;
  text-transform: uppercase;
}

.archive-item__copy {
  min-width: 0;
}

.archive-item__copy strong,
.archive-item__copy small {
  display: block;
}

.archive-item__copy strong {
  display: -webkit-box;
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.89rem;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.archive-item__copy small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.2;
}

.archive-empty {
  padding: 20px 4px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.sync-row {
  display: flex;
  min-height: 58px;
  padding: 9px 18px 9px 24px;
  border-top: 1px solid var(--line);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.68rem;
}

.icon-button--quiet {
  width: 34px;
  height: 34px;
  border-color: transparent;
  background: transparent;
}

.icon-button--quiet.is-spinning svg {
  animation: spin 800ms linear infinite;
}

.empty-state {
  max-width: 520px;
  margin: 70px auto;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
}

.empty-state > svg {
  width: 34px;
  height: 34px;
  color: var(--coral);
}

.empty-state h2 {
  margin: 12px 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
}

.empty-state p {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.88rem;
}

.text-button {
  display: inline-flex;
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid var(--forest);
  border-radius: 6px;
  background: var(--forest);
  color: #fff;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 750;
  cursor: pointer;
}

.text-button svg,
.text-button i {
  width: 16px;
  height: 16px;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 11px 14px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

.loading-line {
  color: transparent !important;
  border-radius: 4px;
  background: #e7ebe7;
  animation: breathe 1.25s ease-in-out infinite alternate;
}

.loading-line--title {
  width: min(620px, 92%);
  min-height: 58px;
}

.story-dek.loading-line {
  width: min(560px, 84%);
  min-height: 30px;
}

.reading-placeholder {
  display: grid;
  gap: 13px;
}

.reading-placeholder span {
  display: block;
  height: 15px;
  border-radius: 3px;
  background: #e7ebe7;
  animation: breathe 1.25s ease-in-out infinite alternate;
}

.reading-placeholder span:nth-child(2),
.reading-placeholder span:nth-child(5) {
  width: 88%;
}

.reading-placeholder span:nth-child(3) {
  width: 72%;
}

.archive-placeholder {
  height: 76px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #e9ede9;
  animation: breathe 1.25s ease-in-out infinite alternate;
}

@keyframes breathe {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 920px) {
  .page-shell {
    padding: 22px 18px 38px;
  }

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

  .reader-rail {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

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

  .sync-row {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .site-header__inner {
    min-height: 64px;
    padding: 9px 16px;
  }

  .brand small {
    display: none;
  }

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

  .brand__mark {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .service-state {
    max-width: 130px;
    font-size: 0.67rem;
    line-height: 1.25;
  }

  .page-shell {
    padding: 0;
  }

  .reader-layout {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .story-reader {
    padding: 31px 18px 44px;
  }

  #storyTitle {
    font-size: 2.25rem;
  }

  .story-dek {
    font-size: 1rem;
  }

  .story-toolbar {
    align-items: flex-end;
  }

  .story-meta {
    display: grid;
    gap: 5px;
  }

  .story-art {
    aspect-ratio: 4 / 3;
    margin: 25px auto 31px;
  }

  .story-body {
    font-size: 1.06rem;
    line-height: 1.78;
  }

  .agent-panel,
  .archive-panel {
    padding: 25px 18px;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  body {
    background: #fff;
  }

  .site-header,
  .reader-rail,
  .story-toolbar,
  .toast,
  .skip-link {
    display: none !important;
  }

  .page-shell,
  .story-reader {
    max-width: none;
    padding: 0;
  }

  .reader-layout {
    display: block;
    border: 0;
    box-shadow: none;
  }

  .story-art {
    max-height: 340px;
    break-inside: avoid;
  }

  .story-body {
    font-size: 12pt;
  }
}
