/* 色はコゲラボ先輩ポケット（frontend/src/ui.js の GlobalStyle）に合わせる */
:root {
  --bg: #FAFAF9;
  --surface: #FFFFFF;
  --text: #18181B;
  --muted: #71717A;
  --border: #E7E5E4;
  --subtle: #F4F4F5;
  --accent: #EA580C;
  --accent-hover: #C2410C;
  --accent-soft: #FFF7ED;
  --accent-border: #FED7AA;
  --danger: #B91C1C;
  --danger-soft: #FEF2F2;
  --ok: #15803D;
  --ok-soft: #F0FDF4;
  --term-bg: #18181B;

  /* 構成図のリンク状態 */
  --link-full: #16A34A;
  --link-forming: #F59E0B;
  --link-noadj: #DC2626;
  --link-up: #94A3B8;
  --link-down: #D4D4D8;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Noto Sans JP', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
[hidden] { display: none !important; }
p { margin: 0; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
.muted { color: var(--muted); }

@keyframes kp-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.entry { animation: kp-rise .25s ease-out; }
@keyframes kp-spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 9999px;
  animation: kp-spin .7s linear infinite;
}
.kp-focusable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- ヘッダー ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(250, 250, 249, .85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 16px; height: 56px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); min-width: 0; border-radius: 6px; }
.brand img { width: 32px; height: 32px; object-fit: contain; }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.timer {
  font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600;
  background: var(--subtle); border-radius: 9999px; padding: 4px 12px;
}
.timer.done { background: var(--ok-soft); color: var(--ok); }

/* ---------- ボタン ---------- */
.btn {
  font: inherit; font-size: 14px; font-weight: 500; border-radius: 10px; padding: 8px 16px;
  cursor: pointer; border: 1px solid transparent; transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: #D6D3D1; background: #FAFAF9; }
.btn-ghost { background: transparent; color: var(--muted); padding: 6px 10px; }
.btn-ghost:hover { color: var(--text); background: var(--subtle); }
.btn-link { background: none; border: none; color: var(--muted); font-size: 13px; text-decoration: underline; cursor: pointer; padding: 4px; }
.btn-link:hover { color: var(--text); }

/* ---------- レイアウト ---------- */
.page { max-width: 880px; margin: 0 auto; padding: 24px 16px 48px; }
.page-wide { max-width: 1280px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }

/* ---------- 先輩の吹き出し ---------- */
.says { display: flex; align-items: flex-end; gap: 8px; }
.avatar { width: 56px; height: 56px; object-fit: contain; flex-shrink: 0; }
.avatar-lg { width: 80px; height: 80px; }
.bubble {
  position: relative; min-width: 0; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 10px 16px; font-size: 15px; line-height: 1.7;
}
.bubble::after {
  content: ""; position: absolute; left: -7px; bottom: 12px; width: 12px; height: 12px;
  background: inherit; transform: rotate(45deg);
  border-left: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.bubble-accent { background: var(--accent-soft); border-color: var(--accent-border); }
.bubble-accent::after { border-color: var(--accent-border); }
.bubble-explain { border: 1.5px solid #3F3F46; }
.bubble-explain::after { border-color: #3F3F46; border-width: 1.5px; }
.bubble-name { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 2px; }
.says-lg { margin-bottom: 24px; }

/* ---------- シナリオ一覧 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
#scenarioCards { display: grid; gap: 28px; }
.course-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.course-head h2 { font-size: 18px; }
.course-head .muted { font-size: 13px; }
.scenario-card {
  padding: 20px; display: flex; flex-direction: column; gap: 10px;
  transition: box-shadow .15s;
}
.scenario-card:hover { box-shadow: 0 4px 16px rgba(24, 24, 27, .06); }
.scenario-card h3 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.scenario-card p { font-size: 14px; color: var(--muted); line-height: 1.7; flex: 1; }
.scenario-card .btn { align-self: flex-start; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 700; border-radius: 9999px; padding: 2px 10px; white-space: nowrap; }
.badge-build { background: var(--accent-soft); color: var(--accent-hover); border: 1px solid var(--accent-border); }
.badge-incident { background: var(--danger-soft); color: var(--danger); border: 1px solid #FECACA; }
.badge-level { background: var(--subtle); color: #52525B; }
.badge-free { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }
.free-card { border-style: dashed; }

/* ---------- チケット ---------- */
.ticket { padding: 20px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: start; }
.ticket .bubble { margin-bottom: 0; }
.pre { white-space: pre-line; }
.ticket-title { font-size: 18px; font-weight: 700; margin: 6px 0 2px; letter-spacing: -.01em; }
.goal {
  display: inline-block; margin-top: 10px; font-size: 13px; font-weight: 500;
  background: var(--subtle); border-radius: 8px; padding: 6px 12px; white-space: normal;
}
.goal strong { color: var(--accent-hover); margin-right: 6px; }
.ticket-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-width: 190px; }
.ticket-actions .btn-link { align-self: center; }
.free-bar { padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.hint-list { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.hint-list:empty { display: none; }
.hint-list .says { margin-left: 8px; }

.check-card { margin-top: 12px; padding: 14px 20px; }
.check-card.ng { border-color: #FECACA; background: var(--danger-soft); }
.check-card h2 { margin-bottom: 8px; }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.check-list li { display: flex; gap: 8px; align-items: center; }
.mark { width: 20px; height: 20px; border-radius: 9999px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.mark.ok { background: var(--ok); }
.mark.ng { background: var(--danger); }

/* ---------- ラボ ---------- */
.lab-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; margin-top: 16px; }
.lab-left { display: grid; gap: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 0; flex-wrap: wrap; }
.legend { display: flex; gap: 12px; list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 18px; height: 4px; border-radius: 2px; display: inline-block; }
.swatch.full { background: var(--link-full); }
.swatch.forming { background: var(--link-forming); }
.swatch.noadj { background: var(--link-noadj); }
.swatch.up { background: var(--link-up); }
.swatch.down { background: repeating-linear-gradient(90deg, #A1A1AA 0 4px, transparent 4px 7px); }
.graph-card { min-width: 0; overflow: hidden; }
#graph { height: 300px; min-width: 0; position: relative; overflow: hidden; }

.detail-card { padding: 16px 20px; font-size: 14px; min-width: 0; }
.detail-card h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-card h3 { font-size: 12px; color: var(--muted); margin: 16px 0 6px; font-weight: 600; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 9999px; font-weight: 600; }
.pill.on { background: var(--ok-soft); color: var(--ok); }
.pill.off { background: var(--danger-soft); color: var(--danger); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 12px 6px 0; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
pre.routes {
  margin: 0; font: 12px/1.6 Consolas, "Cascadia Mono", monospace; white-space: pre; overflow-x: auto;
  background: var(--subtle); border-radius: 10px; padding: 10px 12px;
}
pre.routes .ospf { color: var(--link-full); font-weight: 600; }
pre.routes .static { color: #2563EB; font-weight: 600; }

.term-card { display: flex; flex-direction: column; overflow: hidden; min-height: 560px; background: var(--term-bg); border-color: var(--term-bg); }
.term-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; background: #27272A; padding-right: 8px; }
#tabs { display: flex; gap: 4px; padding: 8px 8px 0; flex-wrap: wrap; min-width: 0; }
.term-tools { display: flex; gap: 4px; padding: 6px 0; flex-shrink: 0; }
.tool {
  font: inherit; font-size: 12px; font-weight: 600; color: #D4D4D8; background: transparent;
  border: 1px solid #3F3F46; border-radius: 8px; padding: 4px 8px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.tool:hover { background: #3F3F46; color: #fff; }
.tool.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tool svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ターミナルを広く */
.lab-grid.wide-term { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
/* ターミナルを最大化（周りは暗くする） */
.term-card.maximized {
  position: fixed; inset: 16px; z-index: 60; min-height: 0;
  box-shadow: 0 0 0 100vmax rgba(24, 24, 27, .45), 0 20px 40px rgba(0, 0, 0, .3);
}
#tabs button {
  font: inherit; font-size: 13px; color: #A1A1AA; background: transparent; border: none; cursor: pointer;
  padding: 7px 12px; border-radius: 8px 8px 0 0; display: flex; align-items: center; gap: 8px;
}
#tabs button.active { background: var(--term-bg); color: #FAFAFA; }
#tabs .close { opacity: .6; }
#tabs .close:hover { opacity: 1; color: #FCA5A5; }
#terms { flex: 1; position: relative; min-height: 0; }
.term { position: absolute; inset: 0; padding: 10px; display: none; }
.term.active { display: block; }
.term-empty { color: #A1A1AA; padding: 20px; font-size: 14px; }

/* ---------- モーダル ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(24, 24, 27, .35);
  display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto;
}
.overlay-top { z-index: 70; } /* 最大化したターミナルより手前 */
.modal { padding: 24px; width: 100%; max-width: 440px; box-shadow: 0 20px 40px rgba(24, 24, 27, .15); margin: auto; }
.modal-wide { max-width: 640px; }
.modal-dialog { max-width: 500px; }
.modal .says + .says { margin-top: 12px; }

.result-stats { display: flex; gap: 8px; margin: 16px 0; }
.stat { flex: 1; background: var(--subtle); border-radius: 12px; padding: 10px 12px; text-align: center; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

@media (max-width: 960px) {
  .lab-grid { grid-template-columns: 1fr; }
  .ticket { grid-template-columns: 1fr; }
  .ticket-actions { flex-direction: row; flex-wrap: wrap; min-width: 0; }
  .brand-sub { display: none; }
  #toggleWide { display: none; }
  .tool span { display: none; }
}
@media (max-width: 520px) {
  .avatar-lg { width: 56px; height: 56px; }
  .bubble { font-size: 14px; }
}

/* ---------- 受講者の名前・環境の状態 ---------- */
.learner-name { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.env-banner { background: var(--danger-soft); border-bottom: 1px solid #FECACA; color: var(--danger); }
.env-banner-inner { max-width: 1280px; margin: 0 auto; padding: 10px 16px; font-size: 14px; font-weight: 500; }

/* ---------- 講師用（管理画面） ---------- */
.badge-admin { background: var(--text); color: #fff; }
.login-card { max-width: 440px; margin: 48px auto 0; padding: 24px; }
.field { display: grid; gap: 6px; margin-top: 16px; font-size: 13px; font-weight: 500; }
.input, .textarea {
  font: inherit; font-size: 14px; width: 100%; padding: 9px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(234, 88, 12, .12); }
.textarea { min-height: 140px; resize: vertical; line-height: 1.6; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 10px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { padding: 14px 16px; }
.stat-card b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-card span { font-size: 12px; color: var(--muted); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.updated { font-size: 12px; color: var(--muted); }

.table-card { overflow-x: auto; }
.learner-table { min-width: 960px; font-size: 13px; }
.learner-table th, .learner-table td { padding: 10px 12px; vertical-align: top; }
.learner-table th { background: #FAFAF9; position: sticky; top: 0; white-space: nowrap; }
.learner-table tr:last-child td { border-bottom: none; }
.learner-table .name { font-weight: 600; font-size: 14px; white-space: nowrap; }
.learner-table .cur-title { font-weight: 600; }
.learner-table .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cell-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.btn-sm { font-size: 12px; padding: 4px 10px; border-radius: 8px; }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { background: var(--danger-soft); color: var(--danger); }

.env-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; border-radius: 9999px; padding: 2px 10px; white-space: nowrap; }
.env-pill::before { content: ""; width: 7px; height: 7px; border-radius: 9999px; background: currentColor; }
.env-running { background: var(--ok-soft); color: var(--ok); }
.env-stopped { background: var(--subtle); color: var(--muted); }
.env-broken { background: var(--danger-soft); color: var(--danger); }
.env-working { background: var(--accent-soft); color: var(--accent-hover); }

.chip { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 8px; padding: 3px 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip-solved { background: var(--ok-soft); color: var(--ok); }
.chip-active { background: var(--accent-soft); color: var(--accent-hover); }
.chip-gaveup { background: var(--danger-soft); color: var(--danger); }
.chip-abandoned { background: var(--subtle); color: #52525B; }
.chip-none { color: #A1A1AA; font-weight: 500; }
.chip-sub { display: block; font-size: 11px; font-weight: 500; opacity: .8; margin-top: 1px; }

.empty-state { padding: 32px 16px; }
.history { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; max-height: 50vh; overflow-y: auto; }
.history li { display: flex; gap: 10px; align-items: center; padding: 8px 10px; background: var(--subtle); border-radius: 10px; }
.history .when { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.link-box { display: flex; gap: 6px; margin-top: 12px; }
.link-box .input { font-size: 12px; font-family: Consolas, "Cascadia Mono", monospace; }

/* ---------- 講師画面: タブ・シナリオ・リソース ---------- */
.tab-nav { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn {
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); background: none; border: none;
  padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent-hover); border-bottom-color: var(--accent); }
.tab-nav .spacer { flex: 1; }
.capacity-note { font-size: 13px; color: var(--muted); }
.capacity-note.warn { color: var(--danger); font-weight: 600; }

.scenario-table { min-width: 760px; font-size: 13px; }
.scenario-table th, .scenario-table td { padding: 10px 12px; vertical-align: top; }
.scenario-table th { background: #FAFAF9; white-space: nowrap; }
.scenario-table tr:last-child td { border-bottom: none; }
.scenario-table .title { font-weight: 600; font-size: 14px; }
.badge-source-builtin { background: var(--subtle); color: #52525B; }
.badge-source-custom { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }

.modal-editor { max-width: 900px; }
.code-area { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; min-height: 46vh; margin-top: 12px; white-space: pre; tab-size: 2; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
select.input { appearance: auto; }

.verify-card { padding: 16px 20px; margin-bottom: 16px; }
.verify-card h3 { margin: 0 0 10px; font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.verify-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 13px; }
.verify-steps li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; }
.verify-steps .mark.run { background: var(--accent); }
.verify-steps .mark.run::after { content: ""; }
.verify-steps .detail { color: var(--muted); white-space: pre-line; margin-top: 2px; }
.verify-steps .checks { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
#editorVerify .verify-card { margin: 12px 0 0; box-shadow: none; }

.res-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.res-card { padding: 18px 20px; }
.res-card h3 { margin: 0 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.res-big { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.res-big small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.res-sub { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.meter { height: 10px; border-radius: 9999px; background: var(--subtle); overflow: hidden; margin-top: 12px; display: flex; }
.meter span { display: block; height: 100%; }
.meter .m-lab { background: var(--accent); }
.meter .m-other { background: #A1A1AA; }
.meter .m-reserve { background: repeating-linear-gradient(45deg, #E4E4E7 0 4px, #F4F4F5 4px 8px); }
.meter-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.meter-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.res-wide { grid-column: 1 / -1; }

.badge-topology { background: #F5F3FF; color: #6D28D9; border: 1px solid #DDD6FE; }

/* ---------- SWG・CASB の演習パネル ---------- */
.sec-panel { margin-top: 16px; padding: 0; overflow: hidden; }
.sec-tabs { display: flex; gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid var(--border); background: #FAFAF9; flex-wrap: wrap; }
.sec-tab {
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); background: none; border: none; cursor: pointer;
  padding: 10px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.sec-tab.active { color: #0F766E; border-bottom-color: #0D9488; }
.sec-body { padding: 16px 20px 20px; }
.sec-caption { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 8px; }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-ng { background: var(--danger-soft); color: var(--danger); }
.chip-warn { background: #FFFBEB; color: #B45309; }

.sec-browser { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 16px; }
.sec-actions { display: grid; gap: 6px; align-content: start; }
.sec-action {
  font: inherit; font-size: 13px; text-align: left; cursor: pointer; border-radius: 10px; padding: 9px 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); display: flex; gap: 8px; align-items: center;
}
.sec-action:hover:not(:disabled) { border-color: #5EEAD4; background: #F0FDFA; }
.sec-action:disabled { opacity: .5; cursor: wait; }
.sec-action .method { font-size: 10px; font-weight: 700; background: var(--subtle); color: #52525B; border-radius: 4px; padding: 1px 5px; }
.sec-url { display: flex; gap: 6px; margin-top: 6px; }
.sec-url .input { font-size: 13px; padding: 7px 10px; }

.sec-window { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; min-height: 220px; background: var(--surface); }
.win-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #F4F4F5; border-bottom: 1px solid var(--border); }
.win-bar .dots { display: flex; gap: 5px; }
.win-bar .dots i { width: 10px; height: 10px; border-radius: 9999px; background: #D4D4D8; display: block; }
.win-url { flex: 1; min-width: 0; background: var(--surface); border-radius: 9999px; padding: 4px 12px; font-size: 13px; font-family: Consolas, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-url .lock { margin-right: 6px; }
.win-url .lock.off { color: var(--danger); }
.win-status { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 8px 14px; font-size: 12px; border-bottom: 1px solid var(--border); }
.win-body { padding: 24px; font-size: 14px; }
.win-page { padding: 18px 22px; }
.win-page h3 { margin: 0 0 8px; font-size: 18px; }
.win-page p { font-size: 14px; line-height: 1.7; }
.win-page.tenant_blocked h3, .win-page.swg_blocked h3 { color: #B45309; }
.win-error { padding: 22px; background: var(--danger-soft); }
.win-error b { color: var(--danger); font-size: 16px; }
.win-error p { margin-top: 8px; font-size: 14px; }

.flow { display: flex; align-items: center; gap: 0; margin-top: 18px; flex-wrap: wrap; row-gap: 8px; }
.flow-node {
  border: 1.5px solid var(--border); border-radius: 12px; padding: 10px 14px; background: var(--surface);
  display: grid; gap: 2px; text-align: center; min-width: 110px; font-size: 13px;
}
.flow-node.swg { border-color: #0D9488; background: #F0FDFA; }
.flow-node.swg.open { border-color: #EA580C; background: var(--accent-soft); }
.flow-node.swg.block { border-color: var(--danger); background: var(--danger-soft); }
.seg { flex: 1; min-width: 120px; position: relative; height: 34px; display: flex; align-items: center; justify-content: center; }
.seg::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 4px solid #0D9488; }
.seg.split::before { border-top-color: #EA580C; }
.seg.tunnel::before { border-top: 4px double #0D9488; border-top-width: 6px; }
.seg.broken::before { border-top: 4px dashed var(--danger); }
.seg.none::before { border-top: 3px dotted #D4D4D8; }
.seg span { white-space: nowrap; position: relative; background: var(--surface); padding: 2px 8px; font-size: 12px; font-weight: 600; border-radius: 9999px; border: 1px solid var(--border); }
.seg.broken span { color: var(--danger); border-color: #FECACA; }
.flow-notes { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 14px; font-size: 13px; }
.seen { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.seen li { background: var(--accent-soft); border: 1px solid var(--accent-border); color: var(--accent-hover); border-radius: 8px; padding: 3px 8px; font-size: 12px; font-weight: 600; }

.console-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.console-head div { display: grid; }
.console-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.console-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: #FCFCFB; }
.console-card h4 { margin: 0 0 10px; font-size: 14px; }
.textarea.small { min-height: 64px; font-family: Consolas, monospace; font-size: 13px; }
.switch { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { width: 38px; height: 22px; border-radius: 9999px; background: #D4D4D8; position: relative; transition: background .15s; flex-shrink: 0; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 9999px; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: #0D9488; }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.mdm-state { margin: 10px 0; font-size: 13px; }
.log-table { font-size: 12px; }
.log-table td { vertical-align: top; }

@media (max-width: 760px) {
  .sec-browser, .flow-notes { grid-template-columns: 1fr; }
}

/* ---------- GUI で操作する機器（ターミナルの代わりのタブ） ---------- */
#tabs .tab-kind { font-size: 10px; font-weight: 700; border-radius: 4px; padding: 1px 4px; background: #0D9488; color: #fff; }
#tabs .tab-kind.cli { background: #52525B; }
.term.gui-pane { background: var(--bg); color: var(--text); overflow-y: auto; padding: 14px 16px; font-size: 13px; }
.gui-loading { padding: 16px; color: var(--muted); }
.gui-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 10px; }
.gui-title { font-size: 15px; font-weight: 700; margin-top: 2px; }
.gui-head-actions { display: flex; gap: 6px; align-items: center; }
.gui-note { font-size: 12px; color: var(--muted); line-height: 1.6; margin-bottom: 10px; }
.gui-sub { font-size: 12px; font-weight: 700; color: var(--muted); margin: 14px 0 6px; }
.gui-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.gui-pane .input { font-size: 13px; padding: 6px 8px; border-radius: 8px; }
.gui-pane select.input { padding-right: 4px; }
.gui-log { margin: 0; font: 12px/1.5 Consolas, "Cascadia Mono", monospace; white-space: pre-wrap; word-break: break-all;
  background: #18181B; color: #E4E4E7; border-radius: 10px; padding: 10px 12px; max-height: 260px; overflow: auto; }
.gui-log.ng { border: 2px solid #FCA5A5; }
.gui-details { margin-top: 10px; }
.gui-details summary { cursor: pointer; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.gui-kv { display: grid; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.gui-kv div { display: flex; justify-content: space-between; gap: 12px; }
.gui-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 4px 10px; }
.gui-grid .field { margin-top: 6px; font-size: 12px; }
.gui-form { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.psk { display: flex; gap: 4px; }

.fw-rules { display: grid; gap: 8px; }
.fw-rule { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--ok); border-radius: 10px; padding: 8px 10px; }
.fw-rule.deny { border-left-color: var(--danger); }
.fw-rule.disabled { opacity: .55; }
.fw-rule.implicit { border-left-color: #A1A1AA; display: flex; gap: 10px; align-items: center; background: var(--subtle); }
.fw-rule-top { display: flex; gap: 8px; align-items: center; }
.fw-no { width: 22px; height: 22px; border-radius: 9999px; background: var(--subtle); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.fw-name { flex: 1; min-width: 80px; font-weight: 600; }
.fw-action { width: auto; }
.fw-hits { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.fw-rule-body { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: flex-end; margin-top: 8px; }
.fw-rule-body label { display: grid; gap: 3px; font-size: 11px; color: var(--muted); align-content: end; }
.fw-rule-body label.pair { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); flex: 1 1 260px; }
.fw-rule-body label span { grid-column: 1 / -1; }
.fw-rule-body label .input { min-width: 0; }
.fw-move { margin-left: auto; display: flex; gap: 2px; }

.vpn-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; align-items: center;
  border: 1px solid var(--border); border-left: 4px solid var(--danger); border-radius: 12px; padding: 10px 14px; background: var(--surface); margin-bottom: 10px; }
.vpn-status.up { border-left-color: var(--ok); }
.vpn-status.half { border-left-color: #F59E0B; }
.vpn-status div { display: grid; gap: 2px; font-size: 12px; }
.vpn-buttons { display: flex !important; gap: 4px; justify-content: flex-end; }

form.diag { display: flex; gap: 6px; }
form.diag .input[name="target"] { flex: 1; min-width: 0; }
form.diag + .gui-log { margin-top: 8px; }

.course-filter { width: auto; font-size: 13px; padding: 7px 10px; }

/* ---------- GW・AP の GUI ---------- */
.gui-rows { display: grid; gap: 6px; margin-bottom: 8px; }
.gui-row { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: flex-end; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.gui-row label { display: grid; gap: 3px; font-size: 11px; color: var(--muted); flex: 1 1 120px; }
.gui-row label.switch { flex: 0 0 auto; display: flex; color: var(--text); padding-bottom: 6px; }
.gui-row .w-num { width: 70px; }
.gui-row label:has(.w-num) { flex: 0 0 auto; }
.gui-row .w-name { min-width: 70px; }
.switch.small span { width: 32px; height: 18px; }
.switch.small span::after { width: 12px; height: 12px; }
.switch.small input:checked + span::after { transform: translateX(14px); }
.gui-table { font-size: 12px; background: var(--surface); border-radius: 10px; }
.wifi-join { gap: 6px; }
.wifi-join select { flex: 1; }

/* ---------- コース・講師アカウント ---------- */
.badge-course { background: #FFF7ED; color: #C2410C; border: 1px solid #FED7AA; }
.field-hint { font-size: 12px; font-weight: 400; color: var(--muted); }
.field-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.field-inline select { width: auto; min-width: 220px; }
.field-inline .muted { font-size: 12px; font-weight: 400; }
.field-row:has(> :nth-child(3)) { grid-template-columns: 1fr 1fr 1fr; }
.otp-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 20px; letter-spacing: .3em; text-align: center; }
.totp-setup { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.totp-qr { width: 180px; height: 180px; padding: 8px; background: #FFFFFF; border: 1px solid var(--border); border-radius: 12px; flex-shrink: 0; }
.totp-qr svg { width: 100%; height: 100%; display: block; }
.totp-key { display: grid; gap: 6px; font-size: 12px; min-width: 0; flex: 1; }
.totp-key code { font-size: 14px; word-break: break-all; background: #FAFAF9; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
@media (max-width: 640px) { .field-row:has(> :nth-child(3)) { grid-template-columns: 1fr; } }

/* ---------- 受講用リンクの管理 ---------- */
.access-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.access-grid { display: grid; gap: 0; margin-top: 16px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.access-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; font-size: 13px; flex-wrap: wrap; }
.access-row + .access-row { border-top: 1px solid var(--border); }
.access-row .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.access-row > div:first-child { flex: 1; min-width: 220px; }
.input-date { width: auto; padding: 6px 10px; font-size: 13px; }
