/* ============ Design System ============ */
:root {
  /* Theme accent (tweakable) */
  --accent: #C6F24E;            /* electric lime */
  --accent-ink: #0A0A0A;

  /* Light mode (default) */
  --bg: #FAFAF9;
  --bg-elev: #FFFFFF;
  --bg-sunken: #F4F4F2;
  --bg-hover: rgba(0,0,0,0.035);
  --bg-active: rgba(0,0,0,0.06);

  --ink-1: #0A0A0A;             /* primary */
  --ink-2: #3A3A38;             /* secondary */
  --ink-3: #737370;             /* tertiary */
  --ink-4: #A8A8A4;             /* quaternary (placeholder) */
  --ink-5: #D4D4D0;             /* subtle lines */

  --line: rgba(0,0,0,0.07);
  --line-strong: rgba(0,0,0,0.12);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 50px -20px rgba(0,0,0,0.25), 0 8px 20px -8px rgba(0,0,0,0.12);
  --shadow-pop: 0 40px 80px -30px rgba(0,0,0,0.35);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --font-sans: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, monospace;
  --font-serif: 'Instrument Serif', Georgia, serif;
}

[data-theme="dark"] {
  --bg: #0B0B0B;
  --bg-elev: #141414;
  --bg-sunken: #080808;
  --bg-hover: rgba(255,255,255,0.04);
  --bg-active: rgba(255,255,255,0.07);

  --ink-1: #F5F5F3;
  --ink-2: #C8C8C3;
  --ink-3: #8A8A85;
  --ink-4: #5A5A55;
  --ink-5: #2A2A28;

  --line: rgba(255,255,255,0.07);
  --line-strong: rgba(255,255,255,0.14);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-lg: 0 20px 50px -20px rgba(0,0,0,0.8), 0 8px 20px -8px rgba(0,0,0,0.5);
  --shadow-pop: 0 40px 80px -30px rgba(0,0,0,0.9);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11";
  background: var(--bg);
  color: var(--ink-1);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
  overflow: hidden;
}

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

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; background: none; border: 0; outline: 0; }

/* ============ App Shell ============ */
.app {
  display: grid;
  grid-template-columns: 232px 380px 1fr;
  height: 100vh;
  background: var(--bg);
}

.app.focused {
  grid-template-columns: 68px 0px 1fr;
}

/* Scrollbars */
.scroll { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--ink-5) transparent; }
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb { background: var(--ink-5); border-radius: 4px; }
.scroll::-webkit-scrollbar-track { background: transparent; }

/* ============ Sidebar ============ */
.sidebar {
  background: var(--bg-sunken);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  gap: 4px;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--ink-1);
  color: var(--bg-elev);
  display: grid; place-items: center;
  position: relative;
  overflow: hidden;
}
.brand-mark::after{
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 30%, var(--accent) 0%, transparent 55%);
  mix-blend-mode: screen;
  opacity: 0.9;
}
.brand-name {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-1);
  font-weight: 500;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.brand-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  margin-left: auto; margin-right: 4px;
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  cursor: pointer;
}
.account:hover { background: var(--bg-hover); }
.avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, #ffb38a, #c44aff);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 500;
  font-size: 11px;
  flex-shrink: 0;
}
.account-email { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.compose-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--ink-1);
  color: var(--bg-elev);
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 12px;
  transition: transform 0.1s;
}
.compose-btn:hover { transform: translateY(-1px); }
.compose-btn .kbd { margin-left: auto; opacity: 0.6; font-size: 11px; font-family: var(--font-mono); }

.nav-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
  position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--ink-1); }
.nav-item.active { background: var(--bg-hover); color: var(--ink-1); font-weight: 500; }
.nav-item.active::before{
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px; background: var(--accent); border-radius: 0 2px 2px 0;
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--ink-3); }
.nav-item.active svg { color: var(--ink-1); }
.nav-count { margin-left: auto; font-size: 11px; color: var(--ink-4); font-family: var(--font-mono); }
.nav-count.pill {
  background: var(--accent); color: var(--accent-ink);
  padding: 1px 6px; border-radius: 10px;
  font-weight: 500;
}

/* ============ Inbox List ============ */
.inbox {
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inbox-header {
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}
.inbox-title {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.015em;
}
.inbox-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
  margin-left: auto;
}
.inbox-actions { display: flex; gap: 2px; }
.icon-btn {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  color: var(--ink-3);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--ink-1); }
.icon-btn svg { width: 15px; height: 15px; }

.inbox-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.inbox-tab {
  padding: 4px 10px;
  font-size: 12px;
  color: var(--ink-3);
  border-radius: 999px;
  white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.inbox-tab:hover { color: var(--ink-1); background: var(--bg-hover); }
.inbox-tab.active { background: var(--ink-1); color: var(--bg-elev); }
.inbox-tab .count { font-family: var(--font-mono); font-size: 10px; opacity: 0.7; }
.inbox-tab.ai { color: var(--accent-ink); background: var(--accent); }
.inbox-tab.ai .count { opacity: 0.8; }

.mail-list { flex: 1; overflow-y: auto; }

.mail-row {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
}
.mail-row:hover { background: var(--bg-hover); }
.mail-row.selected { background: var(--bg-active); }
.mail-row.selected::before{
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px;
  background: var(--accent); border-radius: 0 2px 2px 0;
}
.mail-row.unread .mail-from { font-weight: 600; color: var(--ink-1); }
.mail-row.unread .mail-subject { color: var(--ink-1); }
.mail-row.unread::after{
  content: ""; position: absolute; right: 20px; top: 18px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}

.mail-from {
  font-size: 13px;
  color: var(--ink-2);
  display: flex; align-items: center; gap: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mail-time { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-4); }
.mail-subject {
  font-size: 12.5px;
  color: var(--ink-2);
  grid-column: 1 / -1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mail-preview {
  font-size: 12px;
  color: var(--ink-3);
  grid-column: 1 / -1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.mail-chips { grid-column: 1 / -1; display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.chip {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-sunken);
  color: var(--ink-3);
  border: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chip.ai {
  background: color-mix(in oklch, var(--accent) 18%, transparent);
  color: var(--ink-1);
  border-color: color-mix(in oklch, var(--accent) 40%, transparent);
}
.chip.dot::before { content: "●"; margin-right: 4px; color: var(--accent); }

/* AI summary banner in mail list */
.ai-brief {
  margin: 12px 14px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.ai-brief::before{
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: linear-gradient(to bottom, var(--accent), transparent);
}
.ai-brief-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
}
.ai-brief-label .pulse {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.5; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); }
}
.ai-brief-title {
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-1);
  margin-bottom: 8px;
}
.ai-brief-title em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 15.5px;
}
.ai-brief-stats {
  display: flex; gap: 14px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
}
.ai-brief-stats b { color: var(--ink-1); font-weight: 500; }

/* ============ Reader ============ */
.reader {
  background: var(--bg-elev);
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
}

.reader-topbar {
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}
.reader-topbar .divider {
  width: 1px; height: 18px; background: var(--line); margin: 0 6px;
}
.reader-topbar .spacer { flex: 1; }
.reader-topbar .kbd-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
  display: flex; align-items: center; gap: 4px;
}

.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1.5px 5px;
  border-radius: 4px;
  background: var(--bg-sunken);
  color: var(--ink-2);
  border: 1px solid var(--line);
  line-height: 1;
}

.reader-body { flex: 1; overflow-y: auto; padding: 28px 56px 120px; max-width: 920px; margin: 0 auto; width: 100%; }

.mail-head {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.mail-head-subject {
  font-family: var(--font-serif);
  font-size: 32px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink-1);
  font-weight: 400;
}
.mail-head-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}
.avatar.lg { width: 36px; height: 36px; font-size: 13px; }
.mail-head-who { display: flex; flex-direction: column; gap: 2px; }
.mail-head-from { font-size: 13.5px; color: var(--ink-1); font-weight: 500; }
.mail-head-to { font-size: 11.5px; color: var(--ink-3); font-family: var(--font-mono); }
.mail-head-time {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
  text-align: right;
}

/* AI summary card in reader */
.ai-card {
  margin: 24px 0;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--bg);
  border: 1px solid var(--line);
  position: relative;
}
.ai-card-header {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin-bottom: 14px;
}
.ai-card-header .live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
.ai-card-header .model {
  margin-left: auto;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-4);
}
.ai-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.ai-summary-list {
  list-style: none;
  padding: 0; margin: 0 0 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.ai-summary-list li {
  padding-left: 18px;
  position: relative;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
}
.ai-summary-list li::before{
  content: ""; position: absolute; left: 2px; top: 9px;
  width: 8px; height: 1px; background: var(--ink-4);
}
.ai-summary-list li b { color: var(--ink-1); font-weight: 500; }
.ai-summary-list li mark {
  background: color-mix(in oklch, var(--accent) 35%, transparent);
  color: var(--ink-1);
  padding: 0 3px;
  border-radius: 2px;
}

.ai-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.ai-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-2);
  transition: all 0.15s;
}
.ai-action:hover {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.ai-action svg { width: 12px; height: 12px; }
.ai-action.primary {
  background: var(--ink-1);
  color: var(--bg-elev);
  border-color: var(--ink-1);
}
.ai-action.primary:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Mail body */
.mail-body {
  padding: 24px 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-2);
}
.mail-body p { margin: 0 0 14px; }
.mail-body p strong { color: var(--ink-1); }
.mail-body .quote {
  border-left: 2px solid var(--line-strong);
  padding: 2px 14px;
  color: var(--ink-3);
  font-size: 13px;
  margin: 16px 0;
}
.mail-body a { color: var(--ink-1); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--ink-4); }

/* Attachment chips */
.attachments {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  margin-top: 20px;
}
.att {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 12px;
  min-width: 180px;
}
.att-icon {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: var(--bg-sunken);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-2);
  font-weight: 500;
}
.att-meta { display: flex; flex-direction: column; gap: 2px; }
.att-name { color: var(--ink-1); font-weight: 500; }
.att-size { color: var(--ink-4); font-family: var(--font-mono); font-size: 10.5px; }

/* Reply composer (inline) */
.reply-dock {
  position: sticky;
  bottom: 0;
  margin: 20px -28px -28px;
  padding: 16px 28px;
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
  display: flex;
  gap: 8px;
  align-items: center;
}
.reply-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-1);
}
.reply-input::placeholder { color: var(--ink-4); }
.reply-suggest {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.reply-chip {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-2);
  display: flex; align-items: center; gap: 5px;
}
.reply-chip:hover { border-color: var(--accent); color: var(--ink-1); }
.reply-chip svg { width: 11px; height: 11px; color: var(--accent); }

/* ============ Command Palette ============ */
.cmd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(8px);
  display: grid; place-items: start center;
  padding-top: 18vh;
  z-index: 100;
  animation: fadeIn 0.15s ease-out;
}
[data-theme="dark"] .cmd-overlay { background: rgba(0,0,0,0.6); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.cmd {
  width: min(620px, 92vw);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: slideIn 0.2s ease-out;
}
.cmd-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.cmd-input-wrap svg { width: 16px; height: 16px; color: var(--ink-3); }
.cmd-input {
  flex: 1;
  font-size: 15px;
  color: var(--ink-1);
}
.cmd-input::placeholder { color: var(--ink-4); }
.cmd-mode {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-ink);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.cmd-list { max-height: 420px; overflow-y: auto; padding: 6px; }
.cmd-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 8px 12px 4px;
}
.cmd-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.cmd-item.active { background: var(--bg-sunken); }
.cmd-item svg { width: 15px; height: 15px; color: var(--ink-3); flex-shrink: 0; }
.cmd-item.active svg { color: var(--ink-1); }
.cmd-item-label { font-size: 13px; color: var(--ink-1); flex: 1; }
.cmd-item-hint { font-size: 11.5px; color: var(--ink-4); }
.cmd-item-shortcut {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  display: flex; gap: 2px;
}

.cmd-ai-hint {
  padding: 12px 18px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-sunken);
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-3);
  font-family: var(--font-mono);
}
.cmd-ai-hint .live-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s infinite;
}

/* ============ Agent Panel ============ */
.agent-overlay {
  position: fixed;
  right: 16px; top: 60px; bottom: 16px;
  width: 380px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 80;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: agentIn 0.25s cubic-bezier(.2,.9,.25,1);
}
@keyframes agentIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.agent-head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; gap: 10px;
}
.agent-orb {
  width: 28px; height: 28px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent), var(--ink-1) 80%);
  position: relative;
  flex-shrink: 0;
}
.agent-orb::after {
  content: ""; position: absolute; inset: -3px;
  border-radius: 50%;
  border: 1px solid color-mix(in oklch, var(--accent) 40%, transparent);
  animation: orbRing 2.5s ease-in-out infinite;
}
@keyframes orbRing {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 0.1; }
}
.agent-title { font-size: 14px; font-weight: 500; }
.agent-title em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 15.5px;
}
.agent-subtitle {
  font-size: 11.5px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  margin-top: 2px;
}
.agent-head .close { margin-left: auto; }

.agent-body { flex: 1; overflow-y: auto; padding: 14px 16px 18px; }

.agent-prompt {
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--ink-1);
  margin-bottom: 18px;
  position: relative;
}
.agent-prompt::before {
  content: "YOU";
  position: absolute; top: -7px; left: 10px;
  font-family: var(--font-mono); font-size: 9px;
  padding: 1px 5px; background: var(--bg-elev);
  color: var(--ink-4); letter-spacing: 0.1em;
}

.task-step {
  display: flex; gap: 12px;
  padding: 4px 0;
  position: relative;
}
.task-step + .task-step::before {
  content: ""; position: absolute;
  left: 6px; top: -8px; width: 1px; height: 12px;
  background: var(--line-strong);
}
.task-step-marker {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  display: grid; place-items: center;
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
}
.task-step.done .task-step-marker {
  background: var(--ink-1);
  border-color: var(--ink-1);
  color: var(--bg-elev);
}
.task-step.done .task-step-marker::after {
  content: "";
  width: 5px; height: 3px;
  border: 1.3px solid var(--bg-elev);
  border-top: 0; border-right: 0;
  transform: translateY(-1px) rotate(-45deg);
}
.task-step.active .task-step-marker {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--accent) 22%, transparent);
  animation: stepPulse 1.6s ease-in-out infinite;
}
@keyframes stepPulse {
  0%, 100% { box-shadow: 0 0 0 4px color-mix(in oklch, var(--accent) 22%, transparent); }
  50% { box-shadow: 0 0 0 7px color-mix(in oklch, var(--accent) 10%, transparent); }
}
.task-step-content { flex: 1; padding-bottom: 14px; }
.task-step-title { font-size: 13px; color: var(--ink-1); margin-bottom: 3px; }
.task-step.pending .task-step-title { color: var(--ink-4); }
.task-step-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-4);
  display: flex; gap: 10px;
}
.task-step-meta b { color: var(--ink-2); font-weight: 500; }

.task-output {
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
  line-height: 1.55;
  border-left: 2px solid var(--accent);
}
.task-output.stream::after {
  content: "▍";
  color: var(--accent);
  animation: caret 1s steps(2) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

.agent-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-sunken);
}
.agent-input {
  flex: 1;
  padding: 9px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.agent-send {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--ink-1);
  color: var(--bg-elev);
  display: grid; place-items: center;
}

/* ============ Compose ============ */
.compose-win {
  position: fixed;
  right: 20px; bottom: 20px;
  width: min(620px, calc(100vw - 40px));
  height: min(560px, calc(100vh - 40px));
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 70;
  animation: agentIn 0.2s ease-out;
}
.compose-head {
  padding: 14px 18px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line);
}
.compose-head-title { font-size: 13px; font-weight: 500; }
.compose-head-controls { margin-left: auto; display: flex; gap: 2px; }

.compose-field {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  align-items: center;
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  gap: 8px;
}
.compose-field label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
  text-transform: uppercase;
}
.compose-field input { font-size: 13px; color: var(--ink-1); }
.compose-field input::placeholder { color: var(--ink-4); }
.recipient-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 4px 3px 3px;
  border-radius: 999px;
  background: var(--bg-sunken);
  font-size: 12px;
  border: 1px solid var(--line);
}
.recipient-pill .avatar { width: 18px; height: 18px; font-size: 9px; }

.compose-subject input { font-size: 16px; font-weight: 500; letter-spacing: -0.01em; }

.compose-body {
  flex: 1;
  padding: 20px 22px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-2);
}
.compose-body p { margin: 0 0 12px; }
.compose-body .ghost { color: var(--ink-4); }

.compose-ai {
  margin: 12px 0 0;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-left: 2px solid var(--accent);
}
.compose-ai-label {
  font-family: var(--font-mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-3); margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
.compose-ai-suggestions {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 10px;
}

.compose-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.send-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: var(--ink-1);
  color: var(--bg-elev);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
}
.send-btn:hover { background: var(--accent); color: var(--accent-ink); }
.send-btn .kbd { background: transparent; border-color: currentColor; opacity: 0.5; }

/* ============ Tweaks ============ */
.tweaks-fab {
  position: fixed;
  right: 16px; bottom: 16px;
  z-index: 90;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  display: grid; place-items: center;
  color: var(--ink-2);
}
.tweaks-fab:hover { color: var(--ink-1); }
.tweaks-panel {
  position: fixed;
  right: 16px; bottom: 66px;
  width: 260px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 14px;
  z-index: 90;
  animation: slideIn 0.15s ease-out;
}
.tweaks-panel h4 {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin: 0 0 10px;
}
.tweak-row { margin-bottom: 14px; }
.tweak-row:last-child { margin-bottom: 0; }
.theme-toggle {
  display: flex; gap: 4px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
}
.theme-toggle button {
  flex: 1;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink-3);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.theme-toggle button.active { background: var(--bg-elev); color: var(--ink-1); box-shadow: var(--shadow-sm); }
.theme-toggle svg { width: 13px; height: 13px; }

.swatch-row { display: flex; gap: 6px; }
.swatch {
  flex: 1;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1.5px solid transparent;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s;
}
.swatch:hover { transform: scale(1.06); }
.swatch.active { border-color: var(--ink-1); }
.swatch.active::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 5px;
  border: 1.5px solid var(--bg-elev);
}
