body { height: 100vh; overflow: hidden; display: flex; }

/* Left rail: the key strip of the deck. */
.rail {
  width: 236px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  border-right: 1px solid var(--line);
  transition: width .18s ease;
}
.rail.collapsed { width: 60px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.brand:hover { text-decoration: none; color: var(--amber); }
.brand-mark { width: 28px; height: 28px; flex: none; color: var(--amber); }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .04em; }
.rail.collapsed .brand-name { display: none; }
.rail.collapsed .brand { justify-content: center; padding-inline: 0; }

.tabs { display: flex; flex-direction: column; padding: 10px 8px; gap: 2px; flex: 1; overflow-y: auto; }
.tab {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid transparent;
  position: relative;
}
.tab:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.tab.active { background: var(--panel); color: var(--text); border-color: var(--line); }
.tab.active::before {
  content: '';
  position: absolute;
  left: -8px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 2px;
  background: var(--amber);
}
.tab-icon { width: 28px; height: 28px; display: grid; place-items: center; color: inherit; }
.tab-icon svg { width: 20px; height: 20px; }
.tab.active .tab-icon { color: var(--amber); }
.tab-text { min-width: 0; }
.tab-name { font-weight: 500; font-size: 13.5px; display: block; }
.tab-tech { font-size: 11px; color: var(--text-dim); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-key { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; }
.rail.collapsed .tab { grid-template-columns: 1fr; justify-items: center; padding-inline: 0; }
.rail.collapsed .tab-text, .rail.collapsed .tab-key { display: none; }

.rail-foot { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-top: 1px solid var(--line); }
.rail-toggle, .rail-link {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; color: var(--text-dim); font: inherit; font-size: 12px; cursor: pointer; padding: 4px;
}
.rail-toggle:hover, .rail-link:hover { color: var(--text); text-decoration: none; }
.rail-toggle svg, .rail-link svg { width: 16px; height: 16px; transition: transform .18s; }
.rail.collapsed .rail-toggle svg { transform: rotate(180deg); }
.rail.collapsed .rail-link span { display: none; }
.rail.collapsed .rail-foot { flex-direction: column; gap: 8px; }

/* Stage: one iframe per opened tool, kept alive so state survives tab switches. */
.stage { flex: 1; position: relative; min-width: 0; background: var(--bg); }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--bg); }
.stage iframe[hidden] { display: none; }

.home { position: absolute; inset: 0; overflow-y: auto; display: grid; place-items: center; padding: 40px 24px; }
.home[hidden] { display: none; }
.home-inner { max-width: 720px; width: 100%; }
.home-kicker { color: var(--amber); font-weight: 600; margin-bottom: 14px; }
.home-title { font-size: clamp(26px, 4vw, 38px); line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }
.home-lead { color: var(--text-muted); font-size: 15px; max-width: 58ch; margin: 18px 0 32px; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  color: var(--text);
  text-decoration: none;
}
.card:hover { border-color: var(--amber); text-decoration: none; }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-head svg { width: 22px; height: 22px; color: var(--amber); flex: none; }
.card-name { font-weight: 600; font-size: 15px; }
.card-tag { color: var(--text-muted); font-size: 13px; }
.card-tech { color: var(--text-dim); font-size: 11.5px; font-family: var(--font-mono); margin-top: 4px; }
.home-hint { margin-top: 32px; font-size: 12.5px; }
.home-hint code { font-size: 12px; }

@media (max-width: 720px) {
  .rail { width: 60px; }
  .rail .brand-name, .rail .tab-text, .rail .tab-key, .rail .rail-link span, .rail-toggle { display: none; }
  .rail .brand { justify-content: center; padding-inline: 0; }
  .rail .tab { grid-template-columns: 1fr; justify-items: center; padding-inline: 0; }
  .home { padding: 24px 16px; }
}

/* Gate: protected tools ask for a login in a modal; behind it the deck is blurred and inert. */
body.locked .rail, body.locked .stage { filter: blur(5px); pointer-events: none; user-select: none; }
.gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(21, 23, 27, .45); backdrop-filter: blur(3px); }
.gate[hidden] { display: none; }
.gate-card { width: min(380px, 100%); padding: 24px 24px 20px; display: grid; gap: 12px; box-shadow: var(--shadow); }
.gate-brand { display: flex; align-items: center; gap: 10px; color: var(--amber); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.gate-brand svg { width: 28px; height: 28px; }
.gate-lead { color: var(--text-muted); font-size: 13px; }
.gate-card label { display: grid; gap: 5px; font-size: 12px; }
.gate-card input { width: 100%; }
.gate-err { color: var(--red); font-size: 13px; min-height: 18px; margin: 0; }
.gate-actions { display: flex; gap: 8px; }
.gate-actions .btn.primary { flex: 1; justify-content: center; }
.tab-key.lock, .card-lock { display: inline-flex; color: var(--text-dim); }
.tab-key.lock { border: 0; background: none; }
.tab-key.lock svg, .card-lock svg { width: 13px; height: 13px; }
.card-lock { margin-left: auto; }
.rail.collapsed .tab-key.lock { display: none; }
