/* TRAN3035 · Agent Studio shell.
   One gated front door, a side menu of modules, one module per page.
   Text colours are AA-checked against their own background (>= 4.5:1). */

:root {
  --bg: #f6f6fb;
  --panel: #ffffff;
  --panel-soft: #fafafe;
  --border: #e5e5ef;
  --text: #1f1f2e;
  --muted: #5b5b72;          /* 6.1:1 on --bg */
  --accent: #4f46c8;         /* 6.9:1 on --panel, 5.9:1 on --accent-soft */
  --accent-soft: #ecebff;
  --accent-border: #cdc8f5;
  --on-accent: #ffffff;
  --good: #15803d;           /* 5.0:1 on --panel */
  --good-soft: #eafaf0;
  --good-border: #b7ebc9;
  --warn: #92400e;           /* 7.1:1 on --panel */
  --warn-soft: #fdf6e7;
  --warn-border: #f2ddb0;
  --bad: #b91c1c;            /* 6.5:1 on --panel */
  --bad-soft: #fdeeee;
  --bad-border: #f6c9c9;
  --radius: 14px;
  --sidebar-w: 264px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e0e16;
  --panel: #1a1a28;
  --panel-soft: #21212f;
  --border: #2d2d40;
  --text: #eceaf6;
  --muted: #a9a7c0;
  --accent: #a79cff;
  --accent-soft: #272144;
  --accent-border: #4a4286;
  --on-accent: #14121f;
  --good: #4ade80;
  --good-soft: #14291e;
  --good-border: #2b6b48;
  --warn: #fbbf24;
  --warn-soft: #2b2314;
  --warn-border: #6b5320;
  --bad: #f87171;
  --bad-soft: #2c1719;
  --bad-border: #6d2f33;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
}
a { color: var(--accent); }
h1, h2, h3 { letter-spacing: -0.01em; }

/* ---------------------------------------------------------------- Gate */
body.locked .app { display: none; }

.gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 460px at 18% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.gate[hidden] { display: none; }
.gate-card {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px 28px 24px;
  box-shadow: 0 24px 60px rgba(20, 18, 40, 0.12);
  text-align: center;
}
.gate-logo { font-size: 26px; color: var(--accent); }
.gate-card h1 { margin: 10px 0 6px; font-size: 21px; }
.gate-sub { margin: 0 0 20px; font-size: 13px; color: var(--muted); }
.gate-label { display: block; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.gate-card input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.gate-card input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.gate-card button {
  width: 100%;
  margin-top: 12px;
  padding: 11px;
  border: none;
  border-radius: 11px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.gate-card button:disabled { opacity: 0.6; cursor: default; }
.gate-error { margin: 10px 0 0; min-height: 18px; font-size: 12.5px; color: var(--bad); }
.gate-note { margin: 14px 0 0; font-size: 12px; color: var(--muted); }

/* --------------------------------------------------------------- Shell */
.app { display: flex; min-height: 100vh; width: 100%; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; border-bottom: 1px solid var(--border); }
.brand .logo { font-size: 20px; color: var(--accent); }
.brand-text h1 { margin: 0; font-size: 15px; }
.brand-text p { margin: 0; font-size: 11.5px; color: var(--muted); }

.nav { flex: 1; padding: 12px 10px 18px; display: flex; flex-direction: column; gap: 3px; }
.nav .group { margin: 14px 8px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.nav .group:first-child { margin-top: 2px; }
.nav a {
  display: block;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav a .num { display: block; font-size: 10.5px; color: var(--muted); }
.nav a .title { display: block; font-size: 13.5px; color: inherit; }
.nav a:hover { background: var(--accent-soft); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a.active .num { color: var(--accent); }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }
.logout {
  width: 100%;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.logout:hover { color: var(--accent); border-color: var(--accent-border); background: var(--accent-soft); }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px clamp(18px, 3vw, 40px);
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 5;
}
.crumb { font-size: 13px; color: var(--muted); }
.crumb b { color: var(--text); }
.topbar-tools { display: flex; align-items: center; gap: 8px; }
.theme-toggle, .ghost-btn {
  font: inherit;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.theme-toggle:hover, .ghost-btn:hover { color: var(--accent); border-color: var(--accent-border); }

/* The content column keeps side margins small: it fills the area left of the
   sidebar, capped so lines stay readable on very wide screens. */
.view {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px clamp(18px, 3vw, 40px) 40px;
}
.foot {
  margin-top: auto;
  padding: 18px clamp(18px, 3vw, 40px) 34px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.foot p { margin: 2px 0; }
.foot .muted { color: var(--muted); }

/* --------------------------------------------------------------- Page */
.page-head { margin-bottom: 20px; }
.kicker {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 4px 11px;
  margin-bottom: 12px;
}
.page-head h2 { margin: 0 0 6px; font-size: clamp(22px, 2.4vw, 28px); }
.page-head p { margin: 0; color: var(--muted); font-size: 14.5px; }
.tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.tag { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border); color: var(--muted); }

.card, details.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
details.card { padding: 0; }
details.card > summary {
  cursor: pointer;
  padding: 16px 20px;
  font-weight: 600;
  font-size: 15px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "▸"; color: var(--accent); font-size: 12px; }
details.card[open] > summary::before { content: "▾"; }
details.card > .body { padding: 0 20px 20px; }

.meta-list { list-style: none; margin: 0; padding: 0; }
.meta-list li { display: flex; gap: 12px; font-size: 13.5px; color: var(--muted); padding: 8px 0; border-bottom: 1px dashed var(--border); }
.meta-list li:last-child { border-bottom: none; }
.meta-list li b { color: var(--text); min-width: 116px; font-weight: 600; }

.traffic { display: flex; flex-wrap: wrap; gap: 10px; }
.light { flex: 1 1 190px; border-radius: 12px; padding: 12px 14px; border: 1px solid var(--border); font-size: 13px; background: var(--panel-soft); }
.light b { display: block; margin-bottom: 4px; font-size: 10.5px; letter-spacing: 0.07em; text-transform: uppercase; }
.light.green { background: var(--good-soft); border-color: var(--good-border); }
.light.green b { color: var(--good); }
.light.yellow { background: var(--warn-soft); border-color: var(--warn-border); }
.light.yellow b { color: var(--warn); }
.light.red { background: var(--bad-soft); border-color: var(--bad-border); }
.light.red b { color: var(--bad); }

.diagram { background: var(--panel-soft); border: 1px solid var(--border); border-radius: 12px; padding: 14px; overflow-x: auto; }
.diagram .mermaid { display: flex; justify-content: center; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.grid a.card { text-decoration: none; color: inherit; display: block; transition: box-shadow 0.15s, transform 0.15s; margin-bottom: 0; }
.grid a.card:hover { box-shadow: 0 12px 30px rgba(20, 18, 40, 0.08); transform: translateY(-2px); }
.grid a.card .num { font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; color: var(--accent); text-transform: uppercase; }
.grid a.card h3 { margin: 6px 0 6px; font-size: 16px; }
.grid a.card p { margin: 0; color: var(--muted); font-size: 13.5px; }

/* --------------------------------------------------------------- Chat */
.chat { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); overflow: hidden; margin-bottom: 18px; }
.chat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--panel-soft);
}
.chat-head .title { font-weight: 600; font-size: 14px; }
.chat-head label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.chat-head select {
  font: inherit; font-size: 12px; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--panel); color: var(--text);
}
.messages { height: 380px; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.empty { margin: auto; text-align: center; color: var(--muted); font-size: 13.5px; max-width: 420px; }
.msg { max-width: 86%; border-radius: var(--radius); padding: 9px 13px 11px; font-size: 14px; line-height: 1.55; border: 1px solid var(--border); }
.msg.user { align-self: flex-end; background: var(--panel-soft); }
.msg.assistant { align-self: flex-start; background: var(--accent-soft); border-color: var(--accent-border); }
.msg.thinking { opacity: 0.75; font-style: italic; }
.msg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.who { font-weight: 600; font-size: 11.5px; color: var(--accent); }
.msg.user .who { color: var(--muted); }
.time { font-size: 11px; color: var(--muted); margin-left: auto; }
.msg-body p { margin: 0 0 8px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body ul, .msg-body ol { margin: 4px 0 8px; padding-left: 20px; }
.msg-body li { margin: 2px 0; }
.msg-body h2, .msg-body h3, .msg-body h4, .msg-body h5 { margin: 10px 0 4px; line-height: 1.3; }
.msg-body code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: rgba(127, 127, 160, 0.16); padding: 1px 5px; border-radius: 5px; }
.msg-body pre.code { background: #1f1f2e; color: #f2f2f7; padding: 12px; border-radius: 10px; overflow-x: auto; margin: 8px 0; }
.msg-body pre.code code { background: transparent; color: inherit; padding: 0; }
.msg-body a { color: var(--accent); }
.msg-body blockquote { margin: 6px 0; padding: 2px 12px; border-left: 3px solid var(--accent-border); color: var(--muted); }
.msg.user .msg-body { white-space: pre-wrap; word-break: break-word; }
.caret { display: inline-block; width: 7px; height: 15px; background: var(--accent); vertical-align: -2px; margin-left: 2px; animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.tool-note { text-align: center; font-size: 12px; color: var(--muted); }

.composer { display: flex; gap: 8px; align-items: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--panel-soft); }
.composer .name {
  width: 148px; flex: 0 0 auto; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--panel); color: var(--text); font: inherit; font-size: 13px;
}
.composer .draft {
  flex: 1; resize: none; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); color: var(--text); font: inherit; font-size: 14px; min-height: 40px; max-height: 140px;
}
.composer .send {
  flex: 0 0 auto; padding: 9px 16px; border: none; border-radius: 10px; background: var(--accent);
  color: var(--on-accent); font: inherit; font-weight: 600; cursor: pointer; font-size: 14px;
}
.composer .send:disabled { opacity: 0.5; cursor: default; }
.composer .hint { font-size: 11.5px; color: var(--muted); padding: 0 16px 10px; background: var(--panel-soft); margin: -6px 0 0; }

/* ---------------------------------------------------------- Responsive */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .nav { flex-direction: row; overflow-x: auto; gap: 6px; padding: 10px; }
  .nav .group { display: none; }
  .nav a { white-space: nowrap; padding: 8px 12px; }
  .nav a .num { display: none; }
  .sidebar-foot { display: none; }
  .composer .name { display: none; }
  .topbar { position: static; }
}
