/* Air Flow Room — Fujiya Campus CI（Navy / Gold / Cream） */
:root {
  --cream: #fafae3;
  --navy: #1a3468;
  --deep: #1a2e5a;
  --gold: #f5c440;
  --blue: #2b6baf;
  --sky: #5ab9d0;
  --ink: #1a3468;
  --muted: #55607a;
  --line: rgba(26, 52, 104, 0.16);
  --paper: #ffffff;
  --surface: #ffffff;
  --tabbar: #ffffff;
  --chip-on: #fdeeb8;
  --warn-bg: #fff4d6;
  --warn-ink: #8a4b00;
  --ok-bg: #e4f3e6;
  --ok-ink: #1d5c2a;
  --cut: #737a8c;
  --grid-out: transparent;
  --danger: #b3261e;
  --radius: 12px;
  --tap: 44px;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  color: var(--ink);
  background: var(--cream);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { overflow: hidden; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: 1fr 380px;
  grid-template-rows: 56px 1fr;
  grid-template-areas: "top top" "stage panel";
}
.top {
  grid-area: top;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px;
  background: var(--navy); color: var(--cream);
  border-bottom: 3px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .name { font-weight: 800; letter-spacing: 0.02em; }
.brand .sub { font-size: 12px; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .ghost { color: var(--cream); background: transparent; border-color: rgba(250, 250, 227, 0.5); }
.top .tools { display: flex; align-items: center; gap: 6px; min-width: 0; }
.top .docname { font-size: 13px; color: var(--cream); opacity: 0.92; max-width: 22ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .short { display: none; }
.hud .icon { min-width: 40px; padding: 0; font-size: 18px; }

.stage { grid-area: stage; position: relative; min-height: 0; background: var(--deep); overflow: hidden; }
#gl { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#gl:active { cursor: grabbing; }

.legend {
  position: absolute; right: 12px; top: 56px; bottom: 76px;
  display: flex; gap: 6px; pointer-events: none;
}
.legend .bar { width: 14px; border-radius: 7px; border: 1px solid rgba(255, 255, 255, 0.6); }
.legend .ticks { display: flex; flex-direction: column; justify-content: space-between; font-size: 12px; color: #fff; text-shadow: 0 1px 2px #000a; }

.views { position: absolute; left: 12px; top: 12px; display: flex; gap: 6px; }
.views button, .hud button, .hud select {
  min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(26, 46, 90, 0.75); color: #fff; cursor: pointer;
}
.hud {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: #fff;
}
.hud .ghost { background: rgba(26, 46, 90, 0.75); color: #fff; border-color: rgba(255, 255, 255, 0.35); }
.hud .play { background: var(--gold); color: var(--navy); font-weight: 800; border: none; min-height: var(--tap); padding: 0 18px; }
.hud .clock { font-variant-numeric: tabular-nums; font-size: 14px; text-shadow: 0 1px 2px #000a; }
.hud .status { font-size: 12px; opacity: 0.9; text-shadow: 0 1px 2px #000a; }
.badge {
  position: absolute; right: 12px; top: 12px; font-size: 12px; color: var(--navy);
  background: rgba(250, 250, 227, 0.92); padding: 4px 10px; border-radius: 999px; pointer-events: none;
}
.tip {
  position: absolute; max-width: 240px; padding: 8px 12px; border-radius: 10px;
  background: var(--cream); color: var(--navy); font-size: 13px; font-weight: 700;
  box-shadow: 0 4px 16px #0006; pointer-events: none;
}
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.lbl.north { background: var(--cream); color: var(--navy); }
.lbl.sun { background: #f5c440; color: var(--navy); }
.lbl.wind { background: rgba(90, 185, 208, 0.92); color: #0b2440; }
.nogl { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; color: #fff; text-align: center; }

.panel {
  grid-area: panel; min-height: 0; display: flex; flex-direction: column;
  background: var(--cream); border-left: 1px solid var(--line);
}
.tabs { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; background: var(--tabbar); }
.tabs button {
  flex: 1 0 auto; min-height: var(--tap); padding: 0 10px; border: none; border-radius: 10px;
  background: transparent; font-weight: 700; color: var(--muted); cursor: pointer;
}
.tabs button.on { background: var(--gold); color: var(--navy); }
.body { flex: 1; overflow-y: auto; padding: 4px 16px 32px; overscroll-behavior: contain; }

.sec { padding: 14px 0; border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: none; }
.sec h2 { font-size: 15px; margin: 0 0 10px; }
.sec h3 { font-size: 14px; margin: 0 0 6px; }
.note { font-size: 12.5px; color: var(--muted); line-height: 1.6; margin: 8px 0 0; }
.warn { font-size: 13px; color: var(--warn-ink); background: var(--warn-bg); border-radius: 8px; padding: 8px 10px; line-height: 1.5; }

.field { display: block; margin: 10px 0; }
.field .lab { display: block; font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.field .val { font-weight: 400; color: var(--muted); }
.inp { display: flex; align-items: center; gap: 6px; }
.inp input, .field select, .plans input, .row input[type="text"] {
  width: 100%; min-height: var(--tap); padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.inp .unit { font-size: 13px; color: var(--muted); min-width: 2em; }
.field input[type="range"] { width: 100%; min-height: var(--tap); accent-color: var(--blue); }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-size: 14px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--blue); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button {
  flex: 1 0 auto; min-height: var(--tap); padding: 0 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); cursor: pointer; font-size: 13.5px;
}
.seg button.on { background: var(--navy); color: var(--cream); border-color: var(--navy); font-weight: 700; }
.seg button:disabled { opacity: 0.45; cursor: not-allowed; }

button.primary, button.ghost, button.danger {
  min-height: var(--tap); padding: 0 16px; border-radius: 10px; cursor: pointer; font-weight: 700;
}
button.primary { background: var(--navy); color: var(--cream); border: none; }
button.gold { background: var(--gold); color: #1a3468; border: none; font-weight: 800; border-radius: 10px; cursor: pointer; }
button.gold.pulse { box-shadow: 0 0 0 3px rgba(245, 196, 64, 0.45); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.ghost { background: var(--surface); border: 1px solid var(--line); }
button.danger { background: var(--surface); color: var(--danger); border: 1px solid #e8b4b0; }
button.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
button.wide { width: 100%; margin-top: 8px; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.chips button { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }

.palette { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.palette button {
  display: flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 10px; text-align: left;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; font-size: 13.5px;
}
.palette button:hover { border-color: var(--gold); }
.sw { width: 14px; height: 14px; border-radius: 4px; flex: none; background: var(--sky); }
.sw[data-type="ac"], .sw[data-type="cassette"] { background: #e8eef7; border: 1px solid #9aa9c4; }
.sw[data-type="circulator"] { background: var(--gold); }
.sw[data-type="heater"] { background: #d9593f; }
.sw[data-type="pc"], .sw[data-type="laptop"], .sw[data-type="monitor"], .sw[data-type="console"], .sw[data-type="kettle"], .sw[data-type="heatsrc"], .sw[data-type="lamp"], .sw[data-type="tv"], .sw[data-type="fridge"] { background: #f08a5d; }
.sw[data-type="iwall"] { background: #e9e4cf; border: 1px solid #b8b29a; }
.sw[data-type="idoor"] { background: #a8825d; }
.sw[data-type="sit"], .sw[data-type="stand"] { background: #f2a88c; }
.sw[data-type="cutout"], .sw[data-type="pillar"] { background: #737a8c; }
.sw[data-type="window"], .sw[data-type="tallwindow"] { background: #9fd6f2; }
.sw[data-type="door"], .sw[data-type="bed"], .sw[data-type="table"], .sw[data-type="desk"], .sw[data-type="shelf"], .sw[data-type="chest"] { background: #a8825d; }

.total { display: flex; align-items: baseline; gap: 6px; }
.total .big { font-size: 44px; font-weight: 800; color: var(--ink); line-height: 1; }
.scores { list-style: none; padding: 0; margin: 10px 0 0; }
.scores li { display: grid; grid-template-columns: 7.5em auto; gap: 2px 8px; padding: 8px 0; border-top: 1px dashed var(--line); }
.scores .lab { font-weight: 700; font-size: 13.5px; }
.scores .stars { color: #c99000; letter-spacing: 1px; }
.scores .txt { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
.plans { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.plans li { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; }
.progress { height: 10px; border-radius: 5px; background: #e6e6cf; overflow: hidden; margin-top: 10px; }
.progress span { display: block; height: 100%; background: var(--blue); transition: width 0.3s; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-top: 12px; }
.card h3 { margin: 0 0 4px; font-size: 14px; }
.card p { margin: 0 0 6px; font-size: 13px; }
.tablewrap { overflow-x: auto; margin-top: 12px; }
table.cmp { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.cmp th, .cmp td { border: 1px solid var(--line); padding: 6px 8px; text-align: center; white-space: nowrap; background: var(--surface); }
.cmp th:first-child { text-align: left; }
.cmp td.best { background: var(--chip-on); font-weight: 800; }
.cmp tr.sum td, .cmp tr.sum th { font-weight: 800; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: var(--cream); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; max-width: calc(100vw - 32px); z-index: 10;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
dialog { border: none; border-radius: 16px; padding: 0; max-width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); color: var(--ink); background: var(--cream); }
dialog::backdrop { background: rgba(26, 46, 90, 0.6); }
.about { padding: 20px; line-height: 1.7; font-size: 14px; }
.about h2 { margin: 0 0 8px; font-size: 18px; }
.about h3 { margin: 16px 0 4px; font-size: 15px; border-left: 4px solid var(--gold); padding-left: 8px; }
.about ul, .about ol { padding-left: 1.3em; margin: 4px 0; }
.noscript { padding: 16px; }
.chart { position: relative; margin-top: 8px; }
.chart svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart svg .hit { cursor: pointer; }
.chart .ctip { position: absolute; top: 0; padding: 6px 8px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font-size: 12px; pointer-events: none; box-shadow: 0 2px 8px #0002; white-space: nowrap; }
.legend-row { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend-row .k { display: inline-flex; align-items: center; gap: 6px; }
.legend-row .ln { width: 18px; height: 0; border-top: 2px solid #2b6baf; }
.legend-row .ln.out { border-top: 2px dashed #d9822b; }
.legend-row .band { width: 14px; height: 10px; background: #e3e8f2; border-radius: 2px; }
.legend-row .bar { width: 10px; height: 10px; background: #e5a623; border-radius: 2px; }
table.hours { border-collapse: collapse; font-size: 12px; width: 100%; margin-top: 6px; }
.hours th, .hours td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: right; }
.hours th:first-child, .hours td:first-child { text-align: left; }
details.tbl summary { cursor: pointer; font-size: 13px; margin-top: 10px; min-height: 32px; }

.ok { font-size: 13px; color: var(--ok-ink); background: var(--ok-bg); border-radius: 8px; padding: 8px 10px; line-height: 1.5; }
.docline { margin: 0 0 4px; }
ul.lib { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 8px; }
ul.lib li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
ul.lib li.on { border-color: var(--gold); box-shadow: inset 4px 0 0 var(--gold); }
ul.lib .meta { display: flex; flex-direction: column; gap: 2px; }
ul.lib .meta .note { margin: 0; }
ul.lib .row { margin-top: 6px; }
table.clim { border-collapse: collapse; font-size: 13px; width: 100%; margin-top: 8px; }
.clim th, .clim td { border-bottom: 1px solid var(--line); padding: 5px 6px; text-align: left; }
.clim th { font-weight: 700; width: 9em; color: var(--muted); }
.shapewrap { margin-top: 8px; }
svg.shape { width: 100%; height: auto; max-height: 360px; display: block; touch-action: none; user-select: none; cursor: crosshair; }
svg.shape rect.fl { fill: var(--surface); stroke: var(--navy); stroke-opacity: 0.35; }
svg.shape rect.cut { fill: var(--cut); stroke: var(--cut); }
svg.shape rect.out { fill: var(--grid-out); stroke: var(--muted); stroke-opacity: 0.35; stroke-dasharray: 2 2; }
svg.shape rect.obj { fill: var(--blue); fill-opacity: 0.25; stroke: var(--blue); stroke-opacity: 0.6; pointer-events: none; }
svg.shape text.lbl { font-size: 11px; fill: var(--muted); pointer-events: none; }
.shape-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.shape-legend .k::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -2px; }
.shape-legend .fl::before { background: var(--surface); border: 1px solid var(--muted); }
.shape-legend .cut::before { background: var(--cut); }
.shape-legend .out::before { border: 1px dashed var(--muted); }
.shape-legend .obj::before { background: rgba(43, 107, 175, 0.35); border: 1px solid var(--blue); }

/* ダーク表示：粒の光が目立つよう、まわりを暗くする */
:root[data-theme="dark"] {
  --cream: #e9ebf2;
  --ink: #e6e9f2;
  --muted: #9aa4bb;
  --line: rgba(200, 210, 235, 0.16);
  --surface: #161c2b;
  --tabbar: #0f1420;
  --chip-on: #4a3f1a;
  --warn-bg: #3a2c10;
  --warn-ink: #f3cf7a;
  --ok-bg: #12321b;
  --ok-ink: #a6e3b4;
  --cut: #4b5366;
  --grid-out: transparent;
  --deep: #05070e;
  color: var(--ink);
  background: #0b0f19;
}
:root[data-theme="dark"] body { background: #0b0f19; }
:root[data-theme="dark"] .top { background: #0a0e18; border-bottom-color: #8a6d1f; }
:root[data-theme="dark"] .panel { background: #0f1420; }
:root[data-theme="dark"] .stage { background: #05070e; }
:root[data-theme="dark"] button.primary { background: #2b6baf; color: #fff; }
:root[data-theme="dark"] .seg button.on { background: #2b6baf; color: #fff; border-color: #2b6baf; }
:root[data-theme="dark"] .tabs button.on { background: var(--gold); color: #1a3468; }
:root[data-theme="dark"] .badge { background: rgba(20, 26, 40, 0.85); color: #cfd6e6; }
:root[data-theme="dark"] .tip, :root[data-theme="dark"] .toast { background: #1d2538; color: #eef1f7; }
:root[data-theme="dark"] dialog { background: #121827; color: var(--ink); }
:root[data-theme="dark"] .views button, :root[data-theme="dark"] .hud button:not(.play), :root[data-theme="dark"] .hud select { background: rgba(10, 14, 24, 0.8); }
:root[data-theme="dark"] .chart svg text { fill: #aeb7cc; }
:root[data-theme="dark"] .scores .stars { color: #f5c440; }

@media (max-width: 899px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 52px minmax(0, 56dvh) 1fr; grid-template-areas: "top" "stage" "panel"; }
  .top { padding: 0 12px; }
  .brand .sub { display: none; }
  .brand .name { font-size: 14px; }
  .top .docname { max-width: 9ch; }
  .top .long { display: none; }
  .top .short { display: inline; }
  .top .tools button { white-space: nowrap; padding: 0 9px; font-size: 12.5px; }
  .brand .name { white-space: nowrap; }
  .panel { border-left: none; border-top: 1px solid var(--line); }
  .legend { top: 52px; bottom: 70px; right: 8px; }
  .views { left: 8px; top: 8px; }
  .badge { right: 8px; top: 8px; font-size: 11px; }
  .hud { left: 8px; right: 8px; bottom: 8px; gap: 6px; }
  .hud .status { flex-basis: 100%; }
  .body { padding: 0 12px 24px; }
}
@media (max-width: 440px) {
  .brand .name { display: none; }
  .top .docname { max-width: 11ch; }
}
@media (prefers-reduced-motion: reduce) {
  .toast, .progress span { transition: none; }
}
:root[data-theme="dark"] .chart svg rect[fill="#e3e8f2"] { fill: #1f2940; }
:root[data-theme="dark"] .chart svg line[stroke="#e6e3cf"] { stroke: #2a3248; }

/* v1.6：視点の移動・湿度・窓の開け方 */
#gl.panning { cursor: move; }
.views button.on { background: var(--gold); color: #1a3468; border-color: var(--gold); font-weight: 800; }
.hud .rh { font-size: 12.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: rgba(26, 46, 90, 0.75); color: #fff; border: 1px solid rgba(255, 255, 255, 0.35); white-space: nowrap; }
.hud .rh.dry { background: #b8661b; border-color: #e7a35d; }
.hud .rh.ok { background: #2f7a43; border-color: #7cc48d; }
.hud .rh.damp { background: #2b6baf; border-color: #8cb8e6; }
.hud .rh.wet { background: #173f7a; border-color: #5ab9d0; }
.lbl.dew { background: #5ab9d0; color: #0b2440; }
.adv { border-radius: var(--radius); padding: 10px 12px; margin-top: 10px; border: 1px solid var(--line); background: var(--surface); }
.adv h3 { font-size: 13.5px; margin: 0 0 4px; }
.adv p { font-size: 13px; margin: 0; line-height: 1.6; }
.adv.good { border-left: 5px solid #3c8c4f; }
.adv.warn { border-left: 5px solid #d9822b; }
.adv.info { border-left: 5px solid var(--blue); }
table.cmp.wind td.l { text-align: left; white-space: normal; min-width: 10em; }
table.cmp tr.now th, table.cmp tr.now td { background: var(--chip-on); }
.rhline { font-weight: 700; margin: 8px 0 0; padding: 6px 10px; border-radius: 8px; }
.rhline.dry { background: #fbe9d2; color: #7a3f06; }
.rhline.ok { background: var(--ok-bg); color: var(--ok-ink); }
.rhline.damp { background: #e1ecf8; color: #1a3468; }
.rhline.wet { background: #d6e4f5; color: #102a55; }
h3.sub { font-size: 14px; margin: 16px 0 0; }
.legend-row .dot { width: 10px; height: 10px; border-radius: 50%; background: #1a3468; }
.legend-row .dot.out { background: transparent; border: 2px solid #d9822b; }
.legend-row .band.ok { background: #bfe3c6; }
.legend-row .drop { width: 8px; height: 8px; border-radius: 50%; background: #5ab9d0; }
:root[data-theme="dark"] .chart svg rect.band-ok { fill: #173322; }
:root[data-theme="dark"] .chart svg rect.band-wet { fill: #15233a; }
:root[data-theme="dark"] .chart svg rect.band-dry { fill: #33260f; }
:root[data-theme="dark"] .chart svg rect.zone { fill: #1f4a2a; }
:root[data-theme="dark"] .chart svg text.curlbl { fill: #e6e9f2; }
:root[data-theme="dark"] .rhline.dry { background: #3a2a14; color: #f3cf9a; }
:root[data-theme="dark"] .rhline.damp, :root[data-theme="dark"] .rhline.wet { background: #16253d; color: #cfe0f7; }
