:root {
  color-scheme: light;
  --ink: #3f3028;
  --muted: #8a7665;
  --gold: #b98a29;
  --gold-deep: #8d6418;
  --line: rgba(181, 133, 42, .34);
  --paper: rgba(255, 253, 248, .82);
  --shadow: 0 18px 70px rgba(111, 79, 32, .14);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", Georgia, serif;
  background: #f9f6ef url("celest-palace.png") center top / cover fixed no-repeat;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(255,255,255,.2), rgba(251,248,241,.82) 32%, rgba(250,247,241,.95));
  backdrop-filter: blur(1.5px);
}
.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle at 50% 7%, rgba(255,255,255,.92), transparent 30%);
}
.shell { width: min(1080px, calc(100% - 28px)); margin: 0 auto; padding: 42px 0 30px; }
.hero { text-align: center; text-shadow: 0 1px 0 #fff; margin-bottom: 28px; }
.mark {
  width: 54px; height: 54px; margin: 0 auto 8px; display: grid; place-items: center;
  color: var(--gold-deep); border: 2px solid var(--gold); transform: rotate(30deg);
  font: 700 26px/1 Georgia, serif; background: rgba(255,255,255,.76); box-shadow: 0 0 28px rgba(255,255,255,.9);
}
.mark::first-letter { transform: rotate(-30deg); }
.eyebrow, .kicker { color: var(--gold-deep); letter-spacing: .22em; font: 700 11px/1.4 Arial, sans-serif; }
.hero h1 { margin: 4px 0 0; color: #9d7020; letter-spacing: .12em; font-size: clamp(34px, 5vw, 56px); font-weight: 400; }
.tagline { margin: 4px 0; color: #80654c; letter-spacing: .13em; text-transform: uppercase; font-size: 12px; }
.glass {
  border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: var(--shadow);
  backdrop-filter: blur(18px); overflow: hidden;
}
.input-card, .progress-card, .output-card { padding: clamp(18px, 3vw, 30px); margin-bottom: 18px; }
.section-heading, .progress-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.section-heading h2, .progress-head h2 { margin: 1px 0 13px; font-size: 21px; font-weight: 500; }
.kicker { margin: 0 0 3px; }
.counter, .progress-meta, .note, .status-message, .confirm-meta { color: var(--muted); font: 13px/1.6 Arial, sans-serif; }
textarea, input, select {
  width: 100%; color: var(--ink); border: 1px solid rgba(170,127,46,.36); border-radius: 12px;
  background: rgba(255,255,255,.78); outline: none; transition: border .2s, box-shadow .2s;
}
textarea { resize: vertical; min-height: 62px; padding: 12px 17px; font: 16px/1.7 "Yu Mincho", serif; }
input, select { height: 46px; padding: 0 13px; font: 14px Arial, sans-serif; }
textarea:focus, input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(185,138,41,.13); }
.controls { display: grid; grid-template-columns: 130px auto; align-items: end; gap: 12px; margin-top: 14px; }
.controls label span { display: block; margin: 0 0 6px 3px; color: var(--muted); font: 12px Arial, sans-serif; }
button { border: 0; cursor: pointer; font: 600 14px Arial, sans-serif; }
button:disabled { cursor: not-allowed; opacity: .48; }
.primary, .save-button {
  min-height: 46px; border: 1px solid #c69a40; border-radius: 12px; color: #5f4216;
  background: linear-gradient(180deg, #fff8dc, #e6bd62); box-shadow: 0 8px 24px rgba(157,112,32,.2); padding: 0 23px;
}
.primary:hover:not(:disabled), .save-button:hover:not(:disabled) { filter: brightness(1.04); transform: translateY(-1px); }
.button-glyph { margin-right: 5px; }
.note { margin: 12px 2px 0; }
.note a { color: var(--gold-deep); }
.hidden { display: none !important; }
.progress-head h2 { margin-bottom: 4px; }
#percentLabel { color: var(--gold-deep); font: 400 28px Georgia, serif; }
.progress-track { height: 8px; margin: 17px 0 8px; border-radius: 99px; background: rgba(130,100,61,.13); overflow: hidden; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #b07818, #e3bc60, #fff1b5); transition: width .4s ease; }
.progress-meta { display: flex; justify-content: space-between; }
.mode-message { margin: 10px 0 0; color: var(--gold-deep); font: 700 13px/1.6 Arial, sans-serif; }
.checkpoint { margin-top: 14px; padding: 13px 15px; border-left: 3px solid var(--gold); background: rgba(255,249,225,.65); }
.checkpoint span { color: var(--gold-deep); font: 700 13px Arial, sans-serif; }
.checkpoint p { margin: 5px 0 0; font-size: 14px; line-height: 1.7; }
.status-message { margin: 13px 0 0; }
.stop-button { min-height: 38px; margin-top: 14px; padding: 0 15px; border: 1px solid #b66a52; border-radius: 9px; color: #843e2d; background: rgba(255,246,243,.9); }
.stop-button:hover:not(:disabled) { background: #fff0ea; }
.output-card { min-height: 340px; }
.output-heading { align-items: center; }
.follow-toggle { color: var(--muted); font: 12px Arial, sans-serif; }
.follow-toggle input { width: auto; height: auto; vertical-align: -1px; }
.tabs { display: flex; gap: 5px; border-bottom: 1px solid var(--line); margin-bottom: 17px; }
.tab { color: var(--muted); padding: 10px 13px; background: transparent; border-bottom: 2px solid transparent; }
.tab.active { color: var(--gold-deep); border-color: var(--gold); }
.panel { display: none; }
.panel.active { display: block; }
.empty-state { min-height: 230px; display: grid; place-items: center; align-content: center; gap: 18px; color: var(--muted); text-align: center; }
.orb { width: 78px; height: 78px; border: 1px solid var(--line); border-radius: 50%; box-shadow: inset 0 0 30px #fff, 0 0 30px #fff; position: relative; }
.orb::before, .orb::after { content: ""; position: absolute; inset: 11px; border: 1px solid rgba(185,138,41,.32); transform: rotate(45deg); }
.orb::after { transform: rotate(90deg); }
.live-sections { display: grid; gap: 14px; }
.stream-output { margin-bottom: 14px; border: 1px solid rgba(185,138,41,.52); border-radius: 13px; background: rgba(255,252,239,.86); overflow: hidden; box-shadow: 0 8px 26px rgba(153,109,30,.08); }
.stream-title { margin: 0; padding: 12px 16px; color: var(--gold-deep); border-bottom: 1px solid rgba(185,138,41,.2); background: linear-gradient(90deg, rgba(250,238,199,.8), rgba(255,255,255,.35)); font: 700 13px Arial, sans-serif; }
.stream-text { min-height: 86px; max-height: 420px; margin: 0; padding: 17px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.9 "Yu Mincho", serif; }
.stage-section {
  scroll-margin-top: 16px; border: 1px solid rgba(185,138,41,.23); border-radius: 13px;
  background: rgba(255,255,255,.67); overflow: hidden; animation: reveal .4s ease both;
}
.stage-section header { display: flex; gap: 11px; align-items: center; padding: 13px 16px; border-bottom: 1px solid rgba(185,138,41,.18); }
.stage-number { flex: 0 0 auto; width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid var(--gold); border-radius: 50%; color: var(--gold-deep); font: 12px Arial, sans-serif; }
.stage-section h3 { margin: 0; font-size: 16px; font-weight: 500; }
.stage-section.product-stage { border-color: rgba(185,138,41,.58); box-shadow: 0 10px 28px rgba(153,109,30,.08); }
.stage-section.product-stage header { background: linear-gradient(90deg, rgba(250,238,199,.74), rgba(255,255,255,.25)); }
.round-chip { margin-left: auto; color: var(--muted); font: 11px Arial, sans-serif; }
.stage-body, .product-body { margin: 0; padding: 17px; white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.9 "Yu Mincho", serif; }
.analysis-log { margin: 0 17px 17px; border: 1px solid rgba(185,138,41,.27); border-radius: 9px; background: rgba(252,248,234,.7); }
.analysis-log-title { margin: 0; padding: 11px 13px; color: var(--gold-deep); font: 700 13px Arial, sans-serif; }
.analysis-log-body { max-height: 720px; margin: 0; padding: 14px; overflow: auto; border-top: 1px solid rgba(185,138,41,.18); white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.75 "Yu Mincho", serif; background: rgba(255,255,255,.72); }
.comparison-round { margin-bottom: 22px; }
.comparison-round > h3 { color: var(--gold-deep); font-size: 20px; font-weight: 500; }
.comparison-grid { display: grid; grid-template-columns: minmax(0, .72fr) minmax(0, 1.28fr); gap: 14px; }
.comparison-card { border: 1px solid rgba(185,138,41,.24); border-radius: 13px; background: rgba(255,255,255,.67); overflow: hidden; }
.comparison-card h4 { margin: 0; padding: 12px 15px; color: var(--gold-deep); background: rgba(250,241,212,.56); font-size: 14px; }
.research-frame-block { scroll-margin-top: 18px; padding: 4px 0 18px; }
.research-frame-block h4 { margin: 0; padding: 0 17px; color: var(--ink); font-size: 14px; font-weight: 500; }
.research-frame-block .product-body { padding-top: 8px; }
.previous-president-button {
  position: fixed; right: max(20px, calc((100vw - 1080px) / 2 + 20px)); bottom: 24px; z-index: 20;
  width: 46px; height: 46px; border: 1px solid rgba(141,100,24,.28); border-radius: 50%;
  color: rgba(141,100,24,.72); background: rgba(255,255,255,.18); box-shadow: 0 5px 18px rgba(90,63,25,.08);
  backdrop-filter: blur(4px); font: 400 23px/1 Georgia, serif; opacity: .55;
}
.previous-president-button:hover { opacity: .92; background: rgba(255,255,255,.48); }
.actions { display: flex; justify-content: center; padding: 3px 0 24px; }
.save-button { min-width: 260px; min-height: 56px; font-family: "Yu Mincho", serif; font-size: 17px; }
.save-button span { margin-right: 10px; font-size: 22px; }
footer { padding: 5px 0 10px; color: #8a7256; text-align: center; letter-spacing: .12em; font-size: 10px; }
dialog { width: min(620px, calc(100% - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 18px; color: var(--ink); background: rgba(255,253,247,.97); box-shadow: 0 28px 100px rgba(63,48,40,.28); }
dialog::backdrop { background: rgba(55,42,34,.34); backdrop-filter: blur(5px); }
.confirm-box { padding: 27px; }
.confirm-box h2 { margin: 3px 0 15px; font-weight: 500; }
.confirm-text { padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; white-space: pre-wrap; line-height: 1.8; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.secondary { min-height: 44px; padding: 0 18px; border: 1px solid #cfbd9d; border-radius: 10px; color: var(--ink); background: #fff; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 720px) {
  .shell { width: min(100% - 18px, 1080px); padding-top: 25px; }
  .controls { grid-template-columns: 1fr 1fr; }
  .primary { grid-column: 1 / -1; }
  .comparison-grid { grid-template-columns: 1fr; }
  .output-heading { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 460px) {
  .controls { grid-template-columns: 1fr; }
  .primary { grid-column: auto; }
  .progress-meta { flex-direction: column; gap: 3px; }
  .section-heading { align-items: flex-start; }
  .tabs { overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
