:root {
  --primary: #00597b;
  --primary-dark: #00465f;
  --accent: #1a79a4;
  --accent-light: #eef5f8;
  --text: #1a1a1a;
  --text-sub: #555;
  --border: #d6d6d6;
  --bg: #f5f5f5;
  --surface: #fff;
  --open: #1e7d4f;
  --open-bg: #e6f4ec;
  --soon: #b3261e;
  --soon-bg: #fdecea;
  --upcoming: #8a5a00;
  --upcoming-bg: #fff4dc;
  --closed: #6b6b6b;
  --closed-bg: #ececec;
  --new: #6a3fb5;
  --new-bg: #f1ebfb;
  --warn: #9a5b00;
  --warn-bg: #fff8e6;
  --warn-border: #f0c36a;
  --radius: 4px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "メイリオ", Meiryo, "Hiragino Kaku Gothic ProN", "Noto Sans JP", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
}
body.dialog-open { overflow: hidden; }

a { color: var(--accent); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ===== Header ===== */
.site-header {
  background: var(--surface);
  box-shadow: 0 2px 4px rgba(0,0,0,.12);
  position: sticky; top: 0; z-index: 10;
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 32px;
  padding: 0 24px; height: 64px;
}
.logo {
  font-size: 22px; font-weight: bold; color: var(--text);
  text-decoration: none; letter-spacing: .02em; white-space: nowrap;
}
.global-nav { display: flex; gap: 28px; flex: 1; }
.global-nav a {
  color: var(--text); text-decoration: none; font-size: 15px; font-weight: bold;
  padding: 20px 0; border-bottom: 3px solid transparent;
}
.global-nav a:hover, .global-nav a[aria-current="page"] { border-bottom-color: var(--accent); }
.menu-toggle {
  display: none; background: none; border: 0; padding: 8px; cursor: pointer;
  width: 40px; height: 40px; flex-direction: column; justify-content: center; gap: 5px;
}
.menu-toggle span { display: block; height: 2px; background: var(--text); border-radius: 1px; }

/* ===== Layout ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 16px 24px 48px; }

.breadcrumb { font-size: 13px; color: var(--text-sub); display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.page-title {
  font-size: 30px; margin: 0 0 8px;
  border-left: 4px solid var(--primary); padding-left: 12px; line-height: 1.3;
}
.lead { margin: 0 0 24px; color: var(--text-sub); font-size: 14px; }

/* ===== Buttons ===== */
.btn {
  font: inherit; font-size: 14px; border-radius: var(--radius); padding: 10px 32px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
.btn-small { padding: 6px 16px; font-size: 13px; }
.btn-primary { background: var(--primary); color: #fff; border: 1px solid var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-secondary:hover, .btn-secondary[aria-pressed="true"] { background: var(--accent-light); }
.btn-secondary[aria-pressed="true"] { font-weight: bold; }
.btn-watch { background: #fff; color: var(--text-sub); border: 1px solid var(--border); }
.btn-watch[aria-pressed="true"] { color: #8a5a00; border-color: #e0b44a; background: #fffaf0; font-weight: bold; }
.btn:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== Update alert ===== */
.alert {
  background: var(--warn-bg); border: 1px solid var(--warn-border); border-left: 4px solid #e0a020;
  border-radius: var(--radius); padding: 14px 20px; margin-bottom: 24px;
}
.alert-head { display: flex; align-items: center; gap: 10px; }
.alert-icon { width: 22px; height: 22px; fill: #c88400; flex: none; }
.alert-title { margin: 0; font-weight: bold; color: var(--warn); }
.alert-details { margin-top: 8px; font-size: 14px; }
.alert-details summary { cursor: pointer; color: var(--accent); }
.alert-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 320px; overflow: auto; }
.alert-list > li { background: #fff; border-radius: var(--radius); padding: 10px 12px; margin-bottom: 6px; }
.alert-list a { font-weight: bold; text-decoration: none; }
.alert-list a:hover { text-decoration: underline; }
.alert-list ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: var(--text-sub); }
.diff-old { text-decoration: line-through; color: #888; }
.diff-new { color: var(--soon); font-weight: bold; }
.alert-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ===== Search panel ===== */
.search-panel {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.12); padding: 20px 24px 24px; margin-bottom: 32px;
}
.panel-heading { font-size: 16px; margin: 0 0 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13px; font-weight: bold; color: var(--text-sub); }
.field input, .field select {
  font: inherit; font-size: 16px; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; background: #fff; width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.hint { font-size: 12px; color: var(--text-sub); margin: 0; }
.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 24px; margin-top: 16px; }
.check-row { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px 28px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 15px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; flex: none; }
.form-actions { display: flex; justify-content: center; margin-top: 20px; }

/* ===== Results ===== */
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 12px; }
.results-title { font-size: 18px; margin: 0; }
.results-title strong { color: var(--primary); font-size: 22px; }
.source-info { margin: 0; font-size: 12px; color: var(--text-sub); }

.loading { background: var(--surface); border-radius: var(--radius); padding: 32px 16px; text-align: center; color: var(--text-sub); margin-bottom: 12px; }
.loading p { margin: 12px 0; font-size: 14px; }
.spinner {
  width: 36px; height: 36px; margin: 0 auto; border-radius: 50%;
  border: 4px solid #d8e6ee; border-top-color: var(--accent); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress { max-width: 320px; height: 6px; margin: 0 auto; background: #e6e6e6; border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.error-box { background: var(--soon-bg); color: var(--soon); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.error-box p { margin: 0 0 8px; }

.result-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.12); padding: 18px 24px;
  border-left: 4px solid var(--accent);
}
.card.is-closed { border-left-color: var(--closed); }
.card.is-upcoming { border-left-color: #d9a400; }
.card.is-updated { box-shadow: 0 0 0 2px var(--warn-border), 0 1px 3px rgba(0,0,0,.12); }

.card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.badge {
  display: inline-block; font-size: 12px; font-weight: bold; padding: 2px 10px; border-radius: 999px; white-space: nowrap;
}
.badge-open { color: var(--open); background: var(--open-bg); }
.badge-upcoming { color: var(--upcoming); background: var(--upcoming-bg); }
.badge-closed { color: var(--closed); background: var(--closed-bg); }
.badge-soon { color: var(--soon); background: var(--soon-bg); }
.badge-cat { color: var(--primary); background: var(--accent-light); }
.badge-new { color: var(--new); background: var(--new-bg); }
.badge-updated { color: var(--warn); background: #ffefc7; }

.card-title { font-size: 17px; margin: 0 0 12px; line-height: 1.5; }
.card-title a { color: var(--accent); text-decoration: none; }
.card-title a:hover { text-decoration: underline; }

.card-info {
  display: grid; grid-template-columns: 1.6fr 1fr 1.2fr 2fr 1fr; gap: 12px 24px; margin: 0;
  border-top: 1px solid #eee; padding-top: 12px;
}
.card-info div { min-width: 0; }
.card-info dt { font-size: 12px; color: var(--text-sub); margin-bottom: 2px; }
.card-info dd { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.amount { font-weight: bold; font-size: 16px !important; color: var(--text); }
.muted { color: var(--text-sub); font-weight: normal; font-size: 13px !important; }

.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.empty {
  background: var(--surface); border-radius: var(--radius); padding: 40px 16px;
  text-align: center; color: var(--text-sub);
}
.more-wrap { display: flex; justify-content: center; margin-top: 20px; }

/* ===== Detail dialog ===== */
.detail-dialog {
  width: min(920px, calc(100% - 32px)); max-height: calc(100% - 48px);
  padding: 0; border: 0; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.3);
  color: var(--text); background: var(--surface);
}
.detail-dialog[open] { display: flex; flex-direction: column; }
.detail-dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--primary); color: #fff; padding: 10px 16px 10px 24px; flex: none;
}
.dialog-bar-title { font-size: 14px; font-weight: bold; }
.dialog-close {
  background: none; border: 0; color: #fff; font-size: 26px; line-height: 1; width: 40px; height: 40px; cursor: pointer; border-radius: var(--radius);
}
.dialog-close:hover { background: rgba(255,255,255,.15); }
.dialog-body { overflow-y: auto; padding: 20px 24px 28px; }

.detail-title { font-size: 22px; margin: 6px 0 4px; line-height: 1.4; }
.detail-catch { margin: 0 0 12px; color: var(--text-sub); }
.detail-cta { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; }
.detail-section { margin-top: 28px; }
.detail-section h3 {
  font-size: 17px; margin: 0 0 12px; padding-left: 10px; border-left: 4px solid var(--primary); line-height: 1.3;
}
.spec { display: grid; grid-template-columns: 180px 1fr; margin: 0; border-top: 1px solid var(--border); }
.spec dt, .spec dd { padding: 10px 12px; border-bottom: 1px solid var(--border); margin: 0; font-size: 14px; }
.spec dt { background: #f2f6f8; font-weight: bold; color: #333; }
.spec dd { overflow-wrap: anywhere; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.tag-list li { background: var(--accent-light); color: var(--primary); border-radius: 999px; padding: 2px 10px; font-size: 13px; }

.table-wrap { overflow-x: auto; }
.rounds { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
.rounds th, .rounds td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.rounds th { background: #f2f6f8; }

.rich { font-size: 14px; overflow-wrap: anywhere; }
.rich table { border-collapse: collapse; max-width: 100%; }
.rich td, .rich th { border: 1px solid var(--border); padding: 4px 8px; }
.rich p { margin: 0 0 8px; }

.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-list a { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.file-list a:hover { text-decoration: underline; }
.file-kind { font-size: 12px; background: var(--closed-bg); color: #333; padding: 1px 8px; border-radius: var(--radius); white-space: nowrap; }

.detail-loading { color: var(--text-sub); font-size: 14px; display: flex; align-items: center; gap: 10px; margin-top: 20px; }
.detail-loading .spinner { width: 20px; height: 20px; border-width: 3px; margin: 0; }

/* ===== Simulator ===== */
.sim { background: #f7fafc; border: 1px solid #d8e6ee; border-radius: 6px; padding: 18px 20px; }
.sim-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; }
.sim .field input { font-size: 18px; }
.yen-input { display: flex; align-items: center; gap: 8px; }
.yen-input span { white-space: nowrap; font-size: 14px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.quick button {
  font: inherit; font-size: 12px; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; cursor: pointer; color: var(--text-sub);
}
.quick button:hover { border-color: var(--accent); color: var(--accent); }
.custom-rate { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.custom-rate input { width: 110px !important; }
.sim-result { margin-top: 18px; background: #fff; border-radius: 6px; padding: 16px 18px; border: 1px solid #d8e6ee; }
.sim-main { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sim-main .label { font-size: 14px; font-weight: bold; }
.sim-main .value { font-size: 30px; font-weight: bold; color: var(--primary); line-height: 1.2; }
.sim-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: #e6e6e6; margin: 14px 0 6px; }
.sim-bar-sub { background: var(--accent); }
.sim-bar-self { background: #c9d3d8; }
.sim-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-sub); margin-bottom: 10px; }
.sim-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.sim-legend .l-sub { background: var(--accent); }
.sim-legend .l-self { background: #c9d3d8; }
.sim-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sim-table th, .sim-table td { padding: 6px 0; border-bottom: 1px dashed #e0e0e0; text-align: left; }
.sim-table td { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; }
.sim-note { font-size: 12px; color: var(--text-sub); margin: 10px 0 0; }
.sim-flag { font-size: 13px; color: var(--warn); background: var(--warn-bg); border-radius: var(--radius); padding: 6px 10px; margin: 10px 0 0; }

/* ===== Footer ===== */
.site-footer { background: var(--primary); color: #fff; }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 24px; }
.footer-nav { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 12px; }
.footer-nav a { color: #fff; font-size: 13px; text-decoration: none; }
.footer-nav a:hover { text-decoration: underline; }
.notice { font-size: 12px; opacity: .9; margin: 0 0 8px; }
.copyright { font-size: 12px; margin: 0; opacity: .85; }

/* ===== Tablet ===== */
@media (max-width: 1000px) {
  .card-info { grid-template-columns: 1fr 1fr 1fr; }
  .card-info .c-period { grid-column: span 2; }
  .field-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== Smartphone ===== */
@media (max-width: 768px) {
  .header-inner { height: 56px; padding: 0 16px; gap: 12px; justify-content: space-between; }
  .logo { font-size: 19px; }
  .menu-toggle { display: flex; }
  .global-nav {
    display: none; position: absolute; top: 56px; left: 0; right: 0;
    flex-direction: column; gap: 0; background: #fff; box-shadow: 0 4px 6px rgba(0,0,0,.12);
  }
  .global-nav.is-open { display: flex; }
  .global-nav a { padding: 14px 16px; border-bottom: 1px solid #eee; border-left: 3px solid transparent; }
  .global-nav a[aria-current="page"] { border-bottom-color: #eee; border-left-color: var(--accent); }

  .container { padding: 12px 16px 40px; }
  .page-title { font-size: 22px; }
  .lead { margin-bottom: 16px; }
  .alert { padding: 12px 14px; }
  .search-panel { padding: 16px; margin-bottom: 24px; }
  .field-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .check-row { flex-direction: column; }
  .form-actions .btn { width: 100%; }

  .card { padding: 14px 16px; }
  .card-title { font-size: 16px; }
  .card-info { grid-template-columns: 1fr 1fr; gap: 10px 16px; }
  .card-info .c-inst, .card-info .c-period { grid-column: span 2; }
  .card-actions .btn { flex: 1; padding-left: 8px; padding-right: 8px; }

  .detail-dialog { width: 100%; max-width: 100%; height: 100%; max-height: 100%; border-radius: 0; margin: 0; }
  .dialog-body { padding: 16px 16px 32px; }
  .detail-title { font-size: 19px; }
  .detail-cta .btn { flex: 1; }
  .spec { grid-template-columns: 1fr; }
  .spec dt { border-bottom: 0; padding-bottom: 4px; }
  .spec dd { padding-top: 4px; }
  .sim { padding: 14px; }
  .sim-inputs { grid-template-columns: 1fr; }
  .sim-main .value { font-size: 26px; }
}

@media (max-width: 340px) {
  .field-grid { grid-template-columns: 1fr; }
}
