/* ============================================================
   箱庭研究所 — Arca Hortus Laboratory
   実験部門アクセスターミナル スタイルシート
   ============================================================ */

:root {
  --bg-0: #030906;
  --bg-1: #04100b;
  --bg-2: #071a12;
  --panel: rgba(8, 26, 18, 0.72);
  --line: rgba(77, 255, 166, 0.18);
  --line-strong: rgba(77, 255, 166, 0.45);
  --green: #4dffa6;
  --green-dim: #2a9d6f;
  --green-pale: #b4ffd9;
  --amber: #ffc36b;
  --magenta: #ff5fd2;
  --text: #d8f3e6;
  --text-dim: #7fae99;
  --mono: 'JetBrains Mono', monospace;
  --serif: 'Noto Serif JP', serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: radial-gradient(ellipse at 50% -10%, var(--bg-2), var(--bg-0) 65%);
  color: var(--text);
  font-family: var(--serif);
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}

::selection { background: rgba(77, 255, 166, 0.3); color: #fff; }

/* ===== 背景キャンバス ===== */
#lab-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ===== CRTオーバーレイ（走査線＋ヴィネット） ===== */
.crt-overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.14) 0px,
      rgba(0, 0, 0, 0.14) 1px,
      transparent 1px,
      transparent 3px
    );
}
.crt-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

/* ===== 起動シーケンス ===== */
#boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #020604;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.7s ease, visibility 0.7s;
}
#boot-overlay.done {
  opacity: 0;
  visibility: hidden;
}
.boot-terminal {
  width: min(640px, 90vw);
  font-family: var(--mono);
  font-size: clamp(0.7rem, 2.4vw, 0.85rem);
  color: var(--green);
  text-shadow: 0 0 8px rgba(77, 255, 166, 0.6);
}
#boot-lines {
  white-space: pre-wrap;
  min-height: 14em;
  font-family: inherit;
}
#boot-lines .cursor {
  display: inline-block;
  width: 0.6em;
  height: 1em;
  background: var(--green);
  vertical-align: -0.15em;
  animation: blink 0.9s steps(1) infinite;
}
.boot-skip {
  margin-top: 1.5em;
  color: var(--text-dim);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  animation: blink 1.6s steps(1) infinite;
  text-align: center;
}
@keyframes blink { 50% { opacity: 0; } }

/* pre-boot中は本文を隠す */
body.pre-boot main,
body.pre-boot .lab-header,
body.pre-boot .lab-footer { visibility: hidden; }

/* ===== 出現アニメーション ===== */
.reveal {
  opacity: 0;
  transform: translateY(24px);
}
body.booted .reveal {
  animation: rise 0.9s ease forwards;
  animation-delay: var(--d, 0s);
}
@keyframes rise {
  to { opacity: 1; transform: translateY(0); }
}
/* スクロール出現（JS制御） */
.reveal.on-scroll { animation: none; opacity: 0; transform: translateY(24px); transition: opacity 0.8s ease, transform 0.8s ease; transition-delay: var(--d, 0s); }
.reveal.on-scroll.visible { opacity: 1; transform: translateY(0); }

/* ===== ヘッダー ===== */
.lab-header {
  position: relative;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px 28px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(4, 16, 11, 0.85), rgba(4, 16, 11, 0.4));
  backdrop-filter: blur(6px);
}
.return-link {
  color: var(--green);
  text-decoration: none;
  transition: color 0.3s, text-shadow 0.3s;
}
.return-link:hover {
  color: var(--green-pale);
  text-shadow: 0 0 12px rgba(77, 255, 166, 0.8);
}
.return-link .jp { color: var(--text-dim); }
.facility-id { color: var(--text-dim); }

/* ===== メイン ===== */
main {
  position: relative;
  z-index: 3;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ===== ヒーロー ===== */
.hero {
  position: relative;
  text-align: center;
  padding: 40px 0 30px;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* 次元炉コア */
.core-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(560px, 96vw);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.9;
}
.core { width: 100%; height: 100%; overflow: visible; }

.core-pulse { animation: corePulse 4s ease-in-out infinite; transform-origin: 200px 200px; }
@keyframes corePulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.18); opacity: 1; }
}
.core-heart {
  fill: var(--green-pale);
  filter: drop-shadow(0 0 12px var(--green));
  animation: heartBeat 4s ease-in-out infinite;
  transform-origin: 200px 200px;
}
@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.5); }
}

.ring { transform-origin: 200px 200px; }
.ring-slow { animation: spin 46s linear infinite; }
.ring-mid  { animation: spin 30s linear infinite reverse; }
.ring-fast { animation: spin 18s linear infinite; }
.ring-rev  { animation: spin 70s linear infinite reverse; }
@keyframes spin { to { transform: rotate(360deg); } }

.ring-dashed {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1;
  stroke-dasharray: 4 10;
}
.ring-arc {
  fill: none;
  stroke: var(--green);
  stroke-width: 2;
  stroke-dasharray: 140 690;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px var(--green));
}
.ring-thin { fill: none; stroke: var(--line); stroke-width: 1; }
.ring-faint { fill: none; stroke: rgba(77, 255, 166, 0.08); stroke-width: 1; }
.ring-node {
  fill: var(--green);
  filter: drop-shadow(0 0 5px var(--green));
}
.glyph-text {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.42em;
  fill: rgba(77, 255, 166, 0.55);
}
.glyph-outer { font-size: 10px; fill: rgba(127, 174, 153, 0.4); }

/* ヒーローテキスト */
.hero-over {
  position: relative;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.5em;
  color: var(--text-dim);
}
h1.glitch {
  position: relative;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.6rem, 9vw, 4.6rem);
  letter-spacing: 0.14em;
  color: var(--green-pale);
  text-shadow:
    0 0 18px rgba(77, 255, 166, 0.55),
    0 0 60px rgba(77, 255, 166, 0.25);
  margin: 8px 0 4px;
}
h1.glitch::before,
h1.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0.8;
}
h1.glitch::before {
  color: var(--magenta);
  z-index: -1;
  animation: glitchA 3.8s steps(2, end) infinite;
}
h1.glitch::after {
  color: #57d8ff;
  z-index: -2;
  animation: glitchB 3.8s steps(2, end) infinite;
}
@keyframes glitchA {
  0%, 91%, 100% { transform: none; clip-path: inset(0 0 0 0); opacity: 0; }
  92% { transform: translate(-3px, 2px); clip-path: inset(10% 0 55% 0); opacity: 0.75; }
  94% { transform: translate(2px, -1px); clip-path: inset(60% 0 8% 0); opacity: 0.75; }
  96% { transform: translate(-2px, 1px); clip-path: inset(30% 0 40% 0); opacity: 0.6; }
}
@keyframes glitchB {
  0%, 90%, 100% { transform: none; clip-path: inset(0 0 0 0); opacity: 0; }
  91% { transform: translate(3px, -2px); clip-path: inset(48% 0 20% 0); opacity: 0.7; }
  93% { transform: translate(-2px, 2px); clip-path: inset(5% 0 78% 0); opacity: 0.7; }
  97% { transform: translate(1px, -1px); clip-path: inset(70% 0 5% 0); opacity: 0.55; }
}

.hero-sub {
  position: relative;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.4em;
  color: var(--green);
  text-shadow: 0 0 10px rgba(77, 255, 166, 0.5);
}
.hero-desc {
  position: relative;
  margin-top: 26px;
  font-size: 0.95rem;
  color: var(--text);
}
.hero-desc .dim {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ステータスバー */
.status-bar {
  position: relative;
  margin-top: 34px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 26px;
  padding: 12px 22px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(4px);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: var(--text-dim);
}
.status-bar b {
  font-weight: 700;
  margin-left: 6px;
}
.status-bar .ok { color: var(--green); text-shadow: 0 0 8px rgba(77, 255, 166, 0.5); }
.status-bar .warn { color: var(--amber); text-shadow: 0 0 8px rgba(255, 195, 107, 0.5); animation: blink 1.4s steps(1) infinite; }
.status-bar .alert { color: var(--magenta); text-shadow: 0 0 8px rgba(255, 95, 210, 0.6); animation: blink 0.7s steps(1) infinite; }

/* ===== セクション見出し ===== */
.section-title {
  font-family: var(--mono);
  font-size: 0.95rem;
  letter-spacing: 0.3em;
  color: var(--green);
  margin: 70px 0 28px;
  padding-left: 14px;
  border-left: 3px solid var(--green);
  text-shadow: 0 0 10px rgba(77, 255, 166, 0.4);
}
.section-title .jp {
  font-family: var(--serif);
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
}

/* ===== 研究区画カード ===== */
.sector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 22px;
  perspective: 1200px;
}

.sector-card {
  position: relative;
  display: block;
  padding: 22px 24px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--text);
  backdrop-filter: blur(5px);
  transition: border-color 0.35s, box-shadow 0.35s, transform 0.2s ease-out;
  transform-style: preserve-3d;
  overflow: hidden;
}
/* コーナーブラケット */
.sector-card::before,
.sector-card::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: var(--green);
  border-style: solid;
  opacity: 0.7;
  transition: width 0.3s, height 0.3s, opacity 0.3s;
}
.sector-card::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.sector-card::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }
.sector-card:hover::before,
.sector-card:hover::after { width: 26px; height: 26px; opacity: 1; }

.sector-card:hover {
  border-color: var(--line-strong);
  box-shadow:
    0 0 28px rgba(77, 255, 166, 0.12),
    inset 0 0 40px rgba(77, 255, 166, 0.04);
}
a.sector-card:hover .enter-hint,
.sector-card[role="button"]:not(.sealed):hover .enter-hint {
  color: var(--green-pale);
  text-shadow: 0 0 10px var(--green);
  letter-spacing: 0.3em;
}
.sector-card[role="button"]:not(.sealed) { cursor: pointer; }
.sector-card:hover .sector-name {
  color: var(--green-pale);
  text-shadow: 0 0 14px rgba(77, 255, 166, 0.6);
}

/* ホバースキャンライン（要素はJSで付与） */
@keyframes cardScan {
  0% { top: -20%; opacity: 0; }
  15% { opacity: 1; }
  100% { top: 120%; opacity: 0; }
}
.sector-card .scanline {
  position: absolute;
  left: 0;
  right: 0;
  top: -20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(77, 255, 166, 0.8), transparent);
  opacity: 0;
  pointer-events: none;
}
.sector-card:hover .scanline { animation: cardScan 1.2s ease-in-out infinite; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  margin-bottom: 14px;
}
.sector-no { color: var(--text-dim); }
.sector-status { display: inline-flex; align-items: center; gap: 6px; }
.sector-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.st-active { color: var(--green); }
.st-active i { background: var(--green); box-shadow: 0 0 8px var(--green); animation: blink 2s steps(1) infinite; }
.st-live { color: var(--magenta); }
.st-live i { background: var(--magenta); box-shadow: 0 0 8px var(--magenta); animation: blink 1s steps(1) infinite; }
.st-unstable { color: var(--amber); }
.st-unstable i { background: var(--amber); box-shadow: 0 0 8px var(--amber); animation: blink 0.55s steps(1) infinite; }
.st-sealed { color: #8a8aa0; }
.st-sealed i { background: #8a8aa0; }

.sector-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: 0.08em;
  color: var(--text);
  transition: color 0.3s, text-shadow 0.3s;
}
.sector-en {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.34em;
  color: var(--green-dim);
  margin: 4px 0 12px;
}
.sector-desc {
  font-size: 0.83rem;
  color: var(--text-dim);
  line-height: 1.8;
  min-height: 4.4em;
}
.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.18em;
}
.clearance { color: var(--text-dim); }
.clearance.warn { color: var(--amber); }
.enter-hint { color: var(--green-dim); transition: all 0.3s; }

/* 封鎖区画 */
.sector-card.sealed {
  cursor: not-allowed;
  border-style: dashed;
  filter: saturate(0.4);
}
.sector-card.sealed:hover {
  border-color: rgba(255, 95, 210, 0.4);
  box-shadow: 0 0 24px rgba(255, 95, 210, 0.08);
}
.sector-card.sealed.deny {
  animation: denyShake 0.45s ease;
  border-color: var(--magenta);
}
@keyframes denyShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

/* ==========================================================
   端末選択ダイアログ（SECTOR-04）
   ========================================================== */
/* スクロールバーは常に出さない。
   出し入れで幅が変わるとダイアログ開閉のたびに画面全体が横へ飛ぶため。
   ホイール・キー・タッチでのスクロールは従来どおり効く。 */
html, body { scrollbar-width: none; -ms-overflow-style: none; }
html::-webkit-scrollbar,
body::-webkit-scrollbar { width: 0; height: 0; display: none; }

html.modal-open { overflow: hidden; }

#app-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  perspective: 1400px;
  visibility: hidden;
  pointer-events: none;
}
#app-modal.open { visibility: visible; pointer-events: auto; }
#app-modal.closing { visibility: visible; pointer-events: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(3, 12, 8, 0.72), rgba(1, 4, 3, 0.92));
  opacity: 0;
  backdrop-filter: blur(0px);
  transition: opacity 0.38s ease, backdrop-filter 0.38s ease;
}
#app-modal.open .modal-backdrop { opacity: 1; backdrop-filter: blur(7px) saturate(0.7); }

/* ----- パネル ----- */
.modal-panel {
  position: relative;
  width: min(760px, 100%);
  /* グリッド領域（＝ビューポート − パネル外周の余白）を超えない。
     項目が増えても枠は動かさず、中のリストだけをスクロールさせる */
  max-height: min(760px, 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 26px 30px 20px;
  background: linear-gradient(180deg, rgba(7, 26, 18, 0.96), rgba(3, 11, 8, 0.97));
  border: 1px solid var(--line-strong);
  box-shadow:
    0 0 70px rgba(77, 255, 166, 0.14),
    0 30px 80px rgba(0, 0, 0, 0.6),
    inset 0 0 70px rgba(77, 255, 166, 0.035);
  opacity: 0;
  /* 開く原点はカード中心（JSが transform-origin を差し込む） */
}
/* コーナーブラケット（カードと同じ意匠） */
.modal-panel::before,
.modal-panel::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--green);
  border-style: solid;
  opacity: 0.85;
  pointer-events: none;
}
.modal-panel::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.modal-panel::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

.modal-panel .sweep {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(77, 255, 166, 0.9), transparent);
  opacity: 0;
  pointer-events: none;
}

#app-modal.open .modal-panel { animation: modalIn 0.56s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
#app-modal.closing .modal-panel { animation: modalOut 0.28s ease forwards; }
#app-modal.open .modal-panel .sweep { animation: modalSweep 1.1s ease-out 0.12s 2; }

@keyframes modalIn {
  0%   { opacity: 0; transform: translateY(26px) scale(0.86) rotateX(14deg); filter: blur(7px); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes modalOut {
  from { opacity: 1; transform: none; filter: blur(0); }
  to   { opacity: 0; transform: translateY(10px) scale(0.95); filter: blur(4px); }
}
@keyframes modalSweep {
  0%   { top: 0; opacity: 0; }
  10%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* ----- ヘッダー ----- */
.modal-head {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.modal-no {
  display: block;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  color: var(--text-dim);
}
.modal-title {
  font-family: var(--mono);
  font-size: clamp(0.86rem, 3vw, 1.05rem);
  font-weight: 700;
  letter-spacing: 0.26em;
  color: var(--green);
  text-shadow: 0 0 14px rgba(77, 255, 166, 0.45);
  margin-top: 6px;
}
.modal-close {
  flex: none;
  padding: 7px 12px;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.modal-close:hover,
.modal-close:focus-visible {
  color: var(--green-pale);
  border-color: var(--line-strong);
  box-shadow: 0 0 18px rgba(77, 255, 166, 0.18);
}

.modal-lead {
  flex: none;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 14px 0 18px;
}

/* ----- 端末リスト ----- */
/* 項目が増えたときはここだけがスクロールする。
   スクロールバーは出さず、左右の余白はホバーで5px動く分の逃げ場 */
.app-list {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 10px;
  margin: -4px -10px;
  overflow: hidden auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.app-list::-webkit-scrollbar { width: 0; height: 0; display: none; }

.app-item {
  position: relative;
  flex: none; /* 縦に潰さずリスト側をスクロールさせる */
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: rgba(4, 16, 11, 0.6);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  transition: background 0.28s, border-color 0.28s, box-shadow 0.28s, transform 0.28s;
}
/* 左の点灯バー */
.app-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  transform: scaleY(0);
  transform-origin: 50% 0;
  transition: transform 0.3s ease;
}
a.app-item:hover,
a.app-item:focus-visible {
  background: rgba(77, 255, 166, 0.07);
  border-color: var(--line-strong);
  box-shadow: 0 0 26px rgba(77, 255, 166, 0.12);
  transform: translateX(5px);
  outline: none;
}
a.app-item:hover::before,
a.app-item:focus-visible::before { transform: scaleY(1); }

.app-idx {
  font-family: var(--mono);
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  color: var(--green-dim);
  text-align: center;
}
.app-body { display: block; min-width: 0; }
.app-name {
  display: block;
  font-family: var(--mono);
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--green-pale);
  transition: text-shadow 0.28s;
}
a.app-item:hover .app-name,
a.app-item:focus-visible .app-name { text-shadow: 0 0 14px rgba(77, 255, 166, 0.6); }
.app-jp {
  font-family: var(--serif);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-left: 8px;
}
.app-desc {
  display: block;
  font-size: 0.78rem;
  line-height: 1.75;
  color: var(--text-dim);
  margin-top: 4px;
}
.app-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  white-space: nowrap;
}
.app-state { display: inline-flex; align-items: center; gap: 6px; }
.app-state i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.st-quarantined { color: #8a8aa0; }
.st-quarantined i { background: #8a8aa0; }
.app-go { color: var(--green-dim); transition: color 0.28s, letter-spacing 0.28s, text-shadow 0.28s; }
a.app-item:hover .app-go,
a.app-item:focus-visible .app-go {
  color: var(--green-pale);
  letter-spacing: 0.3em;
  text-shadow: 0 0 10px var(--green);
}

/* 隔離中 */
.app-item.locked {
  cursor: not-allowed;
  border-style: dashed;
  filter: saturate(0.35);
}
.app-item.locked .app-name { color: var(--text-dim); }
.app-item.locked:hover,
.app-item.locked:focus-visible {
  border-color: rgba(255, 95, 210, 0.4);
  box-shadow: 0 0 22px rgba(255, 95, 210, 0.08);
  outline: none;
}

/* ----- リストの段階表示 ----- */
#app-modal.open .app-item {
  animation: appIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(0.18s + var(--i, 0) * 0.08s);
}
@keyframes appIn {
  from { opacity: 0; transform: translateX(-18px); clip-path: inset(0 100% 0 0); }
  to   { opacity: 1; transform: none; clip-path: inset(0 0 0 0); }
}
/* 拒否シェイクは段階表示より優先させる */
#app-modal.open .app-item.locked.deny {
  animation: denyShake 0.45s ease;
  border-color: var(--magenta);
}

/* ----- 補足行 ----- */
.modal-note {
  flex: none;
  margin-top: 14px;
  font-size: 0.76rem;
  color: var(--text-dim);
}
.modal-note a {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.25s, text-shadow 0.25s;
}
.modal-note a:hover,
.modal-note a:focus-visible { color: var(--green-pale); text-shadow: 0 0 10px var(--green); }

/* ----- フッター ----- */
.modal-foot {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: var(--text-dim);
}
.modal-foot-hint { animation: blink 2.4s steps(1) infinite; }

/* ===== 観測ログ ===== */
.log-frame {
  border: 1px solid var(--line);
  background: rgba(3, 10, 7, 0.82);
  padding: 16px 20px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  min-height: 190px;
  max-height: 230px;
  overflow: hidden;
  position: relative;
}
.log-frame::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 60px;
  background: linear-gradient(180deg, transparent, rgba(3, 10, 7, 0.95));
  pointer-events: none;
}
.log-line {
  color: var(--text-dim);
  line-height: 1.9;
  opacity: 0;
  animation: logIn 0.5s ease forwards;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@keyframes logIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.log-line .t { color: var(--green-dim); margin-right: 10px; }
.log-line.warn { color: var(--amber); }
.log-line.alert { color: var(--magenta); }

/* ===== 黒塗り ===== */
.redacted {
  background: #1c2a22;
  color: transparent;
  padding: 0 2px;
  border-radius: 2px;
  cursor: default;
  transition: color 0.4s, background 0.4s;
  text-shadow: none;
  user-select: none;
}
.redacted:hover { background: rgba(77, 255, 166, 0.15); color: var(--green); }

/* ===== フッター ===== */
.lab-footer {
  position: relative;
  z-index: 3;
  text-align: center;
  padding: 40px 20px 60px;
  border-top: 1px solid var(--line);
  background: linear-gradient(0deg, rgba(4, 16, 11, 0.9), transparent);
}
.footer-org {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.24em;
  color: var(--text-dim);
}
.footer-note {
  font-size: 0.74rem;
  color: var(--text-dim);
  margin: 10px 0 18px;
}
.lab-footer .return-link { font-family: var(--mono); font-size: 0.72rem; }
.footer-copyright {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.footer-credits-link {
  color: var(--text-dim);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.footer-credits-link:hover { color: var(--green); }

/* ===== レスポンシブ ===== */
@media (max-width: 640px) {
  .lab-header { padding: 14px 16px; font-size: 0.62rem; }
  .core-wrap { opacity: 0.5; }
  main { padding: 0 14px 60px; }
  .hero { min-height: 440px; padding-top: 20px; }
  .hero-desc { font-size: 0.85rem; }
  .status-bar { gap: 8px 16px; font-size: 0.6rem; }
  .sector-desc { min-height: 0; }
  .log-frame { font-size: 0.62rem; }

  #app-modal { padding: 14px; }
  .modal-panel { padding: 20px 18px 16px; }
  .app-item {
    grid-template-columns: 30px 1fr;
    gap: 6px 12px;
    padding: 12px 14px;
  }
  .app-right {
    grid-column: 2;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }
  .app-desc { font-size: 0.74rem; }
}

/* ==========================================================
   セクター起動インタースティシャル（SECTOR GATE）
   遷移の間にこのページ内で端末起動演出を挟む。遷移先は素のまま。
   ========================================================== */
#ah-gate{
  --ah-hue:#4fd08a;
  position:fixed; inset:0; z-index:99999;
  display:none; place-items:center;
  background:#04100b;
  color:var(--ah-hue);
  font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,"Noto Sans JP",monospace;
  overflow:hidden;
  cursor:pointer;
  -webkit-user-select:none; user-select:none;
}
#ah-gate[data-open]{ display:grid; }

/* 上下からのワイプイン */
#ah-gate[data-open] .ah-gate__inner,
#ah-gate[data-open] .ah-gate__grid,
#ah-gate[data-open] .ah-gate__scan{
  animation:ah-wipe .18s cubic-bezier(.2,.9,.2,1) both;
}
@keyframes ah-wipe{
  from{ clip-path:inset(50% 0 50% 0); opacity:0; }
  to  { clip-path:inset(0 0 0 0);     opacity:1; }
}

/* 背景グリッド */
.ah-gate__grid{
  position:absolute; inset:0; pointer-events:none; opacity:.13;
  background-image:
    linear-gradient(to right, var(--ah-hue) 1px, transparent 1px),
    linear-gradient(to bottom, var(--ah-hue) 1px, transparent 1px);
  background-size:48px 48px;
  mask-image:radial-gradient(ellipse at center, #000 20%, transparent 78%);
  -webkit-mask-image:radial-gradient(ellipse at center, #000 20%, transparent 78%);
}

/* 走査線 */
.ah-gate__scan{
  position:absolute; inset:0; pointer-events:none;
  background:repeating-linear-gradient(
    to bottom, rgba(255,255,255,.045) 0 1px, transparent 1px 3px);
}
.ah-gate__scan::after{
  content:""; position:absolute; left:0; right:0; height:22vh;
  background:linear-gradient(to bottom, transparent, color-mix(in srgb, var(--ah-hue) 16%, transparent), transparent);
  animation:ah-sweep 2.6s linear infinite;
}
@keyframes ah-sweep{ from{ top:-25vh; } to{ top:105vh; } }

/* 周辺減光 */
.ah-gate__vig{
  position:absolute; inset:0; pointer-events:none;
  background:radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,.85) 100%);
}

.ah-gate__inner{
  position:relative; z-index:2;
  width:min(680px, 88vw);
  text-align:left;
}

/* 巨大グリフ（背面の漢字一文字） */
.ah-gate__glyph{
  position:absolute; right:-.08em; top:50%; translate:0 -50%;
  font-size:min(38vh, 300px); line-height:1;
  font-family:"Noto Serif JP",serif; font-weight:700;
  color:var(--ah-hue); opacity:.07;
  pointer-events:none;
}

.ah-gate__head{
  display:flex; align-items:baseline; gap:1em;
  font-size:.78rem; letter-spacing:.22em; opacity:.75;
}
.ah-gate__state{
  border:1px solid currentColor; padding:.1em .6em; font-size:.66rem;
}
.ah-gate__name{
  margin-top:.35em;
  font-size:clamp(1.3rem, 4.4vw, 2.1rem);
  letter-spacing:.14em; font-weight:700;
  text-shadow:0 0 24px color-mix(in srgb, var(--ah-hue) 55%, transparent);
}
.ah-gate__jp{
  margin-top:.2em; font-size:.86rem; letter-spacing:.34em; opacity:.55;
}

.ah-gate__log{
  margin:1.6em 0 0; min-height:6.2em;
  font-size:clamp(.66rem,2.5vw,.8rem); line-height:1.75;
  white-space:pre; opacity:.9;
}
.ah-gate__log b{ font-weight:400; color:#fff; }

.ah-gate__bar{
  margin-top:.6em; height:6px;
  border:1px solid color-mix(in srgb, var(--ah-hue) 45%, transparent);
  background:rgba(0,0,0,.4);
}
.ah-gate__bar i{
  display:block; height:100%; width:0%;
  background:var(--ah-hue);
  box-shadow:0 0 14px var(--ah-hue);
  transition:width .18s linear;
}
.ah-gate__status{
  margin-top:.5em; font-size:.7rem; letter-spacing:.3em; opacity:.6;
}

.ah-gate__skip{
  position:absolute; left:0; right:0; bottom:6vh;
  text-align:center; font-size:.62rem; letter-spacing:.3em;
  opacity:.35; z-index:3;
  animation:ah-blink 1.4s steps(1,end) infinite;
}
@keyframes ah-blink{ 0%,60%{opacity:.35} 61%,100%{opacity:.08} }

/* SECTOR-03 の UNSTABLE 用グリッチ */
#ah-gate[data-glitch] .ah-gate__name{ animation:ah-glitch .22s steps(2,end) 3; }
@keyframes ah-glitch{
  0%  { transform:translate(0);      filter:none; }
  33% { transform:translate(-3px,1px); filter:hue-rotate(35deg); }
  66% { transform:translate(2px,-2px); filter:hue-rotate(-25deg); }
  100%{ transform:translate(0);      filter:none; }
}

/* 締めのフラッシュ */
#ah-gate[data-flash]::after{
  content:""; position:absolute; inset:0; z-index:5;
  background:var(--ah-hue);
  animation:ah-flash .34s ease-out both;
}
@keyframes ah-flash{ from{opacity:.85} to{opacity:0} }

/* ===== モーション低減設定 ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1 !important; transform: none !important; }
  body.pre-boot main,
  body.pre-boot .lab-header,
  body.pre-boot .lab-footer { visibility: visible; }
  /* 演出は出さず、通常のリンクとして直接遷移させる */
  #ah-gate{ display:none !important; }
}
