/* ═══════════════════════════════════════════════════════════
   ASCN Claw — Ivory Slate Light Theme
   Clean, airy command center with depth
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* Palette — warm stone */
  --bg-abyss: #ddd9d1;
  --bg-deep: #e6e2db;
  --bg-base: #edeae4;
  --bg-surface: #f5f3ef;
  --bg-elevated: #f9f7f4;
  --bg-hover: #e8e5de;
  --bg-active: #dedbd4;

  /* Glass */
  --glass: rgba(245, 243, 239, 0.8);
  --glass-border: rgba(0, 0, 0, 0.1);
  --glass-border-hover: rgba(0, 0, 0, 0.16);
  --glass-shine: rgba(255, 255, 255, 0.5);

  /* Accent — deep teal */
  --accent: #0d9373;
  --accent-dim: rgba(13, 147, 115, 0.3);
  --accent-glow: rgba(13, 147, 115, 0.12);
  --accent-soft: rgba(13, 147, 115, 0.07);
  --accent-text: #0a7d62;
  --accent-2: #6d5acd;
  --accent-2-soft: rgba(109, 90, 205, 0.07);

  /* Text */
  --text: #1a1d26;
  --text-secondary: #5c5f6e;
  --text-dim: #9b9daa;
  --text-ghost: #c8c9d0;

  /* Semantic */
  --error: #d93251;
  --error-bg: rgba(217, 50, 81, 0.06);
  --error-border: rgba(217, 50, 81, 0.18);
  --success: #0d9373;
  --success-bg: rgba(13, 147, 115, 0.07);
  --warning: #c47d10;
  --warning-bg: rgba(196, 125, 16, 0.07);
  --warning-border: rgba(196, 125, 16, 0.18);

  /* Chat */
  --user-bg: rgba(13, 147, 115, 0.07);
  --user-border: rgba(13, 147, 115, 0.16);
  --bot-bg: #f5f3ef;
  --bot-border: rgba(0, 0, 0, 0.08);

  /* Typography */
  --font-display: 'Syne', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', monospace;

  /* Layout */
  --ws-sidebar-w: 240px;
  --nav-w: 210px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

html, body {
  height: 100%;
  background: var(--bg-abyss);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

::selection {
  background: var(--accent);
  color: #fff;
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.18);
}

/* ═══════════════════════════════════════
   NOISE TEXTURE OVERLAY
   ═══════════════════════════════════════ */
#app::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.018;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 180px;
}

/* ═══════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════ */
#app {
  display: flex;
  height: 100%;
  background: var(--bg-deep);
  position: relative;
}

/* Ambient gradient mesh */
#app::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 50% 40% at 10% 20%, rgba(13, 147, 115, 0.04), transparent),
    radial-gradient(ellipse 40% 50% at 90% 80%, rgba(109, 90, 205, 0.03), transparent),
    radial-gradient(ellipse 60% 30% at 50% 50%, rgba(13, 147, 115, 0.02), transparent);
}

#app > * { position: relative; z-index: 1; }

/* ═══════════════════════════════════════
   WORKSPACE SIDEBAR (LEFT)
   ═══════════════════════════════════════ */
#ws-sidebar {
  width: var(--ws-sidebar-w);
  min-width: var(--ws-sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--bg-abyss);
  border-right: 1px solid var(--glass-border);
  position: relative;
  overflow: hidden;
}

/* Accent glow line on right edge */
#ws-sidebar::after {
  content: '';
  position: absolute;
  right: 0;
  top: 15%;
  bottom: 15%;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--accent-dim), transparent);
  opacity: 0.5;
  pointer-events: none;
}

#ws-sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#ws-sidebar-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

#ws-sidebar-header .logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
  font-weight: 800;
  font-family: var(--font-display);
  box-shadow: 0 2px 12px var(--accent-glow);
}

#ws-sidebar-header h2 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.btn-new-ws {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  transition: all 0.25s var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-new-ws:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: scale(1.05);
}
.btn-new-ws:active {
  transform: scale(0.95);
}

/* ── Workspace list ── */
#ws-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px;
}

.ws-item {
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 2px;
  font-size: 12.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s var(--ease);
  border: 1px solid transparent;
  color: var(--text-secondary);
  position: relative;
}
.ws-item:hover {
  background: var(--bg-surface);
  border-color: var(--glass-border-hover);
  color: var(--text);
}
.ws-item.active {
  background: var(--bg-elevated);
  border-color: var(--accent-dim);
  color: var(--accent-text);
  box-shadow: 0 1px 6px rgba(13, 147, 115, 0.08);
}
/* Active left bar indicator */
.ws-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  bottom: 25%;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent-glow);
}
.ws-item .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  font-weight: 400;
}
.ws-item.active .name {
  font-weight: 500;
}
.ws-item .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-left: 8px;
  flex-shrink: 0;
  transition: all 0.3s var(--ease);
}
.ws-item .dot.running {
  background: var(--success);
  box-shadow: 0 0 8px rgba(0, 229, 160, 0.5);
  animation: pulse-dot 2.5s infinite;
}
.ws-item .dot.error-dot {
  background: var(--error);
  box-shadow: 0 0 8px rgba(255, 77, 106, 0.5);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(0, 229, 160, 0.5); }
  50% { opacity: 0.5; box-shadow: 0 0 16px rgba(0, 229, 160, 0.7); }
}

.ws-item .delete {
  display: none;
  font-size: 14px;
  margin-left: 6px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  align-items: center;
  justify-content: center;
}
.ws-item .delete:hover {
  color: var(--error);
  background: var(--error-bg);
}
.ws-item:hover .delete { display: flex; }
.ws-item.active .delete { color: var(--accent-dim); }
.ws-item.active .delete:hover { color: var(--error); background: var(--error-bg); }

/* ── Sidebar footer ── */
#ws-sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#ws-sidebar-footer button {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  padding: 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 400;
  transition: all 0.2s var(--ease);
  letter-spacing: 0.02em;
}
#ws-sidebar-footer button:hover {
  border-color: var(--glass-border-hover);
  color: var(--text);
  background: var(--bg-elevated);
}

/* ═══════════════════════════════════════
   NAV SIDEBAR (WORKSPACE SECTIONS)
   ═══════════════════════════════════════ */
#nav-sidebar {
  width: var(--nav-w);
  min-width: var(--nav-w);
  border-right: 1px solid var(--glass-border);
  background: var(--bg-base);
  display: none;
  flex-direction: column;
}
#nav-sidebar.visible { display: flex; }

#nav-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--glass-border);
}
#nav-header .ws-name {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
  color: var(--text);
}
#nav-header .ws-status {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
}
#nav-header .ws-status::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.nav-controls {
  display: flex;
  gap: 5px;
  margin-top: 10px;
}
.nav-ctrl-btn {
  padding: 5px 10px;
  font-size: 11px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  transition: all 0.2s var(--ease);
  display: none;
}
.nav-ctrl-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--glass-border-hover);
  color: var(--text);
}

.nav-section {
  padding: 18px 16px 6px;
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-secondary);
  transition: all 0.15s var(--ease);
  position: relative;
  border-radius: 0;
}
.nav-item:hover {
  background: rgba(0, 0, 0, 0.02);
  color: var(--text);
}
.nav-item.active {
  color: var(--accent-text);
  font-weight: 500;
  background: var(--accent-soft);
}
.nav-item.active::after {
  content: '';
  position: absolute;
  right: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 6px var(--accent-glow);
}
.nav-item .icon {
  width: 18px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.45;
  flex-shrink: 0;
}
.nav-item .icon svg { display: block; }
.nav-item.active .icon { opacity: 1; }
.nav-badge {
  margin-left: auto;
  font-size: 9px;
  background: var(--bg-elevated);
  padding: 2px 7px;
  border-radius: 10px;
  color: var(--text-dim);
  border: 1px solid var(--glass-border);
}

/* ═══════════════════════════════════════
   CONTENT AREA
   ═══════════════════════════════════════ */
#content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-deep);
  position: relative;
  overflow: hidden;
}

/* Ambient gradient in content */
#content::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 50% 40% at 30% 0%, rgba(13, 147, 115, 0.04), transparent),
    radial-gradient(ellipse 40% 40% at 70% 100%, rgba(109, 90, 205, 0.03), transparent);
  pointer-events: none;
  z-index: 0;
}
#content > * { position: relative; z-index: 1; }

#content-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--glass-border);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  background: rgba(237, 234, 228, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── Pages ── */
.page { flex: 1; display: none; flex-direction: column; min-height: 0; }
.page.active { display: flex; }

.page-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 13px;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  animation: fadeIn 0.15s var(--ease) forwards;
}
.page-placeholder .icon {
  font-size: 40px;
  opacity: 0.1;
}

/* ═══════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════ */
#empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
  font-family: var(--font-display);
  font-weight: 400;
  flex-direction: column;
  gap: 16px;
  opacity: 0;
  animation: fadeIn 0.2s var(--ease) forwards;
}
.empty-hex {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--accent-soft), var(--accent-2-soft));
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  opacity: 0.3;
  transform: rotate(5deg);
}

/* ═══════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes msgIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes panelIn {
  from { opacity: 0; transform: scale(0.96) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ═══════════════════════════════════════
   CHAT PAGE
   ═══════════════════════════════════════ */
#page-chat { flex: 1; display: none; flex-direction: column; min-height: 0; }
#page-chat.active { display: flex; }

#chat-meta {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 400;
  font-family: var(--font-mono);
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

/* ── Message bubbles ── */
.msg {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  max-width: 78%;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
  font-size: 13px;
  animation: msgIn 0.15s var(--ease) forwards;
  opacity: 0;
  border: 1px solid transparent;
  position: relative;
}

.msg.user {
  background: var(--user-bg);
  border-color: var(--user-border);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.msg.assistant {
  background: var(--bot-bg);
  border-color: var(--bot-border);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.msg.error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.msg-retry-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-display);
  background: var(--error);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.15s;
}
.msg-retry-btn:hover { opacity: 0.85; }
.msg.system {
  background: rgba(0, 0, 0, 0.02);
  border-color: var(--glass-border);
  align-self: center;
  max-width: 90%;
  font-size: 12px;
  color: var(--text-secondary);
}

.msg .role {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: var(--font-display);
}
.msg.user .role { color: var(--accent-dim); }

.msg .streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: var(--accent);
  animation: cursorBlink 0.8s infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
  border-radius: 1px;
  box-shadow: 0 0 10px var(--accent-glow);
}

.msg .working {
  color: var(--text-dim);
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 10px;
}
.msg .working::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid var(--text-ghost);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ── Thread events / Artifacts ── */
.te-wrap {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.thread-events {
  margin-top: 10px;
  border-top: 1px solid var(--glass-border);
  padding-top: 10px;
}
.thread-events summary {
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 500;
  transition: color 0.15s;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.thread-events summary:hover { color: var(--text-secondary); }
.thread-events summary .te-icon { font-size: 13px; opacity: 0.7; }
.thread-events summary .te-badge {
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 8px;
  font-weight: 600;
  font-family: var(--font-mono);
}
.thread-events summary .te-badge.ok {
  background: var(--success-bg);
  color: var(--success);
}
.thread-events summary .te-badge.has-fail {
  background: var(--error-bg);
  color: var(--error);
}

.te-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.te-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--glass-border);
  font-size: 12px;
  transition: all 0.15s var(--ease);
}
.te-card:hover { background: rgba(0, 0, 0, 0.03); }

.te-card .te-status {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}
.te-card .te-status.ok { background: var(--success-bg); color: var(--success); }
.te-card .te-status.fail { background: var(--error-bg); color: var(--error); }

.te-card .te-tool-name {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 450;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.te-card .te-tool-name .te-prefix {
  color: var(--text-dim);
  font-weight: 400;
}
.te-card .te-tool-tag {
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.te-card .te-tool-tag.mcp { background: var(--accent-2-soft); color: var(--accent-2); }
.te-card .te-tool-tag.tool { background: rgba(0, 0, 0, 0.03); color: var(--text-dim); }

.te-duration {
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.te-card-wrap {
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  overflow: hidden;
}
.te-card-wrap > summary.te-card {
  list-style: none;
  cursor: pointer;
  border: none;
  border-radius: 0;
}
.te-card-wrap > summary.te-card::-webkit-details-marker { display: none; }
.te-card-wrap > summary.te-card.expandable .te-tool-name::after {
  content: '\25B8';
  margin-left: 4px;
  font-size: 9px;
  color: var(--text-dim);
  transition: transform 0.15s var(--ease);
  display: inline-block;
}
details.te-card-wrap[open] > summary.te-card.expandable .te-tool-name::after {
  transform: rotate(90deg);
}
.te-card-detail {
  padding: 6px 10px 8px 34px;
  border-top: 1px solid var(--glass-border);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 150px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.03);
}
.te-card-args {
  color: var(--text-dim);
  border-top-color: var(--glass-border);
}
.te-card-args::before {
  content: 'ARGS';
  display: block;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent);
  opacity: 0.6;
  margin-bottom: 2px;
  font-family: var(--font-display);
}
.te-card-detail + .te-card-detail::before {
  content: 'RESULT';
  display: block;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-dim);
  opacity: 0.6;
  margin-bottom: 2px;
  font-family: var(--font-display);
}
.te-wrap .thread-events { margin-top: 0; border-top: none; padding-top: 0; }
.te-live { }
.te-running {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  animation: fadeIn 0.15s var(--ease) forwards;
  opacity: 0;
}
.te-running .te-tool-name {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
}
.te-running-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--glass-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.te-hint {
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--font-display);
}

/* ── File artifact cards ── */
.te-file-artifact {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 229, 160, 0.15);
  background: rgba(0, 229, 160, 0.04);
  overflow: hidden;
  animation: msgIn 0.15s var(--ease) forwards;
  opacity: 0;
}
.te-file-running {
  border-color: var(--glass-border);
  background: var(--bg-surface);
}
.te-file-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 12px;
  font-family: var(--font-display);
}
.te-file-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
  font-weight: 700;
}
.te-file-verb { font-weight: 500; color: var(--text-secondary); }
.te-file-path { font-family: var(--font-mono); font-weight: 500; color: var(--text); }
.te-file-header .te-duration { margin-left: auto; }
.te-file-preview {
  padding: 6px 12px 8px;
  border-top: 1px solid rgba(0, 229, 160, 0.08);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.02);
}

/* ── Restart banner ── */
.restart-banner {
  margin-top: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-display);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: msgIn 0.15s var(--ease) forwards;
  opacity: 0;
}
.restart-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 179, 71, 0.25);
  border-top-color: var(--warning);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}


/* ═══════════════════════════════════════
   INPUT BAR
   ═══════════════════════════════════════ */
#input-bar {
  display: flex;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--glass-border);
  background: rgba(237, 234, 228, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
#input-bar textarea {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 11px 16px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  resize: none;
  height: 44px;
  max-height: 140px;
  transition: all 0.25s var(--ease);
  line-height: 1.5;
}
#input-bar textarea:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 30px rgba(0, 229, 160, 0.05);
  background: var(--bg-elevated);
}
#input-bar textarea::placeholder {
  color: var(--text-dim);
}
#input-bar button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px 24px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: all 0.25s var(--ease);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
#input-bar button:hover {
  box-shadow: 0 0 30px var(--accent-glow), 0 4px 16px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}
#input-bar button:active { transform: translateY(0); }
#input-bar button:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ═══════════════════════════════════════
   INTEGRATIONS PAGE
   ═══════════════════════════════════════ */
.integ-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--glass-border);
  padding: 0 24px;
}
.integ-tab {
  padding: 10px 18px;
  font-size: 12px;
  font-family: var(--font-mono);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.integ-tab.active {
  color: var(--accent-text);
  border-bottom-color: var(--accent);
}
.integ-tab:hover { color: var(--text); }

#integrations-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 24px;
  overflow-y: auto;
  flex: 1;
  opacity: 0;
  animation: fadeIn 0.15s var(--ease) forwards;
}

.mcp-card {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s var(--ease);
}
.mcp-card:hover { border-color: var(--glass-border-hover); background: var(--bg-elevated); }
.mcp-card-header { display: flex; align-items: center; gap: 10px; }
.mcp-card-name { font-weight: 600; font-size: 13px; color: var(--text); font-family: var(--font-display); }
.mcp-card-transport {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.03);
  padding: 2px 9px;
  border-radius: 20px;
  font-family: var(--font-mono);
  border: 1px solid var(--glass-border);
}
.mcp-card-url {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  word-break: break-all;
}
.mcp-card-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-dim);
}
.mcp-card-meta span { display: flex; align-items: center; gap: 4px; }

.mcp-remove-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  padding: 3px 9px;
  font-size: 11px;
  transition: all 0.2s var(--ease);
}
.mcp-remove-btn:hover {
  color: var(--error);
  border-color: var(--error-border);
  background: var(--error-bg);
}

#integrations-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 13px;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  animation: fadeIn 0.15s var(--ease) forwards;
}
#integrations-empty .icon { font-size: 36px; opacity: 0.1; }

/* ── MCP Add Form ── */
#mcp-add-form {
  display: none;
  padding: 16px 24px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.02);
}
#mcp-add-form .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 640px;
}
#mcp-add-form label {
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
}
#mcp-add-form input,
#mcp-add-form select {
  width: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  font-size: 12px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-family: var(--font-mono);
  color: var(--text);
  transition: all 0.2s var(--ease);
}
#mcp-add-form input:focus,
#mcp-add-form select:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
#mcp-add-form .form-span { grid-column: 1 / -1; }
.mcp-form-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.btn-submit {
  padding: 7px 20px;
  font-size: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  font-weight: 600;
  transition: all 0.2s var(--ease);
}
.btn-submit:hover { box-shadow: 0 0 16px var(--accent-glow); }
.btn-cancel {
  padding: 7px 20px;
  font-size: 12px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  transition: all 0.2s var(--ease);
}
.btn-cancel:hover { border-color: var(--glass-border-hover); color: var(--text); }
#mcp-form-error { font-size: 11px; color: var(--error); }

/* ── Skills list ── */
/* integ-tab-skills initial state controlled by JS */
#skills-list {
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#skills-empty {
  display: none;
  padding: 40px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}
#skills-empty .icon { font-size: 36px; opacity: 0.1; display: block; margin-bottom: 8px; }

/* ═══════════════════════════════════════
   FILES PAGE
   ═══════════════════════════════════════ */
#page-files .file-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

#file-tree-panel {
  width: 260px;
  min-width: 260px;
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.04);
}
.ft-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  padding: 12px 16px 0;
  font-weight: 700;
  font-family: var(--font-display);
}
.ft-search-wrap {
  padding: 8px 12px;
}
#ft-search {
  width: 100%;
  padding: 6px 10px;
  font-size: 11px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-family: var(--font-mono);
  color: var(--text);
  transition: all 0.2s var(--ease);
  outline: none;
}
#ft-search:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
#ft-search::placeholder { color: var(--text-ghost); }

#file-tree {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}

/* Tree items — shared between files and folders */
.ft-row {
  display: flex;
  align-items: center;
  padding: 5px 8px;
  cursor: pointer;
  font-size: 12px;
  border-radius: var(--radius-sm);
  transition: all 0.15s var(--ease);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}
.ft-row:hover { background: var(--bg-surface); color: var(--text); }
.ft-row.active { background: var(--accent-soft); color: var(--accent-text); }
.ft-row .ft-icon {
  flex-shrink: 0;
  width: 18px;
  font-size: 13px;
  text-align: center;
  margin-right: 4px;
}
.ft-row .ft-icon.folder { color: var(--warning); }
.ft-row .ft-icon.file { color: var(--text-dim); opacity: 0.5; }
.ft-row .ft-icon.chevron {
  font-size: 9px;
  color: var(--text-dim);
  transition: transform 0.15s var(--ease);
  margin-right: 2px;
}
.ft-row.expanded .ft-icon.chevron { transform: rotate(90deg); }
.ft-row .ft-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.ft-children { display: none; }
.ft-children.open { display: block; }

#ft-stats {
  padding: 8px 16px;
  border-top: 1px solid var(--glass-border);
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* Legacy compat */
.file-item {
  padding: 7px 12px;
  cursor: pointer;
  font-size: 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all 0.15s var(--ease);
  color: var(--text-secondary);
}
.file-item:hover { background: var(--bg-surface); color: var(--text); }
.file-item.active { background: var(--accent-soft); color: var(--accent-text); }

.file-editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#file-editor-bar {
  display: none;
  padding: 8px 16px;
  border-bottom: 1px solid var(--glass-border);
  font-size: 12px;
  color: var(--text-secondary);
  justify-content: space-between;
  align-items: center;
  background: var(--bg-base);
  font-family: var(--font-mono);
}
#file-editor {
  flex: 1;
  background: var(--bg-deep);
  color: var(--text);
  border: none;
  padding: 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  resize: none;
  outline: none;
  display: none;
}
.file-preview-md {
  flex: 1;
  display: none;
  overflow-y: auto;
  padding: 24px 32px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.75;
  color: var(--text);
}
.file-preview-md h1 { font-family: var(--font-display); font-size: 22px; font-weight: 700; margin: 20px 0 10px; color: var(--text); }
.file-preview-md h2 { font-family: var(--font-display); font-size: 17px; font-weight: 700; margin: 18px 0 8px; color: var(--text); border-bottom: 1px solid var(--glass-border); padding-bottom: 6px; }
.file-preview-md h3 { font-family: var(--font-display); font-size: 14px; font-weight: 700; margin: 14px 0 6px; color: var(--text); }
.file-preview-md h4 { font-family: var(--font-display); font-size: 13px; font-weight: 600; margin: 12px 0 4px; color: var(--text-secondary); }
.file-preview-md p { margin: 6px 0; }
.file-preview-md ul, .file-preview-md ol { margin: 6px 0; padding-left: 24px; }
.file-preview-md li { margin: 3px 0; }
.file-preview-md code {
  background: var(--bg-hover);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  border: 1px solid var(--glass-border);
}
.file-preview-md pre {
  background: var(--bg-hover);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 8px 0;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
}
.file-preview-md pre code {
  background: none;
  border: none;
  padding: 0;
}
.file-preview-md strong { font-weight: 600; }
.file-preview-md em { font-style: italic; }
.file-preview-md hr { border: none; border-top: 1px solid var(--glass-border); margin: 16px 0; }
.file-preview-md blockquote {
  border-left: 3px solid var(--accent-dim);
  padding: 4px 12px;
  margin: 8px 0;
  color: var(--text-secondary);
}
.file-preview-md a { color: var(--accent-text); text-decoration: underline; }

#file-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 13px;
  font-family: var(--font-display);
}

.file-btn {
  border: none;
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  transition: all 0.15s var(--ease);
}
.file-btn:hover { filter: brightness(1.2); }
.file-btn.save { background: var(--success); color: #fff; }
.file-btn.delete { background: var(--error); color: #fff; }
.file-btn.new { background: var(--accent); color: #fff; font-weight: 600; }

/* ═══════════════════════════════════════
   KNOWLEDGE PAGE
   ═══════════════════════════════════════ */
#kb-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 40px;
  opacity: 0;
  animation: fadeIn 0.15s var(--ease) forwards;
  position: relative;
}

.kb-section { margin-bottom: 28px; }

.kb-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--glass-border);
}
.kb-section-icon {
  font-size: 16px;
  opacity: 0.25;
}
.kb-section-title {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}
.kb-section-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
}

.kb-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.kb-card {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.kb-card:hover {
  border-color: var(--glass-border-hover);
  background: var(--bg-elevated);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}
.kb-card:active { transform: translateY(0); }

.kb-card-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.kb-card-badge {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.03);
  padding: 2px 8px;
  border-radius: 20px;
  font-family: var(--font-mono);
  border: 1px solid var(--glass-border);
}
.kb-card-badge.system {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: var(--accent-dim);
}
.kb-card-preview {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
  max-height: 36px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.kb-card-meta {
  font-size: 10px;
  color: var(--text-ghost);
  font-family: var(--font-mono);
  margin-top: 2px;
}
/* Accent stripe on system cards */
.kb-card.system::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0.5;
}

.kb-empty {
  display: none;
  padding: 24px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.8;
}

/* ── Drop zone ── */
#kb-dropzone {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(237, 234, 228, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
#kb-body.dragging #kb-dropzone { display: flex; }

.kb-dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 64px;
  border: 2px dashed var(--accent-dim);
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  animation: dropPulse 1.5s ease infinite;
}
@keyframes dropPulse {
  0%, 100% { border-color: var(--accent-dim); box-shadow: 0 0 0 0 transparent; }
  50% { border-color: var(--accent); box-shadow: 0 0 32px var(--accent-glow); }
}
.kb-dropzone-icon {
  font-size: 36px;
  color: var(--accent);
  animation: dropBounce 1s var(--ease-spring) infinite;
}
@keyframes dropBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.kb-dropzone-text {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-text);
}
.kb-dropzone-hint {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* ── Knowledge editor overlay ── */
#kb-editor-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 10;
  background: var(--bg-base);
  flex-direction: column;
  animation: fadeIn 0.25s var(--ease);
}
#page-knowledge.editing #kb-body { display: none; }
#page-knowledge.editing #kb-editor-overlay { display: flex; }

#kb-editor-top {
  padding: 10px 20px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-base);
}
#kb-editor-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
#kb-editor-name {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
#kb-editor-badge {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 2px 8px;
  border-radius: 20px;
  font-family: var(--font-mono);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.02);
}
#kb-editor-badge.system {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: var(--accent-dim);
}
.kb-editor-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.kb-close-btn {
  background: none;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease);
  line-height: 1;
}
.kb-close-btn:hover {
  color: var(--text);
  border-color: var(--glass-border-hover);
  background: var(--bg-hover);
}

#kb-editor {
  flex: 1;
  background: var(--bg-deep);
  color: var(--text);
  border: none;
  padding: 24px 28px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  resize: none;
  outline: none;
}

/* ═══════════════════════════════════════
   MODAL / OVERLAY SYSTEM
   ═══════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open {
  display: flex;
  animation: overlayIn 0.2s var(--ease);
}

.modal-panel {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border-hover);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 480px;
  max-width: 92vw;
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.12), 0 0 1px rgba(0, 0, 0, 0.08);
  animation: panelIn 0.3s var(--ease-spring);
}
.modal-panel.wide { width: 740px; }

.modal-panel h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.modal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-top-btns {
  display: flex;
  gap: 6px;
}
.modal-btn {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
  font-family: var(--font-mono);
  transition: all 0.2s var(--ease);
}
.modal-btn:hover {
  border-color: var(--glass-border-hover);
  color: var(--text);
  background: var(--bg-hover);
}

.modal-pre {
  background: var(--bg-deep);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  overflow: auto;
  max-height: 70vh;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-secondary);
  margin: 0;
}

/* ── Settings form ── */
#settings-panel label {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 14px;
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
#settings-panel input {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 5px;
  transition: all 0.2s var(--ease);
}
#settings-panel input:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 22px;
  justify-content: flex-end;
}
.modal-actions button {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s var(--ease);
}
.modal-actions button:hover {
  border-color: var(--accent-dim);
  color: var(--accent-text);
  background: var(--accent-soft);
}

/* ── Coming soon badge ── */
.coming-soon {
  font-size: 10px;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.02);
  padding: 3px 12px;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  margin-top: 6px;
  font-family: var(--font-mono);
}

/* ═══════════════════════════════════════
   NEW WORKSPACE POPUP
   ═══════════════════════════════════════ */
.new-ws-panel {
  text-align: center;
  width: 400px;
  padding: 36px 40px 32px;
}
.new-ws-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 24px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px var(--accent-glow);
}
.new-ws-panel h3 {
  margin-bottom: 4px;
}
.new-ws-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 18px;
  font-family: var(--font-mono);
}
.new-ws-panel input {
  width: 100%;
  padding: 11px 16px;
  font-size: 14px;
  font-family: var(--font-mono);
  background: var(--bg-deep);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  transition: all 0.2s var(--ease);
  text-align: center;
}
.new-ws-panel input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.new-ws-panel input::placeholder {
  color: var(--text-ghost);
  font-size: 13px;
}
.new-ws-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: center;
}
.new-ws-actions .btn-submit {
  flex: 1;
  padding: 10px 24px;
  font-size: 13px;
}
.new-ws-actions .btn-cancel {
  padding: 10px 20px;
  font-size: 13px;
}

/* ═══════════════════════════════════════
   BOOT LOADER OVERLAY
   ═══════════════════════════════════════ */
#app.blurred {
  filter: blur(6px) saturate(0.7);
  transition: filter 0.35s var(--ease);
  pointer-events: none;
}

#boot-loader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.08);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
  pointer-events: none;
}
#boot-loader.visible {
  opacity: 1;
  pointer-events: auto;
}

.boot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 44px 56px;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.1),
    0 0 0 1px var(--glass-shine) inset;
  animation: panelIn 0.4s var(--ease-spring);
  min-width: 340px;
}

.boot-text {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
}

.boot-steps {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.boot-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--glass-border);
  opacity: 0.4;
  transition: opacity 0.25s var(--ease);
}
.boot-step:last-child { border-bottom: none; }
.boot-step.pending, .boot-step.ok, .boot-step.error { opacity: 1; }

.boot-step-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  border: 2px solid var(--glass-border);
  color: var(--text-dim);
  transition: all 0.25s var(--ease);
}
.boot-step.pending .boot-step-icon {
  border-color: var(--accent);
  animation: bootPulse 1.2s ease-in-out infinite;
}
.boot-step.ok .boot-step-icon {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}
.boot-step.ok .boot-step-icon::after { content: '\2713'; }
.boot-step.error .boot-step-icon {
  border-color: var(--error);
  background: var(--error);
  color: #fff;
}
.boot-step.error .boot-step-icon::after { content: '\2717'; }

.boot-step-label {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}
.boot-step.error .boot-step-label { color: var(--error); }

.boot-step-status {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.boot-step.error .boot-step-status { color: var(--error); }

@keyframes bootPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

.boot-timer {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  min-width: 40px;
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════
   Memory Page
   ═══════════════════════════════════════════════════════════ */
#mem-body {
  padding: 20px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* ── Panel wrapper (each section is a rounded card) ── */
.mem-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}
.mem-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.mem-panel-icon {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.mem-panel-icon--facts  { background: #fef3c7; color: #d97706; }
.mem-panel-icon--conv   { background: #dbeafe; color: #2563eb; }
.mem-panel-icon--sessions { background: var(--accent-soft); color: var(--accent-text); }
.mem-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.mem-badge {
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 500;
  background: rgba(0,0,0,0.06);
  color: var(--text);
  padding: 2px 9px;
  border-radius: 20px;
}
.mem-panel-hint {
  font-size: 11px;
  color: var(--text-secondary);
  flex: 1;
  min-width: 100px;
}
.mem-panel--muted {
  opacity: 0.55;
}
.mem-coming-soon {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  background: rgba(0,0,0,0.04);
  padding: 2px 10px;
  border-radius: 20px;
  border: 1px solid rgba(0,0,0,0.06);
  letter-spacing: 0.3px;
}
.mem-add-btn {
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  padding: 5px 14px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.mem-add-btn:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(13, 147, 115, 0.15);
}

/* ── Memory cards ── */
.mem-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.mem-card {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s var(--ease);
}
.mem-card:hover {
  border-color: rgba(0,0,0,0.18);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}
.mem-card-content {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  max-height: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.mem-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  padding-top: 6px;
  border-top: 1px solid rgba(0,0,0,0.06);
}
.mem-card-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.15s;
}
.mem-card:hover .mem-card-actions { opacity: 1; }
.mem-card-actions button {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
  padding: 2px 6px;
  border-radius: 6px;
  transition: all 0.15s;
}
.mem-card-actions button:hover {
  color: var(--text);
  background: var(--bg-hover);
  border-color: var(--glass-border);
}
.mem-card-actions button.del:hover {
  color: var(--error);
  background: var(--error-bg);
  border-color: var(--error-border);
}

.mem-card-badge {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 8px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-weight: 500;
  border: 1px solid rgba(0,0,0,0.08);
}

.mem-badge-user {
  color: var(--accent-text) !important;
  background: var(--accent-soft) !important;
  border-color: var(--accent-dim) !important;
}
.mem-badge-bot {
  color: #6d5acd !important;
  background: var(--accent-2-soft) !important;
  border-color: rgba(109, 90, 205, 0.2) !important;
}
.mem-card--conv {
  border-left: 3px solid var(--accent-dim);
}
.mem-card--conv.mem-card { padding-left: 14px; }
#mem-conv-cards {
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.mem-empty {
  text-align: center;
  padding: 28px 20px;
  color: var(--text-secondary);
  font-size: 12px;
  background: rgba(0,0,0,0.02);
  border-radius: var(--radius);
  border: 1px dashed rgba(0,0,0,0.1);
  width: 100%;
  grid-column: 1 / -1;
}

/* ── Sessions layout: calendar left, list right ── */
.mem-sessions-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: start;
}
#mem-sessions-list:empty {
  display: none !important;
}
.mem-sessions-layout:has(#mem-sessions-list:empty) {
  grid-template-columns: 1fr;
  max-width: 320px;
}
@media (max-width: 700px) {
  .mem-sessions-layout { grid-template-columns: 1fr; }
  .mem-sessions-layout:has(#mem-sessions-list:empty) { max-width: none; }
}

/* ── Calendar ── */
#mem-calendar {
  min-width: 250px;
}
.mem-cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.mem-cal-nav button {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.mem-cal-nav button:hover {
  border-color: var(--glass-border-hover);
  color: var(--text);
  background: var(--bg-hover);
}
.mem-cal-month {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.mem-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.mem-cal-dow {
  text-align: center;
  font-size: 9px;
  font-family: var(--font-mono);
  color: var(--text-ghost);
  padding: 4px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.mem-cal-day {
  text-align: center;
  font-size: 12px;
  padding: 7px 2px;
  border-radius: 8px;
  color: var(--text-secondary);
  position: relative;
  cursor: default;
  transition: all 0.12s;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mem-cal-day.empty { visibility: hidden; }
.mem-cal-day.has-session {
  background: var(--accent-soft);
  color: var(--accent-text);
  cursor: pointer;
  font-weight: 600;
}
.mem-cal-day.has-session:hover {
  background: var(--accent-glow);
  transform: scale(1.1);
}
.mem-cal-day.has-session::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
.mem-cal-day.today {
  border: 1.5px solid var(--accent);
  font-weight: 600;
  color: var(--accent-text);
}
.mem-cal-day.selected {
  background: var(--accent);
  color: #fff;
}
.mem-cal-day.selected::after { background: #fff; }

/* ── Sessions list ── */
#mem-sessions-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mem-session-card {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: var(--radius);
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  display: flex;
  align-items: center;
  gap: 12px;
}
.mem-session-card:hover {
  border-color: rgba(0,0,0,0.18);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}
.mem-session-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
}
.mem-session-meta {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  margin-top: 2px;
}
.mem-session-stats {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}
.mem-session-msgs {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  background: var(--bg-hover);
  padding: 3px 10px;
  border-radius: 10px;
  white-space: nowrap;
  border: 1px solid var(--glass-border);
}
.mem-session-tokens {
  font-size: 11px;
  color: var(--accent-text);
  font-family: var(--font-mono);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 10px;
  white-space: nowrap;
  border: 1px solid var(--accent-dim);
}

/* ── Messages viewer overlay ── */
.mem-messages-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: memFadeIn 0.15s ease-out;
}
@keyframes memFadeIn { from { opacity: 0; } to { opacity: 1; } }
.mem-messages-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  width: min(700px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.15);
  animation: memSlideUp 0.2s ease-out;
}
@keyframes memSlideUp { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.mem-messages-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border);
}
.mem-messages-head h3 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
}
.mem-messages-body {
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mem-msg {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.6;
  max-width: 85%;
  word-break: break-word;
}
.mem-msg.user {
  background: var(--user-bg);
  border: 1px solid var(--user-border);
  align-self: flex-end;
}
.mem-msg.assistant {
  background: var(--bot-bg);
  border: 1px solid var(--bot-border);
  align-self: flex-start;
}
.mem-msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.mem-msg-role {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-family: var(--font-mono);
  color: var(--text-dim);
}
.mem-msg-time {
  font-size: 9px;
  font-family: var(--font-mono);
  color: var(--text-ghost);
}

/* ── Modal ── */
.mem-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mem-modal {
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: min(480px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.15);
  animation: memSlideUp 0.2s ease-out;
}
.mem-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
}
.mem-modal input,
.mem-modal textarea,
.mem-modal select {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 10px 14px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  color: var(--text);
  resize: vertical;
  transition: border-color 0.15s;
}
.mem-modal input:focus,
.mem-modal textarea:focus,
.mem-modal select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.mem-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

/* ═══════════════════════════════════════
   USAGE WIDGETS
   ═══════════════════════════════════════ */
.nav-spacer { flex: 1; }
.nav-usage-block, .sidebar-usage-block {
  padding: 10px 14px;
  font-size: 11px;
  color: var(--text-dim);
}
.nav-usage-block {
  border-top: 1px solid var(--glass-border);
}
.sidebar-usage-block {
  padding: 10px;
  border-top: 1px solid var(--glass-border);
}
.usage-label {
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.usage-total {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--text);
  margin-bottom: 6px;
}
.usage-breakdown {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.usage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.usage-model {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.usage-val {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text);
  flex-shrink: 0;
  min-width: 36px;
  text-align: right;
}
.usage-unit {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
}
.usage-sub {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.usage-bar-wrap {
  flex: 1;
  height: 4px;
  background: var(--glass-border);
  border-radius: 2px;
  overflow: hidden;
}
.usage-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s var(--ease);
}
.usage-loading {
  color: var(--text-dim);
  font-size: 11px;
}

/* ═══════════════════════════════════════
   WORKSPACE SETTINGS — DANGER ZONE
   ═══════════════════════════════════════ */
.ws-settings-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.danger-zone {
  border: 1px solid var(--error-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.danger-zone-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--error);
  padding: 10px 16px;
  border-bottom: 1px solid var(--error-border);
  background: var(--error-bg);
}
.danger-zone-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
}
.danger-zone-label {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.danger-zone-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}
.danger-zone-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-display);
  color: var(--error);
  background: transparent;
  border: 1px solid var(--error-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s var(--ease);
}
.danger-zone-btn:hover {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}

/* ═══════════════════════════════════════
   ADMIN PAGE
   ═══════════════════════════════════════ */
.admin-tabs {
  display: flex;
  gap: 2px;
  padding: 0 16px;
  border-bottom: 1px solid var(--glass-border);
  background: var(--bg);
}
.admin-tab {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-display);
  color: var(--text-dim);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.admin-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  gap: 12px;
  animation: fadeIn 0.15s var(--ease) forwards;
  opacity: 0;
}
.admin-panel.active { display: flex; }
.admin-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}
.admin-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-display);
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.15s;
}
.admin-btn:hover { opacity: 0.85; }
.admin-btn.secondary {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
}
.admin-btn.secondary:hover { border-color: var(--glass-border-hover); }
.admin-btn-sm {
  padding: 3px 10px;
  font-size: 11px;
  font-family: var(--font-display);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.admin-btn-sm.danger { color: var(--error); border-color: var(--error); background: transparent; }
.admin-btn-sm.danger:hover { background: var(--error); color: #fff; }
.admin-table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.admin-table th {
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--glass-border);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
}
.admin-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--glass-border);
  color: var(--text);
  vertical-align: middle;
}
.admin-table tr:hover td { background: var(--bg-hover); }
.admin-table .mono { font-family: var(--font-mono); font-size: 11px; }
.admin-table .truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-loading, .admin-empty, .admin-error {
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}
.admin-error { color: var(--error); }
.admin-usage-total {
  padding: 12px 0;
  font-size: 14px;
  font-family: var(--font-display);
  color: var(--text);
}
.admin-form {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px;
}
.admin-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.admin-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-display);
  color: var(--text-dim);
}
.admin-form-grid input {
  padding: 6px 10px;
  font-size: 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}
.admin-form-grid input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.admin-form-checks {
  display: flex;
  gap: 16px;
  align-items: end;
  padding-bottom: 4px;
}
.admin-form-checks .check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}
.admin-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
