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

/* ===== TOKENS ===== */
:root {
  --bg: #09090b;
  --bg-card: #18181b;
  --bg-raised: #1f1f23;
  --bg-hover: #27272a;
  --bg-input: #27272a;
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #52525b;
  --border: #27272a;
  --border-strong: #3f3f46;
  --accent: #3b82f6;
  --accent-soft: rgba(59,130,246,0.12);
  --accent-hover: #60a5fa;
  --accent-text: #ffffff;
  --green-neon: #00ff88;
  --green-neon-dim: rgba(0,255,136,0.15);
  --red: #ef4444;
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
  --radius: 8px;
  --radius-sm: 6px;

  /* Block colors -- dark mode, vivid */
  --c-you-bg: rgba(59,130,246,0.28);
  --c-you-border: #3b82f6;
  --c-you-text: #93c5fd;

  --c-f1-bg: rgba(236,72,153,0.28);
  --c-f1-border: #ec4899;
  --c-f1-text: #f9a8d4;

  --c-f2-bg: rgba(6,182,212,0.25);
  --c-f2-border: #06b6d4;
  --c-f2-text: #67e8f9;

  --c-f3-bg: rgba(245,158,11,0.25);
  --c-f3-border: #f59e0b;
  --c-f3-text: #fde047;

  --c-merged-bg: rgba(239,68,68,0.22);
  --c-merged-border: #ef4444;
  --c-merged-text: #fca5a5;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-card: #f4f4f5;
  --bg-raised: #e4e4e7;
  --bg-hover: #e4e4e7;
  --bg-input: #f4f4f5;
  --text: #09090b;
  --text-secondary: #3f3f46;
  --text-muted: #71717a;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --accent: #2563eb;
  --accent-soft: rgba(37,99,235,0.07);
  --accent-hover: #1d4ed8;
  --accent-text: #ffffff;
  --green-neon: #16a34a;
  --green-neon-dim: rgba(22,163,74,0.08);
  --shadow: 0 1px 4px rgba(0,0,0,0.07);

  --c-you-bg: rgba(37,99,235,0.14);
  --c-you-border: #2563eb;
  --c-you-text: #1d4ed8;

  --c-f1-bg: rgba(219,39,119,0.14);
  --c-f1-border: #db2777;
  --c-f1-text: #9d174d;

  --c-f2-bg: rgba(8,145,178,0.14);
  --c-f2-border: #0891b2;
  --c-f2-text: #155e75;

  --c-f3-bg: rgba(202,138,4,0.14);
  --c-f3-border: #ca8a04;
  --c-f3-text: #78350f;

  --c-merged-bg: rgba(220,38,38,0.12);
  --c-merged-border: #dc2626;
  --c-merged-text: #7f1d1d;
}

/* ===== UTILITY ===== */
.hidden { display: none !important; }

/* ===== BASE ===== */
body {
  font-family: 'Geist', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

/* ===== TOP BAR ===== */
.topbar {
  height: 46px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  gap: 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
  transition: background 0.3s, border-color 0.3s;
}

.brand {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  margin-right: 16px;
  flex-shrink: 0;
}

.divider { width: 1px; height: 20px; background: var(--border-strong); margin: 0 4px; }

.tab-nav { display: flex; height: 100%; }
.tab {
  display: flex; align-items: center; gap: 5px;
  padding: 0 12px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  text-decoration: none; height: 100%; white-space: nowrap;
}
.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab svg { width: 13px; height: 13px; opacity: 0.65; }
.tab.active svg { opacity: 1; }
.tab-badge {
  font-size: 9px; background: var(--accent); color: white;
  padding: 0 5px; border-radius: 99px; font-weight: 700; line-height: 15px;
}

.top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.code-pill {
  font-family: 'Geist Mono', monospace;
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
  padding: 3px 9px; border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--border-strong);
  color: var(--text-secondary); cursor: pointer; transition: all 0.15s;
}
.code-pill:hover { border-color: var(--accent); color: var(--accent); }

.icon-btn {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); cursor: pointer; transition: all 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 13px; height: 13px; }

.avatar-sm {
  width: 28px; height: 28px; border-radius: 99px;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
  color: white; font-size: 10px; font-weight: 700; cursor: pointer; flex-shrink: 0;
}

/* ===== LAYOUT ===== */
.layout {
  display: grid;
  grid-template-columns: 1fr 268px;
  height: calc(100vh - 46px);
}

.main-area {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

/* ===== SUB-HEADER ===== */
.sub-header {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap; flex-shrink: 0;
}

.chip {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px 4px 6px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border-strong); background: transparent;
  transition: all 0.2s; user-select: none;
}
.chip .dot { width: 7px; height: 7px; border-radius: 99px; flex-shrink: 0; }

.chip.you .dot   { background: var(--c-you-border);  }
.chip.f1 .dot    { background: var(--c-f1-border);   }
.chip.f2 .dot    { background: var(--c-f2-border);   }
.chip.f3 .dot    { background: var(--c-f3-border);   }

.chip.active.you { background: var(--c-you-bg); border-color: var(--c-you-border); color: var(--c-you-text); }
.chip.active.f1  { background: var(--c-f1-bg);  border-color: var(--c-f1-border);  color: var(--c-f1-text);  }
.chip.active.f2  { background: var(--c-f2-bg);  border-color: var(--c-f2-border);  color: var(--c-f2-text);  }
.chip.active.f3  { background: var(--c-f3-bg);  border-color: var(--c-f3-border);  color: var(--c-f3-text);  }

.chip-label { color: var(--text-muted); }
.chip:not(.active) { color: var(--text-muted); }

.sub-right { margin-left: auto; display: flex; gap: 6px; }

.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--bg-card);
  color: var(--text-secondary); transition: all 0.15s; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn svg { width: 12px; height: 12px; }
.btn-accent { background: var(--accent); color: white; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: white; }
.btn-green { background: var(--green-neon); color: #000; border-color: var(--green-neon); font-weight: 700; }
.btn-green:hover { filter: brightness(1.1); color: #000; }
.btn-merge { background: var(--c-merged-bg); border-color: var(--c-merged-border); color: var(--c-merged-text); }
.btn-merge.active { background: var(--c-merged-border); color: white; }
.btn-merge:hover { background: var(--c-merged-border); color: white; }

/* ===== SCHEDULE GRID ===== */
.schedule-wrap {
  flex: 1; overflow: auto; position: relative;
}

.schedule-grid {
  display: grid;
  grid-template-columns: 44px repeat(7, 1fr);
  min-width: 520px;
  position: relative;
}

/* Sticky day headers row */
.grid-sticky-row {
  display: contents;
}

.time-corner, .day-header {
  position: sticky;
  top: 0;
  z-index: 15;
  background: var(--bg);
  border-bottom: 1px solid var(--border-strong);
  padding: 8px 0 6px;
  transition: background 0.3s;
}

.time-corner { border-right: 1px solid var(--border); }

.day-header {
  text-align: center; border-right: 1px solid var(--border);
}
.day-header .d-name {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted);
}
.day-header .d-num {
  font-size: 17px; font-weight: 700; color: var(--text); margin-top: 1px;
  line-height: 1;
}
.day-header.today .d-num {
  background: var(--accent); color: white;
  width: 28px; height: 28px; border-radius: 99px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; margin-top: 2px;
}

/* Time rows */
.t-label {
  height: 44px; display: flex; align-items: flex-start; justify-content: flex-end;
  padding: 0 6px 0 0; font-size: 10px; font-weight: 500;
  color: var(--text-muted); font-family: 'Geist Mono', monospace;
  border-right: 1px solid var(--border);
  transform: translateY(-6px);
  user-select: none;
}

.grid-cell {
  height: 44px; border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  transition: background 0.08s;
}
.grid-cell:hover { background: var(--bg-hover); cursor: crosshair; }
.grid-cell:last-child { border-right: none; }

/* ===== SCHEDULE BLOCKS ===== */
.block {
  position: absolute;
  border-radius: var(--radius);
  padding: 4px 7px;
  font-size: 11px; font-weight: 600;
  overflow: hidden; cursor: pointer;
  border-left: 3px solid;
  transition: opacity 0.32s ease, transform 0.32s ease, box-shadow 0.2s;
  transform-origin: top center;
}

.block:hover { z-index: 50 !important; filter: brightness(1.15); box-shadow: 0 4px 12px rgba(0,0,0,0.35); }

.block-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3;
}
.block-time { font-size: 9px; font-weight: 500; opacity: 0.75; }

/* Individual block colors */
.block.you  { background: var(--c-you-bg); border-left-color: var(--c-you-border); color: var(--c-you-text); box-shadow: 0 0 0 1px var(--c-you-border) inset; }
.block.f1   { background: var(--c-f1-bg);  border-left-color: var(--c-f1-border);  color: var(--c-f1-text);  box-shadow: 0 0 0 1px var(--c-f1-border) inset; }
.block.f2   { background: var(--c-f2-bg);  border-left-color: var(--c-f2-border);  color: var(--c-f2-text);  box-shadow: 0 0 0 1px var(--c-f2-border) inset; }
.block.f3   { background: var(--c-f3-bg);  border-left-color: var(--c-f3-border);  color: var(--c-f3-text);  box-shadow: 0 0 0 1px var(--c-f3-border) inset; }

/* Merged block */
.block.merged {
  background: var(--c-merged-bg);
  border-left-color: var(--c-merged-border);
  color: var(--c-merged-text);
  box-shadow: 0 0 0 1px var(--c-merged-border) inset, 0 4px 14px rgba(239,68,68,0.2);
  border-radius: var(--radius);
}

/* Free-time blocks -- sandwiched (between busy blocks) */
.block.free.sandwiched {
  background: rgba(0,255,136,0.10);
  border-left: 3px solid var(--green-neon);
  color: var(--green-neon);
  border-top: 1px solid rgba(0,255,136,0.3);
  border-right: 1px solid rgba(0,255,136,0.3);
  border-bottom: 1px solid rgba(0,255,136,0.3);
  animation: free-glow 2.4s ease-in-out infinite;
}

/* Free-time blocks -- open (no busy block on one or both sides) */
.block.free.open {
  background: rgba(0,255,136,0.04);
  border-left: 2px solid rgba(0,255,136,0.15);
  color: rgba(0,255,136,0.55);
  border-top: 1px dashed rgba(0,255,136,0.12);
  border-right: 1px dashed rgba(0,255,136,0.12);
  border-bottom: 1px dashed rgba(0,255,136,0.12);
  animation: none;
}
.block.free.open .block-name,
.block.free.open .block-time { opacity: 1; }

@keyframes free-glow {
  0%, 100% {
    box-shadow: 0 0 4px rgba(0,255,136,0.2), 0 0 8px rgba(0,255,136,0.08);
  }
  50% {
    box-shadow: 0 0 8px rgba(0,255,136,0.4), 0 0 18px rgba(0,255,136,0.18), 0 0 32px rgba(0,255,136,0.06);
  }
}

[data-theme="light"] .block.free.sandwiched {
  animation: free-glow-light 2.4s ease-in-out infinite;
}
[data-theme="light"] .block.free.open {
  background: rgba(22,163,74,0.05);
  border-left: 2px solid rgba(22,163,74,0.25);
  color: rgba(22,163,74,0.75);
  border-top: 1px dashed rgba(22,163,74,0.15);
  border-right: 1px dashed rgba(22,163,74,0.15);
  border-bottom: 1px dashed rgba(22,163,74,0.15);
}
@keyframes free-glow-light {
  0%, 100% { box-shadow: 0 0 5px rgba(22,163,74,0.3), 0 0 10px rgba(22,163,74,0.1); }
  50% { box-shadow: 0 0 10px rgba(22,163,74,0.5), 0 0 20px rgba(22,163,74,0.2); }
}

/* Block entry animation */
@keyframes block-in {
  from { opacity: 0; transform: scaleY(0.88) translateY(4px); }
  to   { opacity: 1; transform: scaleY(1) translateY(0); }
}
.block.animate-in { animation: block-in 0.28s ease both; }

/* Merge fade states */
.block.fading-out { opacity: 0 !important; transform: scaleY(0.9) !important; }
.block.hidden-block { display: none !important; }
.block.fading-in { opacity: 0; transform: scaleY(0.9); }

/* ===== BLOCK EDIT POPOVER ===== */
.block-popover {
  position: absolute;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  min-width: 220px;
  animation: modal-in 120ms ease both;
}
[data-theme="light"] .block-popover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.block-popover label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 3px;
  margin-top: 8px;
}
.block-popover label:first-child { margin-top: 0; }
.block-popover input,
.block-popover select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: 12px;
  font-family: 'Geist', sans-serif;
  outline: none;
  transition: border-color 0.15s;
}
.block-popover input:focus,
.block-popover select:focus { border-color: var(--accent); }
.block-popover .pop-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.block-popover .pop-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.block-popover .pop-actions .btn { flex: 1; justify-content: center; }
.pop-delete {
  background: rgba(239,68,68,0.12) !important;
  border-color: var(--red) !important;
  color: var(--red) !important;
}
.pop-delete:hover {
  background: var(--red) !important;
  color: white !important;
}

/* ===== BEST OPEN TIMES PANEL ===== */
.best-times-section { padding: 0; }
.best-times-section .sp-head { padding: 10px 14px; }
.best-time-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  transition: background 0.1s;
}
.best-time-item:hover { background: var(--bg-hover); }
.bt-rank {
  font-size: 10px;
  font-weight: 800;
  font-family: 'Geist Mono', monospace;
  color: var(--accent);
  width: 18px;
  flex-shrink: 0;
}
.bt-day {
  font-size: 10px;
  font-weight: 700;
  font-family: 'Geist Mono', monospace;
  color: var(--text-secondary);
  width: 26px;
  flex-shrink: 0;
}
.bt-time { font-size: 12px; font-weight: 600; flex: 1; }
.bt-dur {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: 'Geist Mono', monospace;
}

/* ===== RIGHT PANEL ===== */
.side-panel {
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
}

.sp-section { border-bottom: 1px solid var(--border); }

.sp-head {
  padding: 10px 14px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); display: flex; align-items: center; justify-content: space-between;
}
.sp-head .cnt {
  font-size: 10px; background: var(--bg-raised);
  padding: 1px 6px; border-radius: 99px; font-weight: 600;
}

/* Quick actions */
.quick-row { display: flex; gap: 5px; padding: 10px 12px; }
.qa {
  flex: 1; padding: 9px 6px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); text-align: center; cursor: pointer;
  transition: all 0.13s; background: transparent; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.qa:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.qa svg { width: 16px; height: 16px; }
.qa span { font-size: 10px; font-weight: 600; }

/* Free windows */
.free-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; cursor: pointer; transition: background 0.1s;
}
.free-item:hover { background: var(--bg-hover); }
.fi-day { font-size: 10px; font-weight: 700; font-family: 'Geist Mono', monospace; color: var(--green-neon); width: 26px; flex-shrink: 0; }
.fi-time { font-size: 12px; font-weight: 600; flex: 1; }
.fi-dur {
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 99px;
  background: var(--green-neon-dim); color: var(--green-neon);
  font-family: 'Geist Mono', monospace;
}

/* Friend items */
.fr-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 14px; cursor: pointer; transition: background 0.1s;
}
.fr-item:hover { background: var(--bg-hover); }
.fr-av {
  width: 26px; height: 26px; border-radius: 99px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: white; flex-shrink: 0;
}
.fr-av.pink   { background: linear-gradient(135deg, #db2777, #ec4899); }
.fr-av.cyan   { background: linear-gradient(135deg, #0891b2, #06b6d4); }
.fr-av.amber  { background: linear-gradient(135deg, #d97706, #f59e0b); }
.fr-av.purple { background: linear-gradient(135deg, #7c3aed, #a78bfa); }

.fr-name { font-size: 12px; font-weight: 600; flex: 1; }
.fr-code { font-size: 10px; color: var(--text-muted); font-family: 'Geist Mono', monospace; }

.fr-check {
  width: 15px; height: 15px; border-radius: 3px;
  border: 2px solid var(--border-strong); cursor: pointer;
  transition: all 0.15s; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.fr-check.on { background: var(--accent); border-color: var(--accent); }
.fr-check.on::after {
  content: ''; width: 7px; height: 4px;
  border-left: 2px solid white; border-bottom: 2px solid white;
  transform: rotate(-45deg) translateY(-1px);
}

/* Add friend */
.add-row { display: flex; gap: 5px; padding: 8px 12px 10px; }
.add-row input {
  flex: 1; padding: 5px 8px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--bg-input); color: var(--text);
  font-family: 'Geist Mono', monospace; outline: none; transition: border-color 0.15s;
}
.add-row input:focus { border-color: var(--accent); }
.add-row input::placeholder { text-transform: none; font-family: 'Geist', sans-serif; color: var(--text-muted); letter-spacing: 0; font-weight: 400; }

/* Your blocks list */
.my-block-row {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 14px; border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background 0.1s;
}
.my-block-row:last-child { border-bottom: none; }
.my-block-row:hover { background: var(--bg-hover); }
.mb-day {
  font-size: 9px; font-weight: 700; font-family: 'Geist Mono', monospace;
  width: 22px; color: var(--c-you-text); flex-shrink: 0;
}
.mb-name { font-size: 12px; font-weight: 600; flex: 1; }
.mb-time { font-size: 10px; color: var(--text-muted); font-family: 'Geist Mono', monospace; }

/* ===== MOBILE ===== */
.mobile-bar {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg); border-top: 1px solid var(--border);
  z-index: 100; padding: 4px 0 max(4px, env(safe-area-inset-bottom));
}
.mobile-bar-inner { display: flex; justify-content: space-around; }
.mob-tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px 10px; font-size: 9px; font-weight: 600;
  color: var(--text-muted); cursor: pointer; text-decoration: none;
}
.mob-tab.active { color: var(--accent); }
.mob-tab svg { width: 18px; height: 18px; }

@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; height: calc(100vh - 46px - 52px); }
  .side-panel { display: none; }
  .mobile-bar { display: block; }
  .tab-nav { display: none; }
  .schedule-grid { grid-template-columns: 30px repeat(7, 1fr); }
  .t-label { font-size: 8px; }
  .topbar { padding: 0 10px; }
  .sub-header { padding: 6px 10px; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== ANIMATIONS ===== */
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.98) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

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

/* ===== MODAL BACKDROP (shared) ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  width: min(440px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  padding: 16px;
  animation: modal-in 150ms ease both;
}

.modal-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--text);
}

.modal-card p {
  margin: 0 0 12px;
  color: var(--text-secondary);
}

.modal-card input {
  margin-top: 0;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
  font-family: 'Geist', sans-serif;
  outline: none;
  transition: border-color 0.15s;
}

.modal-card input:focus {
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.modal-cancel {
  background: var(--bg-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.modal-cancel:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.modal-confirm {
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.modal-confirm:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* ===== AUTH MODAL ===== */
.auth-modal-card {
  width: min(420px, 92vw);
  padding: 28px 24px;
}

.auth-header {
  text-align: center;
  margin-bottom: 16px;
}

.auth-header h3 {
  font-size: 22px;
  margin-bottom: 4px;
  color: var(--text);
}

.auth-header p {
  color: var(--text-secondary);
  font-size: 13px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 16px;
}

.auth-tab {
  flex: 1;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 150ms ease;
  min-height: auto;
  box-shadow: none;
}

.auth-tab:hover {
  color: var(--text-secondary);
}

.auth-tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .auth-tab.active {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.auth-tab-content {
  animation: tab-fade-in 200ms ease both;
}

.auth-tab-content.hidden {
  display: none;
}

.auth-tab-content label {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.auth-tab-content input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
  font-family: 'Geist', sans-serif;
  outline: none;
  transition: border-color 0.15s;
}

.auth-tab-content input:focus {
  border-color: var(--accent);
}

.auth-submit-btn {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.auth-submit-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.auth-status {
  margin-top: 10px;
  text-align: center;
  font-size: 13px;
  min-height: 1.3em;
  color: var(--text-secondary);
}

/* ===== IMPORT MODAL ===== */
#import-modal-backdrop {
  /* inherits from .modal-backdrop */
}

.import-modal-card {
  max-width: 640px;
  width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
}

.import-tabs {
  display: flex;
  gap: 4px;
  margin: 16px 0 12px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.import-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.import-tab:hover {
  color: var(--text);
}
.import-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.import-tab-content {
  padding: 12px 0;
}
.import-tab-content.hidden {
  display: none;
}

/* Bookmarklet section */
.bookmarklet-drag-area {
  display: flex;
  justify-content: center;
  padding: 20px;
  margin: 12px 0;
  background: var(--bg-raised);
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
}

.bookmarklet-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff !important;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none !important;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  cursor: grab;
  user-select: none;
  transition: transform 0.15s ease;
}
.bookmarklet-button:hover {
  transform: scale(1.03);
}
.bookmarklet-button:active {
  cursor: grabbing;
}

[data-theme="light"] .bookmarklet-button {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.import-instructions {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-secondary);
}
.import-instructions ol {
  padding-left: 20px;
  line-height: 1.7;
}
.import-instructions code {
  background: var(--bg-raised);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--accent);
  font-family: 'Geist Mono', monospace;
}

/* Upload section */
.upload-dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg-raised);
  margin: 12px 0;
  color: var(--text-secondary);
}
.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upload-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.upload-preview {
  margin: 12px 0;
  text-align: center;
}
.upload-preview img {
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
}
.upload-preview button {
  margin-top: 8px;
}

#upload-parse-btn,
#parse-text-btn {
  margin-top: 10px;
  width: 100%;
}

/* Paste section */
#schedule-text-input {
  width: 100%;
  font-family: 'Geist Mono', monospace;
  font-size: 13px;
  padding: 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  resize: vertical;
}

.import-format-list {
  font-size: 13px;
  padding-left: 18px;
  color: var(--text-muted);
  margin: 6px 0 10px;
  line-height: 1.6;
}

/* Preview section */
.import-preview-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.import-preview-section.hidden {
  display: none;
}

.import-preview-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px;
  margin: 8px 0;
  background: var(--bg-raised);
  font-size: 13px;
}

.import-preview-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.import-preview-item:last-child {
  border-bottom: none;
}
.import-preview-day {
  font-weight: 600;
  min-width: 36px;
  color: var(--accent);
}
.import-preview-time {
  color: var(--text-muted);
  font-family: 'Geist Mono', monospace;
  font-size: 12px;
}
.import-preview-name {
  flex: 1;
  margin-left: 8px;
  font-weight: 500;
}

.import-target-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.import-target-section label {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  color: var(--text);
}
.import-target-section select {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

#import-comparison-name {
  flex: 1;
  min-width: 160px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
#import-comparison-name:focus {
  border-color: var(--accent);
}
#import-comparison-name.hidden {
  display: none;
}

#import-status,
#comparison-status {
  margin-top: 8px;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  padding: 8px 10px;
  color: var(--text-secondary);
}

/* ===== COMPARISON NAME MODAL ===== */
.comparison-name-modal .modal-card {
  width: min(380px, 100%);
}

.comparison-name-modal .modal-card h3 {
  font-size: 16px;
}

/* ===== WORKSPACE GATE ===== */
.workspace-gate.hidden {
  display: none;
}

.workspace-only {
  transition: opacity 180ms ease, filter 180ms ease;
}

body.workspace-locked .workspace-only {
  opacity: 0.44;
  filter: saturate(0.9) blur(0.5px);
  pointer-events: none;
  user-select: none;
}

body.workspace-locked .requires-active {
  display: none !important;
}

/* ===== STATUS HELPERS ===== */
.muted {
  color: var(--text-muted);
  font-size: 13px;
}

.persist-error {
  color: var(--red);
  background: var(--c-merged-bg);
  border-color: var(--c-merged-border);
}

#persist-status {
  margin-top: 8px;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  padding: 8px 10px;
  color: var(--text-secondary);
}

#comparison-status-global {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  padding: 8px 10px;
  color: var(--text-secondary);
  font-size: 13px;
}
