:root {
  color-scheme: light;
  --ink: #202b33;
  --muted: #647079;
  --line: #d8d8d1;
  --paper: #f5f0e8;
  --paper-deep: #e9e0d3;
  --card: #fffdf8;
  --blue: #185a87;
  --blue-dark: #123c5a;
  --blue-soft: #8bb4ca;
  --red: #c94a36;
  --focus: #d86a2e;
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.65;
  overflow-x: hidden;
}
button, input, textarea { font: inherit; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 50; padding: .7rem 1rem; background: var(--ink); color: white; }
.skip-link:focus { top: 1rem; }

.site-header { border-bottom: 1px solid rgba(32,43,51,.14); background: rgba(245,240,232,.92); }
.header-inner { width: min(1180px, calc(100% - 40px)); margin: 0 auto; min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: .04em; }
.brand-mark { display: grid; place-items: center; width: 31px; height: 31px; color: white; background: var(--blue); font-size: 1.3rem; line-height: 1; transform: rotate(-7deg); }
.header-note { color: var(--muted); font-size: .82rem; }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.hero { min-height: 350px; margin: 34px 0 48px; padding: clamp(30px, 5vw, 68px); display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr); gap: clamp(30px, 6vw, 100px); position: relative; isolation: isolate; overflow: hidden; background: var(--blue-dark); color: white; }
.hero::before { content: ""; position: absolute; inset: 0; z-index: -2; background-image: linear-gradient(90deg, rgba(18,60,90,.94), rgba(18,60,90,.62)), url('/assets/editorial-collage.jpg'); background-size: cover; background-position: center; mix-blend-mode: multiply; opacity: .95; }
.hero::after { content: ""; position: absolute; inset: 16px; z-index: -1; border: 1px solid rgba(255,255,255,.31); pointer-events: none; }
.hero-copy { align-self: center; max-width: 680px; }
.eyebrow, .section-index, .example-kicker { margin: 0 0 .7rem; font-size: .72rem; font-weight: 800; letter-spacing: .16em; }
.eyebrow { color: #c9e0ec; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 1.2rem; max-width: 10ch; font-size: clamp(2.5rem, 6vw, 5.3rem); line-height: .99; letter-spacing: -.06em; }
h1 em { color: #f4c7af; font-style: normal; }
.hero-lead { max-width: 58ch; color: #edf1f0; font-size: 1.02rem; }
.hero-tags { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1.5rem; }
.hero-tags span { padding: .32rem .7rem; border: 1px solid rgba(255,255,255,.45); border-radius: 99px; font-size: .78rem; }
.hero-example { align-self: end; padding: 1.3rem; background: rgba(255,253,248,.96); color: var(--ink); box-shadow: 9px 9px 0 rgba(201,74,54,.7); transform: rotate(1.2deg); }
.example-kicker { color: var(--red); }
.example-title { margin-bottom: .65rem; font-weight: 800; }
.hero-example pre { overflow-x: auto; margin: 0; padding: .85rem; background: #e9f0f1; border-left: 3px solid var(--blue); font: .92rem/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; }
.example-note { margin: .75rem 0 0; color: var(--muted); font-size: .8rem; line-height: 1.45; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 20px; }
.panel, .result-card, .table-section, .info-card { background: var(--card); border: 1px solid var(--line); }
.panel { padding: clamp(22px, 3.2vw, 36px); min-width: 0; }
.panel-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; border-bottom: 2px solid var(--ink); margin-bottom: 1.2rem; }
.panel h2, .result-section h2, .table-section h2, .info-card h2 { margin-bottom: .55rem; font-size: clamp(1.35rem, 2.4vw, 1.85rem); line-height: 1.2; letter-spacing: -.04em; }
.section-index { color: var(--red); }
.helper-text, .field-hint { color: var(--muted); font-size: .9rem; }
.helper-text { margin-bottom: 1.2rem; }
.field-label, .subheading, .chart-picker legend { display: block; margin-bottom: .4rem; font-weight: 800; font-size: .9rem; }
.data-input, input { width: 100%; border: 1px solid #aeb7b8; border-radius: 2px; background: #fff; color: var(--ink); font-size: 16px; }
.data-input { min-height: 200px; resize: vertical; padding: .8rem; line-height: 1.55; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.data-input:focus, input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(24,90,135,.15); outline: none; }
.field-hint { margin: .45rem 0 1.6rem; font-size: .79rem; }
.manual-entry { padding-top: 1rem; border-top: 1px dashed var(--line); }
.manual-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(100px, .6fr) auto; align-items: end; gap: .6rem; }
.manual-fields label span { display: block; margin-bottom: .28rem; color: var(--muted); font-size: .78rem; }
input { min-height: 44px; padding: .55rem .7rem; }
.button { min-height: 44px; padding: .6rem 1rem; border: 1px solid transparent; border-radius: 2px; cursor: pointer; font-weight: 800; transition: transform .15s ease, background .15s ease, border-color .15s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .42; cursor: not-allowed; }
.button-small { white-space: nowrap; font-size: .84rem; }
.button-outline { background: transparent; border-color: var(--blue); color: var(--blue); }
.button-primary { background: var(--blue); color: white; }
.button-secondary { background: var(--red); color: white; }
.button-quiet { background: transparent; border-color: #aeb7b8; color: var(--ink); }
.validation-message { min-height: 2.3em; margin-top: 1.25rem; color: var(--red); font-size: .87rem; }
.validation-message[data-kind="success"] { color: #276447; }
.data-count { display: flex; justify-content: space-between; gap: 1rem; padding-top: .7rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .76rem; }
.data-count span:first-child { color: var(--ink); font-weight: 800; }

.settings-panel { display: flex; flex-direction: column; }
.chart-picker { margin: 0; padding: 0; border: 0; }
.chart-options { display: grid; gap: .65rem; }
.chart-option { min-height: 70px; display: flex; align-items: center; gap: .85rem; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 2px; background: #fff; color: var(--ink); text-align: left; cursor: pointer; }
.chart-option:hover, .chart-option.is-selected { border-color: var(--blue); background: #eef5f6; }
.chart-option.is-selected { box-shadow: inset 4px 0 0 var(--red); }
.chart-option strong, .chart-option small { display: block; }
.chart-option strong { font-size: .92rem; }
.chart-option small { margin-top: .12rem; color: var(--muted); font-size: .77rem; }
.option-icon { width: 58px; height: 42px; flex: 0 0 auto; position: relative; display: block; }
.option-icon-bar { display: flex; align-items: end; justify-content: center; gap: 4px; padding: 5px 8px; border-bottom: 2px solid var(--ink); }
.option-icon-bar i { display: block; width: 9px; background: var(--blue); }
.option-icon-bar i:nth-child(1) { height: 13px; }.option-icon-bar i:nth-child(2) { height: 25px; background: var(--blue-soft); }.option-icon-bar i:nth-child(3) { height: 33px; background: var(--red); }
.option-icon-line { background: linear-gradient(145deg, transparent 28%, var(--blue) 29%, var(--blue) 33%, transparent 34%, transparent 56%, var(--red) 57%, var(--red) 61%, transparent 62%); border-bottom: 2px solid var(--ink); }
.option-icon-line::before, .option-icon-line::after { content: ""; position: absolute; width: 7px; height: 7px; border: 2px solid var(--red); background: white; border-radius: 50%; top: 12px; left: 15px; }.option-icon-line::after { top: 26px; left: 37px; }
.option-icon-waterfall { display: flex; align-items: end; gap: 3px; padding: 6px 6px 5px; border-bottom: 2px solid var(--ink); }
.option-icon-waterfall i { width: 13px; display: block; background: var(--blue); }.option-icon-waterfall i:nth-child(1) { height: 25px; }.option-icon-waterfall i:nth-child(2) { height: 14px; background: repeating-linear-gradient(135deg, var(--red), var(--red) 3px, #f9d5c9 3px, #f9d5c9 5px); }.option-icon-waterfall i:nth-child(3) { height: 31px; background: var(--blue-soft); }
.title-field { margin-top: 2rem; }
.meaning-note { display: flex; gap: .7rem; margin-top: auto; padding: 1rem; background: #f5ece5; border-left: 3px solid var(--red); }
.note-mark { display: grid; place-items: center; width: 22px; height: 22px; flex: 0 0 auto; border: 1px solid var(--red); border-radius: 50%; color: var(--red); font-weight: 800; font-family: serif; }
.meaning-note p { margin: 0; font-size: .78rem; line-height: 1.5; }

.result-section { margin-top: 42px; }
.result-heading, .section-heading-row { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; margin-bottom: 1rem; }
.result-heading h2, .section-heading-row h2 { margin-bottom: 0; }
.result-status { padding: .35rem .7rem; border: 1px solid var(--line); color: var(--muted); font-size: .78rem; }
.result-card { min-width: 0; overflow: hidden; }
.chart-viewport { overflow-x: auto; overflow-y: hidden; padding: 14px; background: #f3f0e9; min-height: 330px; }
.chart-viewport svg { display: block; width: 1200px; height: 700px; max-width: none; }
.chart-viewport .chart-empty { min-height: 300px; display: grid; place-items: center; color: var(--muted); font-size: .95rem; }
.result-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.2rem; border-top: 1px solid var(--line); }
.action-note { display: flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .77rem; }
.action-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); }
.button-group { display: flex; flex-wrap: wrap; gap: .55rem; }

.chart-viewport svg text { font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif; fill: var(--ink); }
.chart-viewport svg .chart-title { font-size: 20px; font-weight: 800; }
.chart-viewport svg .legend text, .chart-viewport svg .axis-caption { font-size: 12px; fill: var(--muted); }
.chart-viewport svg .grid-line { stroke: #d9dedc; }.chart-viewport svg .axis-zero { stroke: #a8b5b5; stroke-dasharray: 5 4; }.chart-viewport svg .axis-line { stroke: #829096; }.chart-viewport svg .baseline { stroke: #52636a; stroke-width: 1.5; stroke-dasharray: 4 3; }.chart-viewport svg .y-label { font-size: 12px; fill: var(--muted); }.chart-viewport svg .x-label { font-size: 13px; }.chart-viewport svg .value-label { font-size: 13px; font-weight: 800; }.chart-viewport svg .line-path { vector-effect: non-scaling-stroke; }.chart-viewport svg .connector { stroke: #8a989b; stroke-width: 1.5; stroke-dasharray: 4 3; }

.table-section { margin-top: 42px; padding: clamp(22px, 3vw, 34px); }
.section-heading-row > p { max-width: 32ch; margin-bottom: .25rem; color: var(--muted); font-size: .85rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
caption { padding: .65rem 0; color: var(--muted); text-align: left; font-size: .8rem; }
th, td { padding: .72rem .75rem; border-top: 1px solid var(--line); text-align: left; }
thead th { border-top: 2px solid var(--ink); border-bottom: 1px solid var(--ink); font-size: .8rem; }
tbody th { font-weight: 600; }
tbody td { font-variant-numeric: tabular-nums; }

.info-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 42px 0 60px; }
.info-card { padding: 1.4rem; }
.info-card h2 { font-size: 1.2rem; }
.info-card p, .info-card li { color: var(--muted); font-size: .82rem; }
.info-card ol { margin: 0; padding-left: 1.15rem; }
.info-card li + li { margin-top: .45rem; }
.site-footer { display: flex; justify-content: space-between; gap: 1rem; width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 1.3rem 0 2.2rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; }
.site-footer p { margin: 0; }

@media (max-width: 800px) {
  .hero { grid-template-columns: 1fr; gap: 30px; }
  .hero-copy { max-width: none; }
  .hero-example { max-width: 370px; }
  .workspace { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .header-inner, main, .site-footer { width: min(100% - 28px, 1180px); }
  .header-note { display: none; }
  .hero { margin-top: 18px; padding: 28px 22px; }
  .hero::after { inset: 10px; }
  h1 { font-size: clamp(2.4rem, 14vw, 4rem); }
  .panel { padding: 20px 16px; }
  .manual-fields { grid-template-columns: 1fr 1fr; }
  .manual-fields .button { grid-column: 1 / -1; width: 100%; }
  .result-heading, .section-heading-row, .result-actions { align-items: flex-start; flex-direction: column; }
  .result-actions { gap: .85rem; }
  .button-group { width: 100%; }
  .button-group .button { flex: 1 1 auto; }
  .info-grid { grid-template-columns: 1fr; margin-bottom: 40px; }
  .site-footer { align-items: flex-start; flex-direction: column; }
}
@media print {
  .site-header, .hero, .workspace, .result-heading, .result-actions, .table-section, .info-grid, .site-footer, .skip-link { display: none !important; }
  main { width: 100%; margin: 0; }
  .result-section { margin: 0; }
  .result-card { border: 0; }
  .chart-viewport { padding: 0; overflow: visible; background: transparent; }
  .chart-viewport svg { width: 100%; height: auto; }
}
