/* STRANAH UXモック — 白黒グレーのワイヤーフレーム表示（装飾は最小限） */
:root {
  --fg: #111;
  --muted: #666;
  --line: #bbb;
  --bg: #fff;
  --soft: #f3f3f3;
  --soft2: #e4e4e4;
  font-family: system-ui, "Yu Gothic UI", "Meiryo", "Hiragino Sans", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--fg); background: var(--bg); font-size: 14px; line-height: 1.55; }
a { color: #111; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--soft); padding: 0 3px; }
small { font-size: 12px; }
.muted { color: var(--muted); }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 8px; }
h2 small, h1 small { font-weight: normal; color: var(--muted); margin-left: 6px; }
h3 { font-size: 13px; margin: 0 0 6px; }

/* ヘッダー */
#app-header {
  display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; justify-content: space-between;
  padding: 8px 16px; border-bottom: 2px solid #111; background: #fafafa; position: sticky; top: 0; z-index: 10;
}
.brand a { font-weight: 700; text-decoration: none; letter-spacing: .06em; }
.mock-badge { border: 1px dashed #111; padding: 1px 6px; font-size: 12px; margin-left: 8px; background: #fff; }
.ctx { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.ctx label { display: inline-flex; gap: 4px; align-items: center; }

/* レイアウト */
.layout { display: flex; min-height: calc(100vh - 48px); }
#sidebar { width: 210px; flex: none; border-right: 1px solid var(--line); padding: 12px 8px; background: var(--soft); }
#sidebar[hidden] { display: none; }
.side-env { padding: 4px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.side-item { display: block; padding: 6px 10px; text-decoration: none; border-left: 3px solid transparent; }
.side-item:hover { background: var(--soft2); }
.side-item.active { border-left-color: #111; font-weight: 700; background: #fff; }
.acc { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 6px 10px; font: inherit; font-weight: 600; cursor: pointer; }
.acc:hover { background: var(--soft2); }
.acc-body .side-item { padding-left: 28px; }
.side-foot { margin-top: 16px; padding: 8px 10px; border-top: 1px solid var(--line); font-size: 12px; }
main { flex: 1; min-width: 0; padding: 14px 24px 24px; outline: none; }

/* 共通部品 */
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.crumbs .sep { margin: 0 4px; }
.page-head { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.page-head .sub { margin: 4px 0 0; color: #333; }
.head-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.card { border: 1px solid var(--line); padding: 12px 14px; margin: 0 0 12px; background: #fff; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-bottom: 12px; }
.grid2 > .card { margin: 0; }
.danger-zone { border: 2px solid #111; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.empty { color: var(--muted); padding: 8px 0; margin: 0; }
.note { border-left: 4px solid #999; background: var(--soft); padding: 6px 10px; margin: 0 0 12px; }
.note.exempt { border-left-style: dashed; }
.note.investigate { border-left-color: #111; font-weight: 600; }
.note.warn { border-left-color: #111; }
.tag { display: inline-block; border: 1px solid #777; padding: 0 5px; font-size: 11px; background: #fff; margin-left: 4px; white-space: nowrap; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 3px 0; border-bottom: 1px dotted var(--line); }

.btn, button {
  display: inline-block; font: inherit; font-size: 13px; padding: 4px 10px; border: 1px solid #111; background: #fff; color: #111;
  text-decoration: none; cursor: pointer; border-radius: 2px; line-height: 1.4;
}
.btn:hover, button:hover { background: var(--soft2); }
.btn.primary, button.primary { background: #111; color: #fff; }
.btn.primary:hover, button.primary:hover { background: #333; }
button.danger, .btn.danger { border-width: 2px; font-weight: 700; }
.btn.small, button.small { font-size: 12px; padding: 2px 7px; }
button:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 2px solid #111; outline-offset: 2px; }

.badge { display: inline-block; padding: 0 6px; border: 1px solid #111; border-radius: 2px; font-size: 12px; white-space: nowrap; background: #fff; }
.b-bad { background: #111; color: #fff; }
.b-warn { background: #d6d6d6; font-weight: 700; }
.b-busy { border-style: dashed; }
.b-muted { color: #666; border-color: #999; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
th { background: var(--soft); font-weight: 600; font-size: 12px; white-space: nowrap; }
td.actions { white-space: nowrap; }
/* インフラ一覧: 長いクラウドサービス名は折り返す */
.infra-table td.prod { min-width: 8em; max-width: 14em; overflow-wrap: anywhere; }
tr.sev-error td:first-child { border-left: 4px solid #111; }
tr.sev-warning td:first-child { border-left: 4px double #777; }
dl.kv { display: grid; grid-template-columns: 150px 1fr; gap: 4px 12px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }

/* タブ */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 2px solid #111; margin: 0 0 12px; }
.tab { padding: 5px 12px; text-decoration: none; border: 1px solid var(--line); border-bottom: 0; background: var(--soft); }
.tab.active { background: #111; color: #fff; border-color: #111; font-weight: 700; }

/* フォーム */
form.stack { display: grid; gap: 8px; max-width: 640px; }
form.stack label { display: grid; gap: 2px; }
form.inline { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
form.inline label { display: grid; gap: 2px; }
label.check { display: flex !important; gap: 6px; align-items: center; }
input, select, textarea { font: inherit; font-size: 13px; padding: 4px 6px; border: 1px solid #777; background: #fff; color: #111; }
textarea { resize: vertical; }
.form-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
fieldset.testctl { border: 1px dashed #777; padding: 6px 10px; display: grid; gap: 6px; }
fieldset.testctl legend { font-size: 12px; color: var(--muted); }
.radio-card { display: block !important; border: 1px solid var(--line); padding: 8px 10px; cursor: pointer; }
.toolbar-inline { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 8px; }
.mask { letter-spacing: 2px; }

/* ログ */
ol.log { list-style: none; margin: 0; padding: 8px; background: #f7f7f7; border: 1px solid var(--line); font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; max-height: 480px; overflow: auto; }
ol.log li { padding: 1px 4px; white-space: pre-wrap; word-break: break-all; }
ol.log time { color: var(--muted); }
ol.log li.lv-WARN b { text-decoration: underline; }
ol.log li.lv-ERROR { background: #e2e2e2; }
ol.log li.lv-ERROR b { background: #111; color: #fff; padding: 0 3px; }
ol.log li.hl { outline: 2px solid #111; outline-offset: -2px; }

/* 構成図 */
.diagram-wrap { display: flex; gap: 12px; align-items: flex-start; }
.diagram { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 10px; min-width: 0; }
.layer { border: 1px dashed #999; padding: 8px; display: grid; gap: 8px; align-content: start; }
.node { display: grid; gap: 2px; border: 1px solid #111; padding: 6px 8px; text-decoration: none; background: #fff; }
.node:hover { background: var(--soft2); }
.node.attention { border-width: 3px; }
.node.selected { background: #111; color: #fff; }
.node.selected .badge { color: #111; }
.drawer { width: 360px; flex: none; border: 2px solid #111; padding: 10px 12px; background: #fff; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.drawer form.stack { max-width: none; }

/* ヘッダーのパンくず（組織 › プロジェクト › 環境 › 画面） */
.header-crumbs { font-size: 13px; }
.header-crumbs .sep { color: var(--muted); margin: 0 2px; }
.header-crumbs [aria-current] { font-weight: 700; }

/* サイドバー（正本 app-sidebar の階層: プロジェクト一覧 → PROJECT → ENVIRONMENT） */
.side-org { padding: 2px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.side-org a { text-decoration: none; }
.side-gear { float: right; border: 1px solid var(--line); padding: 0 6px; background: #fff; }
.side-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--muted); padding: 12px 10px 4px; border-top: 1px solid var(--line); margin-top: 8px; }
.side-switch { display: block; padding: 2px 6px 6px; }
.side-heading { font-size: 12px; font-weight: 700; padding: 8px 10px 2px; border-bottom: 1px dotted var(--line); margin: 4px 6px 2px; }
.bg-table { width: auto; margin: 4px 0; }
.bg-table th, .bg-table td { padding: 2px 10px; }
ol.plain-steps { margin: 4px 0 6px; padding-left: 20px; }
.side-switch select { width: 100%; }
.side-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; background: #111; color: #fff; border-radius: 9px; font-size: 11px; text-align: center; font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* プロジェクト一覧・概要の環境行 */
.proj-card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.proj-card-head h2 { font-size: 16px; margin: 0; }
.env-list { display: grid; gap: 6px; }
.env-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; border: 1px solid var(--line); padding: 8px 12px; text-decoration: none; background: #fff; }
.env-row:hover { background: var(--soft); border-color: #111; }
.env-row-sub { grid-column: 1; font-size: 12px; }
.env-row-go { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-weight: 700; }

/* 構成図（SVG、全幅） */
.dg-wrap { position: relative; border: 1px solid #111; background: #fff; height: max(460px, calc(100vh - 330px)); overflow: hidden; }
.dg-svg { width: 100%; height: 100%; display: block; }
.dg-legend { position: absolute; top: 6px; left: 8px; z-index: 2; font-size: 11px; background: rgba(255, 255, 255, .92); border: 1px solid var(--line); padding: 3px 8px; }
.dg-boundary > rect { fill: none; stroke: #888; stroke-width: 1.5; stroke-dasharray: 8 4; }
.dg-boundary.att > rect { stroke: #111; stroke-width: 3; }
.dg-blabel rect { fill: #f3f3f3; stroke: #888; }
.dg-blabel text { font-size: 12px; font-weight: 700; fill: #111; }
.dg-blabel:hover rect, .dg-boundary.sel .dg-blabel rect { fill: #111; }
.dg-blabel:hover text, .dg-boundary.sel .dg-blabel text { fill: #fff; }
.dg-edge { fill: none; stroke: #111; stroke-width: 1.8; }
.dg-edge.dashed { stroke: #777; stroke-dasharray: 6 4; }
.dg-node rect { fill: #fff; stroke: #111; stroke-width: 1.5; }
.dg-node.att rect, .dg-svc.att rect { stroke-width: 4; }
.dg-node.off rect { fill: #ececec; stroke-dasharray: 4 3; }
.dg-node.sel rect { fill: #111; }
.dg-node.sel text { fill: #fff; }
.dg-node:hover rect, .dg-svc:hover rect { fill: #e4e4e4; }
.dg-svc rect { fill: #fafafa; stroke: #111; stroke-width: 1.5; }
.dg-synth rect { fill: #fff; stroke: #777; stroke-dasharray: 3 3; }
.dg-t { font-size: 13px; font-weight: 700; fill: #111; }
.dg-s { font-size: 11px; fill: #444; }
.dg-mark { font-size: 16px; font-weight: 900; fill: #111; }
.dg-svg a:focus-visible rect { stroke: #111; stroke-width: 4; stroke-dasharray: 2 2; }
/* 右パネルは構成図の上に重ねる（Railway 風）。図の幅・縮尺・位置は開閉・タブ切替・幅調整で変わらない。
   パネルの中だけがスクロールし、パネルの外の図はそのまま見えてクリックできる。 */
.dg-drawer { position: absolute; top: 0; right: 0; bottom: 0; z-index: 3; width: 380px; max-width: 100%; overflow: auto; overscroll-behavior: contain; box-shadow: -6px 0 16px rgba(0, 0, 0, .18); }
.dg-drawer h2:focus { outline: 2px dashed #111; outline-offset: 2px; }
/* 右パネル表示中は図を左側に縮めて全体を見せ続ける */
/* 幅広パネル（幅はドラッグ／キーボードで調整。変わるのはパネルの幅だけで、図は縮めない） */
.dg-drawer.wide { padding-left: 18px; }
.dg-resize { position: absolute; left: 0; top: 0; bottom: 0; width: 10px; cursor: ew-resize; background: repeating-linear-gradient(0deg, #ddd 0 4px, #fff 4px 8px); border-right: 1px solid #999; touch-action: none; }
.dg-resize:hover, .dg-resize:focus-visible { background: #111; }
.dg-drawer.wide ol.log { max-height: 360px; }
.stage-switch { display: flex; flex-wrap: wrap; gap: 4px; }
/* メトリクス（ダミーデータの簡易グラフ） */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin-top: 8px; }
.metric { margin: 0; border: 1px solid var(--line); padding: 6px 8px; }
.metric-svg { width: 100%; height: auto; display: block; }
.metric-svg .axis { stroke: #999; stroke-width: 1; }
.metric-svg .line { fill: none; stroke: #111; stroke-width: 2; }
.metric-svg .tick { font-size: 9px; fill: #555; }
.dg-svc.sel rect { fill: #111; }
.dg-svc.sel text { fill: #fff; }

.stepper { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 12px; }
.stepper li { border: 1px solid var(--line); padding: 3px 10px; background: var(--soft); }
.stepper li.current { background: #111; color: #fff; border-color: #111; }
.preview { margin-top: 8px; border-top: 1px dotted var(--line); padding-top: 6px; }

/* モーダル・トースト */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border: 2px solid #111; width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 14px 16px; }
.modal h2 { font-size: 16px; }
.modal-body { margin: 8px 0; display: grid; gap: 8px; }
.modal-body label { display: grid; gap: 2px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
#toast { position: fixed; right: 16px; top: 60px; display: grid; gap: 6px; z-index: 60; max-width: 420px; }
.toast-item { background: #111; color: #fff; padding: 8px 12px; font-size: 13px; }

/* レビュー用ツールバー（テスト用） */
#reviewer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #ececec; border-top: 2px dashed #111;
  padding: 6px 12px; font-size: 12px; max-height: 48vh; overflow: auto;
}
#reviewer button { font-size: 12px; padding: 2px 8px; }
#reviewer select { font-size: 12px; padding: 1px 4px; max-width: 360px; }
.rt-row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding: 2px 0; }
.rt-trace { color: #333; }
.rt-trace .silent { color: var(--muted); font-style: italic; }
.rt-eval { font-weight: 700; }
.rt-demo { border-top: 1px solid #aaa; margin-top: 4px; padding-top: 4px; }
.rt-demo .hint { margin: 0 0 2px; }

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  #sidebar { width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .diagram-wrap { flex-direction: column; }
  .drawer { width: 100%; }
  .dg-drawer.wide { width: 100% !important; padding-left: 12px; }
  .dg-resize { display: none; }
  .diagram { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  main { padding: 12px; }
}
