/* ==========================================================================
   RUButler console — self-contained stylesheet (no external fonts or assets)
   ========================================================================== */

:root {
  --slate-950: #0b1220;
  --slate-900: #101a2b;
  --slate-800: #1a2740;
  --ink: #101828;
  --ink-soft: #344054;
  --muted: #667085;
  --canvas: #f5f4f0;
  --surface: #ffffff;
  --surface-alt: #fbfaf7;
  --line: #e4e1da;
  --line-strong: #d3cec4;
  --accent: #0f766e;
  --accent-strong: #0b5d57;
  --accent-soft: #e6f2f0;
  --amber: #b45309;
  --amber-soft: #fdf3e3;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #15803d;
  --ok-soft: #e8f5ec;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 18px 40px -20px rgba(16, 24, 40, 0.35);
  --sidebar-w: 292px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
p,
ul,
dl,
dd {
  margin: 0;
}

h1,
h2,
h3 {
  font-weight: 600;
  letter-spacing: 0.01em;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.mono {
  font-family: var(--mono);
  font-size: 12.5px;
  word-break: break-all;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------- buttons */

.primary-button {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #0f766e, #0b5d57);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 18px -10px rgba(15, 118, 110, 0.8);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px -10px rgba(15, 118, 110, 0.9);
}

.primary-button:active {
  transform: none;
}

.primary-button:disabled {
  opacity: 0.55;
  cursor: progress;
  transform: none;
  box-shadow: none;
}

.ghost-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink-soft);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 12.5px;
  white-space: nowrap;
  flex: none;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.ghost-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.ghost-button.small {
  padding: 5px 9px;
  font-size: 11.5px;
  border-radius: 7px;
}

.icon-button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 19px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 7px;
  cursor: pointer;
}

.icon-button:hover {
  background: #f2f4f7;
  color: var(--ink);
}

/* ------------------------------------------------------------- app shell */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100vh;
  padding: 22px 18px 18px;
  overflow-y: auto;
  background: linear-gradient(180deg, #101a2b 0%, #0b1220 100%);
  color: #e6e9ef;
  scrollbar-width: thin;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 4px 6px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(140deg, #14b8a6, #0f766e);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  box-shadow: 0 6px 16px -8px rgba(20, 184, 166, 0.9);
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-text strong {
  font-size: 16px;
  letter-spacing: 0.02em;
}

.brand-text span {
  font-size: 11px;
  color: #8b9bb0;
}

.entry-rail {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry-card {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #f2f4f7;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.entry-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}

.entry-card.is-active {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.38), rgba(15, 118, 110, 0.12));
  border-color: rgba(45, 212, 191, 0.5);
}

.entry-concierge {
  padding: 15px 14px;
}

.entry-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}

.entry-copy strong {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.entry-kind {
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: #8b9bb0;
}

.entry-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16);
  animation: dot-breathe 2.8s ease-in-out infinite;
}

.entry-dot[data-state="polling"] {
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16);
}

.entry-dot[data-state="connecting"] {
  background: #94a3b8;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.16);
  animation: none;
}

.entry-dot[data-state="offline"] {
  background: #64748b;
  box-shadow: none;
  animation: none;
}

@keyframes dot-breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.entry-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 1px dashed rgba(255, 255, 255, 0.32);
  color: #cbd5e1;
  font-size: 15px;
  line-height: 1;
  flex: none;
}

.count-badge {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #0f766e;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
  flex: none;
}

.count-badge.is-zero {
  background: rgba(255, 255, 255, 0.12);
  color: #a9b6c7;
  font-weight: 600;
}

.nav-item .count-badge {
  background: rgba(255, 255, 255, 0.14);
  color: #e2e8f0;
}

.rail-label {
  margin: 12px 6px 2px;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: #7d8da3;
}

.thread-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 30vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.thread-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: #c3cedd;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.thread-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.thread-item.is-active {
  background: rgba(15, 118, 110, 0.24);
  border-color: rgba(45, 212, 191, 0.35);
  color: #fff;
}

.thread-index {
  font-weight: 600;
  white-space: nowrap;
}

.thread-id {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: #7f8fa6;
  flex: none;
}

.thread-empty {
  padding: 8px 11px;
  font-size: 12px;
  color: #7f8fa6;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  color: #aab7c8;
  text-decoration: none;
  font-size: 13.5px;
  transition: background 0.14s ease, color 0.14s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav-item.is-active {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
}

.side-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.session-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  color: #c3cedd;
  min-width: 0;
}

.session-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(45, 212, 191, 0.2);
  color: #5eead4;
  font-weight: 700;
  flex: none;
}

.session-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-logout {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.14);
  color: #aab7c8;
}

.side-logout:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}

/* ------------------------------------------------------------- workspace */

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  background: var(--canvas);
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 26px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.topbar-title h1 {
  font-size: 20px;
}

.topbar-title p {
  font-size: 12.5px;
  margin-top: 2px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.live-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.live-pill.is-live {
  background: var(--ok-soft);
  color: var(--ok);
}

.live-pill.is-polling {
  background: var(--amber-soft);
  color: var(--amber);
}

.live-pill.is-offline {
  background: var(--danger-soft);
  color: var(--danger);
}

.view-host {
  flex: 1;
  min-height: 0;
  padding: 22px 26px 30px;
  overflow-y: auto;
}

.view {
  max-width: 1180px;
  margin: 0 auto;
}

#view-console {
  display: flex;
  height: 100%;
  min-height: 0;
}

/* ------------------------------------------------------------- chat */

.chat-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-width: 1040px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #fbfaf7);
}

.chat-head h2 {
  font-size: 16px;
}

.chat-head-copy {
  min-width: 0;
}

.chat-head-copy p {
  font-size: 12px;
  margin-top: 2px;
}

.timeline {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 22px 10px;
  overflow-y: auto;
  background: radial-gradient(1100px 360px at 50% -80px, #fbfaf7, #ffffff 62%);
  scrollbar-width: thin;
}

.timeline-empty {
  margin: auto;
  padding: 32px 20px;
  text-align: center;
}

.empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.bubble-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: min(78%, 720px);
}

.row-mine {
  align-self: flex-end;
  align-items: flex-end;
}

.row-butler,
.row-report {
  align-self: flex-start;
  align-items: flex-start;
}

.bubble-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  font-size: 11.5px;
  color: var(--muted);
}

.bubble-author {
  font-weight: 600;
  color: var(--ink-soft);
}

.bubble-time {
  font-variant-numeric: tabular-nums;
}

.urgency-chip {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 10.5px;
  font-weight: 700;
}

.bubble {
  padding: 12px 15px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 14.5px;
  line-height: 1.68;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.row-mine .bubble {
  background: linear-gradient(135deg, #0f766e, #0b5d57);
  border-color: transparent;
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 8px 20px -14px rgba(15, 118, 110, 0.9);
}

.row-butler .bubble {
  border-bottom-left-radius: 5px;
}

.row-report .bubble {
  background: #fffdf7;
  border-color: #f0e2c8;
  border-left: 3px solid var(--amber);
  border-bottom-left-radius: 5px;
}

.row-report .bubble-author {
  color: var(--amber);
}

.bubble-state {
  padding: 0 4px;
  font-size: 11px;
  color: var(--muted);
}

.task-capsule {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: flex-start;
  width: min(78%, 720px);
  padding: 12px 14px;
  border: 1px solid #d9e7e4;
  border-radius: 13px;
  background: linear-gradient(180deg, #f7fbfa, #ffffff);
  box-shadow: var(--shadow-sm);
}

.capsule-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.capsule-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
}

.capsule-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.capsule-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  word-break: break-all;
}

.capsule-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.composer {
  padding: 14px 18px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 54px;
  max-height: 180px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-alt);
  font-size: 14.5px;
  line-height: 1.6;
  resize: none;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.composer textarea:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.composer-hint {
  font-size: 11.5px;
  color: var(--muted);
}

/* ------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  background: #eef2f6;
  color: #475467;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-queued {
  background: #eef2f6;
  color: #475467;
}

.badge-running {
  background: #e8f0fe;
  color: #1d4ed8;
}

.badge-waiting {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-done {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-stopped {
  background: #f2f4f7;
  color: #667085;
}

.badge-failed {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ------------------------------------------------------------- panes & cards */

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.pane-head h2 {
  font-size: 16px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(330px, 0.88fr);
  gap: 20px;
  align-items: start;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 12px;
}

.task-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.task-card:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.task-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.task-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.task-title {
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.task-sub {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  word-break: break-all;
}

.detail-pane {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.detail-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 46vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.detail-section h3 {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.detail-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-alt);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.detail-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--muted);
}

.kv {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 6px 12px;
  font-size: 12.5px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.inline-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.inline-form textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  font-size: 13.5px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}

.inline-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.inline-form .primary-button {
  align-self: flex-start;
}

/* ------------------------------------------------------------- drill & approvals */

.drill-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 22px;
  margin-bottom: 22px;
  padding: 20px;
  border: 1px solid #e9dfcd;
  border-radius: 16px;
  background: linear-gradient(180deg, #fffdf8, #ffffff);
  box-shadow: var(--shadow-sm);
}

.drill-copy {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drill-copy h2 {
  font-size: 17px;
}

.drill-copy p {
  font-size: 13px;
  line-height: 1.7;
}

.drill-copy code {
  font-family: var(--mono);
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 5px;
  background: #f4efe4;
  color: #6b4a12;
}

.drill-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.drill-steps li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  line-height: 1.55;
}

.drill-steps span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  flex: none;
  margin-top: 1px;
}

.drill-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drill-result {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px dashed var(--line-strong);
  font-size: 13px;
}

.drill-result pre {
  margin: 0;
}

.result-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.result-label {
  min-width: 96px;
  color: var(--muted);
  font-size: 12px;
  flex: none;
}

.approval-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.approval-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.approval-route {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
}

.approval-action {
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 6px;
  background: #f4f5f7;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
}

.approval-target-line {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.approval-arrow {
  color: var(--muted);
  font-size: 12px;
}

.approval-target {
  font-size: 13.5px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.payload-preview {
  max-height: 180px;
  padding: 10px 12px;
  border: 1px solid #ece7dc;
  border-radius: 10px;
  background: #fcfaf5;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
}

.payload-label {
  display: block;
  margin-bottom: 6px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.approval-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px 16px;
  font-size: 12px;
}

.approval-meta div {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.approval-meta .k {
  color: var(--muted);
  flex: none;
}

.approval-meta .v {
  overflow-wrap: anywhere;
}

.approval-note {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  font-size: 13px;
  resize: vertical;
  outline: none;
}

.approval-note:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.approval-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-approve {
  background: linear-gradient(135deg, #15803d, #116634);
  box-shadow: 0 8px 18px -10px rgba(21, 128, 61, 0.8);
}

.btn-reject {
  border: 1px solid #f0c8c2;
  background: #fff;
  color: var(--danger);
}

.btn-reject:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 26px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: var(--surface-alt);
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ------------------------------------------------------------- token drawer */

.token-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(430px, calc(100vw - 32px));
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-md);
}

.token-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.token-head h3 {
  font-size: 14.5px;
}

.token-panel p {
  font-size: 12px;
  line-height: 1.65;
}

.token-fields {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 6px 12px;
  font-size: 12px;
}

.token-fields dt {
  color: var(--muted);
}

.token-fields dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  word-break: break-all;
}

.token-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------- audit */

.audit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.chain-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.chain-badge.is-valid {
  background: var(--ok-soft);
  color: var(--ok);
}

.chain-badge.is-broken {
  background: var(--danger-soft);
  color: var(--danger);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.audit-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  font-size: 12.5px;
}

.audit-table th {
  position: sticky;
  top: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.audit-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1efea;
  vertical-align: top;
  word-break: break-all;
}

.audit-table tbody tr:last-child td {
  border-bottom: none;
}

.audit-table tbody tr:hover {
  background: #fafaf8;
}

.hash-cell {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------- settings */

.settings-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 560px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.settings-card h2 {
  font-size: 18px;
}

.settings-card > p {
  font-size: 13px;
  line-height: 1.7;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}

.field input,
.field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field textarea {
  resize: vertical;
  line-height: 1.6;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--ink-soft);
  cursor: pointer;
}

.switch-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex: none;
}

.time-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ------------------------------------------------------------- login */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background:
    radial-gradient(900px 520px at 12% 0%, #eaf1ef, transparent 62%),
    radial-gradient(900px 520px at 100% 100%, #f4efe4, transparent 58%),
    #f6f5f1;
}

.login-shell {
  width: 100%;
  max-width: 960px;
}

.login-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.06fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 34px 70px -38px rgba(16, 24, 40, 0.45);
}

.login-aside {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 36px 34px;
  background: linear-gradient(160deg, #101a2b, #0b1220 62%, #0f2b28);
  color: #e8edf4;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-aside-title {
  font-size: 21px;
  line-height: 1.55;
}

.login-points {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  line-height: 1.6;
  color: #c4cfdd;
}

.login-points li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.login-points span {
  color: #2dd4bf;
  line-height: 1.5;
}

.login-aside-foot {
  margin-top: auto;
  font-size: 11px;
  color: #7f8fa6;
}

.login-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 40px 38px;
}

.login-head h1 {
  margin: 6px 0;
  font-size: 22px;
}

.login-head p {
  font-size: 13px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-submit {
  width: 100%;
  padding: 12px;
  font-size: 14px;
}

.form-error {
  padding: 10px 12px;
  border: 1px solid #f0c8c2;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.55;
}

.login-foot {
  font-size: 11.5px;
  line-height: 1.65;
}

/* ------------------------------------------------------------- toasts */

.toast-stack {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 380px;
  min-width: 220px;
  padding: 11px 14px;
  border-radius: 11px;
  background: #101828;
  color: #fff;
  font-size: 13px;
  line-height: 1.55;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
}

.toast.is-ok {
  background: #0f5132;
}

.toast.is-error {
  background: #7a271a;
}

.toast.is-warn {
  background: #7a4a12;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ------------------------------------------------------------- scrollbars */

.timeline::-webkit-scrollbar,
.thread-list::-webkit-scrollbar,
.view-host::-webkit-scrollbar,
.detail-body::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

.timeline::-webkit-scrollbar-thumb,
.thread-list::-webkit-scrollbar-thumb,
.view-host::-webkit-scrollbar-thumb,
.detail-body::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(16, 24, 40, 0.16);
}

.sidebar::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.timeline::-webkit-scrollbar-track,
.thread-list::-webkit-scrollbar-track,
.view-host::-webkit-scrollbar-track,
.detail-body::-webkit-scrollbar-track {
  background: transparent;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 1120px) {
  .split {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-pane {
    position: static;
  }

  .detail-body {
    max-height: none;
  }

  .drill-card {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    height: auto;
    max-height: 46vh;
    position: static;
    padding: 18px 16px 14px;
  }

  .thread-list {
    max-height: 168px;
  }

  .side-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 4px;
    overflow-x: auto;
    padding-top: 10px;
    scrollbar-width: none;
  }

  .nav-item {
    white-space: nowrap;
    font-size: 12.5px;
    padding: 8px 10px;
  }

  .side-foot {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    margin-top: 0;
  }

  .workspace {
    height: auto;
  }

  .view-host {
    padding: 16px 14px 24px;
    overflow: visible;
  }

  #view-console {
    height: auto;
  }

  .chat-card {
    height: auto;
    min-height: 0;
  }

  .timeline {
    max-height: none;
    overflow: visible;
    padding: 16px 14px 6px;
  }

  .composer {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -10px 26px -20px rgba(16, 24, 40, 0.6);
  }

  .topbar {
    padding: 16px 16px 12px;
  }

  .bubble-row,
  .task-capsule {
    max-width: 88%;
    width: auto;
  }

  .token-panel {
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
  }
}

@media (max-width: 720px) {
  .login-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .login-aside {
    gap: 14px;
    padding: 24px 22px;
  }

  .login-points {
    display: none;
  }

  .login-aside-foot {
    display: none;
  }

  .login-panel {
    padding: 26px 22px 30px;
  }

  .topbar {
    flex-wrap: wrap;
    align-items: flex-start;
  }
}

@media (max-width: 520px) {
  .bubble-row,
  .task-capsule {
    max-width: 94%;
  }

  .card-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .time-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .composer-foot {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
