/* ElevatorSim — 配色は docs/design.md と対応 */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #FFFFFF;
  --surface: #F6F8FB;
  --line: #E1E6EE;
  --primary: #00489D;
  --primary-soft: #E6EEF8;
  --text: #1F2937;
  --muted: #6B7280;
  --warn: #D97706;
  --danger: #DC2626;
  --ok: #059669;
  --ui: "Yu Gothic UI", "Yu Gothic", "Meiryo", "Hiragino Sans", system-ui, sans-serif;
  --mono: Consolas, "Cascadia Mono", "BIZ UDGothic", Menlo, monospace;
}

html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font-family: var(--ui); font-size: 14px; line-height: 1.5;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
kbd { font: 12px var(--ui); color: var(--muted); margin-left: 8px; }

/* ---------- 上部バー ---------- */
.topbar {
  flex: none; min-height: 56px; padding: 8px 16px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--muted); text-decoration: none; font-size: 12px; }
.brand img { display: block; border-radius: 4px; }
.brand:hover { color: var(--text); }
.topbar h1 { margin: 0; font-size: 16px; font-weight: 700; }
.clock { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.run-state { font-size: 12px; color: var(--muted); min-width: 64px; }
.run-state.paused { color: var(--warn); }

.toolbar { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.toolbar button {
  height: 32px; padding: 0 13px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--bg); cursor: pointer; white-space: nowrap;
}
.toolbar button:hover { background: var(--primary-soft); }
.toolbar button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.toolbar button.active kbd { color: rgba(255, 255, 255, 0.8); }
button:focus-visible, input:focus-visible, canvas:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- 本体 ---------- */
.layout {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(380px, 40%) 1fr;
}
.editor-pane {
  min-width: 0; min-height: 0; display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
}
.view-pane { min-width: 0; min-height: 0; position: relative; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.pane-head {
  flex: none; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.file-tabs { display: flex; gap: 2px; align-self: stretch; margin: -8px 0 -9px -12px; }
.file-tab {
  padding: 0 14px; border: none; border-bottom: 2px solid transparent; background: none; cursor: pointer;
  font: 13px var(--mono); color: var(--muted);
}
.file-tab:hover { color: var(--text); background: var(--primary-soft); }
.file-tab.active { color: var(--text); background: var(--bg); border-bottom-color: var(--primary); }
.name-field { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.name-field input {
  width: 130px; height: 28px; padding: 0 8px; font-size: 13px; color: var(--primary);
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg);
}
.run-btn {
  margin-left: auto; height: 32px; padding: 0 14px; border-radius: 6px;
  border: 1px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer; white-space: nowrap;
}
.run-btn kbd { color: rgba(255, 255, 255, 0.75); }
.run-btn:hover:not(:disabled) { background: #003B82; }
.run-btn:disabled { opacity: 0.55; cursor: default; }
.ghost-btn {
  height: 32px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); cursor: pointer;
}
.ghost-btn:hover:not(:disabled) { background: var(--primary-soft); }
.ghost-btn:disabled { opacity: 0.5; cursor: default; }
.ghost-btn.danger { color: var(--danger); }

.editor-wrap { flex: 1; min-height: 120px; position: relative; display: flex; flex-direction: column; }
.editor { flex: 1; min-height: 0; overflow: hidden; }
.editor[hidden] { display: none; }
.editor .cm-editor { height: 100%; }
/* 編集できない場所を書き換えようとしたときの知らせ */
.ro-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  padding: 7px 14px; border-radius: 17px; white-space: nowrap; pointer-events: none;
  background: rgba(31, 41, 55, 0.92); color: #fff; font-size: 13px; box-shadow: 0 4px 14px rgba(15, 23, 42, 0.2);
}
.ro-hint[hidden] { display: none; }

.output {
  flex: none; max-height: 34%; overflow: auto;
  border-top: 1px solid var(--line); padding: 8px 12px;
}
.output-head { display: flex; align-items: center; gap: 12px; }
.build-status { font-size: 13px; color: var(--muted); }
.build-status.ok { color: var(--ok); }
.build-status.err { color: var(--danger); }
.build-status.busy { color: var(--primary); }
.link-btn { margin-left: auto; border: none; background: none; padding: 0; font-size: 12px; color: var(--muted); text-decoration: underline; cursor: pointer; }
.link-btn:hover { color: var(--text); }
.problems { list-style: none; margin: 6px 0 0; padding: 0; }
.problems:empty { display: none; }
.problems li {
  display: flex; gap: 8px; padding: 4px 6px; border-radius: 4px; cursor: pointer;
  font: 12.5px/1.5 var(--mono); overflow-wrap: anywhere;
}
.problems li:hover { background: var(--surface); }
.problems .loc { flex: none; color: var(--muted); min-width: 52px; }
.problems .error { color: var(--danger); }
.problems .warning { color: var(--warn); }
.log {
  margin: 6px 0 0; padding: 6px 8px; max-height: 120px; overflow: auto;
  font: 12.5px/1.45 var(--mono); background: var(--surface); border-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.send-note { flex: none; margin: 0; padding: 6px 12px 8px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); }

/* ---------- ダイアログ ---------- */
.dlg {
  width: min(820px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--line); border-radius: 12px; color: var(--text);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
}
.dlg[open] { display: flex; flex-direction: column; }
.dlg::backdrop { background: rgba(15, 23, 42, 0.35); }
.dlg-head { flex: none; display: flex; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.dlg-close { margin-left: auto; width: 32px; height: 32px; border: none; background: none; border-radius: 6px; cursor: pointer; color: var(--muted); }
.dlg-close:hover { background: var(--surface); color: var(--text); }
.dlg-body { overflow: auto; padding: 4px 20px 20px; }
.dlg-body h3 { margin: 20px 0 8px; font-size: 15px; font-weight: 600; }
.dlg-body h4 { margin: 14px 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.dlg-body p, .dlg-body ul { margin: 8px 0; }
.dlg-body ul { padding-left: 20px; }
.dlg-body li { margin: 3px 0; }
.dlg-body code, .dlg-body pre { font-family: var(--mono); font-size: 13px; }
.dlg-body code { background: var(--surface); padding: 1px 5px; border-radius: 4px; }
.dlg-body pre { background: var(--surface); padding: 10px 12px; border-radius: 6px; overflow: auto; }
.doc table { border-collapse: collapse; width: 100%; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 5px 10px 5px 0; border-bottom: 1px solid var(--line); font-weight: 400; }
.doc th { white-space: nowrap; width: 1%; padding-right: 18px; }
.muted { color: var(--muted); font-size: 12.5px; }

.eval-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.eval-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.eval-form input { height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; color: var(--text); }
#eval-seeds { width: 180px; }
#eval-seconds { width: 90px; }
.eval-form .run-btn { margin-left: 0; }
.table-wrap { overflow: auto; max-height: 260px; border: 1px solid var(--line); border-radius: 8px; }
.table-wrap:has(table:empty) { display: none; }
.grid { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.grid th, .grid td { padding: 6px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.grid th { position: sticky; top: 0; background: var(--surface); font-weight: 600; color: var(--muted); }
.grid td.l, .grid th.l { text-align: left; }
.grid tr.mean td { background: var(--surface); font-weight: 600; }
.grid tr:last-child td { border-bottom: none; }

/* ---------- 狭い画面 ---------- */
@media (max-width: 900px) {
  body { overflow: auto; }
  .layout { grid-template-columns: 1fr; grid-template-rows: 460px auto; }
  .view-pane { order: -1; border-bottom: 1px solid var(--line); }
  .editor-pane { border-right: none; }
  .editor-wrap { min-height: 360px; }
  .output { max-height: none; }
  .toolbar { margin-left: 0; justify-content: flex-start; }
  kbd { display: none; }
}
