/* ============================================================================
   Ruby — dark theme
   Near-black panels, hairline borders, warm off-white text, orange accent.
   ========================================================================== */

:root {
  --bg: #0a0a0b;
  --bg-elev: #101012;
  --bg-elev-2: #161618;
  --bg-hover: #1c1c20;
  --panel: #0e0e10;
  --border: #232327;
  --border-soft: #1a1a1d;
  --text: #ece9e3;
  --text-dim: #9a9aa2;
  --text-faint: #62626a;
  --accent: #ff6a2b;
  --accent-soft: rgba(255, 106, 43, 0.14);
  --accent-border: rgba(255, 106, 43, 0.4);
  --blue: #4285f4;
  --green: #34c759;
  --danger: #ff4d4d;
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  font-family: inherit;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent-border); }
input::placeholder, textarea::placeholder { color: var(--text-faint); }

/* Match native <select> chrome to the dark inputs (custom chevron, no OS look). */
select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  cursor: pointer; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239a9aa2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #26262b; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #34343a; }
::-webkit-scrollbar-track { background: transparent; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--bg-elev-2); border: 1px solid var(--border);
  font-size: 13px; font-weight: 500; transition: 0.15s;
}
.btn:hover { background: var(--bg-hover); border-color: #34343a; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink, #160a03); font-weight: 600; }
.btn.primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(255,77,77,0.3); }
.btn.danger:hover { background: rgba(255,77,77,0.1); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.lg { padding: 11px 20px; font-size: 14.5px; border-radius: 10px; }
.btn.icon { padding: 7px; width: 32px; height: 32px; justify-content: center; }

.mono { font-family: var(--mono); }
.dim { color: var(--text-dim); }

/* ----- Logo ------------------------------------------------------------- */
.logo { display: block; }
.logo path, .logo polygon { fill: var(--text); }

/* ============================================================================
   Auth screen
   ========================================================================== */
.auth-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1100px 600px at 75% -10%, rgba(255,106,43,0.12), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(66,133,244,0.07), transparent 55%),
    var(--bg);
}
.auth-card {
  width: 380px; padding: 34px 30px;
  background: linear-gradient(180deg, var(--bg-elev), var(--panel));
  border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.auth-brand .logo { width: 30px; height: 30px; }
.auth-brand h1 { font-size: 21px; margin: 0; letter-spacing: -0.5px; }
.auth-sub { color: var(--text-dim); font-size: 13px; margin: 0 0 24px; }
.auth-field { margin-bottom: 13px; }
.auth-field label { display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--text-faint); margin-bottom: 6px; }
.auth-field input { width: 100%; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 6px; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--text-faint);
  font-size: 11px; margin: 18px 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-google { width: 100%; justify-content: center; gap: 9px; background: #fff; color: #1f1f1f; border: none; }
.btn-google:hover { background: #f1f1f1; }
.auth-toggle { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-dim); }
.auth-toggle a { color: var(--accent); cursor: pointer; text-decoration: none; }
.auth-error { background: rgba(255,77,77,0.1); border: 1px solid rgba(255,77,77,0.3);
  color: #ff8a8a; padding: 9px 11px; border-radius: var(--radius-sm); font-size: 12.5px;
  margin-bottom: 14px; }

/* ============================================================================
   App shell
   ========================================================================== */
.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 18px;
  height: 56px; padding: 0 16px; flex-shrink: 0;
  border-bottom: 1px solid var(--border-soft); background: var(--bg);
  position: relative;
}
.brand { display: flex; align-items: center; gap: 10px; width: 150px; }
.brand .logo { width: 22px; height: 22px; }
.brand-name { font-weight: 600; letter-spacing: -0.3px; font-size: 15px; }

.ask-bar {
  flex: 1; max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 10px; padding: 0 10px 0 13px; height: 38px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ask-bar:focus-within { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-soft); }
.ask-bar svg { color: var(--text-faint); flex-shrink: 0; }
.ask-bar input { flex: 1; border: none; background: transparent; padding: 0; font-size: 13.5px; }
.ask-bar input:focus { border: none; }
.ask-kbd { font-family: var(--mono); font-size: 11px; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px; }
.ask-send { color: var(--accent); padding: 4px 6px; border-radius: 6px; display: flex; }
.ask-send:hover { background: var(--accent-soft); }

.top-actions { display: flex; align-items: center; gap: 8px; width: 150px; justify-content: flex-end; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent);
  color: var(--accent-ink, #160a03); font-weight: 700; display: flex; align-items: center; justify-content: center;
  font-size: 13px; cursor: pointer; }

.body { flex: 1; display: flex; min-height: 0; }

/* ----- Left icon rail --------------------------------------------------- */
.rail {
  width: 60px; flex-shrink: 0; padding: 14px 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  border-right: 1px solid var(--border-soft); background: var(--bg);
}
.rail-btn {
  width: 40px; height: 40px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); border: 1px solid transparent; transition: 0.15s; position: relative;
}
.rail-btn:hover { background: var(--bg-elev-2); color: var(--text); }
.rail-btn.active { background: var(--bg-elev-2); color: var(--accent); border-color: var(--border); }
.rail-btn.active::before {
  content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px;
  background: var(--accent); border-radius: 0 3px 3px 0;
}
.rail-spacer { flex: 1; }

/* ----- Main column + tab bar ------------------------------------------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.tabbar {
  display: flex; align-items: center; gap: 4px; height: 42px; padding: 0 10px;
  border-bottom: 1px solid var(--border-soft); background: var(--bg);
  overflow-x: auto; scrollbar-width: none; flex-shrink: 0;
}
.tabbar::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px;
  border-radius: 8px; color: var(--text-dim); font-size: 13px; white-space: nowrap;
  border: 1px solid transparent; max-width: 220px;
}
.tab:hover { background: var(--bg-elev); color: var(--text); }
.tab.active { background: var(--bg-elev-2); color: var(--text); border-color: var(--border); }
.tab svg { flex-shrink: 0; opacity: 0.8; }
.tab .tab-title { overflow: hidden; text-overflow: ellipsis; }
.tab .tab-close { width: 16px; height: 16px; border-radius: 4px; display: flex;
  align-items: center; justify-content: center; color: var(--text-faint); opacity: 0; }
.tab:hover .tab-close, .tab.active .tab-close { opacity: 1; }
.tab .tab-close:hover { background: var(--bg-hover); color: var(--text); }

.tab-content { flex: 1; min-height: 0; overflow: hidden; position: relative; }

/* ----- Toolbars shared across views ------------------------------------ */
.view { height: 100%; display: flex; flex-direction: column; }
.view-toolbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  border-bottom: 1px solid var(--border-soft); flex-shrink: 0;
}
.view-toolbar h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.3px; }
.spacer { flex: 1; }

.segmented { display: flex; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 9px; padding: 2px; }
.segmented button { padding: 5px 13px; border-radius: 7px; font-size: 12.5px;
  color: var(--text-dim); font-weight: 500; }
.segmented button.active { background: var(--bg-elev-2); color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3); }

.nav-arrows { display: flex; gap: 2px; }
.icon-btn { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center;
  justify-content: center; color: var(--text-dim); border: 1px solid transparent; }
.icon-btn:hover { background: var(--bg-elev-2); color: var(--text); border-color: var(--border); }
.range-label { font-size: 14px; font-weight: 600; min-width: 180px; }

/* ============================================================================
   Calendar
   ========================================================================== */
.cal-scroll { flex: 1; overflow: auto; position: relative; }

/* Week / day grid */
.week-head { display: grid; position: sticky; top: 0; z-index: 5;
  background: var(--bg); border-bottom: 1px solid var(--border); }
.week-head .gutter { width: 58px; }
.week-head .daycol { padding: 8px 6px; text-align: center; border-left: 1px solid var(--border-soft); }
.week-head .dow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-faint); }
.week-head .dom { font-size: 18px; font-weight: 600; margin-top: 2px; }
.week-head .daycol.today .dom { color: var(--accent); }

.week-grid { display: grid; position: relative; }
.time-gutter { width: 58px; }
.time-slot-label { height: 48px; position: relative; }
.time-slot-label span { position: absolute; top: -7px; right: 8px; font-size: 11px;
  color: var(--text-faint); font-family: var(--mono); }
.daycol-body { position: relative; border-left: 1px solid var(--border-soft); }
.hour-cell { height: 48px; border-bottom: 1px solid var(--border-soft); }
.hour-cell .half { height: 24px; border-bottom: 1px dashed rgba(255,255,255,0.03); }

.cal-event {
  position: absolute; left: 3px; right: 3px; border-radius: 7px; padding: 4px 7px;
  font-size: 12px; color: #fff; overflow: hidden; cursor: pointer; z-index: 2;
  border: 1px solid rgba(0,0,0,0.25); box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  user-select: none;
}
.cal-event .ev-time { font-size: 10.5px; opacity: 0.85; }
.cal-event .ev-title { font-weight: 600; line-height: 1.25; }
.cal-event .resize-handle { position: absolute; left: 0; right: 0; bottom: 0; height: 7px;
  cursor: ns-resize; }
.cal-event .resize-handle.top { top: 0; bottom: auto; }
.cal-event.dragging { opacity: 0.8; z-index: 20; box-shadow: var(--shadow); }
.cal-event.creating {
  pointer-events: none; z-index: 19; color: #fff; box-shadow: none;
  background: rgba(255, 106, 43, 0.30); border: 1.5px dashed var(--accent);
}
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--accent); z-index: 6; }
.now-line::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent); }

/* Month grid */
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr;
  flex: 1; min-height: 0; }
.month-dow { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); }
.month-dow div { padding: 7px 10px; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--text-faint); text-align: left; }
.month-cell { border-right: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft);
  padding: 5px 6px; overflow: hidden; cursor: pointer; min-height: 0; }
.month-cell:hover { background: var(--bg-elev); }
.month-cell.dim { background: var(--cell-dim, #08080a); }
.month-cell .num { font-size: 12.5px; color: var(--text-dim); width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.month-cell.today .num { background: var(--accent); color: #160a03; font-weight: 700; }
.month-pill { display: flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 2px 6px;
  border-radius: 5px; margin-top: 3px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  color: var(--text); }
.month-pill .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.month-more { font-size: 11px; color: var(--text-faint); margin-top: 2px; padding-left: 6px; }

/* Year grid */
.year-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; padding: 20px; overflow: auto; }
.mini-month { border: 1px solid var(--border-soft); border-radius: 12px; padding: 12px; background: var(--bg-elev); }
.mini-month h4 { margin: 0 0 8px; font-size: 13px; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mini-grid .d { font-size: 10.5px; text-align: center; padding: 3px 0; border-radius: 50%;
  color: var(--text-dim); cursor: pointer; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.mini-grid .d.dow { color: var(--text-faint); cursor: default; }
.mini-grid .d.today { background: var(--accent); color: #160a03; font-weight: 700; }
.mini-grid .d.has-ev { box-shadow: inset 0 -6px 0 -4px var(--accent); }
.mini-grid .d:not(.dow):hover { background: var(--bg-hover); color: var(--text); }

/* ============================================================================
   Tasks (Trello)
   ========================================================================== */
.board { flex: 1; display: flex; gap: 14px; padding: 18px; overflow-x: auto; align-items: flex-start; }
.column { width: 290px; flex-shrink: 0; background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius); display: flex; flex-direction: column; max-height: 100%; }
.column.drop-target { border-color: var(--accent-border); box-shadow: 0 0 0 2px var(--accent-soft); }
.column-head { display: flex; align-items: center; gap: 8px; padding: 11px 12px; }
.column-head .col-title { flex: 1; font-weight: 600; font-size: 13.5px; background: transparent;
  border: 1px solid transparent; padding: 3px 6px; border-radius: 6px; }
.column-head .col-title:focus { background: var(--bg-elev); border-color: var(--border); }
.column-head .count { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }
.cards { padding: 4px 10px 10px; overflow-y: auto; flex: 1; min-height: 24px;
  display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 11px; cursor: grab; transition: border-color 0.12s, transform 0.05s; }
.card:hover { border-color: #34343a; }
.card.dragging { opacity: 0.5; }
.card .card-title { font-size: 13px; font-weight: 500; line-height: 1.35; }
.card .card-desc { font-size: 11.5px; color: var(--text-dim); margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-placeholder { height: 2px; background: var(--accent); border-radius: 2px; margin: -3px 0; }
.add-card { margin: 2px 10px 10px; padding: 8px; border-radius: 8px; color: var(--text-dim);
  font-size: 12.5px; text-align: left; display: flex; align-items: center; gap: 6px; }
.add-card:hover { background: var(--bg-elev); color: var(--text); }
.add-column { width: 270px; flex-shrink: 0; }
.add-column button { width: 100%; padding: 12px; border-radius: var(--radius); border: 1px dashed var(--border);
  color: var(--text-dim); font-size: 13px; display: flex; align-items: center; gap: 7px; justify-content: center; }
.add-column button:hover { background: var(--bg-elev); color: var(--text); border-color: #34343a; }

/* ============================================================================
   Notes (Obsidian)
   ========================================================================== */
.notes-layout { flex: 1; display: flex; min-height: 0; }
.notes-sidebar { width: 270px; flex-shrink: 0; border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column; background: var(--panel); }
.notes-sidebar .ns-head { display: flex; align-items: center; gap: 6px; padding: 12px 12px 8px; }
.notes-sidebar .ns-head .ns-title { flex: 1; font-weight: 600; font-size: 13px; }
.notes-search { margin: 0 12px 8px; }
.notes-search input { width: 100%; }
.notes-tree { flex: 1; overflow-y: auto; padding: 4px 8px 14px; }
.tree-row { display: flex; align-items: center; gap: 5px; padding: 5px 6px; border-radius: 6px;
  font-size: 13px; color: var(--text); cursor: pointer; user-select: none; }
.tree-row:hover { background: var(--bg-elev); }
.tree-row.active { background: var(--accent-soft); color: var(--text); }
.tree-row.drop-target { background: var(--bg-hover); box-shadow: inset 0 0 0 1px var(--accent-border); }
.tree-row .twisty { width: 14px; display: flex; justify-content: center; color: var(--text-faint); }
.tree-row .ic { color: var(--text-dim); display: flex; }
.tree-row.folder .ic { color: var(--accent); }
.tree-row .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .row-actions { opacity: 0; display: flex; gap: 2px; }
.tree-row:hover .row-actions { opacity: 1; }
.tree-row .row-actions button { width: 20px; height: 20px; border-radius: 4px; color: var(--text-faint);
  display: flex; align-items: center; justify-content: center; }
.tree-row .row-actions button:hover { background: var(--bg-hover); color: var(--text); }
.tree-children { margin-left: 12px; border-left: 1px solid var(--border-soft); padding-left: 2px; }

.note-editor { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.note-editor-empty { flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); flex-direction: column; gap: 10px; }
.note-title-input { font-size: 22px; font-weight: 700; border: none; background: transparent;
  padding: 18px 26px 6px; letter-spacing: -0.4px; }
.note-title-input:focus { border: none; }
.note-meta { padding: 0 26px 10px; font-size: 11.5px; color: var(--text-faint); display: flex; gap: 12px;
  border-bottom: 1px solid var(--border-soft); }
.note-split { flex: 1; display: flex; min-height: 0; }
.note-body { flex: 1; border: none; background: transparent; resize: none; padding: 18px 26px;
  font-size: 14.5px; line-height: 1.7; font-family: var(--sans); }
.note-body:focus { border: none; }
.note-preview { flex: 1; overflow-y: auto; padding: 18px 26px; border-left: 1px solid var(--border-soft); }

/* ============================================================================
   Ask Ruby tab
   ========================================================================== */
.ask-view { height: 100%; overflow-y: auto; }
.ask-inner { max-width: 760px; margin: 0 auto; padding: 32px 28px 80px; }
.ask-question { display: flex; gap: 12px; margin-bottom: 22px; }
.ask-question .q-badge { width: 30px; height: 30px; border-radius: 8px; background: var(--bg-elev-2);
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--text-dim); font-size: 12px; font-weight: 600; }
.ask-question .q-text { font-size: 18px; font-weight: 600; line-height: 1.4; padding-top: 3px; }
.ask-answer { display: flex; gap: 12px; }
.ask-answer .a-badge { width: 30px; height: 30px; border-radius: 8px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ask-answer .a-badge .logo path, .ask-answer .a-badge .logo polygon { fill: #160a03; }
.markdown { flex: 1; min-width: 0; line-height: 1.7; font-size: 14.5px; }
.ask-typing { display: inline-block; width: 8px; height: 16px; background: var(--accent);
  margin-left: 2px; vertical-align: text-bottom; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Each follow-up turn sits below the previous one, divided by a hairline. */
.ask-turn + .ask-turn { margin-top: 28px; padding-top: 28px; border-top: 1px solid var(--border); }
.ask-turn .ask-answer { margin-bottom: 0; }

/* Follow-up composer pinned under the latest answer. */
.ask-followup { display: flex; align-items: center; gap: 10px; margin-top: 28px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
  padding: 0 8px 0 14px; height: 42px; transition: border-color 0.15s, box-shadow 0.15s; }
.ask-followup:focus-within { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-soft); }
.ask-followup-input { flex: 1; border: none; background: transparent; padding: 0; font-size: 14px; color: inherit; }
.ask-followup-input::placeholder { color: var(--text-faint); }
.ask-followup-send { color: var(--accent); padding: 6px 8px; border-radius: 7px; display: flex; }
.ask-followup-send:hover:not(:disabled) { background: var(--accent-soft); }
.ask-followup-send:disabled, .ask-followup-input:disabled { opacity: 0.5; cursor: default; }

/* ==========================================================================
   Admin stats modal
   ========================================================================== */
.stats-body { display: flex; flex-direction: column; gap: 20px; min-width: 360px; max-width: 480px; }
.stat-section { display: flex; flex-direction: column; gap: 10px; }
.stat-head { margin: 0; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-dim); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); gap: 8px; }
.stat-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 10px; text-align: center; }
.stat-num { font-size: 22px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.stat-recent { display: flex; flex-direction: column; gap: 6px; max-height: 30vh; overflow: auto; }
.stat-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.stat-row:last-child { border-bottom: none; }
.stat-row .sr-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-row .dim { flex-shrink: 0; font-size: 12px; }

/* Markdown elements */
.markdown h1, .markdown h2, .markdown h3 { letter-spacing: -0.3px; margin: 1.2em 0 0.5em; line-height: 1.3; }
.markdown h1 { font-size: 1.5em; } .markdown h2 { font-size: 1.3em; } .markdown h3 { font-size: 1.12em; }
.markdown p { margin: 0.7em 0; }
.markdown ul, .markdown ol { margin: 0.6em 0; padding-left: 1.4em; }
.markdown li { margin: 0.3em 0; }
.markdown code { font-family: var(--mono); font-size: 0.88em; background: var(--bg-elev-2);
  border: 1px solid var(--border-soft); padding: 1px 5px; border-radius: 5px; }
.markdown pre { background: #0c0c0e; border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; overflow-x: auto; margin: 0.9em 0; }
.markdown pre code { background: none; border: none; padding: 0; font-size: 12.5px; }
.markdown blockquote { border-left: 3px solid var(--accent); margin: 0.8em 0; padding: 2px 0 2px 14px;
  color: var(--text-dim); }
.markdown a { color: var(--accent); }
.markdown table { border-collapse: collapse; margin: 0.8em 0; font-size: 13px; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }
/* LaTeX math (KaTeX). Display blocks get breathing room and scroll if wide. */
.markdown .math-block { margin: 0.9em 0; overflow-x: auto; overflow-y: hidden; }
.markdown .katex-display { margin: 0; }
.markdown .math-error { color: #ff6b6b; background: var(--bg-elev-2); }

/* ============================================================================
   Empty states
   ========================================================================== */
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-faint); gap: 12px; text-align: center; padding: 40px; }
.empty-state .es-icon { width: 48px; height: 48px; opacity: 0.4; }
.empty-state h3 { margin: 0; color: var(--text-dim); font-weight: 600; }

/* ============================================================================
   Modal + Toast + Context menu
   ========================================================================== */
.modal-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px); }
.modal { width: 460px; max-width: calc(100vw - 32px); max-height: calc(100vh - 60px); overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; padding: 18px 20px 4px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .close { margin-left: auto; color: var(--text-faint); }
.modal-body { padding: 14px 20px 20px; }
.modal-field { margin-bottom: 13px; }
.modal-field label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-faint); margin-bottom: 6px; }
.modal-field input, .modal-field textarea, .modal-field select { width: 100%; }
.modal-row { display: flex; gap: 10px; }
.modal-row > * { flex: 1; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal-actions .spacer { flex: 1; }
.color-swatches { display: flex; gap: 8px; }
.color-swatches .sw { width: 26px; height: 26px; border-radius: 7px; cursor: pointer; border: 2px solid transparent; }
.color-swatches .sw.active { border-color: var(--text); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.checkbox-row input { width: auto; }

.toast-root { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; font-size: 13px; box-shadow: var(--shadow); animation: toastin 0.2s ease; }
.toast.error { border-color: rgba(255,77,77,0.4); color: #ff9a9a; }
.toast.success { border-color: rgba(52,199,89,0.4); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

.ctx-menu { position: fixed; z-index: 250; background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 5px; box-shadow: var(--shadow); min-width: 170px; }
.ctx-menu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px;
  border-radius: 7px; font-size: 13px; color: var(--text); text-align: left; }
.ctx-menu button:hover { background: var(--bg-hover); }
.ctx-menu button.danger { color: var(--danger); }
.ctx-menu .sep { height: 1px; background: var(--border-soft); margin: 4px 0; }

.dropdown { position: absolute; top: 46px; right: 14px; z-index: 60; background: var(--bg-elev-2);
  border: 1px solid var(--border); border-radius: 12px; padding: 6px; box-shadow: var(--shadow); min-width: 220px; }
.dropdown .dd-user { padding: 9px 11px; border-bottom: 1px solid var(--border-soft); margin-bottom: 5px; }
.dropdown .dd-user .name { font-weight: 600; font-size: 13.5px; }
.dropdown .dd-user .email { font-size: 12px; color: var(--text-faint); }
.dropdown button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 11px;
  border-radius: 7px; font-size: 13px; text-align: left; color: var(--text); }
.dropdown button:hover { background: var(--bg-hover); }
.dropdown .status-chip { font-size: 11px; padding: 1px 7px; border-radius: 20px; margin-left: auto; }
.status-chip.on { background: rgba(52,199,89,0.15); color: var(--green); }
.status-chip.off { background: var(--bg-hover); color: var(--text-faint); }

/* ============================================================================
   New-feature UI
   ========================================================================== */

/* ----- Native color inputs (event color, card labels) ------------------- */
input[type="color"] {
  -webkit-appearance: none; appearance: none; padding: 0;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-elev); cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }

/* ----- Calendar: weekly day picker + custom color ----------------------- */
.weekday-picker { display: flex; gap: 6px; }
.weekday-picker .wd {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--text-dim); font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.weekday-picker .wd:hover { border-color: #34343a; color: var(--text); }
.weekday-picker .wd.active { background: var(--accent); border-color: var(--accent); color: #160a03; }
.color-row { display: flex; align-items: center; gap: 12px; }
.color-custom { width: 34px; height: 34px; flex-shrink: 0; }

/* ----- Tasks: column reorder ------------------------------------------- */
.col-grip { display: flex; align-items: center; color: var(--text-faint); cursor: grab; }
.col-grip:active { cursor: grabbing; }
.column-head .col-grip:hover { color: var(--text-dim); }
.column.col-dragging { opacity: 0.4; }
.col-placeholder {
  width: 290px; flex-shrink: 0; align-self: stretch; min-height: 160px;
  border: 2px dashed var(--accent-border); border-radius: var(--radius);
  background: var(--accent-soft);
}

/* ----- Tasks: card labels, cover image, attachments -------------------- */
.card-cover { margin: -10px -11px 8px; max-height: 150px; overflow: hidden; border-radius: 8px 8px 0 0; }
.card-cover img { width: 100%; max-height: 150px; object-fit: cover; display: block; }
.card-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.card-label {
  font-size: 10.5px; font-weight: 600; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,0.35);
  padding: 1px 7px; min-width: 28px; border-radius: 5px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.card-badge {
  display: inline-flex; align-items: center; gap: 4px; max-width: 150px;
  font-size: 11px; color: var(--text-dim); text-decoration: none;
  background: var(--bg-elev); border: 1px solid var(--border-soft); border-radius: 6px; padding: 2px 7px;
}
.card-badge:hover { color: var(--text); border-color: #34343a; }
.card-badge span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Card editor: reusable tag palette */
.tag-palette { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 7px;
  font-size: 12px; cursor: pointer; user-select: none;
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text-dim);
}
.tag-chip:hover { border-color: #34343a; color: var(--text); }
.tag-chip .tag-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tag, #4285f4); flex-shrink: 0; }
.tag-chip.on { color: var(--text); border-color: var(--tag, #4285f4);
  box-shadow: inset 0 0 0 1px var(--tag, #4285f4); background: color-mix(in srgb, var(--tag, #4285f4) 16%, var(--bg-elev)); }
.tag-chip .tag-del { display: none; width: 15px; height: 15px; border-radius: 4px; color: inherit; opacity: 0.7; align-items: center; justify-content: center; }
.tag-chip:hover .tag-del { display: inline-flex; }
.tag-chip .tag-del:hover { opacity: 1; background: var(--bg-hover); }

/* Card editor: label + attachment builders */
.labels-editor, .attach-editor { display: flex; flex-direction: column; gap: 9px; }
.label-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.label-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 7px 3px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,0.35);
}
.chip-x { display: flex; align-items: center; color: inherit; opacity: 0.8; }
.chip-x:hover { opacity: 1; }
.label-add { display: flex; gap: 8px; align-items: center; }
.label-add .lbl-color { width: 34px; height: 34px; flex-shrink: 0; }
.label-add .lbl-name { flex: 1; }
.attach-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  background: var(--bg-elev); border: 1px solid var(--border-soft); border-radius: 8px;
}
.attach-row .ic { display: flex; color: var(--text-dim); flex-shrink: 0; }
.attach-row .attach-label {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12.5px; color: var(--text); text-decoration: none;
}
.attach-row .attach-label:hover { color: var(--accent); }
.attach-add { display: flex; flex-direction: column; gap: 8px; }
.attach-add-fields { display: flex; gap: 8px; }
.attach-add-fields input { flex: 1; }
.attach-add-btns { display: flex; gap: 8px; }

/* ----- Tab bar: "+" new tab -------------------------------------------- */
.tab-new {
  width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: var(--text-dim);
}
.tab-new:hover { background: var(--bg-elev-2); color: var(--text); }

/* ----- Notes: editor toolbar (censor / grammar / pdf) ------------------ */
.note-toolbar { display: flex; gap: 6px; padding: 6px 26px 0; flex-wrap: wrap; }
.note-tool {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px;
  font-size: 12px; color: var(--text-dim); background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 7px;
}
.note-tool svg { display: block; }
.note-tool:hover { background: var(--bg-hover); color: var(--text); }
.note-tool.active { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
.note-tool .g-count:empty { display: none; }
.note-tool .g-count {
  font-size: 10.5px; font-weight: 700; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--accent); color: #160a03;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Folder reorder drop indicator (top edge of a folder row). */
.tree-row.drop-before { box-shadow: inset 0 2px 0 0 var(--accent); }

/* ----- Notes: live grammar underlines + fix popover -------------------- */
.grammar-flag {
  text-decoration: underline wavy #ff6b6b; text-decoration-skip-ink: none;
  text-underline-offset: 3px; cursor: pointer;
}
.grammar-pop {
  position: fixed; z-index: 260; min-width: 200px; max-width: 300px; padding: 10px 12px;
  background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
}
.grammar-pop .gp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.grammar-pop .gp-bad { color: #ff8a8a; text-decoration: line-through; }
.grammar-pop .gp-arrow { display: flex; color: var(--text-faint); }
.grammar-pop .gp-good { color: var(--green); font-weight: 600; }
.grammar-pop .gp-msg { font-size: 11.5px; color: var(--text-dim); margin-top: 6px; }
.grammar-pop .gp-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ----- Censored / redacted text (||secret||), click to reveal ---------- */
.censored {
  background: #2b2b30; color: transparent; border-radius: 4px; padding: 0 3px;
  cursor: pointer; user-select: none; box-shadow: inset 0 0 0 1px var(--border-soft);
  transition: background 0.12s;
}
.censored:hover { background: #34343a; }
.censored.revealed { color: inherit; background: rgba(255,255,255,0.07); user-select: text; }

/* ============================================================================
   Notes: persistent collapsible sidebar + single-pane WYSIWYG editor
   ========================================================================== */
/* Collapse the folder/notes list in & out (global, persisted). */
body.notes-collapsed .notes-sidebar { display: none; }

.note-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.note-bar { display: flex; align-items: center; gap: 8px; padding: 10px 24px 0; }
.note-main .note-title-input,
.note-main .note-meta { width: 100%; max-width: 820px; margin: 0 auto; }
.note-main .note-title-input { padding: 10px 40px 4px; }
.note-main .note-meta { padding: 0 40px 9px; }

.note-doc { flex: 1; overflow-y: auto; min-height: 0; }
.note-doc-empty { flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; color: var(--text-faint); }

/* The editor itself reuses .markdown element styles; it's one editable pane. */
.wysiwyg {
  max-width: 820px; margin: 0 auto; padding: 16px 40px 90px;
  outline: none; min-height: 100%; line-height: 1.7; font-size: 15px;
  caret-color: var(--accent);
}
.wysiwyg:focus { outline: none; }
.wysiwyg p { margin: 0.55em 0; }
.wysiwyg h1, .wysiwyg h2, .wysiwyg h3 { margin: 0.9em 0 0.4em; }
.wysiwyg ul, .wysiwyg ol { margin: 0.5em 0; }
.wysiwyg pre.cb { white-space: pre-wrap; }
.wysiwyg code.ic { white-space: pre-wrap; }
/* LaTeX rendered inline; display math centred on its own line. */
.wysiwyg .math-atom { cursor: default; }
.wysiwyg .math-atom[data-display="1"] { display: inline-block; }
.wysiwyg .math-blk-wrap { margin: 0.8em 0; text-align: center; }
.wysiwyg .math-blk-wrap .math-atom { display: block; }
.wysiwyg .math-err { color: #ff6b6b; }
.wysiwyg .grammar-flag { text-decoration: underline wavy #ff6b6b; text-decoration-skip-ink: none;
  text-underline-offset: 3px; cursor: pointer; }

/* ============================================================================
   Design Market — theme palettes  (set via data-theme on <html>)
   The default "ruby" theme is the :root block at the top of this file.
   Accent-only themes keep the near-black base; "Palette" / "Light" themes
   override the full set of surfaces and text colors.
   ========================================================================== */
[data-theme="sapphire"] {
  --accent: #4f8cff; --accent-soft: rgba(79,140,255,0.15); --accent-border: rgba(79,140,255,0.45);
  --accent-ink: #ffffff;
}
[data-theme="emerald"] {
  --accent: #28c76f; --accent-soft: rgba(40,199,111,0.15); --accent-border: rgba(40,199,111,0.45);
  --accent-ink: #04140a;
}
[data-theme="amethyst"] {
  --accent: #b06cff; --accent-soft: rgba(176,108,255,0.16); --accent-border: rgba(176,108,255,0.5);
  --accent-ink: #ffffff;
}
[data-theme="rose"] {
  --accent: #ff5d8f; --accent-soft: rgba(255,93,143,0.15); --accent-border: rgba(255,93,143,0.5);
  --accent-ink: #ffffff;
}
[data-theme="gold"] {
  --accent: #f5b301; --accent-soft: rgba(245,179,1,0.15); --accent-border: rgba(245,179,1,0.5);
  --accent-ink: #281c00;
}
[data-theme="slate"] {
  --bg: #0c0e12; --bg-elev: #12151b; --bg-elev-2: #191d25; --bg-hover: #222732;
  --panel: #0f1217; --border: #262c38; --border-soft: #1b212b;
  --text: #e6e9ef; --text-dim: #98a0b0; --text-faint: #5d6573;
  --accent: #7aa2f7; --accent-soft: rgba(122,162,247,0.16); --accent-border: rgba(122,162,247,0.5);
  --accent-ink: #07101f; --cell-dim: #0a0c10;
}
[data-theme="nord"] {
  --bg: #242933; --bg-elev: #2e3440; --bg-elev-2: #3b4252; --bg-hover: #434c5e;
  --panel: #2a2f3a; --border: #3b4252; --border-soft: #333a47;
  --text: #eceff4; --text-dim: #aeb6c6; --text-faint: #6c7488;
  --accent: #88c0d0; --accent-soft: rgba(136,192,208,0.18); --accent-border: rgba(136,192,208,0.5);
  --accent-ink: #0d1f25; --cell-dim: #20242e;
}
[data-theme="dracula"] {
  --bg: #1e1f29; --bg-elev: #282a36; --bg-elev-2: #343746; --bg-hover: #3c4052;
  --panel: #21222c; --border: #3a3d4d; --border-soft: #2d303d;
  --text: #f8f8f2; --text-dim: #bcc0d6; --text-faint: #6b6f85;
  --accent: #bd93f9; --accent-soft: rgba(189,147,249,0.18); --accent-border: rgba(189,147,249,0.5);
  --accent-ink: #1a1230; --cell-dim: #191a22;
}
[data-theme="daylight"] {
  --bg: #f6f6f4; --bg-elev: #ffffff; --bg-elev-2: #f0f0ec; --bg-hover: #e8e8e2;
  --panel: #ffffff; --border: #e2e2db; --border-soft: #ecece5;
  --text: #1f1d1b; --text-dim: #5f5d58; --text-faint: #9a978f;
  --accent: #ff6a2b; --accent-soft: rgba(255,106,43,0.14); --accent-border: rgba(255,106,43,0.45);
  --accent-ink: #2a1204; --cell-dim: #eeeee9;
  --shadow: 0 18px 50px rgba(40,30,20,0.14);
}

/* ============================================================================
   Home / landing — signed-out explainer page (Notion-style, Ruby palette)
   ========================================================================== */
.home {
  position: fixed; inset: 0; z-index: 90; overflow-y: auto;
  background:
    radial-gradient(1200px 640px at 78% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(900px 520px at 6% 4%, rgba(66,133,244,0.06), transparent 55%),
    var(--bg);
}
.home a { color: inherit; text-decoration: none; }

.home-nav {
  display: flex; align-items: center; gap: 18px;
  max-width: 1080px; margin: 0 auto; padding: 18px 24px;
}
.home-nav .brand { display: flex; align-items: center; gap: 10px; }
.home-nav .brand .logo { width: 24px; height: 24px; }
.home-nav .brand-name { font-weight: 600; font-size: 16px; letter-spacing: -0.3px; }
.home-links { display: flex; gap: 22px; margin-left: 30px; margin-right: auto;
  font-size: 14px; color: var(--text-dim); }
.home-links a:hover { color: var(--text); }
.home-nav-actions { display: flex; align-items: center; gap: 10px; }

.home-hero { max-width: 880px; margin: 0 auto; padding: 54px 24px 26px; text-align: center; }
.home-eyebrow { display: inline-block; font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-border);
  padding: 5px 12px; border-radius: 20px; margin-bottom: 22px; font-weight: 600; }
.home-headline { font-size: 52px; line-height: 1.05; letter-spacing: -1.6px; margin: 0 0 18px; font-weight: 700; }
.home-headline .grad { color: var(--accent); }
.home-sub { font-size: 17px; line-height: 1.6; color: var(--text-dim); max-width: 620px; margin: 0 auto 28px; }
.home-sub strong { color: var(--text); font-weight: 600; }
.home-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.home-hint { margin-top: 16px; font-size: 13px; color: var(--text-faint); }

/* hero product mockup */
.home-mock { max-width: 860px; margin: 46px auto 0; border: 1px solid var(--border);
  border-radius: 16px; overflow: hidden; background: var(--bg-elev); box-shadow: var(--shadow); }
.hm-top { display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft); background: var(--bg); }
.hm-dots { display: flex; gap: 6px; }
.hm-dots i { width: 11px; height: 11px; border-radius: 50%; background: var(--bg-hover); }
.hm-search { flex: 1; max-width: 420px; margin: 0 auto; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px;
  font-size: 12.5px; color: var(--text-faint); text-align: center; }
.hm-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent);
  color: var(--accent-ink, #160a03); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; }
.hm-body { display: flex; height: 320px; }
.hm-rail { width: 52px; flex-shrink: 0; border-right: 1px solid var(--border-soft);
  padding: 14px 0; display: flex; flex-direction: column; align-items: center; gap: 12px; background: var(--bg); }
.hm-rail i { width: 26px; height: 26px; border-radius: 8px; background: var(--bg-hover); }
.hm-rail i.on { background: var(--accent-soft); border: 1px solid var(--accent-border); }
.hm-rail span { flex: 1; }
.hm-main { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; background: var(--bg-elev); }
.hm-cell { border-right: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); position: relative; }
.hm-ev { position: absolute; left: 5px; right: 5px; border-radius: 4px; opacity: 0.9; }

/* features + designs sections */
.home-features, .home-designs { max-width: 1080px; margin: 0 auto; padding: 58px 24px; }
.home-section-head { text-align: center; max-width: 640px; margin: 0 auto 38px; }
.home-section-head h2 { font-size: 30px; letter-spacing: -0.8px; margin: 0 0 10px; }
.home-section-head p { color: var(--text-dim); font-size: 15.5px; line-height: 1.6; margin: 0; }
.home-section-head strong { color: var(--text); font-weight: 600; }
.home-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.home-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 14px; padding: 24px; }
.home-card h3 { margin: 14px 0 8px; font-size: 17px; }
.home-card p { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.6; }
.hc-ic { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.hc-ic[data-tone="orange"] { color: #ff6a2b; background: rgba(255,106,43,0.13); }
.hc-ic[data-tone="blue"]   { color: #4285f4; background: rgba(66,133,244,0.13); }
.hc-ic[data-tone="green"]  { color: #34c759; background: rgba(52,199,89,0.13); }
.hc-ic[data-tone="violet"] { color: #a855f7; background: rgba(168,85,247,0.13); }

.home-designs { text-align: center; }
.home-themes { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.home-theme { display: flex; flex-direction: column; align-items: center; gap: 9px; }
.home-theme .theme-preview { width: 150px; height: 96px; transition: transform 0.15s; }
.home-theme:hover .theme-preview { transform: translateY(-3px); }
.ht-name { font-size: 13px; color: var(--text-dim); }
.home-theme:hover .ht-name { color: var(--text); }

.home-foot { max-width: 1080px; margin: 0 auto; padding: 30px 24px 52px;
  display: flex; align-items: center; gap: 14px; border-top: 1px solid var(--border-soft); }
.home-foot .brand { display: flex; align-items: center; gap: 9px; }
.home-foot .brand .logo { width: 20px; height: 20px; }
.home-foot .brand-name { font-weight: 600; }
.home-foot .dim { margin-left: auto; font-size: 13px; }

@media (max-width: 720px) {
  .home-links { display: none; }
  .home-headline { font-size: 38px; letter-spacing: -1px; }
  .home-sub { font-size: 15.5px; }
  .home-grid { grid-template-columns: 1fr; }
  .hm-body { height: 240px; }
}

/* "Home" link on the auth card */
.auth-back { display: inline-flex; align-items: center; gap: 5px; font-size: 13px;
  color: var(--text-dim); margin-bottom: 16px; padding: 4px 2px; }
.auth-back:hover { color: var(--text); }

/* ============================================================================
   Theme preview chip — used in the landing strip and the Market cards.
   Driven by per-theme --p-* vars set inline so each chip shows its own palette.
   ========================================================================== */
.theme-preview { width: 100%; height: 92px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border); background: var(--p-bg); display: flex; flex-direction: column; }
.tp-bar { height: 16px; display: flex; align-items: center; gap: 5px; padding: 0 8px; background: var(--p-panel); }
.tp-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--p-accent); }
.tp-line { flex: 1; height: 4px; border-radius: 3px; background: var(--p-text); opacity: 0.28; max-width: 58%; }
.tp-body { flex: 1; display: flex; min-height: 0; }
.tp-rail { width: 16px; background: var(--p-panel); display: flex; flex-direction: column;
  align-items: center; gap: 4px; padding-top: 6px; }
.tp-rail i { width: 8px; height: 8px; border-radius: 3px; background: var(--p-text); opacity: 0.2; }
.tp-rail i.on { background: var(--p-accent); opacity: 1; }
.tp-card { flex: 1; margin: 7px; border-radius: 6px; background: var(--p-panel);
  padding: 7px; display: flex; flex-direction: column; gap: 5px; }
.tp-h { height: 6px; width: 50%; border-radius: 3px; background: var(--p-accent); }
.tp-row { height: 5px; border-radius: 3px; background: var(--p-text); opacity: 0.24; }
.tp-row.short { width: 65%; }
.tp-pill { margin-top: auto; height: 12px; width: 38px; border-radius: 6px; background: var(--p-accent); }

/* ============================================================================
   Market modal — the theme gallery
   ========================================================================== */
.market-intro { margin: 0 0 16px; color: var(--text-dim); font-size: 13.5px; line-height: 1.55; }
.market-grid { display: flex; flex-direction: column; gap: 10px; }
.market-card { display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 12px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg-elev); transition: 0.15s; width: 100%; }
.market-card:hover { border-color: var(--accent-border); background: var(--bg-elev-2); }
.market-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.market-card .theme-preview { width: 116px; height: 72px; flex-shrink: 0; }
.mc-meta { flex: 1; min-width: 0; }
.mc-title { display: flex; align-items: center; gap: 8px; }
.mc-name { font-weight: 600; font-size: 14.5px; }
.mc-tag { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 20px; padding: 1px 7px; }
.mc-desc { margin-top: 4px; font-size: 12.5px; color: var(--text-dim); line-height: 1.45; }
.mc-check { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-ink, #160a03); opacity: 0; transition: opacity 0.15s; }
.market-card.selected .mc-check { opacity: 1; }
