:root {
  --bg: #ebe6df;
  --ink: #28222e;
  --teal: #543b6c;
  --muted: #61586a;
  --line: #dcd3ce;
  --soft: #ebe4f2;
  --white: #fffdf8;
  --rose: #9b493d;
  --paper: #fbf8f1;
  --accent: #614286;
  --deep: #231b2d;
  --rule: #ddd5cf;
  --roman: Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, Consolas, monospace;
}

body { background: var(--bg); color: var(--ink); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid #835ba8; outline-offset: 3px; }
.journal-header { border-bottom: 1px solid #dcd3cd; background: #f7f3eb; }
.journal-masthead, .journal-shell { width: min(1270px, calc(100% - 64px)); margin-inline: auto; }
.journal-masthead { min-height: 66px; display: flex; align-items: center; gap: 17px; }
.journal-logo { display: inline-flex; align-items: center; gap: 8px; font: 700 26px/1 var(--roman); letter-spacing: -.07em; color: var(--deep); text-decoration: none; }
.journal-logo svg { width: 27px; height: 27px; fill: #654689; }
.journal-logo svg circle { fill: #f7f3eb; }
.journal-product { padding-left: 17px; border-left: 1px solid var(--rule); color: var(--muted); font-size: 12px; }
.journal-utility { margin-left: auto; }
.journal-utility, .journal-action, .journal-next {
  min-height: 42px;
  border: 0;
  padding: 5px 0;
  color: var(--deep);
  background: transparent;
  font-weight: 750;
  font-size: 13px;
  text-align: left;
}
.journal-utility span, .journal-action span, .journal-next span { color: var(--accent); margin-left: 4px; }
.journal-utility:hover, .journal-action:hover, .journal-next:hover { text-decoration: underline; text-underline-offset: 4px; }

.edition { display: grid; grid-template-columns: minmax(0, .86fr) minmax(0, 1.14fr); margin-top: 26px; background: var(--paper); border: 1px solid #d7cfc8; box-shadow: 0 14px 34px #34263714; }
.journal-cover { min-height: 620px; position: relative; isolation: isolate; overflow: hidden; background: #241b2d; color: #fff5e9; }
.journal-portrait { position: absolute; width: 100%; height: 100%; object-fit: cover; object-position: 50% 52%; z-index: -2; }
.journal-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, #241a2eed 0%, #241a2e38 38%, transparent 55%, #201725ad 100%);
}
.journal-cover-heading { padding: clamp(29px, 3.6vw, 54px); }
.journal-edition { display: inline-flex; align-items: center; gap: 9px; color: #efdfef; font: 700 10px/1.4 var(--mono); letter-spacing: .17em; }
.journal-edition span { color: #bf9bdc; }
.journal-cover h1 {
  margin: 17px 0 0;
  font: 700 clamp(35px, 4.3vw, 62px)/1.13 'Malgun Gothic', system-ui, sans-serif;
  letter-spacing: -.093em;
  color: #fff8ec;
  word-break: keep-all;
}
.journal-cover-caption {
  position: absolute; inset: auto clamp(22px, 3.6vw, 54px) 24px;
  display: flex; justify-content: space-between; gap: 10px;
  padding-top: 12px; border-top: 1px solid #fff6e96a; font-size: 11px; font-weight: 650; color: #fff5eb;
}
.journal-cover-caption span:last-child { font-family: var(--mono); white-space: nowrap; }

.journal-page { min-width: 0; display: flex; flex-direction: column; padding: clamp(24px, 3.1vw, 46px) clamp(24px, 4vw, 62px) 20px; }
.journal-page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.journal-section-label { margin: 0; display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .04em; }
.journal-section-label > span { display: inline-block; width: 7px; height: 7px; background: #9a79b5; transform: rotate(45deg); }
.ai-pets { display: flex; align-items: center; gap: 7px; }
.ai-pet {
  display: inline-flex; align-items: center; gap: 5px; min-height: 40px; padding: 5px 8px;
  background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13px; font-weight: 750;
}
.ai-pet[aria-pressed="true"] { color: var(--deep); border-color: var(--accent); }
.pet-ink { width: 7px; height: 7px; border-radius: 50%; background: #a45c3b; }
.pet-ink.luna { background: #776199; }

.ai-result { flex: 1; min-width: 0; min-height: 326px; padding: clamp(24px, 3.1vw, 43px) 0 18px; scroll-margin-top: 14px; }
.ai-result:focus { outline: none; }
.ai-result > :first-child { margin-top: 0; }
.ai-kicker { margin: 0 0 8px; color: var(--accent); font-weight: 800; font-size: 12px; }
.ai-result-title { margin: 0 0 18px; color: var(--deep); font-size: clamp(23px, 2.8vw, 38px); line-height: 1.23; letter-spacing: -.075em; word-break: keep-all; }
.journal-wait, .ai-action-line { margin: 10px 0; color: var(--muted); font-size: 13px; line-height: 1.55; word-break: keep-all; }
.action-note { margin: 14px 0 7px; border-left: 2px solid #9b7cb6; padding-left: 10px; color: #494050; }
.is-urgent .ai-kicker, .is-urgent .action-note { color: #903a2d; }
.is-urgent .action-note { border-color: #bd7767; font-weight: 750; }
.journal-data { display: grid; grid-template-columns: auto minmax(78px, 1fr); gap: clamp(12px, 2vw, 28px); align-items: end; }
.ai-compare { display: flex; align-items: flex-end; gap: clamp(8px, 1.3vw, 20px); }
.ai-compare div { display: grid; gap: 4px; }
.ai-compare div span { white-space: nowrap; color: var(--muted); font-size: 11px; font-weight: 700; }
.ai-compare strong { color: #42334b; font: 700 clamp(37px, 5vw, 67px)/.92 var(--roman); letter-spacing: -.08em; font-variant-numeric: lining-nums tabular-nums; }
.ai-compare div:last-child strong { color: var(--accent); }
.is-urgent .ai-compare div:last-child strong { color: #903a2d; }
.ai-arrow { font: 400 clamp(14px, 2vw, 23px)/1.25 system-ui; color: #8b738e; padding-bottom: 3px; }
.journal-trend { margin: 0; min-width: 0; justify-self: end; text-align: right; width: min(100%, 220px); }
.journal-trend svg { width: 100%; display: block; max-height: 74px; }
.journal-trend figcaption { color: var(--muted); font-size: 10px; }
.trend-axis { stroke: #ded4e3; }
.trend-line { fill: none; stroke: #8564a8; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.trend-fill { fill: #eadff0; }
.trend-point { fill: var(--accent); stroke: var(--paper); stroke-width: 2; }
.is-urgent .trend-line { stroke: #a15545; }
.is-urgent .trend-fill { fill: #f0dfd8; }
.is-urgent .trend-point { fill: #903a2d; }

.ai-links, .ai-baseline-list { display: flex; align-items: baseline; gap: 7px 15px; flex-wrap: wrap; }
.ai-source, .ai-baseline summary {
  display: inline-flex; align-items: center; min-height: 38px; padding: 4px 0; border: 0;
  color: var(--accent); background: transparent; font-size: 12px; font-weight: 750; line-height: 1.4; text-align: left;
  text-decoration: underline; text-underline-offset: 4px; text-decoration-color: #b09cbe;
}
.ai-source:hover, .ai-baseline summary:hover { color: var(--deep); text-decoration-color: var(--deep); }
.ai-baseline summary { display: list-item; list-style-position: inside; cursor: pointer; padding-block: 10px; }
.ai-baseline[open] { flex-basis: 100%; }
.ai-baseline-list { gap: 2px 13px; }
.ai-baseline-list button { min-height: 33px; }
.ai-result > a.ai-source { margin-right: 12px; min-height: 32px; }
.ai-document { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: stretch; gap: 16px; border-block: 1px solid #d7c9dc; background: #f3ebf4; padding: 16px; }
.document-date { min-width: 105px; display: grid; align-content: center; gap: 3px; padding-right: 15px; border-right: 1px solid #d9cbe0; color: #554068; }
.document-date strong { font: 700 clamp(32px, 4vw, 53px)/1 var(--roman); letter-spacing: -.075em; }
.document-date span, .document-code { font: 700 11px/1.4 var(--mono); letter-spacing: .08em; color: var(--accent); }
.document-note { min-width: 0; }
.document-note p { margin: 6px 0 1px; font-size: 13px; line-height: 1.55; word-break: keep-all; }
.ai-timeline, .ai-flow { margin: 0; padding: 0; list-style: none; border-bottom: 1px solid var(--rule); }
.ai-timeline li, .ai-flow > div {
  display: grid; align-items: center; gap: 10px; padding: 4px 0;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 43px; border-top: 1px solid var(--rule);
}
.ai-timeline li strong, .ai-flow strong { font-size: 13px; word-break: keep-all; }
.ai-timeline li strong::before { content: ''; display: inline-block; width: 7px; height: 7px; border: 1px solid #9877ac; border-radius: 50%; margin: 0 9px 1px 1px; background: #9877ac; }
.ai-timeline li.ai-observation strong::before { background: transparent; }
.ai-timeline li:last-child strong { color: var(--accent); }
.ai-flow > div { grid-template-columns: 102px minmax(0, 1fr) auto; }
.ai-flow span { color: var(--muted); font-size: 11px; font-weight: 700; }
.ai-flow strong { padding-block: 4px; }
.ai-timeline .ai-source, .ai-flow .ai-source { min-height: 36px; }

.journal-reading { border-top: 1px solid var(--rule); }
.journal-reading-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-block: 4px; }
.journal-page-number { font: 700 12px/1.2 var(--mono); color: var(--muted); letter-spacing: .11em; }
.journal-next { min-height: 40px; }
.journal-chapters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.journal-chapters button {
  display: flex; align-items: baseline; justify-content: flex-start; gap: 7px; min-height: 47px; min-width: 0;
  border: 0; border-top: 2px solid var(--rule); padding: 8px 0 5px; background: transparent;
  color: var(--muted); text-align: left; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.journal-chapters button span { font: 700 10px/1.4 var(--mono); }
.journal-chapters button[aria-pressed="true"] { border-color: var(--accent); color: var(--deep); font-weight: 850; }
.journal-chapters button[aria-pressed="true"] span { color: var(--accent); }
.journal-actions { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--rule); padding: 2px 0 0; margin: 0; }
.journal-site-footer { margin-top: 0; padding: 13px 0 18px; font-size: 11px; color: var(--muted); }

.workbench-heading { padding: 24px 0 16px; }
.workbench-heading p { margin: 7px 0 0; color: var(--deep); font-size: clamp(24px, 4vw, 42px); font-weight: 800; letter-spacing: -.065em; }
.app-navigation { background: var(--bg); border-radius: 0; }
.main-nav, .board, .sidebar { background: var(--paper); border-color: var(--rule); border-radius: 2px; }
.group-tab { border-radius: 2px; }
.group-tab.current, .subnav .tab.current, .pet[aria-pressed="true"], .pet:hover { background: #eee6f0; border-color: #d9c8df; color: #51396a; }
.primary, .secondary { border-radius: 3px; }
.primary:hover { background: #49325f; }
.section-kicker, .source-open, .evidence-link, .scope-label { color: var(--accent); }
.scope-label { background: #eee5f2; }
dialog { border: 1px solid #cfbfcc; background: var(--paper); color: var(--ink); border-radius: 4px; }
dialog::backdrop { background: #271a31a5; }
#doc-body { border-radius: 0; border-left: 2px solid #c2a9cf; background: #f1eaf3; }

@media (max-width: 960px) {
  .journal-masthead, .journal-shell { width: calc(100% - 36px); }
  .journal-page { padding-inline: 24px; }
  .journal-cover { min-height: 560px; }
  .journal-chapters { gap: 7px; }
  .journal-chapters button { gap: 4px; }
}
@media (max-width: 700px) {
  .journal-masthead, .journal-shell { width: calc(100% - 24px); }
  .journal-masthead { min-height: 54px; gap: 10px; }
  .journal-logo { font-size: 23px; }
  .journal-logo svg { width: 22px; height: 22px; }
  .journal-product { padding-left: 9px; font-size: 10px; }
  .journal-utility { font-size: 11px; }
  .edition { display: block; margin-top: 12px; }
  .journal-cover { min-height: 196px; }
  .journal-portrait { width: 62%; right: 0; object-position: center 53%; }
  .journal-cover::after { background: linear-gradient(90deg, #241a2e 36%, #241a2e18 72%), linear-gradient(0deg, #1c1324b0, transparent 34%); }
  .journal-cover-heading { padding: 24px 18px; }
  .journal-edition { font-size: 8px; }
  .journal-cover h1 { margin-top: 10px; font-size: clamp(29px, 7vw, 43px); }
  .journal-cover-caption { inset: auto 18px 12px; padding-top: 6px; font-size: 9px; }
  .journal-page { padding: 10px 17px 6px; }
  .journal-page-head { padding-bottom: 4px; }
  .ai-pet { min-height: 40px; font-size: 12px; }
  .ai-result { min-height: 234px; padding: 20px 0 14px; }
  .ai-result-title { margin-bottom: 13px; font-size: clamp(23px, 5.6vw, 34px); }
  .ai-compare strong { font-size: clamp(32px, 8.5vw, 51px); }
  .ai-source, .ai-baseline summary { min-height: 40px; font-size: 11px; }
  .ai-flow > div { grid-template-columns: 72px minmax(0, 1fr) auto; gap: 7px; }
  .journal-chapters button { font-size: 11px; min-height: 43px; }
  .journal-chapters button span { font-size: 9px; }
  .journal-site-footer { flex-wrap: wrap; gap: 3px 10px; padding-top: 11px; }
}
@media (max-width: 350px) {
  .journal-product { display: none; }
  .journal-cover { min-height: 178px; }
  .journal-chapters button { display: grid; align-content: start; gap: 2px; min-height: 50px; }
  .journal-page { padding-inline: 13px; }
  .ai-compare div span { font-size: 10px; }
}
@media print {
  .journal-header, .edition, .workbench-heading, .journal-site-footer { display: none !important; }
}

#workbench .main-nav .group-tab { color: var(--muted); border-radius: 2px; }
#workbench .main-nav .group-tab.current { color: #4e3666; background: #ece2ee; border-color: #dbccdf; }
#workbench .subnav .tab { border-radius: 2px; }
#workbench .primary { color: #fff; background: #573e6d; border-color: #573e6d; }
#workbench .primary:hover { background: #422d54; border-color: #422d54; }
#workbench .shop-summary { background: #eee5ef; border-radius: 2px; }
#workbench .product-card { background: transparent; border-radius: 2px; border-color: var(--rule); }
#workbench .product-card img, #workbench .shop-hero { border-radius: 2px; }
#workbench .product-card h3 { font-size: 16px; }
#workbench .pet-selected { color: #563a69; background: #e9dbed; }

@media (min-width: 961px) {
  #workbench { display: grid; grid-template-columns: 185px minmax(0, 1fr); gap: 0 23px; align-items: start; }
  .workbench-heading { grid-column: 1 / -1; }
  #workbench .app-navigation { top: 14px; margin: 0; padding: 0; }
  #workbench .main-nav { grid-template-columns: 1fr; padding: 0; border: 0; background: transparent; gap: 0; }
  #workbench .main-nav .group-tab { justify-content: flex-start; padding-inline: 12px; min-height: 51px; border-bottom: 1px solid #d9d0cb; }
  #workbench .subnav { display: grid; gap: 2px; padding: 8px 0; }
  #workbench .subnav .tab { justify-self: stretch; text-align: left; padding: 7px 12px 7px 34px; }
  #workbench .workspace { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  #workbench .sidebar { display: flex; align-items: center; gap: 15px; padding: 8px 16px; }
  #workbench .sidebar h2 { margin: 0; flex-shrink: 0; }
  #workbench .pets { display: flex; gap: 6px; }
  #workbench .pets .pet { min-width: 138px; }
  #workbench .shop-summary { top: 0; }
}

@media print {
  #workbench { display: block; }
}
