:root {
  --ink: #14231c;
  --muted: #69776f;
  --surface: rgba(255, 255, 255, .78);
  --surface-solid: #f9fbf9;
  --line: rgba(28, 58, 43, .11);
  --green: #176b49;
  --green-soft: #dff2e8;
  --amber: #b56b12;
  --red: #b5443f;
  --shadow: 0 22px 70px rgba(36, 68, 51, .12);
  --radius: 24px;
}

* { box-sizing: border-box; }
.launch-screen {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  color: #d8dee9;
  background: #090c10;
  opacity: 1;
  transition: opacity .32s ease, visibility .32s ease;
}
.launch-screen.ready { visibility: hidden; opacity: 0; pointer-events: none; }
html.refresh-resume .launch-screen { display: none !important; }
html { min-height: 100%; background: #eef3ef; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(255,255,255,.9), transparent 30%),
    linear-gradient(145deg, #e9f0eb 0%, #f5f2e9 100%);
  overflow-x: hidden;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.app-shell { position: relative; width: 100%; max-width: 1440px; min-width: 0; min-height: 100vh; margin: 0 auto; padding: 30px 34px 40px; }
.kicker { margin: 0 0 6px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }

.node-tabs { display: flex; width: 100%; max-width: 100%; gap: 9px; overflow-x: auto; padding: 3px 2px 14px; scrollbar-width: none; }
.node-tab { min-width: 112px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: rgba(255,255,255,.55); text-align: left; transition: .2s ease; }
.node-tab.active { color: white; background: var(--ink); transform: translateY(-1px); box-shadow: 0 12px 25px rgba(20,35,28,.16); }
.node-tab span { display: block; font-weight: 800; }
.node-tab small { display: block; margin-top: 4px; color: inherit; opacity: .65; }
.node-tab.offline { opacity: .48; }

.workspace-grid { display: grid; width: 100%; min-width: 0; grid-template-columns: 370px minmax(0, 1fr); gap: 16px; min-height: 630px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); backdrop-filter: blur(22px); box-shadow: var(--shadow); overflow: hidden; }
.session-panel { min-width: 0; max-width: 100%; }
.panel-heading, .conversation-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 22px; border-bottom: 1px solid var(--line); }
.session-list { max-height: 680px; overflow-y: auto; padding: 10px; }
.session-item { width: 100%; display: grid; grid-template-columns: 12px 1fr auto; gap: 12px; align-items: start; padding: 15px 13px; border: 0; border-radius: 16px; color: inherit; background: transparent; text-align: left; }
.session-item > span:nth-child(2) { min-width: 0; }
.session-item:hover, .session-item.active { background: rgba(222,238,228,.78); }
.state-dot { width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: #a7b0aa; }
.state-dot.active { background: #21a367; box-shadow: 0 0 0 5px rgba(33,163,103,.1); }
.state-dot.open { background: #438d74; box-shadow: 0 0 0 4px rgba(67,141,116,.09); }
.state-dot.systemError { background: var(--red); }
.session-name { display: block; overflow: hidden; font-weight: 800; white-space: nowrap; text-overflow: ellipsis; }
.session-preview { display: -webkit-box; margin-top: 5px; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.5; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.session-time { color: var(--muted); font-size: 10px; white-space: nowrap; }
.list-empty { padding: 50px 20px; color: var(--muted); text-align: center; }

.conversation-panel { position: relative; display: flex; flex-direction: column; min-width: 0; }
.empty-state { margin: auto; padding: 60px 20px; color: var(--muted); text-align: center; }
.empty-state h2 { margin: 18px 0 8px; color: var(--ink); }
.conversation { display: flex; flex: 1; min-height: 0; flex-direction: column; }
.session-breadcrumb { margin-bottom: 5px; color: var(--green); font-size: 12px; font-weight: 800; }
.status-chip { padding: 7px 11px; border-radius: 999px; background: #edf1ee; font-size: 12px; font-weight: 800; white-space: nowrap; }
.status-chip.active { color: #11603e; background: var(--green-soft); }
.status-chip.open { color: #176b49; background: #e6f1eb; }
.timeline { flex: 1; min-height: 300px; max-height: 470px; overflow-y: auto; padding: 22px; scroll-behavior: smooth; }
.event { margin-bottom: 14px; padding: 13px 15px; border-left: 3px solid #c8d3cc; border-radius: 4px 14px 14px 4px; background: rgba(247,249,247,.86); }
.event.agent { border-color: var(--green); background: rgba(230,243,235,.82); }
.event.command { border-color: #b88635; font-family: Consolas, monospace; }
.event.error { border-color: var(--red); }
.event-label { margin-bottom: 6px; color: var(--muted); font: 700 10px/1 system-ui; letter-spacing: .08em; text-transform: uppercase; }
.event-body { white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.65; }

.approval-box { margin: 0 18px 14px; padding: 16px; border: 1px solid rgba(181,107,18,.24); border-radius: 17px; background: #fff8e9; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.composer { padding: 15px 18px 18px; border-top: 1px solid var(--line); background: rgba(250,252,250,.82); }
.composer textarea, .auth-card input { width: 100%; resize: none; outline: none; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); background: white; padding: 13px 14px; transition: .2s; }
.composer textarea:focus, .auth-card input:focus { border-color: rgba(23,107,73,.55); box-shadow: 0 0 0 4px rgba(23,107,73,.07); }
.button { border: 1px solid var(--line); border-radius: 12px; padding: 10px 13px; color: var(--ink); background: white; font-weight: 750; font-size: 12px; }
.button.primary { border-color: var(--green); color: white; background: var(--green); }
.button.danger { color: var(--red); }
.button.subtle { background: transparent; }
.button:disabled { cursor: not-allowed; opacity: .45; }

.auth-layer { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(230,237,232,.82); backdrop-filter: blur(18px); }
.auth-card { width: min(400px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 28px; background: white; box-shadow: var(--shadow); }
.auth-card p { color: var(--muted); line-height: 1.6; }
.auth-card .button { width: 100%; margin-top: 12px; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 3px; color: var(--muted); font-size: 11px; text-align: center; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.token-login input { margin-top: 10px; }
.security-actions { margin-top: 10px; }
.form-error { min-height: 20px; margin-top: 10px; color: var(--red); font-size: 12px; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 25px; max-width: calc(100vw - 32px); padding: 11px 15px; border-radius: 12px; color: white; background: rgba(20,35,28,.92); opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: .22s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.push-prompt { position: fixed; inset: 0; z-index: 24; display: grid; place-items: center; padding: 22px; background: rgba(5,7,9,.76); backdrop-filter: blur(10px); }
.push-prompt.hidden { display: none; }
.push-prompt-card { width: min(310px, calc(100vw - 40px)); padding: 22px; border: 1px solid #26303a; border-radius: 14px; color: #e6edf3; background: #0d1117; box-shadow: 0 18px 60px rgba(0,0,0,.42); text-align: center; }
.push-prompt-card h2 { margin: 0; font: 700 18px/1.4 "Microsoft YaHei UI", sans-serif; }
.push-prompt-card p { margin: 9px 0 19px; color: #8b949e; font: 13px/1.6 "Microsoft YaHei UI", sans-serif; }
.push-prompt-card .button { width: 100%; min-height: 44px; }
.push-prompt-card .button + .button { margin-top: 8px; }
.goal-prompt { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; padding: 18px; background: rgba(5,7,9,.82); }
.quota-card { max-height: 80dvh; overflow: auto; }
.goal-prompt-card { width: min(520px, calc(100vw - 28px)); padding: 20px; border: 1px solid #30363d; border-radius: 10px; color: #e6edf3; background: #0d1117; box-shadow: 0 20px 70px rgba(0,0,0,.55); }
.goal-prompt-card h2 { margin: 0 0 14px; font-size: 17px; }
.goal-prompt-card label, .goal-current > span { display: block; margin-bottom: 6px; color: #8b949e; font-size: 11px; }
.goal-current { margin-bottom: 14px; padding: 10px 12px; border-left: 2px solid #d29922; background: #161b22; }
.goal-current p { max-height: 110px; margin: 0; overflow-y: auto; color: #c9d1d9; font-size: 12px; line-height: 1.55; white-space: pre-wrap; }
.goal-prompt-card textarea { width: 100%; min-height: 120px; padding: 11px 12px; resize: vertical; border: 1px solid #30363d; border-radius: 6px; outline: 0; color: #f0f6fc; background: #010409; font-size: 14px; line-height: 1.55; }
.goal-prompt-card textarea:focus { border-color: #2f81f7; }
.goal-prompt-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

@media (max-width: 820px) {
  .app-shell { padding: max(18px, env(safe-area-inset-top)) 14px calc(22px + env(safe-area-inset-bottom)); }
  .workspace-grid { display: block; min-height: 0; }
  .session-panel { min-height: 520px; }
  .conversation-panel { position: fixed; z-index: 10; inset: 0; border: 0; border-radius: 0; background: #f7faf7; transform: translateX(105%); transition: transform .25s ease; }
  .conversation-panel.mobile-open { transform: translateX(0); }
  .conversation-head { padding-top: max(18px, env(safe-area-inset-top)); }
  .conversation-head:before { content: "‹"; margin-right: 2px; font-size: 32px; cursor: pointer; }
  .timeline { max-height: none; }
  .composer { padding-bottom: calc(15px + env(safe-area-inset-bottom)); }
}

/* Daily login is intentionally reduced to the welcome line and Face ID. */
.auth-layer.login-mode { background: #050709; }
.auth-card.login-mode {
  display: flex;
  width: min(320px, calc(100vw - 40px));
  min-width: 0;
  box-sizing: border-box;
  flex-direction: column;
  align-items: center;
  padding: 0;
  border: 0;
  color: var(--term-text);
  background: transparent;
  box-shadow: none;
  text-align: center;
}
.auth-card.login-mode > h2,
.auth-card.login-mode > p { display: none; }
.auth-card.login-mode .passkey-button {
  display: inline-flex;
  width: auto;
  min-width: 148px;
  min-height: 48px;
  margin: 0;
  align-self: center;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 11px 22px;
  border: 1px solid rgba(63, 185, 80, .36);
  border-radius: 999px;
  color: #edf7ef;
  background: rgba(63, 185, 80, .055);
  box-shadow: inset 0 0 18px rgba(63, 185, 80, .035), 0 0 18px rgba(63, 185, 80, .045);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: .04em;
  animation: face-id-ready 2.4s ease-in-out infinite;
}
.auth-card.login-mode .passkey-button:hover,
.auth-card.login-mode .passkey-button:active {
  color: #fff;
  border-color: rgba(63, 185, 80, .68);
  background: rgba(63, 185, 80, .1);
}
.auth-card.login-mode .passkey-button:disabled { opacity: .48; }
.face-id-glyph {
  position: relative;
  display: inline-block;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  color: #58d06b;
  background:
    linear-gradient(currentColor, currentColor) left top / 7px 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) left top / 1.5px 7px no-repeat,
    linear-gradient(currentColor, currentColor) right top / 7px 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) right top / 1.5px 7px no-repeat,
    linear-gradient(currentColor, currentColor) left bottom / 7px 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) left bottom / 1.5px 7px no-repeat,
    linear-gradient(currentColor, currentColor) right bottom / 7px 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) right bottom / 1.5px 7px no-repeat;
  border-radius: 6px;
}
.face-id-glyph::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 6px;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 8px 0 currentColor;
}
.face-id-glyph::after {
  content: "";
  position: absolute;
  top: 10px;
  left: 6px;
  width: 10px;
  height: 5px;
  border-bottom: 1.5px solid currentColor;
  border-radius: 0 0 8px 8px;
}
@keyframes face-id-ready {
  0%, 100% { box-shadow: inset 0 0 18px rgba(63, 185, 80, .025), 0 0 12px rgba(63, 185, 80, .03); }
  50% { box-shadow: inset 0 0 20px rgba(63, 185, 80, .065), 0 0 22px rgba(63, 185, 80, .085); }
}
@media (prefers-reduced-motion: reduce) {
  .auth-card.login-mode .passkey-button { animation-duration: 4s; }
}
.auth-card.login-mode .token-login { width: min(310px, calc(100vw - 42px)); }
.auth-card.login-mode .auth-divider { display: none; }
.auth-card.login-mode .form-error {
  max-width: min(310px, calc(100vw - 42px));
  min-height: 0;
  margin: 18px auto 0;
  color: #8b949e;
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}
.auth-card.login-mode .form-error:empty { display: none; }

/* Pure terminal theme. Keep this block last so it deliberately replaces the
   original dashboard styling without changing any realtime behavior. */
:root {
  --term-bg: #090c10;
  --term-panel: #0d1117;
  --term-panel-2: #11161d;
  --term-hover: #161b22;
  --term-border: #30363d;
  --term-text: #d8dee9;
  --term-bright: #f0f6fc;
  --term-muted: #7d8590;
  --term-green: #3fb950;
  --term-blue: #58a6ff;
  --term-amber: #d29922;
  --term-red: #f85149;
}

html, body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  color: var(--term-text);
  background: var(--term-bg);
  font-family: "Cascadia Code", "JetBrains Mono", Consolas, "Microsoft YaHei UI", monospace;
}

button, input, textarea { font-family: inherit; }
.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  height: 100dvh;
  min-height: 0;
  margin: 0;
  padding: 0;
  background: var(--term-bg);
}

h2 { color: var(--term-bright); font-size: 13px; font-weight: 600; letter-spacing: 0; }

.node-tabs {
  flex: 0 0 38px;
  width: 100%;
  height: 38px;
  gap: 0;
  overflow-x: auto;
  padding: 0 8px;
  border-bottom: 1px solid var(--term-border);
  background: var(--term-panel);
}
.node-tab {
  min-width: auto;
  height: 37px;
  padding: 6px 14px;
  border: 0;
  border-right: 1px solid #21262d;
  border-radius: 0;
  color: var(--term-muted);
  background: transparent;
  text-align: left;
  transition: none;
}
.node-tab:first-child { border-left: 1px solid #21262d; }
.node-tab:hover { color: var(--term-text); background: var(--term-hover); }
.node-tab.active { border-bottom: 2px solid var(--term-blue); color: var(--term-bright); background: var(--term-hover); box-shadow: none; transform: none; }
.node-tab span { font-size: 11px; font-weight: 600; }
.node-tab small { margin-top: 1px; font-size: 9px; opacity: .7; }

.workspace-grid {
  display: grid;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 0;
}
.panel { min-height: 0; border: 0; border-radius: 0; background: var(--term-bg); box-shadow: none; backdrop-filter: none; }
.session-panel { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--term-border); background: var(--term-panel); }
.panel-heading, .conversation-head {
  flex: 0 0 48px;
  min-height: 48px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--term-border);
  background: var(--term-panel);
}
.kicker { margin: 0 0 2px; color: var(--term-muted); font-size: 9px; font-weight: 400; letter-spacing: .08em; text-transform: uppercase; }
.session-list { flex: 1; min-height: 0; max-height: none; overflow-y: auto; padding: 3px; }
.session-item {
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 8px;
  padding: 9px 7px;
  border: 0;
  border-radius: 0;
  color: var(--term-text);
  background: transparent;
}
.session-item:hover, .session-item.active { background: var(--term-hover); }
.session-item.active { box-shadow: inset 2px 0 var(--term-blue); }
.state-dot { width: 6px; height: 6px; margin-top: 5px; box-shadow: none !important; }
.state-dot.active { background: var(--term-green); }
.state-dot.open { background: var(--term-blue); }
.state-dot.systemError { background: var(--term-red); }
.session-name { color: var(--term-bright); font-size: 11px; font-weight: 500; }
.session-preview { margin-top: 3px; color: var(--term-muted); font-size: 10px; line-height: 1.4; }
.session-time { color: #545d68; font-size: 9px; }
.list-empty { padding: 32px 12px; color: var(--term-muted); font-size: 11px; text-align: center; }

.conversation-panel { display: flex; min-width: 0; min-height: 0; flex-direction: column; background: var(--term-bg); }
.empty-state { margin: auto; padding: 30px 18px; color: var(--term-muted); font-size: 11px; }
.empty-state h2 { margin: 0 0 8px; color: var(--term-text); }
.empty-state p { margin: 0; }
.conversation { flex: 1; min-height: 0; }
.conversation-head { color: var(--term-text); }
.session-breadcrumb { margin-bottom: 2px; color: var(--term-blue); font-size: 9px; font-weight: 400; }
.status-chip { padding: 3px 6px; border: 1px solid var(--term-border); border-radius: 2px; color: var(--term-muted); background: transparent; font-size: 9px; font-weight: 400; }
.status-chip.active, .status-chip.open { border-color: #238636; color: var(--term-green); background: transparent; }
.working-bar { display: flex; flex: 0 0 34px; align-items: center; gap: 7px; padding: 6px 12px; border-bottom: 1px solid #1e2935; color: #a9c7df; background: #0b1219; font-size: 10px; }
.working-label {
  display: inline-flex;
  color: #58a6ff;
  font-weight: 700;
}
.working-label > span {
  color: #58a6ff;
  animation: working-letter-flow 1.35s linear infinite;
  animation-delay: calc(-1.35s + var(--working-delay));
  will-change: color, text-shadow;
}
.working-time { color: var(--term-muted); font-variant-numeric: tabular-nums; }
.working-detail { min-width: 0; overflow: hidden; color: #8ea4b6; white-space: nowrap; text-overflow: ellipsis; }
.working-stop { margin-left: auto; padding: 4px 9px; border: 1px solid #743431; border-radius: 4px; color: #ff8b84; background: #1b0e0e; font: 600 10px/1.2 inherit; }
.working-stop:hover { border-color: var(--term-red); background: #271212; }
@keyframes working-letter-flow {
  0%, 20%, 100% { color: #4f91d7; text-shadow: none; }
  38% { color: #85caff; text-shadow: 0 0 2px rgba(88, 166, 255, .28); }
  50% { color: #f5fbff; text-shadow: 0 0 5px rgba(143, 211, 255, .62); }
  62% { color: #85caff; text-shadow: 0 0 2px rgba(88, 166, 255, .28); }
  80% { color: #4f91d7; text-shadow: none; }
}
.timeline-shell { position: relative; display: flex; flex: 1; min-height: 0; }
.conversation-loading {
  position: absolute;
  z-index: 4;
  top: 12px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid #29445e;
  border-radius: 999px;
  color: #a9c7df;
  background: rgba(11, 18, 25, .96);
  box-shadow: 0 5px 18px rgba(0, 0, 0, .28);
  font-size: 11px;
  pointer-events: none;
  transform: translateX(-50%);
}
.conversation-loading-spinner {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  border: 2px solid rgba(88, 166, 255, .24);
  border-top-color: #70bdff;
  border-radius: 50%;
  animation: conversation-loading-spin .72s linear infinite;
}
@keyframes conversation-loading-spin { to { transform: rotate(360deg); } }
.timeline {
  flex: 1;
  width: 100%;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  padding: 8px 14px 14px;
  background: var(--term-bg);
  scroll-behavior: auto;
  overscroll-behavior-y: contain;
  overflow-anchor: none;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
.latest-button { position: absolute; z-index: 3; right: 12px; bottom: 10px; padding: 6px 10px; border: 1px solid #28557a; border-radius: 999px; color: #c7e1f8; background: rgba(13,28,42,.96); box-shadow: 0 5px 18px rgba(0,0,0,.35); font: 600 10px/1.2 inherit; }
.latest-button:hover { border-color: var(--term-blue); color: #fff; }
.event {
  margin: 0;
  padding: 9px 4px 10px 10px;
  border: 0;
  border-bottom: 1px solid #161b22;
  border-left: 2px solid #30363d;
  border-radius: 0;
  color: var(--term-text);
  background: transparent;
}
.event.agent { border-left-color: var(--term-green); background: transparent; }
.event.pending { border-left-color: var(--term-blue); opacity: .72; }
.event.command { border-left-color: var(--term-amber); color: #c9d1d9; background: transparent; font-family: inherit; }
.event.error { border-left-color: var(--term-red); }
.event-label { margin-bottom: 5px; color: var(--term-muted); font: 500 9px/1 inherit; letter-spacing: .04em; text-transform: none; }
.event.agent .event-label { color: var(--term-green); }
.event-body { color: inherit; white-space: normal; word-break: break-word; font-size: 12px; line-height: 1.55; }
.event-body .plain-text, .event-body .md-line { white-space: pre-wrap; }
.event-body strong { color: #f3f6fa; font-weight: 700; }
.event-body code {
  padding: 0 0.25em;
  border: 1px solid #263342;
  border-radius: 3px;
  background: #111820;
  color: #d7e7f7;
  font-family: inherit;
}
.event-body h1, .event-body h2, .event-body h3, .event-body h4, .event-body h5, .event-body h6 { margin: .8em 0 .35em; color: var(--term-bright); font: 700 1em/1.35 inherit; }
.event-body h1 { font-size: 1.25em; }
.event-body h2 { font-size: 1.16em; }
.event-body h3 { font-size: 1.08em; }
.event-body ul, .event-body ol { margin: .4em 0 .55em; padding-left: 1.8em; }
.event-body li { margin: .18em 0; }
.event-body .md-task { list-style: none; margin-left: -1.35em; }
.event-body .md-checkbox { display: inline-flex; width: 1em; height: 1em; margin-right: .45em; align-items: center; justify-content: center; border: 1px solid #596777; border-radius: 3px; color: var(--term-green); font-size: .82em; vertical-align: -.08em; }
.event-body pre { margin: .55em 0; padding: 9px 10px; overflow-x: auto; border: 1px solid #263342; background: #070a0e; white-space: pre; }
.event-body pre code { padding: 0; border: 0; background: transparent; }
.event-body blockquote { margin: .5em 0; padding: .2em 0 .2em .8em; border-left: 2px solid var(--term-blue); color: #aab5c2; }
.event-body a { color: var(--term-blue); text-decoration: none; }
.event-body a:hover { text-decoration: underline; }
.event-body hr { height: 1px; margin: .7em 0; border: 0; background: var(--term-border); }
.event-body .md-gap { height: .55em; }
.md-table-wrap { max-width: 100%; margin: .5em 0; overflow-x: auto; }
.event-body table { width: max-content; min-width: 100%; border-collapse: collapse; }
.event-body th, .event-body td { padding: 5px 7px; border: 1px solid var(--term-border); text-align: left; }
.event-body th { color: var(--term-bright); background: var(--term-panel-2); }

.approval-box { margin: 0; padding: 10px 12px; border: 0; border-top: 1px solid var(--term-amber); border-radius: 0; color: var(--term-text); background: #16120a; }
.button-row { gap: 5px; margin-top: 7px; }
.composer { flex: 0 0 auto; padding: 8px 10px 9px; border-top: 1px solid var(--term-border); background: var(--term-panel); }
.terminal-input-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 50px; gap: 7px; align-items: stretch; }
.terminal-prompt { padding: 9px 0 0 2px; color: var(--term-green); font-size: 16px; line-height: 1; }
.terminal-send { border: 1px solid #238636; border-radius: 5px; color: white; background: #238636; font: 600 11px/1 inherit; }
.terminal-send:hover { border-color: var(--term-green); background: var(--term-hover); }
.terminal-send:disabled { cursor: wait; opacity: .65; }
.composer textarea, .auth-card input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--term-border);
  border-radius: 2px;
  outline: none;
  color: var(--term-bright);
  background: var(--term-bg);
  caret-color: var(--term-green);
}
.composer textarea:focus, .auth-card input:focus { border-color: var(--term-blue); box-shadow: none; }
.composer textarea.voice-recording { border-color: var(--term-green); background: #0b1711; box-shadow: 0 0 0 2px rgba(63,185,80,.1); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.composer textarea::placeholder, .auth-card input::placeholder { color: #545d68; }
.button {
  padding: 6px 9px;
  border: 1px solid var(--term-border);
  border-radius: 2px;
  color: var(--term-text);
  background: transparent;
  font-size: 10px;
  font-weight: 500;
}
.button:hover { color: var(--term-bright); background: var(--term-hover); }
.button.primary { border-color: #238636; color: #fff; background: #238636; }
.button.primary:hover { background: #2ea043; }
.button.danger { border-color: #6e2825; color: var(--term-red); }
.button.subtle { background: transparent; }

.auth-layer { background: rgba(9, 12, 16, .96); backdrop-filter: none; }
.auth-card { width: min(430px, 100%); padding: 22px; border: 1px solid var(--term-border); border-radius: 2px; color: var(--term-text); background: var(--term-panel); box-shadow: none; }
.auth-card p { color: var(--term-muted); font-size: 11px; line-height: 1.6; }
.passkey-button { min-height: 38px; }
.auth-divider { color: var(--term-muted); }
.auth-divider::before, .auth-divider::after { background: var(--term-border); }
.token-login input { border-radius: 2px; color: var(--term-text); background: #090c10; }
.form-error { color: var(--term-red); }
.toast { bottom: 14px; padding: 7px 10px; border: 1px solid var(--term-border); border-radius: 2px; color: var(--term-text); background: var(--term-panel-2); font-size: 10px; }

* { scrollbar-width: thin; scrollbar-color: #30363d #0d1117; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: var(--term-panel); }
*::-webkit-scrollbar-thumb { background: #30363d; }

@media (max-width: 820px) {
  html, body {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }
  .app-shell {
    position: fixed;
    inset: 0;
    height: var(--console-viewport-height, 100dvh);
    max-height: var(--console-viewport-height, 100dvh);
    min-height: 220px;
    padding: 0;
  }
  .node-tabs {
    display: grid;
    flex: 0 0 calc(46px + max(48px, env(safe-area-inset-top)));
    height: calc(46px + max(48px, env(safe-area-inset-top)));
    grid-template-columns: repeat(var(--node-count, 5), minmax(0, 1fr));
    overflow: clip;
    padding: max(48px, env(safe-area-inset-top)) 4px 0;
    background: #0b0f14;
  }
  .node-tab { width: 100%; min-width: 0; height: 45px; padding: 7px 2px 5px; border-right-color: #20262e; text-align: center; }
  .node-tab:first-child { border-left: 0; }
  .node-tab span { overflow: hidden; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
  .node-tab.active { border-bottom-width: 3px; background: #121923; }
  .node-tab small { display: none; }
  .workspace-grid { display: flex; flex: 1; min-height: 0; flex-direction: column; }
  .session-panel { display: flex; flex: 0 0 62px; width: 100%; min-height: 0; border-right: 0; border-bottom: 1px solid var(--term-border); background: #0b0f14; }
  .session-panel .panel-heading { display: none; }
  .session-list { display: flex; gap: 5px; width: 100%; overflow-x: auto; overflow-y: hidden; padding: 5px 6px 6px; scroll-snap-type: x proximity; }
  .session-item { flex: 0 0 min(202px, calc(50vw - 9px)); height: 50px; padding: 7px 8px; border: 1px solid #222a34; border-radius: 6px; background: #0e131a; scroll-snap-align: start; }
  .session-item:hover { background: #121923; }
  .session-item.active { border-color: #294a68; background: #111b26; box-shadow: inset 0 -2px var(--term-blue); }
  .session-item .session-name { display: -webkit-box; overflow: hidden; color: #e6edf3; white-space: normal; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .session-item .session-preview { display: none; }
  .session-item .session-time { color: #65707d; font-size: 8px; }
  .conversation-panel { position: static; flex: 1 1 auto; width: 100%; height: auto; min-height: 0; border: 0; border-radius: 0; background: var(--term-bg); transform: none; transition: none; }
  .conversation-panel.mobile-open { transform: none; }
  .conversation-head { display: none; }
  .conversation-head:before { content: none; }
  .working-bar { flex-basis: 32px; padding: 5px 9px; }
  .working-detail { flex: 1; font-size: 9px; }
  .timeline { max-height: none; padding: 7px 7px 11px; }
  .latest-button { right: 9px; bottom: 8px; min-height: 34px; padding: 7px 11px; }
  .event { margin: 0 0 6px; padding: 9px 9px 10px; border: 1px solid #171e26; border-left: 3px solid #30363d; border-radius: 6px; background: #0b0f14; }
  .event.agent { border-color: #173c29; border-left-color: var(--term-green); background: #0b1210; }
  .event.pending { border-color: #18334d; border-left-color: var(--term-blue); background: #0b1118; }
  .event.command { border-color: #3a2b13; border-left-color: var(--term-amber); background: #100e0a; }
  .event-body { font-size: 11px; line-height: 1.62; }
  .event-label { margin-bottom: 6px; }
  .composer { padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); background: #0b0f14; }
  .terminal-input-row { grid-template-columns: 32px minmax(0, 1fr) 52px; gap: 6px; }
  .composer textarea { border-radius: 6px; background: #080c11; }
  .terminal-send { border-radius: 6px; background: #238636; }
  .auth-layer { padding: max(14px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom)); }
  .auth-card { width: 100%; max-width: 390px; padding: 18px 16px; }
  .auth-card h2 { font-size: 17px; }
  .auth-card p { margin: 9px 0; font-size: 11px; }
  .auth-card .button { min-height: 42px; }
}

/* Minimal Codex CLI surface. */
.working-bar {
  position: static;
  width: 100%;
  box-sizing: border-box;
  min-height: 38px;
  gap: 6px;
  padding: 7px 14px;
  border-top: 1px solid var(--term-border);
  border-bottom: 0;
  color: var(--term-text);
  background: rgba(9, 12, 16, .97);
  box-shadow: none;
  font-size: 11px;
}
.working-bullet {
  display: inline-block;
  color: var(--term-blue);
  font-size: 9px;
  transform-origin: center;
  animation: cli-working-pulse 1.35s ease-in-out infinite;
}
.working-label { color: var(--term-bright); font-weight: 700; }
.working-meta { color: var(--term-muted); white-space: nowrap; }
.working-separator { color: #4b5561; }
.working-time { color: var(--term-muted); }
.working-stop {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--term-muted);
  background: transparent;
  font: inherit;
}
.working-stop:hover { color: var(--term-red); background: transparent; }
.working-detail { color: var(--term-muted); }
@keyframes cli-working-pulse { 50% { opacity: .28; } }

.event,
.event.agent,
.event.pending,
.event.command,
.event.error {
  margin: 0;
  padding: 10px 7px 11px;
  border: 0;
  border-bottom: 1px solid #151a20;
  border-radius: 0;
  background: transparent;
}
.event-label { margin-bottom: 6px; font-size: 9px; }
.event-body { font-size: 12px; line-height: 1.62; }

.composer { position: relative; padding: 10px 12px 12px; background: #0b0f14; }
.voice-draft {
  position: absolute;
  z-index: 14;
  right: 12px;
  bottom: calc(100% + 8px);
  left: 12px;
  overflow: hidden;
  border: 1px solid #4b5562;
  border-radius: 10px;
  background: #151a20;
  box-shadow: 0 -14px 38px rgba(0,0,0,.48);
}
.voice-draft.recording { border-color: rgba(63,185,80,.82); }
.voice-draft-head {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-bottom: 1px solid var(--term-border);
  color: #aab4c0;
  font-size: 12px;
}
.voice-draft-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--term-green); }
.voice-draft.recording .voice-draft-dot { animation: working-pulse .75s ease-in-out infinite alternate; }
.voice-draft textarea {
  display: block;
  width: 100%;
  min-height: 88px;
  max-height: min(180px, 30vh);
  resize: none;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  outline: 0;
  padding: 12px;
  color: var(--term-text);
  background: #0d1218;
  font: 14px/1.65 inherit;
}
.voice-draft textarea[readonly] { color: #eef4fb; }
.voice-draft-edit-surface {
  position: absolute;
  z-index: 3;
  top: 34px;
  right: 0;
  bottom: 51px;
  left: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.voice-editor-active .voice-draft-edit-surface { display: none; }
.voice-draft-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--term-border); }
.voice-draft-actions button { min-width: 64px; border: 1px solid #4b5562; border-radius: 6px; padding: 7px 12px; color: var(--term-text); background: transparent; }
.voice-draft-actions .voice-draft-edit { margin-right: auto; }
.voice-draft-actions button.primary { border-color: var(--term-green); color: #8fe29f; }
.voice-draft-actions button:disabled { opacity: .38; }
.terminal-input-row {
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 0;
  overflow: hidden;
  border: 1px solid #3a4048;
  background: #292c31;
}
.terminal-input-row:focus-within { border-color: #626b76; }
.terminal-editor { position: relative; display: flex; min-width: 0; align-items: stretch; }
.terminal-editor .terminal-prompt {
  position: absolute;
  z-index: 2;
  top: 13px;
  left: 12px;
  padding: 0;
  color: var(--term-blue);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}
.composer .terminal-editor textarea {
  min-height: 46px;
  max-height: 132px;
  padding: 11px 12px 10px 34px;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  line-height: 1.55;
  touch-action: manipulation;
}
.composer .terminal-editor textarea:focus { border-color: transparent; box-shadow: none; }
.composer .terminal-editor textarea.voice-only {
  cursor: default;
  touch-action: manipulation;
  caret-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.composer .terminal-editor textarea.voice-only::placeholder {
  color: #717b88;
  font-size: 14px;
  letter-spacing: -.04em;
  text-align: center;
  opacity: 1;
}
.voice-composer-hint {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  box-sizing: border-box;
  place-items: center;
  padding: 0 34px;
  color: #717b88;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: -.04em;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}
.voice-composer-hint.hidden { display: none; }
.terminal-send {
  min-height: 46px;
  border: 0;
  border-left: 1px solid #3a4048;
  border-radius: 0;
  background: transparent;
}
.terminal-send { color: var(--term-green); font-size: 18px; }
.terminal-send:hover { border-color: var(--term-green); color: #fff; background: #112016; }

@media (max-width: 820px) {
  .session-panel { flex-basis: 42px; }
  .session-list { gap: 13px; padding: 0 9px; align-items: stretch; scroll-snap-type: none; }
  .session-item {
    flex: 0 0 auto;
    width: auto;
    height: 41px;
    grid-template-columns: 7px auto;
    gap: 7px;
    padding: 8px 3px 7px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
  }
  .session-item:hover { background: transparent; }
  .session-item.active { border-color: var(--term-blue); background: transparent; box-shadow: none; }
  .session-item .session-name { display: block; max-width: 145px; white-space: nowrap; font-size: 11px; }
  .session-item .session-time, .session-item .session-preview { display: none; }
  .working-bar { flex-basis: 38px; min-height: 38px; padding: 7px 10px; font-size: 12px; }
  .working-detail { font-size: 10px; }
  .timeline { padding: 4px 10px 9px; }
  .event, .event.agent, .event.pending, .event.command, .event.error { margin: 0; padding: 10px 3px 11px; }
  .event-label { font-size: 10px; }
  .event-body { font-size: 12px; line-height: 1.68; }
  .composer { padding: 8px 9px max(8px, calc(env(safe-area-inset-bottom) - 12px)); }
  .terminal-input-row { min-height: 64px; grid-template-columns: minmax(0, 1fr) 46px; }
  .composer .terminal-editor textarea {
    min-height: 64px;
    padding-top: 18px;
    padding-bottom: 17px;
    font-size: 16px;
  }
  .composer .terminal-editor textarea.voice-only {
    padding-right: 34px;
  }
  .terminal-editor .terminal-prompt { top: 21px; }
  .terminal-send { min-height: 64px; }
  .voice-draft { right: 9px; left: 9px; bottom: calc(100% + 6px); }
  .voice-draft textarea { min-height: 94px; font-size: 16px; }
  .keyboard-editing .voice-draft {
    max-height: calc(var(--console-viewport-height, 100dvh) - 96px);
  }
  .keyboard-editing .voice-draft textarea {
    max-height: calc(var(--console-viewport-height, 100dvh) - 190px);
  }
  .voice-editor-active .composer {
    padding: 0;
    border-top-color: #303844;
    background: #11161c;
  }
  .voice-editor-active .composer .terminal-input-row {
    display: none !important;
  }
  .voice-editor-active .voice-draft {
    position: relative;
    inset: auto;
    display: flex;
    width: 100%;
    max-height: calc(var(--console-viewport-height, 100dvh) - 8px);
    flex-direction: column;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 12px 12px 0 0;
    background: #151a20;
    box-shadow: none;
    animation: none;
  }
  .voice-editor-active .voice-draft textarea {
    flex: 1 1 auto;
    min-height: 112px;
    max-height: calc(var(--console-viewport-height, 100dvh) - 104px);
  }
  .voice-editor-active .voice-draft-actions {
    flex: 0 0 auto;
    background: #11161c;
  }
  .auth-card input { font-size: 16px; }
}

.working-bullet {
  color: var(--term-blue);
  animation: working-pulse .9s ease-in-out infinite alternate;
}
@keyframes working-pulse {
  from { opacity: .35; transform: scale(.78); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-width: 820px) {
  .composer .terminal-editor textarea::placeholder {
    font-size: 12px;
    letter-spacing: -.045em;
  }
  .composer .terminal-editor textarea.voice-only::placeholder {
    font-size: 14px;
    letter-spacing: -.05em;
    text-align: center;
  }
  .node-tab span { font-size: 11px; }
  .list-empty { font-size: 12px; }
  .session-list > .list-empty {
    align-self: center;
    flex: 0 0 auto;
    padding: 8px 2px;
    font-size: 9px;
    line-height: 24px;
    white-space: nowrap;
  }
  .toast { font-size: 10px; }
}

/* One consistent, more readable type scale for the iPhone console. */
@media (max-width: 820px) {
  body { font-size: 15px; }
  .node-tab span { font-size: 12px; }
  .session-item .session-name { font-size: 13px; }
  .working-bar { font-size: 13px; }
  .working-detail { font-size: 11px; }
  .event-label { font-size: 11px; }
  .event-body { font-size: 14px; line-height: 1.68; }
  .voice-draft-head { font-size: 14px; }
  .voice-draft textarea,
  .voice-editor-active .voice-draft textarea { font-size: 17px; }
  .voice-draft-actions button { font-size: 14px; }
  .voice-composer-hint,
  .composer .terminal-editor textarea.voice-only::placeholder { font-size: 15px; }
  .list-empty { font-size: 13px; }
  .session-list > .list-empty { font-size: 11px; }
  .latest-button,
  .toast { font-size: 12px; }
  .auth-card h2 { font-size: 19px; }
  .auth-card p { font-size: 13px; }
  .auth-card .button { font-size: 14px; }
}
