/* ============================================================
   90年表 自動計算ツール — スタイル
   トークン: 藍(#152341) / 金(#b8923f) / 和紙(#f6f1e2) / 墨(#241f18) / 朱(#a8433c)
   ============================================================ */

:root {
  --indigo-900: #101d36;
  --indigo-800: #16274a;
  --indigo-700: #1e3462;
  --gold-500: #b8923f;
  --gold-400: #d3af64;
  --gold-100: #f0e2bf;
  --washi: #f6f1e2;
  --washi-dim: #ece4cf;
  --ink: #251f17;
  --ink-soft: #4a4136;
  --vermillion: #a8433c;
  --pale-blue: #dfeaf1;
  --pale-blue-line: #bcd2e0;
  --pale-gold: #f3e9cd;
  --pale-gold-line: #e0cfa0;
  --line: rgba(37, 31, 23, 0.14);
  --radius: 3px;
  --font-display: 'Shippori Mincho', serif;
  --font-body: 'Noto Sans JP', sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--washi);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.paper-texture {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(184,146,63,0.05), transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(21,35,65,0.04), transparent 50%);
}

/* ---------- Header ---------- */

.site-header {
  background: var(--pale-blue);
  color: var(--indigo-800);
  border-bottom: 3px solid var(--gold-500);
  position: relative;
  z-index: 1;
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 18px; }

.brand-mark {
  font-family: var(--font-display);
  font-size: 2.6rem;
  line-height: 1;
  color: var(--gold-400);
  border: 1.5px solid var(--gold-500);
  border-radius: 50%;
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.9rem;
  margin: 0;
  letter-spacing: 0.03em;
}
.brand-sub-inline {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--gold-100);
  opacity: 0.85;
  margin-left: 6px;
}
.brand-tagline {
  margin: 4px 0 0;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: var(--gold-100);
  opacity: 0.7;
}

.data-status {
  font-size: 0.82rem;
  padding: 7px 14px;
  border: 1px solid rgba(211,175,100,0.4);
  border-radius: 20px;
  color: var(--gold-100);
  opacity: 0.85;
}
.data-status.ready { border-color: var(--gold-500); opacity: 1; }
.data-status.error { border-color: var(--vermillion); color: #f3c9c5; }

/* ---------- Layout ---------- */

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  position: relative;
  z-index: 1;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--indigo-800);
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 20px;
}
.panel-title-eyebrow {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--gold-500);
  border-bottom: 2px solid var(--gold-500);
  padding-bottom: 2px;
}

/* ---------- Input panel ---------- */

.input-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-top: 4px solid var(--indigo-800);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 1px 3px rgba(37,31,23,0.06);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field span {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}
.field input, .field select {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 10px 12px;
  border: 1px solid #cfc6b0;
  border-radius: var(--radius);
  background: var(--washi);
  color: var(--ink);
}
.field input:focus, .field select:focus {
  outline: 2px solid var(--gold-500);
  outline-offset: 1px;
  border-color: var(--gold-500);
}

.form-actions { display: flex; gap: 14px; flex-wrap: wrap; }

.btn-primary {
  background: var(--pale-blue);
  color: var(--indigo-800);
  border: 1px solid var(--pale-blue-line);
  padding: 13px 30px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-primary:hover:not(:disabled) { background: var(--pale-gold); border-color: var(--pale-gold-line); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }

.btn-ghost {
  background: transparent;
  color: var(--indigo-800);
  border: 1px solid var(--indigo-800);
  padding: 13px 24px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
}
.btn-ghost:hover { background: var(--washi-dim); }
.btn-ghost:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }

.input-note {
  margin: 18px 0 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.error-box {
  margin: 16px 0 0;
  padding: 12px 16px;
  background: #fbeceb;
  border: 1px solid var(--vermillion);
  border-radius: var(--radius);
  color: var(--vermillion);
  font-size: 0.88rem;
}

.hidden { display: none !important; }

/* ---------- Result panel ---------- */

.result-panel { margin-top: 48px; }
.result-panel > div { margin-bottom: 44px; }

/* Meishiki cards */

.meishiki-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}
.mcard {
  background: var(--pale-blue);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  border-bottom: 3px solid var(--gold-500);
}
.mcard-label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  opacity: 0.7;
  margin-bottom: 8px;
  color: var(--ink-soft);
}
.mcard-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--indigo-800);
}
.mcard-sub {
  margin-top: 6px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

/* Timeline (signature element) */

.timeline {
  display: flex;
  width: 100%;
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
}
.tband {
  flex: 1 0 70px;
  padding: 14px 8px;
  text-align: center;
  min-width: 70px;
  border-right: 1px solid rgba(37,31,23,0.12);
}
.tband:last-child { border-right: none; }
.tband:nth-child(odd) { background: var(--pale-blue); color: var(--ink); }
.tband:nth-child(even) { background: var(--pale-gold); color: var(--ink); }
.tband-age { font-size: 0.68rem; opacity: 0.7; margin-bottom: 4px; white-space: nowrap; color: var(--ink-soft); }
.tband-gz { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; color: var(--indigo-800); }
.tband-no { font-size: 0.72rem; color: var(--ink-soft); margin-top: 2px; }

.timeline-caption {
  margin: 12px 0 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

/* Table */

.table-caption {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: 0 0 8px;
}

.table-legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: #fff;
}
.legend-swatch.num-green { background: #dcefdd !important; }
.legend-swatch.num-red { background: #f7dcda !important; }

.table-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 75vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.table-scroll table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
  min-width: 920px;
  font-variant-numeric: tabular-nums;
  font-size: 0.86rem;
}

/* 列幅: 年齢・西暦年・前半・後半は控えめに、12ヶ月分は残りを均等割り */
col.col-age   { width: 6.5%; }
col.col-year  { width: 9%; }
col.col-half  { width: 8%; }
col.col-month { width: calc((100% - 6.5% - 9% - 16%) / 12); }

.table-scroll table thead th {
  background: var(--indigo-900);
  color: var(--gold-100);
  font-weight: 600;
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  padding: 10px 6px;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-scroll table tbody td {
  padding: 7px 6px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-scroll table tbody tr:nth-child(even) { background: #fff; }
.table-scroll table tbody tr:hover { background: var(--gold-100); }

/* 素質論比較表による色分け（〇=薄緑 / ×=薄赤、△は無印） */
.num-green { background: #dcefdd !important; }
.num-red { background: #f7dcda !important; }
.table-scroll table tbody tr:hover .num-green { background: #cbe6cd !important; }
.table-scroll table tbody tr:hover .num-red { background: #f1c6c3 !important; }

/* 素質論／鳥海側の相違マーク（丸印・3色） */
.mark-circle,
.mark-square {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.3em;
  min-height: 1.9em;
  padding: 2px 4px;
  border: 3px solid var(--ink);
  line-height: 1.25;
  font-weight: 700;
}
.mark-circle { border-radius: 50%; }
.mark-square { border-radius: 2px; }

.mark-circle.mark-black, .mark-square.mark-black { border-color: var(--ink); }
.mark-circle.mark-green, .mark-square.mark-green { border-color: #2e7d3b; }
.mark-circle.mark-red, .mark-square.mark-red { border-color: var(--vermillion); }
.legend-item .mark-circle, .legend-item .mark-square { border-width: 2px; min-width: 1.6em; min-height: 1.4em; font-weight: 400; }

.agecell { font-weight: 700; color: var(--indigo-800); }

.dash { color: #b7ac93; }
.changed {
  color: var(--ink);
  font-weight: normal;
}

/* ---------- Footer ---------- */

.site-footer {
  background: var(--indigo-900);
  color: rgba(246,241,226,0.65);
  text-align: center;
  padding: 28px 24px;
  font-size: 0.78rem;
}
.site-footer p { margin: 4px 0; max-width: 720px; margin-left: auto; margin-right: auto; }
.footer-small { opacity: 0.75; font-size: 0.72rem; }

/* ---------- Print ---------- */

@media print {
  .site-header, .site-footer, .input-panel, .timeline-block, .form-actions { display: none; }
  body { background: #fff; }
  table#table { font-size: 10px; min-width: 0; }
  table#table thead th { position: static; }
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .header-inner { padding: 20px 16px; }
  .brand-text h1 { font-size: 1.4rem; }
  .container { padding: 28px 14px 60px; }
  .input-panel { padding: 22px; }
  .tband-age { font-size: 0.6rem; }
}
