@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── TOKENS ─────────────────────────────────────────────── */
:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1c1c1c;
  --border: #262626;
  --text: #f0f0f0;
  --muted: #888;
  --accent: #7c6ef5;
  --accent-soft: rgba(124,110,245,0.12);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --sidebar-w: 220px;
  --radius: 10px;
  --radius-sm: 6px;
}
[data-theme="light"] {
  --bg: #f4f4f5;
  --surface: #ffffff;
  --surface2: #f9f9f9;
  --border: #e4e4e7;
  --text: #111111;
  --muted: #71717a;
  --accent: #6366f1;
  --accent-soft: rgba(99,102,241,0.10);
}

/* ── RESET ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100dvh;
  display: flex;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; cursor: pointer; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── SIDEBAR ─────────────────────────────────────────────── */
#sidebar-overlay { display: none; }
.sidebar {
  width: var(--sidebar-w);
  height: 100dvh;
  position: fixed;
  left: 0; top: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
  transition: transform 250ms cubic-bezier(0.4,0,0.2,1);
}
.sidebar-logo {
  padding: 20px 16px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo-mark {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-mark svg { width: 18px; height: 18px; }
.logo-img { width: 34px; height: 34px; object-fit: contain; flex-shrink: 0; }
/* Tema escuro (padrão): logo branca. Tema claro: logo preta. */
.logo-black { display: none; }
.logo-white { display: block; }
[data-theme="light"] .logo-white { display: none; }
[data-theme="light"] .logo-black { display: block; }
.logo-text { font-weight: 700; font-size: 15px; letter-spacing: -0.3px; }
.logo-sub { font-size: 10px; color: var(--muted); margin-top: 1px; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  opacity: 0.7;
  padding: 16px 10px 6px;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--muted);
  transition: background 140ms, color 140ms;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item:hover svg { color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--accent); border-radius: 0 3px 3px 0;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: color 140ms; }
.nav-item span:first-of-type { font-size: 13px; font-weight: 500; flex: 1; }
.nav-item.active span:first-of-type { font-weight: 600; }

.phase-tag {
  font-size: 9px; font-weight: 600;
  padding: 2px 6px; border-radius: 4px;
  background: var(--surface2); color: var(--muted);
  white-space: nowrap;
}
.phase-tag.mvp { background: rgba(34,197,94,0.12); color: var(--success); }
.phase-tag.p2  { background: rgba(245,158,11,0.12); color: var(--warning); }
.phase-tag.p3  { background: var(--accent-soft); color: var(--accent); }

.sidebar-footer {
  padding: 10px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.theme-toggle {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--muted);
  transition: background 120ms, color 120ms;
  background: none; border: none; width: 100%;
}
.theme-toggle:hover { background: var(--surface2); color: var(--text); }
.theme-toggle svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.theme-toggle span { font-size: 13px; font-weight: 500; }

/* ── MAIN ────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* ── TOPBAR ──────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: none;
  transition: opacity 120ms, background 120ms;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: 0.88; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── PAGES ───────────────────────────────────────────────── */
.page { display: none; padding: 24px; flex: 1; }
.page.active { display: block; }

/* ── GRID ────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }

/* ── CARD ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-sm { padding: 16px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.card-value { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 4px; }
.card-delta { font-size: 12px; color: var(--success); font-weight: 500; }
.card-delta.down { color: var(--danger); }

.stat-icon {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 16px; height: 16px; stroke: var(--accent); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: rgba(34,197,94,.12);  color: var(--success); }
.badge-yellow { background: rgba(245,158,11,.12); color: var(--warning); }
.badge-purple { background: var(--accent-soft);   color: var(--accent); }
.badge-red    { background: rgba(239,68,68,.12);  color: var(--danger); }
.badge-gray   { background: var(--surface2);      color: var(--muted); }
.badge-pink   { background: rgba(244,114,182,.12);color: #f472b6; }

/* ── SECTION HEADER ──────────────────────────────────────── */
.section-header { margin-bottom: 20px; }
.section-title { font-size: 20px; font-weight: 700; letter-spacing: -0.4px; margin-bottom: 4px; }
.section-desc { font-size: 13px; color: var(--muted); }

/* ── CHARTS ──────────────────────────────────────────────── */
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 80px; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; opacity: 0.75; transition: opacity 150ms; }
.bar:hover { opacity: 1; }
.bar-label { font-size: 10px; color: var(--muted); }

/* ── AUDIENCE BARS ───────────────────────────────────────── */
.aud-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.aud-track { height: 4px; background: var(--border); border-radius: 2px; }
.aud-fill  { height: 4px; border-radius: 2px; background: var(--accent); }

/* ── DIVIDER ─────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ── ROADMAP ─────────────────────────────────────────────── */
.roadmap { display: flex; flex-direction: column; gap: 16px; }
.phase-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.phase-line { height: 1px; flex: 1; background: var(--border); }
.phase-label { font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.phase-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 8px; }
.phase-item {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
  display: flex; align-items: flex-start; gap: 8px;
}
.phase-item-num {
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0; margin-top: 1px;
}
.mvp-num { background: rgba(34,197,94,.15); color: var(--success); }
.p2-num  { background: rgba(245,158,11,.15); color: var(--warning); }
.p3-num  { background: var(--accent-soft);   color: var(--accent); }
.phase-item-name { font-size: 12px; font-weight: 600; }
.phase-item-desc { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── KANBAN ──────────────────────────────────────────────── */
.kanban-board {
  display: flex; gap: 12px;
  overflow-x: auto; padding-bottom: 8px;
  min-height: calc(100dvh - 200px);
}
.kanban-board::-webkit-scrollbar { height: 4px; }
.kanban-board::-webkit-scrollbar-track { background: transparent; }
.kanban-board::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.kanban-col { min-width: 200px; flex-shrink: 0; }
.kanban-col-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.col-title { font-size: 12px; font-weight: 600; }
.col-count { background: var(--surface2); color: var(--muted); border-radius: 20px; font-size: 11px; font-weight: 600; padding: 1px 7px; }
.kanban-cards { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kanban-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
  cursor: grab; transition: border-color 150ms, box-shadow 150ms;
}
.kanban-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.kanban-card:active { cursor: grabbing; }
.kcard-type { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.kcard-title { font-size: 12px; font-weight: 600; margin-bottom: 8px; line-height: 1.4; }
.kcard-footer { display: flex; align-items: center; justify-content: space-between; }
.kcard-date { font-size: 10px; color: var(--muted); }
.kcard-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-reel      { background: #818cf8; }
.dot-carrossel { background: #f472b6; }
.dot-foto      { background: #34d399; }
.add-card {
  width: 100%; padding: 8px;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  color: var(--muted); font-size: 12px;
  background: none; cursor: pointer;
  transition: border-color 150ms, color 150ms;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.add-card:hover { border-color: var(--accent); color: var(--accent); }

/* ── CALENDAR ────────────────────────────────────────────── */
.calendar-layout { display: grid; grid-template-columns: 1fr 280px; gap: 16px; }
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.cal-month { font-size: 15px; font-weight: 700; }
.cal-nav { display: flex; gap: 4px; }
.cal-nav button {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 150ms, color 150ms;
}
.cal-nav button:hover { border-color: var(--accent); color: var(--accent); }
.cal-grid-header { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; margin-bottom: 4px; }
.cal-day-name { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; }
.cal-cell {
  border-radius: 6px; padding: 4px 3px;
  cursor: pointer; transition: background 120ms;
  min-height: 52px;
  display: flex; flex-direction: column;
  border: 1px solid transparent;
}
.cal-cell:hover { background: var(--surface2); }
.cal-cell.today { border-color: var(--accent); }
.cal-cell.selected { background: var(--accent-soft); border-color: var(--accent); }
.cal-cell.other-month { opacity: 0.3; pointer-events: none; }
.cal-day-num { font-size: 11px; font-weight: 500; margin-bottom: 2px; padding: 0 2px; }
.cal-cell.today .cal-day-num { color: var(--accent); font-weight: 700; }
.cal-events { display: flex; flex-direction: column; gap: 2px; }
.cal-event { font-size: 9px; font-weight: 500; padding: 1px 3px; border-radius: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-reel      { background: rgba(129,140,248,.2); color: #818cf8; }
.ev-carrossel { background: rgba(244,114,182,.2); color: #f472b6; }
.ev-foto      { background: rgba(52,211,153,.2);  color: #34d399; }
.ev-gcal      { background: rgba(251,146,60,.2);  color: #fb923c; }
.gcal-connect {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px dashed var(--border); margin-bottom: 12px;
  font-size: 12px; color: var(--muted);
}
.gcal-dot { width: 8px; height: 8px; border-radius: 50%; background: #fb923c; flex-shrink: 0; }
.cal-sidebar-title { font-size: 12px; font-weight: 600; margin-bottom: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.cal-post-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  margin-bottom: 8px; transition: border-color 150ms;
}
.cal-post-item:hover { border-color: var(--accent); }
.cal-post-thumb {
  width: 34px; height: 34px; border-radius: 6px;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cal-post-thumb svg { width: 14px; height: 14px; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cal-post-title { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-post-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.cal-post-info { flex: 1; min-width: 0; }

/* ── REEL ANALYSIS ───────────────────────────────────────── */
.url-input-wrap {
  display: flex; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
  margin-bottom: 20px;
  transition: border-color 150ms;
}
.url-input-wrap:focus-within { border-color: var(--accent); }
.url-input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 14px; color: var(--text);
}
.url-input::placeholder { color: var(--muted); }
.analysis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.analysis-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.analysis-text {
  font-size: 13px; line-height: 1.7; color: var(--text);
  white-space: pre-wrap; padding: 4px 0;
}
.analysis-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px;
}

/* ── REEL TABS ───────────────────────────────────────────── */
.reel-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0; margin-bottom: 16px;
}
.reel-tab {
  padding: 8px 14px; font-size: 12px; font-weight: 500;
  color: var(--muted); background: transparent; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  cursor: pointer; border-radius: 4px 4px 0 0;
  transition: color .15s, border-color .15s;
}
.reel-tab:hover { color: var(--text); }
.reel-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── HOOKS ───────────────────────────────────────────────── */
.hook-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  margin-bottom: 8px;
  display: flex; align-items: flex-start; gap: 12px;
  transition: border-color 150ms;
}
.hook-card:hover { border-color: var(--accent); }
.hook-num { font-size: 11px; font-weight: 700; color: var(--accent); min-width: 20px; margin-top: 2px; }
.hook-text { font-size: 13px; line-height: 1.55; flex: 1; }
.hook-actions { display: flex; gap: 6px; margin-top: 10px; }

/* ── ICON BUTTON ─────────────────────────────────────────── */
.icon-btn {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border); background: none;
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 150ms, color 150ms, background 150ms;
  flex-shrink: 0;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.icon-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── BATCH ───────────────────────────────────────────────── */
.batch-controls { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.batch-result-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border);
  margin-bottom: 8px; transition: border-color 150ms;
}
.batch-result-item:hover { border-color: var(--accent); }
.batch-num { font-size: 11px; font-weight: 700; color: var(--accent); min-width: 22px; margin-top: 2px; }
.batch-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.batch-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }
.batch-content { flex: 1; }

/* ── INSIGHTS ────────────────────────────────────────────── */
.insight-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border);
  margin-bottom: 8px;
}
.insight-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.insight-text { font-size: 13px; flex: 1; }
.insight-count { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── TRACKER ─────────────────────────────────────────────── */
.tracker-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  margin-bottom: 8px; transition: border-color 150ms;
}
.tracker-item:hover { border-color: var(--accent); }
.tracker-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #f472b6);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.tracker-info { flex: 1; min-width: 0; }
.tracker-name { font-size: 13px; font-weight: 600; }
.tracker-handle { font-size: 11px; color: var(--muted); }
.tracker-stats { display: flex; gap: 20px; }
.tracker-stat { text-align: right; }
.tracker-stat-val { font-size: 13px; font-weight: 600; }
.tracker-stat-label { font-size: 10px; color: var(--muted); }

/* ── TRENDS ──────────────────────────────────────────────── */
.trend-item {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.trend-item:last-child { border-bottom: none; padding-bottom: 0; }
.trend-rank { font-size: 13px; font-weight: 800; color: var(--muted); min-width: 28px; flex-shrink: 0; }
.trend-info { flex: 1; min-width: 0; }
.trend-name { font-size: 13px; font-weight: 600; color: var(--text); }
.trend-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.trend-bar-bg { height: 4px; background: var(--border); border-radius: 2px; }
.trend-bar-fill { height: 4px; background: var(--accent); border-radius: 2px; transition: width .4s ease; }
.trend-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }
.trend-hook { font-size: 12px; padding: 6px 10px; background: rgba(99,102,241,.07); border-left: 2px solid var(--accent); border-radius: 0 4px 4px 0; color: var(--text); font-style: italic; }

/* ── CAROUSEL TEMPLATES ──────────────────────────────────── */
.template-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.template-card {
  cursor: pointer; border-radius: var(--radius); overflow: hidden;
  border: 2px solid var(--border); transition: border-color 150ms;
}
.template-card:hover, .template-card.selected { border-color: var(--accent); }
.template-preview {
  aspect-ratio: 1;
  display: flex; align-items: flex-start;
  overflow: hidden; position: relative;
}
/* T1 Clean */
.t1 { background: #fff; border-bottom: 1px solid var(--border); }
.t1-inner { padding: 16px; width: 100%; }
.t1-tag { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: #6366f1; margin-bottom: 8px; }
.t1-title { font-size: 16px; font-weight: 800; color: #111; line-height: 1.2; margin-bottom: 8px; }
.t1-line { height: 2px; width: 36px; background: #6366f1; }
/* T2 Dark */
.t2 { background: #0d0d0d; }
.t2-inner { padding: 16px; width: 100%; }
.t2-tag { font-size: 9px; letter-spacing: .15em; text-transform: uppercase; color: #c9a84c; margin-bottom: 8px; }
.t2-title { font-size: 16px; font-weight: 800; color: #fff; line-height: 1.2; margin-bottom: 10px; }
.t2-bar { height: 1px; background: linear-gradient(90deg, #c9a84c, transparent); }
/* T3 Bold */
.t3 { background: linear-gradient(135deg, #7c3aed, #db2777); }
.t3-inner { padding: 16px; width: 100%; }
.t3-num { font-size: 42px; font-weight: 900; color: rgba(255,255,255,.25); line-height: 1; }
.t3-title { font-size: 15px; font-weight: 800; color: #fff; line-height: 1.2; margin-top: 4px; }
/* T4 Photo */
.t4 { background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.7) 100%), #3a4a5a; align-items: flex-end; }
.t4-inner { padding: 14px; width: 100%; }
.t4-label { font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.7); margin-bottom: 4px; }
.t4-title { font-size: 14px; font-weight: 700; color: #fff; line-height: 1.3; }
.template-name { padding: 10px 12px; font-size: 12px; font-weight: 600; background: var(--surface); }
.template-style { font-size: 10px; color: var(--muted); margin-top: 2px; font-weight: 400; }

/* ── FORM CONTROLS ───────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.form-input, .form-select, textarea.form-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px; color: var(--text);
  outline: none; transition: border-color 150ms;
  width: 100%;
}
.form-input:focus, .form-select:focus, textarea.form-input:focus { border-color: var(--accent); }
.form-select { appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
.form-select option { background: var(--surface); }
textarea.form-input { resize: vertical; }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%; max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 16px; font-weight: 700; }

/* ── TOAST ───────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 300; pointer-events: none;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  transform: translateX(110%);
  transition: transform 250ms cubic-bezier(0.4,0,0.2,1);
  pointer-events: auto;
  max-width: 320px;
  color: var(--text);
}
.toast.show { transform: translateX(0); }
.toast-success { border-color: var(--success); }
.toast-error   { border-color: var(--danger); }
.toast-info    { border-color: var(--accent); }

/* ── SPINNER ─────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 800ms linear infinite; }

/* ── BOTTOM NAV ──────────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  justify-content: space-around;
}
.bnav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px 10px; cursor: pointer; color: var(--muted);
  background: none; border: none; transition: color 150ms;
}
.bnav-item.active { color: var(--accent); }
.bnav-item svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bnav-item span { font-size: 10px; font-weight: 500; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 1200px) {
  .template-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2,1fr); }
  .calendar-layout { grid-template-columns: 1fr; }
  .analysis-grid { grid-template-columns: 1fr; }
  .tracker-stats { display: none; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); z-index: 250; padding-bottom: env(safe-area-inset-bottom); }
  .sidebar.open { transform: translateX(0); }
  #sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; opacity: 0; visibility: hidden; transition: opacity 250ms; }
  #sidebar-overlay.open { opacity: 1; visibility: visible; }
  .main { margin-left: 0; }
  .bottom-nav { display: flex; }
  .sidebar.open ~ .bottom-nav { display: none; }
  .page { padding: 16px; padding-bottom: 80px; }
  .topbar { padding: 0 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .template-grid { grid-template-columns: repeat(2,1fr); }
  .batch-controls { grid-template-columns: 1fr; }
  .analysis-grid { grid-template-columns: 1fr; }
  #toast-container { bottom: 80px; right: 12px; left: 12px; }
  .toast { max-width: 100%; }
}
@media (max-width: 480px) {
  .template-grid { grid-template-columns: 1fr; }
  .cal-event { display: none; }
}
