/* TomFlow — layout and components. Every color/size comes from tokens.css. */

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--text-14);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; }
.display { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.03em; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code, .mono { font-family: var(--font-mono); font-size: 0.93em; }
[hidden] { display: none !important; }

svg.icon {
  width: 18px; height: 18px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}

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

.muted { color: var(--text-muted); }
.small { font-size: var(--text-13); }
.num { font-variant-numeric: tabular-nums; }
.section-label {
  font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted);
}

/* ---------- Shell ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 30;
  width: var(--sidebar-width);
  display: flex; flex-direction: column; gap: var(--space-6);
  padding: var(--space-5) var(--space-3);
  background: var(--surface);
  border-right: var(--line) solid var(--border);
  transition: width var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.wordmark {
  display: flex; align-items: baseline; gap: var(--space-2);
  padding: 0 var(--space-2);
  font-family: var(--font-display); font-weight: 800; font-size: 28px; line-height: 1;
  letter-spacing: -0.04em; color: var(--text);
}
.wordmark:hover { text-decoration: none; }
.wordmark .wordmark-short { display: none; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: var(--space-3);
  height: 40px; padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  color: var(--text-muted); font-weight: 500;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-bg); color: var(--primary-text); }
.nav-label { white-space: nowrap; overflow: hidden; }

.sidebar-foot {
  margin-top: auto;
  display: flex; flex-direction: column; gap: var(--space-2);
  padding-top: var(--space-4); border-top: var(--line) solid var(--border);
}
.user-email {
  padding: 0 var(--space-2);
  font-family: var(--font-mono); font-size: var(--text-12); color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-actions { display: flex; justify-content: space-between; align-items: center; gap: var(--space-1); }

/* Theme toggle: shows the theme you'd switch to */
.theme-btn .icon-sun { display: none; }
html[data-theme="dark"] .theme-btn .icon-sun { display: block; }
html[data-theme="dark"] .theme-btn .icon-moon { display: none; }

/* Collapsed to icons (desktop only) */
html[data-sidebar="collapsed"] .sidebar { width: var(--sidebar-collapsed); }
html[data-sidebar="collapsed"] .nav-label,
html[data-sidebar="collapsed"] .user-email,
html[data-sidebar="collapsed"] .logout-label,
html[data-sidebar="collapsed"] .wordmark-full { display: none; }
html[data-sidebar="collapsed"] .wordmark .wordmark-short { display: inline; }
html[data-sidebar="collapsed"] .nav a { justify-content: center; padding: 0; }
html[data-sidebar="collapsed"] .sidebar-actions { flex-direction: column; align-items: center; }
html[data-sidebar="collapsed"] .main { margin-left: var(--sidebar-collapsed); }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-width); transition: margin-left var(--duration) var(--ease); }

.topbar {
  display: flex; align-items: center; gap: var(--space-3);
  height: 64px; padding: 0 var(--space-8);
  border-bottom: var(--line) solid var(--border);
}
.topbar-spacer { flex: 1; }
.topbar .menu-btn { display: none; }

/* Centered in the space beside the sidebar, so wide screens don't leave a band on one side. */
.page { max-width: var(--content-max); margin: 0 auto; padding: var(--space-10) var(--space-10) var(--space-12); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-8); }
.page-title {
  font-family: var(--font-display); font-weight: 800;
  font-size: var(--text-40); line-height: 1; letter-spacing: -0.03em;
}
.page-desc { margin-top: var(--space-2); color: var(--text-muted); max-width: 60ch; }
.view { display: flex; flex-direction: column; gap: var(--space-8); }

.backdrop { display: none; }

@media (max-width: 767px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-width) !important; box-shadow: var(--shadow-pop); }
  .sidebar.open { transform: none; }
  .backdrop.open { display: block; position: fixed; inset: 0; z-index: 20; background: var(--overlay); }
  .main, html[data-sidebar="collapsed"] .main { margin-left: 0; }
  .collapse-btn { display: none !important; }
  html[data-sidebar="collapsed"] .nav-label,
  html[data-sidebar="collapsed"] .user-email,
  html[data-sidebar="collapsed"] .logout-label,
  html[data-sidebar="collapsed"] .wordmark-full { display: initial; }
  html[data-sidebar="collapsed"] .wordmark .wordmark-short { display: none; }
  html[data-sidebar="collapsed"] .nav a { justify-content: flex-start; padding: 0 var(--space-2); }
  html[data-sidebar="collapsed"] .sidebar-actions { flex-direction: row; }
  .topbar { padding: 0 var(--space-4); }
  .topbar .menu-btn { display: inline-grid; }
  .page { padding: var(--space-6) var(--space-4) var(--space-10); }
  .page-title { font-size: var(--text-28); }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 40px; padding: 0 var(--space-4);
  border: var(--line) solid var(--border-strong); border-radius: var(--radius-control);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease), color var(--duration) var(--ease);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger-soft); }
.btn-sm { height: 36px; padding: 0 var(--space-3); font-size: var(--text-13); }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border: 1px solid transparent; border-radius: var(--radius-control);
  background: none; color: var(--text-muted); cursor: pointer;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.link-btn { padding: 0; border: none; background: none; color: var(--accent-text); font: inherit; font-weight: 500; cursor: pointer; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Form controls ---------- */
.form { display: flex; flex-direction: column; gap: var(--space-5); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 220px; gap: var(--space-3); }
label, .label { font-size: var(--text-13); font-weight: 500; }
.hint { font-size: var(--text-13); color: var(--text-muted); }
.field-error { font-size: var(--text-13); color: var(--danger); }
.field-error:empty { display: none; }

input[type="text"], input[type="url"], input[type="email"], input[type="password"], textarea, select {
  width: 100%; height: var(--control-height); padding: 0 var(--space-3);
  border: var(--line) solid var(--border-strong); border-radius: var(--radius-control);
  background: var(--surface); color: var(--text); font: inherit;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
textarea { height: auto; min-height: 80px; padding: var(--space-2) var(--space-3); resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 0.8; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.field.has-error input, .field.has-error textarea { border-color: var(--danger); }
input[type="text"].mono-input { font-family: var(--font-mono); }

@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }

/* Segmented control (used as tabs) */
.segmented {
  display: inline-flex; gap: 2px; padding: 2px; width: fit-content;
  background: var(--surface-2); border: var(--line) solid var(--border); border-radius: var(--radius-pill);
}
.segmented label {
  padding: 6px var(--space-4); border-radius: var(--radius-pill); cursor: pointer;
  font-weight: 500; color: var(--text-muted);
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Toggle */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.toggle span { position: absolute; inset: 0; border-radius: 11px; background: var(--border-strong); transition: background var(--duration) var(--ease); }
.toggle span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--surface); transition: transform var(--duration) var(--ease);
}
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(18px); }
.toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle input:disabled { cursor: not-allowed; }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: var(--line) solid var(--border); border-radius: var(--radius-card); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-5) var(--space-6); border-bottom: var(--line) solid var(--border);
}
.card-title { font-size: var(--text-14); font-weight: 600; }
.card-body { padding: var(--space-6); }

.notice {
  padding: var(--space-3) var(--space-4); border: var(--line) solid var(--border); border-radius: var(--radius-card);
  background: var(--surface-2); font-size: var(--text-13);
}
.notice.warning { border-color: var(--warning-soft); background: var(--warning-soft); color: var(--warning); }
.notice.danger { border-color: var(--danger-soft); background: var(--danger-soft); color: var(--danger); }

.empty { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-4); padding: var(--space-8) var(--space-6); }
.empty p { max-width: 52ch; font-family: var(--font-display); font-weight: 700; font-size: var(--text-16); letter-spacing: -0.02em; line-height: 1.3; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  height: 26px; padding: 0 10px; border-radius: var(--radius-pill);
  border: var(--line) solid var(--border); background: var(--surface-2);
  font-size: var(--text-12); font-weight: 500; color: var(--text-muted); white-space: nowrap;
}
a.badge:hover { text-decoration: none; border-color: var(--border-strong); }
.badge-success { background: var(--success-soft); border-color: transparent; color: var(--success-on-soft); }
.badge-warning { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.badge-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.keyword {
  display: inline-block; padding: 2px 10px; border-radius: var(--radius-pill);
  background: var(--surface-2); border: var(--line) solid var(--border);
  font-family: var(--font-mono); font-size: var(--text-12); color: var(--text);
}

/* ---------- Metrics ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border: var(--line) solid var(--border); border-radius: var(--radius-card); background: var(--surface);
}
.stat { padding: var(--space-6); }
.stat + .stat { border-left: var(--line) solid var(--border); }
.stat-value {
  font-family: var(--font-display); font-weight: 800; font-size: var(--text-40); line-height: 1;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
.stat-label { margin-top: var(--space-3); font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }

@media (max-width: 767px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(3) { border-left: none; }
  .stat:nth-child(n + 3) { border-top: var(--line) solid var(--border); }
  .stat-value { font-size: var(--text-28); }
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 14px var(--space-6); text-align: left; vertical-align: middle; border-bottom: var(--line) solid var(--border); }
.table th { font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); background: var(--surface-2); white-space: nowrap; }
.table tbody tr { transition: background var(--duration) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table .cell-sub { font-size: var(--text-12); color: var(--text-muted); }
.table .cell-right { text-align: right; }
.table .cell-actions { width: 1%; white-space: nowrap; text-align: right; }

/* Tables become stacked rows on small screens */
@media (max-width: 767px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: var(--space-3) var(--space-4); border-bottom: var(--line) solid var(--border); }
  .table tbody tr:last-child { border-bottom: none; }
  .table td { display: flex; justify-content: space-between; gap: var(--space-4); padding: 4px 0; border: none; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--text-muted); font-size: var(--text-12); text-align: left; flex-shrink: 0; }
  .table td.cell-main { display: block; text-align: left; padding-bottom: var(--space-2); }
  .table td.cell-main::before { content: none; }
  .table .cell-actions { width: 100%; text-align: right; }
}

/* ---------- Activity list ---------- */
.activity { display: flex; flex-direction: column; }
.activity-item {
  display: grid; grid-template-columns: 1fr auto; gap: var(--space-1) var(--space-4);
  padding: var(--space-4) var(--space-6); border-bottom: var(--line) solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-item .who { font-family: var(--font-mono); font-size: var(--text-13); }
.activity-item .comment {
  justify-self: start; max-width: 100%; padding: 8px 14px;
  border-radius: 18px 18px 18px 4px; background: var(--surface-2);
  overflow-wrap: anywhere;
}
.activity-item .meta { grid-column: 1; padding-left: 14px; font-size: var(--text-12); color: var(--text-muted); }
.activity-item .meta time { font-family: var(--font-mono); }
.activity-item .badge { grid-row: 1; grid-column: 2; justify-self: end; }
.activity-item .error { grid-column: 1 / -1; font-size: var(--text-12); color: var(--danger); white-space: pre-line; }

/* ---------- Account chip ---------- */
.account-chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: 40px; padding: 0 var(--space-3) 0 5px; max-width: 300px;
  border: var(--line) solid var(--border); border-radius: var(--radius-pill);
  color: var(--text); font-family: var(--font-mono); font-size: var(--text-13);
}
a.account-chip:hover { background: var(--surface-2); text-decoration: none; }
.account-chip .icon { color: var(--text-muted); }
.account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  display: grid; place-items: center; width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 50%; background: var(--surface-2); overflow: hidden;
  font-family: var(--font-ui); font-size: var(--text-12); font-weight: 600; color: var(--text-muted);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 600px) { .account-name { display: none; } .account-chip { padding-right: 4px; } }

/* ---------- Media grid ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-4); }
.media-tile {
  display: flex; flex-direction: column; gap: 6px; padding: 0; min-width: 0;
  border: none; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.media-tile .thumb {
  position: relative; aspect-ratio: 1; overflow: hidden;
  border: var(--line) solid var(--border); border-radius: var(--radius-control); background: var(--surface-2);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.media-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile:hover .thumb { border-color: var(--border-strong); }
.media-tile.selected .thumb { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent); }
.media-tile .caption { font-size: var(--text-12); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-tile .media-type, .media-tile .check {
  position: absolute; top: 8px; display: grid; place-items: center; width: 24px; height: 24px;
  border-radius: var(--radius-pill); background: var(--surface); color: var(--text);
}
.media-tile .media-type { right: 6px; }
.media-tile .check { left: 6px; display: none; background: var(--accent); color: var(--on-accent); }
.media-tile .media-type .icon, .media-tile .check .icon { width: 14px; height: 14px; }
.media-tile.selected .check { display: grid; }
.media-tile.any-post .thumb { display: grid; place-items: center; border-style: dashed; color: var(--text-muted); }
.media-tile.any-post .thumb span { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: var(--text-13); font-weight: 500; }
.media-tile.any-post.selected .thumb { color: var(--accent-text); background: var(--accent-soft); }

/* ---------- Automation builder ---------- */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--space-10); align-items: start; }
.steps { display: flex; flex-direction: column; }
.step { position: relative; padding-left: var(--space-10); }
.step + .step { margin-top: var(--space-4); }
.step::before { /* dashed connector between steps */
  content: ""; position: absolute; left: 13px; top: 32px; bottom: calc(-1 * var(--space-4));
  border-left: 2px dashed var(--border-strong);
}
.step:last-of-type::before { display: none; }
.step-num {
  position: absolute; left: 0; top: 2px; display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  border: none; background: var(--primary-bg); color: var(--primary-text);
  font-family: var(--font-display); font-size: var(--text-13); font-weight: 800; font-variant-numeric: tabular-nums;
}
.step-card { display: flex; flex-direction: column; gap: var(--space-5); padding: var(--space-6); }
.step-title { font-size: var(--text-14); font-weight: 600; }
.step-desc { margin-top: 2px; font-size: var(--text-13); color: var(--text-muted); }
.form-actions { display: flex; justify-content: flex-end; gap: var(--space-2); padding-left: var(--space-10); }

.preview { position: sticky; top: var(--space-6); display: flex; flex-direction: column; gap: var(--space-3); }
.phone {
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-5); min-height: 420px;
  border: 2px solid var(--text); border-radius: 28px; background: var(--surface);
  box-shadow: var(--shadow-hard);
}
.phone-bar { display: flex; align-items: center; gap: var(--space-2); padding-bottom: var(--space-3); border-bottom: var(--line) solid var(--border); }
.phone-bar .avatar { border-radius: 50%; }
.phone-handle { font-family: var(--font-mono); font-size: var(--text-12); }
.trigger { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.phone-section { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); text-align: center; }
.bubble {
  max-width: 85%; padding: 8px 12px; border-radius: 16px;
  font-size: var(--text-13); line-height: 1.4; white-space: pre-line; overflow-wrap: anywhere;
}
.bubble.them { align-self: flex-start; background: var(--surface); border: var(--line) solid var(--border); border-bottom-left-radius: 4px; }
.bubble.me { align-self: flex-end; background: var(--primary-bg); color: var(--primary-text); border-bottom-right-radius: 4px; }
.bubble .bubble-link { display: block; margin-top: 4px; text-decoration: underline; text-underline-offset: 2px; opacity: 0.85; }
.bubble.placeholder { opacity: 0.45; }
.comment-line { font-size: var(--text-13); overflow-wrap: anywhere; }
.comment-line .who { font-family: var(--font-mono); font-size: var(--text-12); margin-right: 6px; }
.comment-reply { margin-left: var(--space-6); padding-left: var(--space-3); border-left: var(--line) solid var(--border); }

@media (max-width: 960px) {
  .builder { grid-template-columns: 1fr; }
  .preview { position: static; }
}
@media (max-width: 600px) {
  .step { padding-left: 0; }
  .step::before, .step-num { display: none; }
  .form-actions { padding-left: 0; }
}

/* ---------- Settings-style rows (Support) ---------- */
.settings { display: flex; flex-direction: column; }
.settings-row { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: var(--space-8); padding: var(--space-8) 0; border-top: var(--line) solid var(--border); }
.settings-row:first-child { border-top: none; padding-top: 0; }
.settings-label h2 { font-size: var(--text-14); }
.settings-label p { margin-top: var(--space-1); font-size: var(--text-13); color: var(--text-muted); }
.prose { display: flex; flex-direction: column; gap: var(--space-3); max-width: 64ch; }
.prose h3 { font-size: var(--text-14); margin-top: var(--space-2); }
.prose ol, .prose ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.prose code { padding: 1px 6px; border-radius: 6px; background: var(--surface-2); border: var(--line) solid var(--border); overflow-wrap: anywhere; }
@media (max-width: 767px) { .settings-row { grid-template-columns: 1fr; gap: var(--space-3); } }

/* ---------- Template cards ---------- */
.template-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--space-5); }
.template-card { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-6); }
.template-card h3 { font-family: var(--font-display); font-weight: 700; font-size: var(--text-20); letter-spacing: -0.02em; }
.template-card .template-desc { margin-top: var(--space-1); font-size: var(--text-13); color: var(--text-muted); }
.template-preview {
  display: flex; flex-direction: column; gap: var(--space-1);
  padding: var(--space-3) var(--space-4); border-radius: 18px 18px 18px 4px;
  background: var(--surface-2); font-size: var(--text-13); white-space: pre-line;
}
.template-card .btn { margin-top: auto; align-self: flex-start; }

/* ---------- Login / onboarding ---------- */
.login-screen { position: fixed; inset: 0; z-index: 40; overflow-y: auto; background: var(--bg); }
.login-inner { display: flex; flex-direction: column; min-height: 100%; padding: var(--space-8); }
.login-inner .wordmark { padding: 0; }
.login-top { display: flex; align-items: center; justify-content: space-between; }
.login-card { width: 100%; max-width: 420px; margin: auto; padding: var(--space-12) 0; display: flex; flex-direction: column; gap: var(--space-5); }
.login-title { font-family: var(--font-display); font-weight: 800; font-size: var(--text-40); line-height: 1; letter-spacing: -0.03em; }
.login-switch { font-size: var(--text-13); color: var(--text-muted); }
@media (max-width: 600px) { .login-inner { padding: var(--space-5); } }

.connect { max-width: 640px; display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-5); padding: var(--space-8); }
.connect h2 { font-family: var(--font-display); font-weight: 800; font-size: var(--text-28); letter-spacing: -0.03em; line-height: 1.05; }
.permissions { width: 100%; margin: 0; padding: 0; list-style: none; border-top: var(--line) solid var(--border); }
.permissions li { display: grid; grid-template-columns: 200px 1fr; gap: var(--space-4); padding: var(--space-3) 0; border-bottom: var(--line) solid var(--border); font-size: var(--text-13); }
.permissions li span:first-child { font-weight: 500; }
.permissions li span:last-child { color: var(--text-muted); }
@media (max-width: 600px) { .permissions li { grid-template-columns: 1fr; gap: 2px; } .connect { padding: var(--space-5); } }

/* ---------- Feedback ---------- */
.skeleton { border-radius: var(--radius-control); background: var(--surface-2); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.toasts { position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: 50; display: flex; flex-direction: column; gap: var(--space-2); max-width: calc(100vw - 32px); }
.toast {
  padding: var(--space-3) var(--space-4); max-width: 380px;
  border: var(--line) solid var(--border); border-radius: var(--radius-card);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop);
  font-size: var(--text-13); animation: toast-in var(--duration) var(--ease);
}
.toast.error { border-left: 3px solid var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(4px); } }
