:root {
  --ink: #090909;
  --ink-soft: #292929;
  --paper: #f3efe4;
  --paper-deep: #ded7c8;
  --paper-light: #fffdf6;
  --rust: #e11b22;
  --rust-bright: #ff3138;
  --brass: #f4c430;
  --line: rgba(9, 9, 9, 0.28);
  --shadow: 12px 12px 0 rgba(9, 9, 9, 0.16);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(9, 9, 9, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(9, 9, 9, .035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: "DM Sans", system-ui, sans-serif;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .3;
  background-image: radial-gradient(rgba(49, 39, 27, .1) .5px, transparent .5px);
  background-size: 5px 5px;
}
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }

.site-header {
  min-height: 78px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 28px;
  padding: 14px clamp(22px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 5;
}
.brand { display: inline-flex; align-items: center; gap: 12px; width: max-content; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  color: var(--paper-light); background: var(--rust); font: 600 24px/1 "Noto Serif JP", serif;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}
.brand b { display: block; letter-spacing: .2em; font-size: 14px; }
.brand small { display: block; color: #777064; font: 500 10px/1.4 "DM Sans"; letter-spacing: .06em; }
nav { display: flex; align-items: center; gap: 30px; color: #6b6459; font-size: 13px; }
nav a { padding: 10px 0; position: relative; }
nav a.active { color: var(--ink); font-weight: 600; }
nav a.active::after { content: ""; position: absolute; height: 2px; left: 0; right: 0; bottom: 3px; background: var(--rust); }
.agent-launch { justify-self: end; border: 0; color: var(--paper-light); background: var(--ink); padding: 12px 16px; cursor: pointer; }
.agent-launch span { color: #d7b878; margin-left: 12px; }

.identify-shell {
  min-height: calc(100vh - 78px);
  display: grid;
  grid-template-columns: minmax(260px, .82fr) minmax(410px, 1.18fr);
  gap: clamp(40px, 7vw, 118px);
  align-items: center;
  padding: clamp(54px, 8vw, 105px) clamp(22px, 7vw, 112px) 105px;
  position: relative;
  overflow: hidden;
}
.identify-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  opacity: .16;
  background: repeating-conic-gradient(from -18deg at 17% 52%, transparent 0 4deg, #000 4.4deg 4.8deg);
  mask-image: linear-gradient(90deg, #000, transparent 52%);
}
.identify-shell::after {
  content: "鑑定";
  position: absolute;
  z-index: -1;
  right: -42px;
  top: 4%;
  color: rgba(225, 27, 34, .08);
  font: 900 min(33vw, 470px)/.82 "Noto Sans JP", sans-serif;
  writing-mode: vertical-rl;
}
.intro { align-self: center; max-width: 610px; }
.eyebrow { color: #766c5e; text-transform: uppercase; letter-spacing: .16em; font-size: 11px; font-weight: 600; }
.eyebrow span { display: inline-block; width: 30px; height: 1px; background: var(--rust); vertical-align: middle; margin: 0 10px 3px 0; }
h1 { margin: 22px 0 16px; font: 400 clamp(68px, 8.7vw, 132px)/.78 "Bebas Neue", Impact, sans-serif; letter-spacing: -.025em; text-transform: uppercase; transform: skewY(-2deg); text-shadow: 4px 4px 0 rgba(225,27,34,.14); }
h1 em { color: var(--rust); font-style: normal; }
.impact-callout { display: inline-flex; gap: 8px; margin: 0 0 18px; padding: 7px 10px 5px; color: var(--paper-light); background: var(--ink); font: 400 18px/1 "Bebas Neue", Impact, sans-serif; letter-spacing: .08em; transform: rotate(-2deg); box-shadow: 5px 5px 0 var(--rust); }
.impact-callout span { color: var(--brass); }
.lede { max-width: 550px; color: #5f584e; font: 400 16px/1.72 "DM Sans"; }
.trust-row { margin-top: 28px; display: flex; gap: 24px; flex-wrap: wrap; color: #625b51; font-size: 12px; }

.workspace { background: rgba(255,253,246,.94); border: 3px solid var(--ink); box-shadow: var(--shadow); padding: 24px; backdrop-filter: blur(8px); transform: rotate(.35deg); }
.workspace-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 15px; padding-bottom: 20px; }
.step { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--rust); color: var(--rust); font-size: 12px; }
.workspace-head p { margin: 0 0 3px; color: #81776a; text-transform: uppercase; letter-spacing: .13em; font-size: 9px; }
.workspace-head h2 { margin: 0; font: 600 19px/1.2 "Noto Serif JP", serif; }
.tip-button { border: 0; border-bottom: 1px solid #938673; background: none; color: #5f584e; padding: 4px 0; font-size: 11px; cursor: pointer; }
.drop-zone { min-height: 310px; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; border: 1px dashed #9c8e79; background: rgba(234,225,208,.42); cursor: pointer; transition: background .2s, border-color .2s, transform .2s; }
.drop-zone:hover { background: rgba(232,218,195,.75); border-color: var(--rust); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
#photo-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #1b1915; display: none; }
.drop-zone.has-photo #photo-preview { display: block; }
.drop-zone.has-photo .camera-icon,
.drop-zone.has-photo #drop-title,
.drop-zone.has-photo #drop-subtitle { display: none; }
.drop-zone.has-photo .choose-button { position: absolute; right: 18px; bottom: 18px; z-index: 2; box-shadow: 0 4px 15px rgba(0,0,0,.24); }
.drop-zone.dragging { border-color: var(--rust); background: #eadcc4; transform: scale(.995); }
.camera-icon { width: 50px; height: 50px; display: grid; place-items: center; border: 1px solid #a2947e; color: var(--rust); font-size: 28px; margin-bottom: 17px; transform: rotate(-6deg); }
.drop-zone strong { font: 600 17px/1.4 "Noto Serif JP", serif; }
.drop-zone > span:not(.scan-corner):not(.camera-icon):not(.choose-button) { margin-top: 4px; color: #887d6d; font-size: 11px; }
.choose-button { margin-top: 21px; padding: 10px 18px; background: var(--rust); color: white; font-size: 11px; letter-spacing: .04em; }
.scan-corner { position: absolute; width: 27px; height: 27px; border-color: var(--rust); }
.top-left { top: 13px; left: 13px; border-top: 1px solid; border-left: 1px solid; }
.top-right { top: 13px; right: 13px; border-top: 1px solid; border-right: 1px solid; }
.bottom-left { bottom: 13px; left: 13px; border-bottom: 1px solid; border-left: 1px solid; }
.bottom-right { bottom: 13px; right: 13px; border-bottom: 1px solid; border-right: 1px solid; }
.workspace-foot { display: flex; justify-content: space-between; gap: 20px; align-items: center; padding-top: 17px; color: #7a7165; font-size: 10px; }
.workspace-foot p { margin: 0; }
.workspace-foot b { color: var(--ink-soft); }
.workspace-foot > span { white-space: nowrap; }

.sample-match { position: absolute; right: 4vw; bottom: 24px; width: 228px; background: var(--ink); color: var(--paper-light); padding: 14px 16px; box-shadow: 0 18px 34px rgba(25,21,16,.18); transform: rotate(-1deg); }
.sample-top, .sample-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 8px; text-transform: uppercase; letter-spacing: .08em; color: #bdb4a5; }
.sample-top b { color: #dfbc79; font-weight: 500; }
.sample-kanji { margin-top: 12px; font: 600 27px/1 "Noto Serif JP", serif; letter-spacing: .18em; }
.romaji { margin: 8px 0 13px; color: #dfbc79; font-size: 9px; letter-spacing: .16em; }
.sample-meta { border-top: 1px solid rgba(255,255,255,.14); padding-top: 10px; }

@media (max-width: 920px) {
  .site-header { grid-template-columns: 1fr auto; }
  nav { display: none; }
  .identify-shell { grid-template-columns: 1fr; align-items: start; padding-top: 55px; }
  .intro { max-width: 680px; }
  .workspace { max-width: 720px; width: 100%; }
  .sample-match { display: none; }
}
@media (max-width: 560px) {
  .site-header { padding-inline: 16px; }
  .agent-launch { padding: 11px 12px; font-size: 11px; }
  .brand small { display: none; }
  .identify-shell { padding-inline: 16px; padding-bottom: 55px; gap: 34px; }
  h1 { font-size: clamp(44px, 15vw, 62px); }
  .workspace { padding: 16px; }
  .workspace-head { grid-template-columns: auto 1fr; }
  .tip-button { display: none; }
  .drop-zone { min-height: 275px; }
  .workspace-foot { align-items: flex-start; }
  .workspace-foot > span { display: none; }
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.primary-button, .secondary-button { border: 0; padding: 13px 18px; cursor: pointer; transition: transform .18s, background .18s; }
.primary-button { background: var(--rust); color: #fff; }
.primary-button:hover { background: #852a18; transform: translateY(-1px); }
.primary-button span { margin-left: 16px; }
.secondary-button { border: 1px solid var(--line); color: #5e5548; background: transparent; }
.secondary-button:hover { border-color: #7b6d5b; }

.analysis-panel { position: relative; padding: 105px clamp(22px, 7vw, 112px); background: var(--paper-light); border-top: 1px solid var(--line); }
.section-number { position: absolute; top: 24px; left: clamp(22px, 3vw, 48px); writing-mode: vertical-rl; color: #978c7c; letter-spacing: .15em; font-size: 9px; }
.analysis-grid { display: grid; grid-template-columns: .78fr 1.22fr; align-items: start; gap: clamp(50px, 8vw, 130px); max-width: 1300px; margin: auto; }
.analysis-copy h2, .atlas-heading h2, .method-intro h2, .field-guide h2, .sources-section h2 { margin: 14px 0 20px; font: 600 clamp(35px, 4.3vw, 61px)/1.04 "Noto Serif JP", serif; letter-spacing: -.035em; }
.analysis-copy > p:last-of-type, .atlas-heading > p, .method-intro > p, .field-guide > div > p, .sources-section > p { color: #655d52; line-height: 1.72; }
.ocr-status { margin-top: 28px; display: flex; align-items: center; gap: 13px; border-top: 1px solid var(--line); padding-top: 18px; }
.status-dot { width: 10px; height: 10px; background: #b7aa96; border-radius: 50%; box-shadow: 0 0 0 5px rgba(133,111,80,.09); }
.ocr-status.working .status-dot { background: var(--brass); animation: pulse 1.2s infinite; }
.ocr-status.done .status-dot { background: #46755b; }
.ocr-status.error .status-dot { background: var(--rust); }
.ocr-status b, .ocr-status small { display: block; }
.ocr-status b { font-size: 12px; }
.ocr-status small { margin-top: 3px; color: #81776a; font-size: 10px; }
@keyframes pulse { 50% { opacity: .4; transform: scale(.78); } }

.transcription-card { background: var(--paper); border: 1px solid var(--line); padding: clamp(22px, 3vw, 38px); box-shadow: 0 22px 50px rgba(56,42,27,.09); }
.transcription-card > label, .field-row label { color: #756b5d; text-transform: uppercase; letter-spacing: .11em; font-size: 9px; font-weight: 600; }
.transcription-card textarea { width: 100%; margin: 10px 0 20px; resize: vertical; min-height: 110px; border: 1px solid #b8aa95; background: rgba(255,255,255,.4); padding: 18px; color: var(--ink); font: 600 30px/1.5 "Noto Serif JP", serif; outline: none; }
.transcription-card textarea:focus, select:focus, .atlas-search:focus-within, .agent-form:focus-within { border-color: var(--rust); box-shadow: 0 0 0 3px rgba(159,55,31,.1); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field-row label { display: grid; gap: 8px; }
select { width: 100%; appearance: none; border: 1px solid #b8aa95; border-radius: 0; background: rgba(255,255,255,.42); padding: 12px 34px 12px 12px; color: var(--ink-soft); outline: none; background-image: linear-gradient(45deg,transparent 50%,#746b5e 50%),linear-gradient(135deg,#746b5e 50%,transparent 50%); background-position: calc(100% - 16px) 50%,calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; text-transform: none; letter-spacing: 0; font-size: 12px; }
.form-actions { margin-top: 25px; display: flex; justify-content: space-between; gap: 12px; }

.results-shell { display: none; max-width: 1300px; margin: 72px auto 0; }
.results-shell.visible { display: block; animation: reveal .35s ease both; }
@keyframes reveal { from { opacity: 0; transform: translateY(12px); } }
.results-head { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 18px; }
.results-head span { color: #8e8373; text-transform: uppercase; letter-spacing: .14em; font-size: 9px; }
.results-head h3 { margin: 6px 0 0; font: 600 27px/1.2 "Noto Serif JP", serif; }
.results-head > p { max-width: 370px; margin: 0; color: #776d5f; text-align: right; font-size: 11px; line-height: 1.5; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.result-card { position: relative; background: var(--paper); border: 1px solid var(--line); padding: 22px; overflow: hidden; }
.result-card:first-child { background: var(--ink); color: var(--paper-light); }
.rank { position: absolute; top: 15px; right: 17px; color: #918675; font: 600 9px/1 "DM Sans"; letter-spacing: .1em; }
.result-card:first-child .rank { color: #b8ac9c; }
.confidence { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; color: #776e61; text-transform: uppercase; letter-spacing: .12em; font-size: 8px; }
.result-card:first-child .confidence { color: #c2b8aa; }
.confidence b { color: var(--rust); font-size: 9px; }
.result-card:first-child .confidence b { color: #e6bf75; }
.result-kanji { font: 600 clamp(25px,3vw,36px)/1.2 "Noto Serif JP", serif; letter-spacing: .08em; }
.result-name { margin: 7px 0 19px; color: var(--rust); font-size: 10px; letter-spacing: .13em; text-transform: uppercase; }
.result-card:first-child .result-name { color: #e0b66a; }
.result-card dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 13px; padding: 15px 0; margin: 0 0 16px; border-top: 1px solid currentColor; border-bottom: 1px solid currentColor; border-color: rgba(117,104,84,.22); font-size: 10px; }
.result-card dt { color: #8a7f6f; }
.result-card dd { margin: 0; text-align: right; }
.result-reason { min-height: 52px; color: #675f54; font-size: 11px; line-height: 1.55; }
.result-card:first-child .result-reason { color: #c7beb0; }
.source-link { display: inline-flex; margin-top: 15px; color: var(--rust); border-bottom: 1px solid currentColor; font-size: 10px; }
.result-card:first-child .source-link { color: #e2ba72; }
.result-note { margin-top: 14px; padding: 13px 16px; background: #ebe3d6; color: #71685c; font-size: 10px; line-height: 1.5; }

.atlas-section { padding: 110px clamp(22px, 7vw, 112px); background: var(--ink); color: var(--paper-light); }
.atlas-heading { display: grid; grid-template-columns: 1fr minmax(280px, 450px); gap: 50px; align-items: end; max-width: 1300px; margin: auto; }
.atlas-heading h2 { margin-bottom: 0; }
.atlas-heading > p { color: #bbb1a1; margin: 0; }
.eyebrow.light { color: #aaa091; }
.atlas-toolbar { max-width: 1300px; margin: 42px auto 28px; padding: 16px 0; border-top: 1px solid rgba(255,255,255,.13); border-bottom: 1px solid rgba(255,255,255,.13); display: flex; justify-content: space-between; gap: 24px; align-items: center; }
.filters { display: flex; flex-wrap: wrap; gap: 5px; }
.filter { border: 0; background: transparent; color: #a99f91; padding: 8px 11px; cursor: pointer; font-size: 11px; }
.filter.active { background: var(--paper); color: var(--ink); }
.filter span { margin-left: 5px; opacity: .55; }
.atlas-search { width: min(280px,100%); display: flex; align-items: center; gap: 8px; border: 1px solid rgba(255,255,255,.2); padding: 9px 11px; color: #a99f91; }
.atlas-search input { width: 100%; border: 0; outline: none; background: none; color: white; font-size: 11px; }
.atlas-search input::placeholder { color: #81786c; }
.atlas-grid { max-width: 1300px; margin: auto; display: grid; grid-template-columns: repeat(3,1fr); border-top: 1px solid rgba(255,255,255,.12); border-left: 1px solid rgba(255,255,255,.12); }
.atlas-card { min-height: 246px; position: relative; padding: 22px; border-right: 1px solid rgba(255,255,255,.12); border-bottom: 1px solid rgba(255,255,255,.12); transition: background .2s; }
.atlas-card:hover { background: rgba(255,255,255,.045); }
.atlas-card .card-index { position: absolute; right: 17px; top: 17px; color: #6f675d; font-size: 9px; }
.atlas-card .type-chip { display: inline-block; padding: 5px 7px; border: 1px solid rgba(255,255,255,.2); color: #b8aea0; font-size: 8px; text-transform: uppercase; letter-spacing: .11em; }
.atlas-card h3 { margin: 22px 0 4px; font: 600 28px/1.25 "Noto Serif JP", serif; letter-spacing: .08em; }
.atlas-card .atlas-name { color: #dfa55d; font-size: 9px; letter-spacing: .13em; text-transform: uppercase; }
.atlas-card .atlas-meta { display: flex; gap: 10px; margin: 15px 0; color: #8e8579; font-size: 9px; }
.atlas-card p { margin: 0; color: #bbb2a5; line-height: 1.48; font-size: 10px; }
.atlas-card a { position: absolute; left: 22px; bottom: 20px; color: #d7b574; border-bottom: 1px solid #7c6842; font-size: 9px; }
.atlas-empty { max-width: 1300px; margin: 35px auto 0; color: #aaa092; }

.method-section { padding: 115px clamp(22px, 7vw, 112px); display: grid; grid-template-columns: .8fr 1.2fr; gap: clamp(55px, 9vw, 145px); align-items: center; }
.method-intro { max-width: 540px; }
.text-link { padding: 9px 0; border: 0; border-bottom: 1px solid var(--rust); background: transparent; color: var(--rust); cursor: pointer; font-weight: 600; font-size: 11px; }
.text-link span { margin-left: 12px; }
.method-cards { border-top: 1px solid var(--line); }
.method-cards article { display: grid; grid-template-columns: 42px minmax(150px,.7fr) 1fr; gap: 20px; align-items: start; padding: 27px 0; border-bottom: 1px solid var(--line); }
.method-cards article > span { color: var(--rust); font-size: 10px; }
.method-cards h3 { margin: 0; font: 600 17px/1.35 "Noto Serif JP", serif; }
.method-cards p { margin: 0; color: #6d6458; font-size: 11px; line-height: 1.65; }
.method-cards p b { color: var(--ink); font: 600 15px/1 "Noto Serif JP", serif; }

.field-guide { display: grid; grid-template-columns: 1fr 1fr; min-height: 620px; background: #dfd4c2; }
.field-guide figure { position: relative; margin: 0; min-height: 500px; background: #27231d; overflow: hidden; }
.field-guide figure::after { content: ""; position: absolute; inset: 0; box-shadow: inset -60px 0 90px rgba(26,22,17,.2); }
.field-guide img { width: 100%; height: 100%; object-fit: cover; filter: saturate(.62) contrast(1.06); }
.field-guide figcaption { position: absolute; z-index: 2; left: 18px; bottom: 15px; padding: 7px 9px; background: rgba(20,18,15,.78); color: #d2cabd; font-size: 8px; }
.field-guide figcaption a { color: #ebc984; }
.field-guide > div { padding: clamp(60px, 8vw, 120px); align-self: center; }
.field-guide ul { padding: 0; margin: 28px 0 0; list-style: none; border-top: 1px solid rgba(58,49,38,.2); }
.field-guide li { display: grid; grid-template-columns: 75px 1fr; gap: 18px; padding: 14px 0; border-bottom: 1px solid rgba(58,49,38,.2); color: #61584d; font-size: 11px; }
.field-guide li span { color: var(--rust); text-transform: uppercase; letter-spacing: .1em; font-size: 9px; }

.sources-section { padding: 90px clamp(22px, 7vw, 112px); background: var(--paper-light); display: grid; grid-template-columns: .7fr 1fr; gap: 25px 80px; align-items: end; }
.sources-section h2 { font-size: clamp(34px,4vw,54px); margin-bottom: 0; }
.sources-section > p { margin: 0; max-width: 600px; }
.source-links { grid-column: 1/-1; margin-top: 28px; display: grid; grid-template-columns: repeat(3,1fr); border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
.source-links a { display: grid; gap: 7px; padding: 20px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.source-links b { font: 600 15px/1.2 "Noto Serif JP", serif; }
.source-links span { color: var(--rust); font-size: 9px; }

footer { padding: 27px clamp(22px,5vw,72px); background: #11100d; color: var(--paper-light); display: grid; grid-template-columns: 1fr auto 1fr; gap: 30px; align-items: center; }
.footer-brand .brand-mark { background: #8d2e1a; }
footer > p { color: #827a6f; font-size: 9px; }
footer > div { justify-self: end; display: flex; gap: 20px; color: #b6ada0; font-size: 10px; }

.agent-drawer { position: fixed; z-index: 50; top: 0; right: 0; width: min(430px,100%); height: 100vh; display: grid; grid-template-rows: auto auto 1fr auto auto auto; background: #f7f2e8; border-left: 1px solid var(--line); box-shadow: -24px 0 70px rgba(22,18,13,.22); transform: translateX(105%); transition: transform .28s ease; }
.agent-drawer.open { transform: none; }
.drawer-scrim { display: none; position: fixed; z-index: 49; inset: 0; background: rgba(20,17,13,.44); backdrop-filter: blur(2px); }
.drawer-scrim.open { display: block; }
.agent-head { display: flex; align-items: center; justify-content: space-between; padding: 19px 20px; border-bottom: 1px solid var(--line); }
.agent-head > div { display: flex; align-items: center; gap: 11px; }
.agent-seal { width: 38px; height: 38px; display: grid; place-items: center; background: var(--rust); color: white; font: 600 20px/1 "Noto Serif JP",serif; }
.agent-head p, .agent-head b, .agent-head small { display: block; margin: 0; }
.agent-head b { font: 600 13px/1.3 "Noto Serif JP",serif; }
.agent-head small { color: #857b6d; font-size: 9px; }
.agent-head > button { border: 0; background: none; color: #70675b; font-size: 24px; cursor: pointer; }
.agent-context { padding: 9px 20px; background: #ece4d7; color: #756c60; text-transform: uppercase; letter-spacing: .1em; font-size: 8px; }
.agent-context span { display: inline-block; width: 6px; height: 6px; margin-right: 6px; background: #47745a; border-radius: 50%; }
.agent-messages { overflow-y: auto; padding: 20px; }
.message { max-width: 88%; margin: 0 0 14px; }
.message p { margin: 0; padding: 12px 14px; font-size: 11px; line-height: 1.58; }
.message time { display: block; margin: 4px 4px 0; color: #9a9082; font-size: 8px; }
.message.assistant p { background: #e9e0d2; color: #524b42; }
.message.user { margin-left: auto; }
.message.user p { background: var(--ink); color: #f4eee4; }
.message.user time { text-align: right; }
.message a { color: var(--rust); text-decoration: underline; }
.agent-prompts { padding: 0 20px 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.agent-prompts button { border: 1px solid #b9aa95; background: transparent; color: #6b6257; padding: 8px 9px; cursor: pointer; font-size: 9px; }
.agent-form { margin: 0 20px; display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 8px; border: 1px solid #aa9c88; background: #fffaf1; padding: 8px; }
.agent-form textarea { min-height: 49px; max-height: 120px; resize: none; border: 0; outline: none; background: transparent; padding: 6px; color: var(--ink); font-size: 11px; }
.agent-form button { width: 38px; height: 38px; border: 0; background: var(--rust); color: white; cursor: pointer; font-size: 18px; }
.agent-disclaimer { margin: 9px 20px 12px; color: #9a9082; text-align: center; font-size: 8px; }
body.drawer-open { overflow: hidden; }

dialog { width: min(530px,calc(100% - 28px)); border: 1px solid var(--line); padding: 38px; background: var(--paper-light); color: var(--ink); box-shadow: 0 30px 100px rgba(28,22,15,.35); }
dialog::backdrop { background: rgba(23,20,15,.6); backdrop-filter: blur(3px); }
dialog h2 { margin: 12px 0 24px; font: 600 34px/1.1 "Noto Serif JP",serif; }
dialog ol { padding: 0; margin: 0 0 24px; list-style: none; counter-reset: tips; }
dialog li { display: grid; gap: 4px; padding: 12px 0; border-top: 1px solid var(--line); counter-increment: tips; }
dialog li b::before { content: "0" counter(tips) "  "; color: var(--rust); font: 500 9px/1 "DM Sans"; }
dialog li b { font: 600 14px/1.4 "Noto Serif JP",serif; }
dialog li span { color: #756c60; font-size: 10px; padding-left: 25px; }
.dialog-close { position: absolute; top: 14px; right: 14px; border: 0; background: none; color: #756c60; font-size: 21px; cursor: pointer; }

@media (max-width: 980px) {
  .analysis-grid, .method-section { grid-template-columns: 1fr; }
  .analysis-copy { max-width: 650px; }
  .result-grid, .atlas-grid, .source-links { grid-template-columns: repeat(2,1fr); }
  .atlas-heading { grid-template-columns: 1fr; }
  .field-guide { grid-template-columns: 1fr; }
  .field-guide figure { min-height: 500px; }
  .sources-section { grid-template-columns: 1fr; }
  footer { grid-template-columns: 1fr 1fr; }
  footer > p { display: none; }
}

@media (max-width: 680px) {
  .analysis-panel, .atlas-section, .method-section, .sources-section { padding: 74px 16px; }
  .section-number { display: none; }
  .analysis-grid { gap: 32px; }
  .field-row, .result-grid, .atlas-grid, .source-links { grid-template-columns: 1fr; }
  .form-actions { align-items: stretch; flex-direction: column-reverse; }
  .results-head, .atlas-toolbar { align-items: flex-start; flex-direction: column; }
  .results-head > p { text-align: left; }
  .atlas-search { width: 100%; }
  .method-cards article { grid-template-columns: 30px 1fr; }
  .method-cards article p { grid-column: 2; }
  .field-guide > div { padding: 70px 20px; }
  .field-guide figure { min-height: 420px; }
  footer { padding-inline: 16px; }
  footer > div { gap: 13px; }
  dialog { padding: 30px 22px; }
}

/* Original high-energy manga casefile direction: ink, paper, halftone, motion. */
.site-header {
  min-height: 82px;
  border-bottom: 4px solid var(--ink);
  background: rgba(255,253,246,.96);
  box-shadow: 0 7px 0 var(--rust);
}
.brand-mark { border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); transform: rotate(-4deg); font-weight: 900; }
.brand small, nav, .agent-launch, .eyebrow, .workspace-head p, .type-chip { font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
nav a::before { content: "//"; color: var(--rust); margin-right: 6px; font-weight: 900; }
nav a.active::after { height: 5px; bottom: 0; transform: skewX(-22deg); }
.agent-launch { border: 3px solid var(--ink); background: var(--rust); box-shadow: 5px 5px 0 var(--ink); transform: skewX(-5deg); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.agent-launch:hover { transform: skewX(-5deg) translate(-2px,-2px); box-shadow: 7px 7px 0 var(--ink); }
.agent-launch span { color: #fff; }

.identify-shell { border-bottom: 8px solid var(--ink); background: linear-gradient(105deg, transparent 0 54%, rgba(225,27,34,.08) 54% 55%, transparent 55%); }
.intro { position: relative; z-index: 1; }
.eyebrow { display: inline-flex; align-items: center; margin: 0; padding: 6px 9px; color: var(--paper-light); background: var(--ink); transform: skewX(-6deg); }
.eyebrow span { width: 18px; height: 7px; margin-bottom: 0; background: var(--rust); transform: skewX(-20deg); }
.lede { margin: 12px 0 0; padding: 15px 17px; border-left: 6px solid var(--rust); background: rgba(255,253,246,.82); color: var(--ink-soft); font-weight: 500; }
.trust-row span { padding: 7px 9px; border: 2px solid var(--ink); background: var(--paper-light); box-shadow: 3px 3px 0 rgba(9,9,9,.18); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.trust-row b { color: var(--rust); font-size: 1.15em; }
.workspace-head { border-bottom: 3px solid var(--ink); margin-bottom: 16px; }
.workspace-head h2 { font: 400 25px/1 "Bebas Neue", Impact, sans-serif; letter-spacing: .04em; text-transform: uppercase; }
.step { border: 3px solid var(--ink); background: var(--brass); color: var(--ink); box-shadow: 3px 3px 0 var(--ink); font-weight: 900; transform: rotate(-4deg); }
.tip-button { border: 2px solid var(--ink); padding: 7px 10px; background: transparent; color: var(--ink); font-weight: 800; text-transform: uppercase; }
.drop-zone { border: 3px solid var(--ink); background-color: #ece7da; background-image: radial-gradient(rgba(9,9,9,.26) 1px, transparent 1.5px), linear-gradient(135deg, transparent 0 47%, rgba(225,27,34,.1) 47% 53%, transparent 53%); background-size: 8px 8px, 100% 100%; }
.drop-zone:hover { border-color: var(--ink); background-color: #fffdf6; box-shadow: inset 0 0 0 7px var(--rust); }
.camera-icon { width: 64px; height: 64px; border: 4px solid var(--ink); background: var(--paper-light); color: var(--rust); box-shadow: 5px 5px 0 var(--rust); font-size: 36px; }
.drop-zone strong { font: 700 20px/1.2 "Noto Sans JP", sans-serif; text-transform: uppercase; }
.choose-button, .primary-button { background: var(--rust); border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); font-weight: 800; text-transform: uppercase; }
.choose-button:hover, .primary-button:hover { background: var(--rust-bright); transform: translate(-2px,-2px); box-shadow: 7px 7px 0 var(--ink); }
.scan-corner { width: 34px; height: 34px; border-width: 4px !important; }
.workspace-foot { border-top: 3px solid var(--ink); margin-top: 16px; padding-top: 12px; }
.sample-match { border: 3px solid var(--paper-light); outline: 4px solid var(--ink); background: var(--ink); box-shadow: 9px 9px 0 var(--rust); transform: rotate(2deg); }
.sample-top b, .romaji { color: var(--brass); }

.analysis-panel { border-top: 0; overflow: hidden; background: var(--paper-light); }
.analysis-panel::after { content: ""; position: absolute; width: 360px; height: 360px; right: -140px; top: 40px; border-radius: 50%; opacity: .09; background: repeating-radial-gradient(circle, var(--ink) 0 2px, transparent 2px 8px); }
.section-number { padding: 8px 5px; background: var(--rust); color: white; font-weight: 900; }
.analysis-copy h2, .atlas-heading h2, .method-intro h2, .field-guide h2, .sources-section h2 { font: 400 clamp(48px,6vw,82px)/.9 "Bebas Neue", Impact, sans-serif; letter-spacing: 0; text-transform: uppercase; }
.ocr-status { border: 3px solid var(--ink); padding: 13px; background: var(--paper); box-shadow: 5px 5px 0 var(--ink); }
.status-dot { border-radius: 0; background: var(--brass); box-shadow: none; transform: rotate(45deg); }
.transcription-card { position: relative; z-index: 1; border: 4px solid var(--ink); background: var(--paper); box-shadow: 12px 12px 0 var(--rust); transform: rotate(-.35deg); }
.transcription-card textarea, select { border: 3px solid var(--ink); background: var(--paper-light); }
.transcription-card textarea:focus, select:focus, .atlas-search:focus-within, .agent-form:focus-within { border-color: var(--rust); box-shadow: 5px 5px 0 rgba(9,9,9,.2); }
.secondary-button { border: 3px solid var(--ink); color: var(--ink); background: var(--paper-light); font-weight: 700; text-transform: uppercase; }
.results-shell { padding-top: 28px; border-top: 6px solid var(--ink); }
.results-head h3 { font: 400 36px/1 "Bebas Neue", Impact, sans-serif; letter-spacing: .04em; text-transform: uppercase; }
.result-card { border: 3px solid var(--ink); box-shadow: 7px 7px 0 rgba(9,9,9,.2); }
.result-card::after { content: ""; position: absolute; right: -25px; bottom: -25px; width: 90px; height: 90px; opacity: .08; background: repeating-radial-gradient(circle, currentColor 0 1px, transparent 1px 5px); }
.result-card:first-child { background: var(--ink); box-shadow: 8px 8px 0 var(--rust); }
.rank { padding: 5px 7px; background: var(--rust); color: white !important; font-weight: 900; }
.confidence b { color: var(--rust-bright); font-size: 12px; }
.result-name { font-weight: 900; }
.result-note { border: 2px solid var(--ink); border-left: 8px solid var(--brass); background: var(--paper); }

.atlas-section { position: relative; overflow: hidden; border-top: 8px solid var(--rust); background: #090909; }
.atlas-section::before { content: "CASEFILE"; position: absolute; right: -20px; top: 45px; color: rgba(255,255,255,.045); font: 400 min(17vw,230px)/1 "Bebas Neue", Impact, sans-serif; letter-spacing: .05em; transform: rotate(8deg); }
.atlas-heading, .atlas-toolbar, .atlas-grid { position: relative; z-index: 1; }
.atlas-heading .eyebrow { background: var(--paper-light); color: var(--ink); }
.atlas-heading .eyebrow span { background: var(--rust); }
.atlas-toolbar { border-width: 3px 0; border-color: rgba(255,255,255,.42); }
.filter { border: 2px solid transparent; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.filter:hover { color: white; border-color: white; }
.filter.active { background: var(--brass); color: var(--ink); border-color: var(--ink); box-shadow: 3px 3px 0 var(--rust); }
.atlas-search { border: 3px solid var(--paper-light); background: rgba(255,255,255,.06); }
.atlas-grid { border-width: 3px 0 0 3px; border-color: rgba(255,255,255,.55); }
.atlas-card { min-height: 285px; border-width: 0 3px 3px 0; border-color: rgba(255,255,255,.55); background: linear-gradient(140deg, rgba(255,255,255,.03), transparent 60%); }
.atlas-card::before { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 42px 42px 0; border-color: transparent var(--rust) transparent transparent; opacity: 0; transition: opacity .2s; }
.atlas-card:hover { background: var(--paper-light); color: var(--ink); transform: translate(-3px,-3px); box-shadow: 7px 7px 0 var(--rust); }
.atlas-card:hover::before { opacity: 1; }
.atlas-card:hover p, .atlas-card:hover .atlas-meta { color: #4b4b4b; }
.atlas-card .type-chip { border: 2px solid var(--brass); color: var(--brass); }
.atlas-card:hover .type-chip { border-color: var(--ink); color: var(--ink); }
.atlas-card h3 { margin-top: 20px; font: 900 34px/1.15 "Noto Sans JP", sans-serif; }
.atlas-card .atlas-name { color: var(--rust-bright); font-weight: 900; font-size: 10px; }
.atlas-card a { color: var(--brass); border-bottom: 2px solid currentColor; font-weight: 800; text-transform: uppercase; }
.atlas-card:hover a { color: var(--rust); }

.method-section { position: relative; background-image: linear-gradient(110deg, transparent 0 72%, rgba(225,27,34,.07) 72%); }
.text-link { border: 3px solid var(--ink); padding: 12px 14px; background: var(--brass); color: var(--ink); box-shadow: 5px 5px 0 var(--ink); text-transform: uppercase; }
.method-cards { border-top: 4px solid var(--ink); }
.method-cards article { border-bottom: 4px solid var(--ink); }
.method-cards article > span { display: grid; place-items: center; width: 34px; height: 34px; background: var(--rust); color: white; font-weight: 900; transform: rotate(-5deg); }
.method-cards h3 { font: 700 19px/1.2 "Noto Sans JP", sans-serif; text-transform: uppercase; }
.field-guide { border-top: 8px solid var(--ink); border-bottom: 8px solid var(--ink); background: var(--brass); }
.field-guide figure { border-right: 8px solid var(--ink); }
.field-guide figure::after { box-shadow: inset 0 0 0 7px var(--rust); }
.field-guide img { filter: grayscale(1) contrast(1.28); }
.field-guide > div { background-image: radial-gradient(rgba(9,9,9,.2) 1px, transparent 1px); background-size: 7px 7px; }
.field-guide > div > p, .field-guide li { background: rgba(244,196,48,.88); color: var(--ink); }
.field-guide li { border-color: var(--ink); }

.sources-section { border-bottom: 7px solid var(--rust); }
.source-links { grid-template-columns: repeat(4,1fr); border-width: 3px 0 0 3px; border-color: var(--ink); }
.source-links a { min-height: 118px; border-width: 0 3px 3px 0; border-color: var(--ink); background: var(--paper); transition: transform .15s, box-shadow .15s; }
.source-links a:hover { position: relative; z-index: 1; transform: translate(-4px,-4px) rotate(-1deg); box-shadow: 8px 8px 0 var(--rust); }
.source-links b { font-family: "Noto Sans JP", sans-serif; font-weight: 900; text-transform: uppercase; }
footer { border-top: 0; background: var(--ink); }

.agent-drawer { width: min(470px,100%); border-left: 6px solid var(--ink); background-color: var(--paper-light); background-image: radial-gradient(rgba(9,9,9,.1) 1px, transparent 1px); background-size: 8px 8px; box-shadow: -12px 0 0 var(--rust); }
.agent-head { border-bottom: 4px solid var(--ink); background: var(--paper-light); }
.agent-seal { border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); transform: rotate(-4deg); }
.agent-head b { font: 400 21px/1 "Bebas Neue", Impact, sans-serif; letter-spacing: .06em; text-transform: uppercase; }
.agent-context { border-bottom: 3px solid var(--ink); background: var(--brass); color: var(--ink); font-weight: 800; }
.agent-context span { border-radius: 0; background: var(--rust); transform: rotate(45deg); }
.message p { border: 3px solid var(--ink); box-shadow: 4px 4px 0 rgba(9,9,9,.15); background: var(--paper-light) !important; color: var(--ink) !important; }
.message.user p { background: var(--ink) !important; color: white !important; box-shadow: 4px 4px 0 var(--rust); }
.agent-prompts button { border: 2px solid var(--ink); background: var(--paper-light); color: var(--ink); font-weight: 700; }
.agent-prompts button:hover { background: var(--brass); }
.agent-form { border: 3px solid var(--ink); background: var(--paper-light); box-shadow: 5px 5px 0 var(--rust); }
.agent-form button { border: 2px solid var(--ink); background: var(--rust); font-weight: 900; }
dialog { border: 5px solid var(--ink); box-shadow: 12px 12px 0 var(--rust); }
dialog h2 { font: 400 42px/.95 "Bebas Neue", Impact, sans-serif; text-transform: uppercase; }

@media (max-width: 980px) {
  .source-links { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 680px) {
  .site-header { box-shadow: 0 5px 0 var(--rust); }
  .agent-launch { box-shadow: 3px 3px 0 var(--ink); }
  .identify-shell::before { opacity: .09; mask-image: linear-gradient(#000,transparent 55%); }
  h1 { font-size: clamp(68px,20vw,104px); }
  .workspace { transform: none; box-shadow: 7px 7px 0 rgba(9,9,9,.16); }
  .source-links { grid-template-columns: 1fr; }
  .field-guide figure { border-right: 0; border-bottom: 8px solid var(--ink); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
