/* 音の届く範囲シミュレーター（皮算用と同じ配色・ライト／ダーク・スマホ対応） */
:root {
  --bg: #f7f3ec; --surface: #fffdf9; --surface-2: #f3ede3; --text: #2b2420; --text-sub: #6b5f55;
  --line: #e2d8c9; --accent: #a4532b; --accent-soft: #f3e2d6; --warn: #9a6a00; --warn-soft: #fbf0d0;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 20px rgba(60, 40, 20, .07); --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", Meiryo, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1714; --surface: #272220; --surface-2: #211c19; --text: #efe7de; --text-sub: #b3a69a;
    --line: #3b332d; --accent: #e08a5c; --accent-soft: #3a2a21; --warn: #e8c060; --warn-soft: #3a3018;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); }
a { color: var(--accent); }
.top { max-width: 1400px; margin: 0 auto; padding: 14px 16px 4px; }
.top-bar { display: flex; justify-content: space-between; align-items: center; }
h1 { font-size: 24px; margin: 10px 0 2px; }
h2 { font-size: 17px; margin: 0 0 8px; }
.lead { margin: 0 0 8px; color: var(--text-sub); }
.layout { max-width: 1400px; margin: 0 auto; padding: 8px 16px; display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 16px; align-items: start; }
/* 条件の欄は画面の高さに収めて中で動かす（地図や結果を見ながら条件を変えられる） */
.panel { position: sticky; top: 8px; max-height: calc(100vh - 16px); overflow-y: auto; overscroll-behavior: contain; padding: 0 4px 0 0; scrollbar-width: thin; }
.mapcol { min-width: 0; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .mapcol { order: -1; }
  .panel { position: static; max-height: none; overflow: visible; padding: 0; }
}
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 12px; }
details.card > summary { cursor: pointer; font-weight: 700; margin: -2px 0 6px; padding: 2px 0; }
details.card:not([open]) > summary { margin-bottom: -2px; }
details.card:not([open]) > summary::after { content: "（開く）"; font-weight: 400; font-size: 12px; color: var(--text-sub); margin-left: 6px; }
details.card[open] > summary { padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
/* 小見出しでまとまりを分ける。親のチェックに従う項目は字下げする */
.grp { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.grp:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.grp h3 { margin: 0 0 2px; font-size: 13px; color: var(--accent); }
.sub { margin-left: 22px; }
.btns.sub { margin-top: 4px; }
/* 長い説明は折りたたむ */
details.more { margin: 4px 0 6px; }
details.more > summary { cursor: pointer; font-size: 12px; color: var(--text-sub); }
details.more > summary:hover { color: var(--accent); }
details.more > .hint { margin-top: 4px; padding-left: 8px; border-left: 2px solid var(--line); }
label { display: block; font-size: 13px; color: var(--text-sub); }
label.row { margin: 8px 0; }
label.check { display: flex; gap: 6px; align-items: center; margin: 8px 0; color: var(--text); font-size: 14px; }
.u { font-size: 11px; }
input[type=number], input[type=search], select {
  width: 100%; padding: 6px 8px; margin-top: 2px; font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin: 8px 0; }
button { font: inherit; font-size: 14px; cursor: pointer; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: 6px 12px; }
button:hover { filter: brightness(1.08); }
.search, .fetch { display: flex; gap: 6px; align-items: center; }
.search input { margin: 0; }
.fetch select { margin: 0; }
.qres { list-style: none; margin: 6px 0; padding: 0; font-size: 13px; }
.qres button { background: none; border: none; color: var(--accent); padding: 3px 0; text-align: left; }
.hint { font-size: 12px; color: var(--text-sub); margin: 6px 0; }
.warn { font-size: 13px; color: var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 6px 10px; }
.refr ul { margin: 6px 0; padding-left: 18px; font-size: 13px; }
.mapbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 8px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.seg { display: inline-flex; border: 1px solid var(--accent); border-radius: 8px; overflow: hidden; }
.seg button { border: none; border-radius: 0; background: var(--surface); color: var(--accent); }
.seg button.on { background: var(--accent); color: #fff; }
.mini { display: inline-flex; gap: 6px; align-items: center; }
.mini select { width: auto; margin: 0; }
.status { font-size: 12px; color: var(--text-sub); flex: 1 1 100%; min-height: 1.2em; }
.status:empty { display: none; }
.map { height: calc(100vh - 150px); min-height: 380px; max-height: 760px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; margin: 8px 0 12px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; color: var(--text-sub); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; border: 1px solid var(--line); }
.sum { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: 14px; }
.sum dt { color: var(--text-sub); }
.sum dd { margin: 0; }
.c0 { color: #b02a1e; } .c1 { color: #9a4a0c; } .c2 { color: #765c00; } /* 白地で 4.5:1 以上 */ .c3 { color: var(--text-sub); }
@media (prefers-color-scheme: dark) { .c0 { color: #ff7b6b; } .c1 { color: #ffaa5c; } .c2 { color: #f0cf50; } }
.profile { width: 100%; height: 220px; display: block; margin-top: 10px; background: var(--surface-2); border-radius: 10px; }
.tablewrap { overflow-x: auto; }
table.bands { border-collapse: collapse; font-size: 12px; width: 100%; margin-top: 8px; font-variant-numeric: tabular-nums; }
.bands th, .bands td { border-bottom: 1px solid var(--line); padding: 3px 5px; text-align: right; white-space: nowrap; }
.bands th:first-child { text-align: left; color: var(--text-sub); font-weight: normal; }
.notes { max-width: 1368px; margin: 4px auto 24px; font-size: 13px; }
.notes ul { padding-left: 18px; }
.credit { color: var(--text-sub); font-size: 12px; }
.wind { color: rgba(40, 110, 190, .55); pointer-events: none; }
@media (max-width: 900px) { .map { height: 60vh; max-height: none; } }
@media (max-width: 520px) { .sum { grid-template-columns: 1fr; } .sum dd { margin-bottom: 4px; } }
/* 図形 */
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
button.ghost { background: var(--surface); color: var(--accent); }
button.ghost.on { background: var(--accent); color: #fff; }
.shape-list { list-style: none; margin: 6px 0; padding: 0; }
.shape-list button { width: 100%; text-align: left; background: var(--surface-2); color: var(--text); border-color: var(--line); margin-bottom: 4px; }
.shape-list button.on { border-color: var(--accent); background: var(--accent-soft); }
.shape-editor:not(:empty) { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
.ed-head { display: flex; gap: 6px; align-items: center; }
.ed-name { flex: 1; padding: 6px 8px; font: inherit; font-weight: 700; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; }
table.faces { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0; }
.faces th, .faces td { border-bottom: 1px solid var(--line); padding: 2px 4px; text-align: left; }
.faces input[type=number] { width: 70px; margin: 0; padding: 3px 6px; }
.items { margin-top: 8px; }
.item { border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; margin: 6px 0; background: var(--surface-2); }
.item-head { display: flex; gap: 6px; align-items: center; }
.item-head select { margin: 0; }
.item-head button { padding: 2px 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; margin-top: 4px; }
.item input, .item select { background: var(--surface); }
.shape-handle { width: 22px; height: 22px; border-radius: 6px; background: #fff; border: 2px solid #e08a3c; color: #7a3d10; font: 700 12px/18px system-ui, sans-serif; text-align: center; cursor: move; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.shape-handle.sel { border-color: #c0392b; background: #c0392b; color: #fff; }
.contrib { margin: 8px 0; font-size: 13px; }
.contrib table th { white-space: normal; }
/* フッター・免責事項（js/legal.js） */
.foot { max-width: 1368px; margin: 0 auto 32px; padding: 0 16px; font-size: 12.5px; color: var(--text-sub); }
.foot p { margin: 6px 0; }
.top-note { max-width: 1368px; margin: 8px auto; }
dialog.legal { width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 48px); padding: 0 20px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: inherit; overflow: auto; }
dialog.legal::backdrop { background: rgba(0, 0, 0, .45); }
.legal-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface); padding: 16px 0 8px; }
.legal-head h2 { margin: 0; font-size: 18px; }
.legal-close { font: inherit; font-size: 22px; line-height: 1; border: 0; background: transparent; color: var(--text-sub); cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.legal-close:hover { background: var(--surface-2); }
.legal-body { font-size: 14px; }
.legal-body h4 { margin: 16px 0 4px; font-size: 14.5px; }
.legal-body p { margin: 0 0 6px; }
.legal-date { color: var(--text-sub); font-size: 12px; margin-top: 12px !important; }
/* キーボード用のボタン・地図のエラー */
.map-keys { margin: 6px 0 0; }
.map-keys button { font-size: 12.5px; padding: 4px 10px; }
.map-error { position: absolute; left: 12px; right: 12px; top: 12px; z-index: 5; }
.map { position: relative; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ダークテーマ：アクセント色の上の文字は暗い色にする（白だと 2.6:1 で読みにくい。暗い色で 7:1 程度） */
@media (prefers-color-scheme: dark) {
  button, .seg button.on, button.ghost.on, .shape-handle.sel { color: #1b1714; }
  button.ghost, .seg button { color: var(--accent); }
  .shape-list button { color: var(--text); }
  .qres button { color: var(--accent); }
}

/* 言語の選択欄・右書き（アラビア語） */
.top-bar .lang { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.top-bar .lang select { width: auto; margin: 0; font-size: 13px; padding: 3px 6px; }
@media (max-width: 640px) { .top-bar .lang select { font-size: 16px; min-height: 40px; } }
.load-error { max-width: 1368px; margin: 8px auto; padding: 6px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }
[dir="rtl"] .sub { margin-left: 0; margin-right: 22px; }
[dir="rtl"] .top-bar .lang { margin-left: 0; margin-right: auto; }
[dir="rtl"] .status { text-align: right; }
[dir="rtl"] .bands th, [dir="rtl"] .bands td { text-align: left; }
[dir="rtl"] .bands th:first-child { text-align: right; }
[dir="rtl"] .panel { padding: 0 0 0 4px; }
