/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
@supports (height: 100dvh) {
  #app, #auth-screen { height: 100dvh; }
}
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: #1a202c;
  background: #f7fafc;
}
button { font: inherit; }

#app { display: flex; height: 100vh; }

.btn {
  background: #fff;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  color: #2d3748;
}
.btn:hover { background: #edf2f7; }
.btn.active { background: #2b6cb0; border-color: #2b6cb0; color: #fff; }

/* ---------- sidebar ---------- */
#sidebar {
  width: 240px;
  flex: 0 0 240px;
  padding: 16px 14px;
  border-right: 1px solid #e2e8f0;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
#sidebar h1 { font-size: 17px; margin: 0 0 4px; }

.calendar-list { display: flex; flex-direction: column; gap: 8px; }
.cal-item { display: flex; align-items: flex-start; gap: 2px; }
.cal-main { flex: 1; display: flex; align-items: flex-start; gap: 8px; cursor: pointer; min-width: 0; }
.cal-item input[type="checkbox"] { margin-top: 3px; cursor: pointer; }
.cal-edit {
  border: none; background: none;
  color: #a0aec0; cursor: pointer;
  font-size: 13px; padding: 2px 5px; border-radius: 4px;
}
.cal-edit:hover { color: #2b6cb0; background: #edf2f7; }
.cal-swatch {
  width: 12px; height: 12px; border-radius: 3px;
  flex: 0 0 12px; margin-top: 4px;
}
.cal-info { min-width: 0; }
.cal-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-sync { font-size: 11px; color: #718096; }
.cal-sync.error { color: #c53030; font-weight: 600; }

.sidebar-note { font-size: 11px; color: #a0aec0; margin: 0; }
.cal-empty { font-size: 12px; color: #718096; margin: 0; }
.btn-subtle {
  background: none; border: none;
  color: #718096; font-size: 12px;
  cursor: pointer; text-align: left; padding: 2px 0;
  text-decoration: underline dotted;
}
.btn-subtle:hover { color: #2b6cb0; }

#user-row {
  margin-top: auto;
  display: flex; align-items: center; gap: 8px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
}
#user-name {
  flex: 1; min-width: 0;
  font-weight: 600; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#user-row .btn { font-size: 12px; padding: 3px 9px; }

/* ---------- landing / auth screen ---------- */
#auth-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #ebf4ff, #f7fafc 55%, #fefcbf22);
  padding: 20px;
  overflow-y: auto;
}
.landing {
  display: flex; align-items: center; gap: 48px;
  max-width: 900px; flex-wrap: wrap; justify-content: center;
}
.landing-hero { flex: 1 1 400px; max-width: 470px; }
.landing-hero h1 { font-size: 26px; margin: 0 0 6px; }
.hero-tag { font-size: 17px; color: #4a5568; margin: 0 0 18px; line-height: 1.4; }
.hero-points { list-style: none; padding: 0; margin: 0 0 20px; }
.hero-points li { margin: 9px 0; font-size: 14px; color: #2d3748; line-height: 1.45; }
.hero-demo {
  display: inline-block; text-decoration: none;
  font-size: 15px; padding: 9px 18px;
  border: 2px solid #2b6cb0; color: #2b6cb0; font-weight: 600;
}
.hero-demo:hover { background: #ebf8ff; }
.hero-note { font-size: 12px; color: #a0aec0; margin: 10px 0 0; }
.auth-title { font-size: 17px; margin: 0 0 4px; }
.auth-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  padding: 28px 30px 22px;
  width: 100%; max-width: 360px;
}
.auth-card h1 { font-size: 19px; margin: 0 0 4px; }
.auth-sub { color: #718096; font-size: 13px; margin: 0 0 16px; }
.auth-card .ce-field { margin-bottom: 12px; }
.auth-submit { width: 100%; padding: 8px 0; margin-top: 2px; }
.auth-toggle { font-size: 13px; color: #718096; text-align: center; margin: 14px 0 0; }
.auth-toggle a { color: #2b6cb0; }
.auth-error {
  background: #fed7d7; color: #822727;
  border-radius: 6px; padding: 7px 10px;
  font-size: 12px; margin-bottom: 12px;
}
.auth-divider {
  display: flex; align-items: center; gap: 10px;
  color: #a0aec0; font-size: 11px; margin: 14px 0 12px;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; border-top: 1px solid #e2e8f0;
}
.auth-demo { display: block; text-align: center; text-decoration: none; padding: 7px 0; }
.auth-demo-note { font-size: 11px; color: #a0aec0; text-align: center; margin: 6px 0 0; }

#demo-banner {
  background: #ebf8ff;
  border-bottom: 1px solid #bee3f8;
  color: #2a4365;
  font-size: 13px;
  padding: 7px 14px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
#demo-banner a { color: #2b6cb0; font-weight: 600; }
#demo-banner .demo-cta {
  margin-left: auto;
  background: #2b6cb0; color: #fff !important;
  border-radius: 6px; padding: 4px 12px; text-decoration: none;
  white-space: nowrap;
}
#demo-banner .demo-cta:hover { background: #2c5282; }

/* ---------- onboarding checklist ---------- */
#onboarding {
  background: #fffff0;
  border-bottom: 1px solid #ecc94b66;
  padding: 10px 16px 12px;
  font-size: 13px;
}
.ob-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ob-progress { color: #975a16; font-size: 12px; font-weight: 700; }
.ob-close {
  margin-left: auto; border: none; background: none;
  font-size: 18px; color: #a0aec0; cursor: pointer; line-height: 1;
}
.ob-close:hover { color: #1a202c; }
.ob-steps { display: flex; gap: 18px; flex-wrap: wrap; }
.ob-step { flex: 1 1 240px; display: flex; gap: 8px; }
.ob-step.done { opacity: 0.55; }
.ob-check { font-weight: 700; flex: 0 0 auto; }
.ob-hint { color: #718096; font-size: 12px; line-height: 1.45; }

/* ---------- toolbar ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
}
.nav-group { display: flex; gap: 4px; }
#range-label { font-weight: 600; font-size: 15px; flex: 1; }
.view-toggle { display: flex; gap: 0; }
.view-toggle .btn { border-radius: 0; }
.view-toggle .btn:first-child { border-radius: 6px 0 0 6px; }
.view-toggle .btn:last-child { border-radius: 0 6px 6px 0; border-left: none; }

/* ---------- grid ---------- */
:root { --hour-h: 72px; --axis-w: 56px; }

#grid-header {
  display: flex;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
  padding-right: 8px; /* approx scrollbar width so columns line up */
}
#grid-header .axis-spacer { flex: 0 0 var(--axis-w); }
.day-head {
  flex: 1; text-align: center; padding: 6px 0 4px;
  border-left: 1px solid #edf2f7;
  font-size: 12px; color: #4a5568;
}
.day-head .day-num { font-size: 18px; font-weight: 600; color: #1a202c; display: block; }
.day-head.today .day-num {
  background: #2b6cb0; color: #fff; border-radius: 50%;
  width: 28px; height: 28px; line-height: 28px; margin: 0 auto;
}

#allday-row {
  display: flex;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
  min-height: 0;
  padding-right: 8px;
}
#allday-row.has-events { min-height: 26px; }
#allday-row .axis-spacer {
  flex: 0 0 var(--axis-w);
  font-size: 10px; color: #a0aec0; text-align: right; padding: 4px 6px 0 0;
}
.allday-cell { flex: 1; border-left: 1px solid #edf2f7; padding: 2px; min-width: 0; }
.allday-chip {
  font-size: 11px; border-radius: 4px; padding: 1px 6px; margin: 1px 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

#grid-scroll { flex: 1; overflow-y: auto; position: relative; }
#grid { display: flex; position: relative; min-height: calc(var(--hour-h) * 24); }

.hour-axis { flex: 0 0 var(--axis-w); position: relative; }
.hour-label {
  position: absolute; right: 6px; transform: translateY(-50%);
  font-size: 11px; color: #a0aec0;
}

.day-col {
  flex: 1; position: relative;
  border-left: 1px solid #edf2f7;
  background:
    repeating-linear-gradient(to bottom,
      transparent 0, transparent calc(var(--hour-h) - 1px),
      #edf2f7 calc(var(--hour-h) - 1px), #edf2f7 var(--hour-h));
}
.day-col.today-col { background-color: #fbfdff; }

.event-chip {
  position: absolute;
  border-radius: 4px;
  border-left: 3px solid;
  padding: 4px 7px;
  font-size: 12px;
  overflow: hidden;
  cursor: pointer;
  line-height: 1.35;
}
.event-chip:hover, .allday-chip:hover { filter: brightness(0.96); }
.allday-chip { cursor: pointer; }
.event-chip .chip-title { font-weight: 600; }
.event-chip .chip-time { font-size: 10px; opacity: 0.75; }

.now-line {
  position: absolute; left: 0; right: 0; height: 2px;
  background: #e53e3e; z-index: 5; pointer-events: none;
}
.now-line::before {
  content: ""; position: absolute; left: -4px; top: -3px;
  width: 8px; height: 8px; border-radius: 50%; background: #e53e3e;
}

/* ---------- event details popup ---------- */
.ep-overlay {
  position: fixed; inset: 0;
  background: rgba(26, 32, 44, 0.4);
  z-index: 400; /* above the mobile sidebar drawer */
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.ep-footer {
  margin-top: 14px;
  display: flex; justify-content: flex-end;
}
.ep-panel {
  position: relative;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  width: 100%; max-width: 440px;
  max-height: 80vh; overflow-y: auto;
  padding: 18px 20px 20px;
}
.ep-close {
  position: absolute; top: 8px; right: 10px;
  border: none; background: none;
  font-size: 22px; line-height: 1;
  color: #a0aec0; cursor: pointer; padding: 4px;
}
.ep-close:hover { color: #1a202c; }
.ep-title {
  font-size: 17px; font-weight: 700;
  border-left: 4px solid;
  padding: 2px 0 2px 10px;
  margin: 0 24px 12px 0;
  overflow-wrap: break-word;
}
.ep-rows { display: flex; flex-direction: column; gap: 9px; }
.ep-row { display: flex; gap: 10px; }
.ep-label { flex: 0 0 88px; color: #718096; font-size: 12px; padding-top: 1px; }
.ep-value { flex: 1; min-width: 0; overflow-wrap: break-word; }
.ep-value a { color: #2b6cb0; }
.ep-swatch {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 3px; margin-right: 6px;
}
.ep-description {
  white-space: pre-wrap;
  font-size: 13px;
  max-height: 32vh; overflow-y: auto;
}

/* ---------- calendar editor ---------- */
.ce-panel { max-width: 400px; }
.ce-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.ce-field { display: block; margin-bottom: 11px; }
.ce-label { display: block; font-size: 12px; color: #718096; margin-bottom: 3px; }
.ce-input {
  width: 100%;
  border: 1px solid #cbd5e0; border-radius: 6px;
  padding: 6px 9px; font: inherit;
}
.ce-input:focus { outline: 2px solid #90cdf4; outline-offset: -1px; }
.ce-color-row { display: flex; align-items: center; gap: 8px; }
.ce-color {
  width: 38px; height: 31px; padding: 2px;
  border: 1px solid #cbd5e0; border-radius: 6px;
  background: #fff; cursor: pointer; flex: 0 0 38px;
}
.ce-hex { width: 92px; flex: 0 0 92px; }
.ce-sound { font-size: 12px; color: #718096; }
.ce-error {
  background: #fed7d7; color: #822727;
  border-radius: 6px; padding: 7px 10px;
  font-size: 12px; margin-bottom: 10px;
}
.ce-error.warning { background: #fefcbf; color: #744210; }
.ce-actions { display: flex; gap: 8px; align-items: center; }
.ce-actions-spacer { flex: 1; }
.ce-save { background: #2b6cb0; border-color: #2b6cb0; color: #fff; }
.ce-save:hover { background: #2c5282; }
.ce-delete { color: #c53030; border-color: #fc8181; }
.ce-delete:hover { background: #fff5f5; }

/* ---------- search ---------- */
#search-wrap { position: relative; }
#search-input {
  border: 1px solid #cbd5e0; border-radius: 6px;
  padding: 5px 10px; font: inherit; width: 200px;
  background: #fff; color: inherit;
}
#search-results {
  position: absolute; top: calc(100% + 4px); right: 0;
  width: 320px; max-height: 50vh; overflow-y: auto;
  background: #fff; border: 1px solid #cbd5e0; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 150; padding: 4px;
}
.sr-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  border: none; background: none; cursor: pointer;
  padding: 6px 8px; border-radius: 6px; font: inherit; color: inherit;
}
.sr-item:hover { background: #edf2f7; }
.sr-swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.sr-main { min-width: 0; }
.sr-title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-time { font-size: 11px; color: #718096; }
.sr-empty { padding: 10px; color: #718096; font-size: 13px; text-align: center; }

/* ---------- context menu ---------- */
.ctx-menu {
  position: fixed; z-index: 300;
  background: #fff; border: 1px solid #cbd5e0; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 4px; min-width: 200px;
}
.ctx-item {
  display: block; width: 100%; text-align: left;
  border: none; background: none; cursor: pointer;
  padding: 7px 10px; border-radius: 6px; font: inherit; color: inherit;
}
.ctx-item:hover { background: #edf2f7; }
.ctx-danger:hover { background: #fff5f5; color: #c53030; }

/* ---------- settings / hidden events / recovery ---------- */
.st-hint { font-size: 11px; color: #718096; margin: 4px 0 12px; }
.rc-note { font-size: 13px; color: #4a5568; }
.rc-code {
  font-family: Consolas, Menlo, monospace;
  font-size: 20px; font-weight: 700; letter-spacing: 1px;
  text-align: center;
  background: #f7fafc; border: 1px dashed #cbd5e0; border-radius: 8px;
  padding: 14px; margin: 12px 0 16px;
  user-select: all;
}
.he-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.he-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border: 1px solid #e2e8f0; border-radius: 6px;
}
.he-main { flex: 1; min-width: 0; }
.he-title { display: block; font-weight: 600; text-decoration: line-through; color: #718096; }
.he-sub { font-size: 11px; color: #a0aec0; }
.he-show { font-size: 12px; padding: 3px 10px; }

/* ---------- ICS help box ---------- */
.ce-help-btn {
  border: 1px solid #cbd5e0; background: #fff; color: #718096;
  border-radius: 50%; width: 17px; height: 17px; line-height: 1;
  font-size: 11px; cursor: pointer; margin-left: 5px; padding: 0;
}
.ce-help-btn:hover { color: #2b6cb0; border-color: #2b6cb0; }
.ce-help-box {
  font-size: 12px; color: #4a5568;
  background: #f7fafc; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 11px;
}
.ce-help-box ol { margin: 6px 0; padding-left: 18px; }
.ce-help-box li { margin: 3px 0; }
.ce-help-others { color: #718096; }

/* ---------- alarm widget ---------- */
#alarm-widget {
  position: fixed;
  top: 16px; right: 16px;
  width: 320px;
  background: #fff;
  border: 1px solid #cbd5e0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  z-index: 100;
  font-size: 13px;
  user-select: none;
}
.aw-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: #2d3748; color: #fff;
  border-radius: 9px 9px 0 0;
  cursor: move;
}
.aw-header .aw-title { font-weight: 700; flex: 1; }
.aw-status { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #cbd5e0; }
.aw-dot { width: 8px; height: 8px; border-radius: 50%; background: #718096; }
.aw-dot.on { background: #48bb78; }
.aw-dot.blocked { background: #e53e3e; }

.aw-body { padding: 10px 12px 12px; }
.aw-controls { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.aw-controls .btn { font-size: 12px; padding: 4px 9px; }

.aw-list { display: flex; flex-direction: column; gap: 6px; }
.aw-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border: 1px solid #e2e8f0; border-radius: 6px;
  background: #f9fafb;
}
.aw-row.started { border-color: #48bb78; background: #f0fff4; }
.aw-row-swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.aw-row-main { flex: 1; min-width: 0; }
.aw-row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aw-row-sub { font-size: 11px; color: #718096; }
.aw-row-count { font-size: 11px; font-weight: 700; color: #2b6cb0; white-space: nowrap; }
.aw-row-count.started-label { color: #2f855a; }
.aw-row-x {
  border: none; background: none; color: #a0aec0;
  font-size: 15px; cursor: pointer; padding: 0 3px; line-height: 1;
}
.aw-row-x:hover { color: #e53e3e; }

.aw-empty { color: #718096; text-align: center; padding: 8px 0; }

.aw-dismissed { margin-top: 10px; }
.aw-dismissed-toggle {
  width: 100%; text-align: left;
  border: none; background: none; cursor: pointer;
  color: #718096; font-size: 12px; padding: 4px 0;
}
.aw-dismissed-list { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.aw-dismissed-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; border-radius: 6px; background: #f7fafc;
  color: #a0aec0;
}
.aw-dismissed-row .aw-row-main { text-decoration: line-through; }
.aw-undo-btn { font-size: 11px; padding: 2px 8px; }

/* ==================== dark mode ==================== */
html.dark body { background: #171923; color: #e2e8f0; }

html.dark .btn { background: #2d3748; border-color: #4a5568; color: #e2e8f0; }
html.dark .btn:hover { background: #4a5568; }
html.dark .btn.active { background: #3182ce; border-color: #3182ce; color: #fff; }

html.dark #sidebar { background: #1a202c; border-color: #2d3748; }
html.dark #toolbar { background: #1a202c; border-color: #2d3748; }
html.dark #grid-header { background: #1a202c; border-color: #2d3748; }
html.dark #allday-row { background: #1a202c; border-color: #2d3748; }
html.dark .day-head { border-color: #2d3748; color: #a0aec0; }
html.dark .day-head .day-num { color: #e2e8f0; }
html.dark .day-head.today .day-num { background: #3182ce; color: #fff; }
html.dark .allday-cell { border-color: #2d3748; }

html.dark .day-col {
  border-color: #2d3748;
  background:
    repeating-linear-gradient(to bottom,
      transparent 0, transparent calc(var(--hour-h) - 1px),
      #2d3748 calc(var(--hour-h) - 1px), #2d3748 var(--hour-h));
}
html.dark .day-col.today-col { background-color: #1c2434; }
html.dark .hour-label { color: #4a5568; }
html.dark .event-chip { color: #f7fafc; }
html.dark .allday-chip { color: #f7fafc; }

html.dark .cal-sync { color: #718096; }
html.dark .cal-sync.error { color: #fc8181; }
html.dark .cal-edit:hover { color: #63b3ed; background: #2d3748; }
html.dark #user-row { border-color: #2d3748; }
html.dark .view-toggle .btn { border-color: #4a5568; }

html.dark #search-input { background: #2d3748; border-color: #4a5568; color: #e2e8f0; }
html.dark #search-results { background: #1a202c; border-color: #4a5568; }
html.dark .sr-item:hover { background: #2d3748; }
html.dark .sr-time, html.dark .sr-empty { color: #a0aec0; }

html.dark .ep-panel { background: #1a202c; color: #e2e8f0; }
html.dark .ep-close:hover { color: #f7fafc; }
html.dark .ep-label { color: #a0aec0; }
html.dark .ep-value a { color: #63b3ed; }

html.dark .auth-card { background: #1a202c; border-color: #2d3748; color: #e2e8f0; }
html.dark #auth-screen { background: linear-gradient(135deg, #171923, #1a202c); }
html.dark .auth-sub, html.dark .auth-toggle { color: #a0aec0; }
html.dark .auth-toggle a, html.dark .auth-demo-note a { color: #63b3ed; }

html.dark .ce-input { background: #2d3748; border-color: #4a5568; color: #e2e8f0; }
html.dark .ce-label, html.dark .st-hint, html.dark .rc-note { color: #a0aec0; }
html.dark .ce-title { color: #e2e8f0; }
html.dark .ce-color { background: #2d3748; border-color: #4a5568; }
html.dark .ce-sound { color: #a0aec0; }
html.dark .ce-help-btn { background: #2d3748; border-color: #4a5568; color: #a0aec0; }
html.dark .ce-help-box { background: #2d3748; border-color: #4a5568; color: #cbd5e0; }
html.dark .ce-help-others { color: #a0aec0; }
html.dark .rc-code { background: #2d3748; border-color: #4a5568; }
html.dark .he-row { border-color: #2d3748; }

html.dark .ctx-menu { background: #1a202c; border-color: #4a5568; }
html.dark .ctx-item:hover { background: #2d3748; }
html.dark .ctx-danger:hover { background: #4a2020; color: #fc8181; }

html.dark .aw-header { background: #0d1117; }
html.dark #alarm-widget { background: #1a202c; border-color: #4a5568; color: #e2e8f0; }
html.dark .aw-row { background: #2d3748; border-color: #4a5568; }
html.dark .aw-row.started { background: #1c3a2a; border-color: #2f855a; }
html.dark .aw-row-sub { color: #a0aec0; }
html.dark .aw-row-count { color: #63b3ed; }
html.dark .aw-dismissed-row { background: #2d3748; color: #718096; }
html.dark .aw-empty { color: #a0aec0; }

html.dark #demo-banner { background: #1c2f45; border-color: #2c5282; color: #bee3f8; }
html.dark #demo-banner a { color: #63b3ed; }
html.dark #demo-banner .demo-cta { background: #3182ce; color: #fff !important; }
html.dark .hero-tag { color: #a0aec0; }
html.dark .hero-points li { color: #cbd5e0; }
html.dark .hero-demo { border-color: #63b3ed; color: #63b3ed; }
html.dark .hero-demo:hover { background: #1c2f45; }
html.dark #onboarding { background: #2a2a1a; border-color: #975a1666; }
html.dark .ob-progress { color: #ecc94b; }
html.dark .ob-hint { color: #a0aec0; }
html.dark .cal-empty, html.dark .sidebar-note { color: #718096; }
html.dark .btn-subtle { color: #a0aec0; }
html.dark .btn-subtle:hover { color: #63b3ed; }
html.dark .auth-divider { color: #4a5568; }
html.dark .auth-divider::before, html.dark .auth-divider::after { border-color: #2d3748; }
html.dark .ce-error { background: #4a2020; color: #feb2b2; }
html.dark .ce-error.warning { background: #4a3f18; color: #faf089; }
html.dark .auth-error { background: #4a2020; color: #feb2b2; }

/* ==================== mobile ==================== */
#menu-btn { display: none; }
#sidebar-backdrop { display: none; }

@media (max-width: 760px) {
  #menu-btn { display: inline-block; }

  /* Sidebar becomes a slide-in drawer */
  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 280px; max-width: 85vw;
    z-index: 260;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
  }
  #app.sidebar-open #sidebar { transform: none; }
  #app.sidebar-open #sidebar-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 255;
  }

  #toolbar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  #range-label { font-size: 13px; flex: 1 1 auto; min-width: 110px; }
  #search-wrap { order: 5; }
  #search-input { width: 130px; }
  #search-input:focus { width: 170px; }
  #search-results { width: min(320px, calc(100vw - 20px)); }

  /* Tighter grid */
  :root { --hour-h: 56px; --axis-w: 42px; }
  .hour-label { font-size: 10px; right: 3px; }
  .event-chip { font-size: 11px; padding: 2px 4px; border-left-width: 2px; }
  .event-chip .chip-time { font-size: 9px; }
  .day-head { font-size: 10px; padding: 4px 0 3px; }
  .day-head .day-num { font-size: 14px; }
  .day-head.today .day-num { width: 22px; height: 22px; line-height: 22px; }
  .allday-chip { font-size: 10px; }

  /* Alarm widget can't overflow small screens */
  #alarm-widget { width: min(320px, calc(100vw - 16px)); }

  /* Dialogs: stack label/value, use the width we have */
  .ep-panel { padding: 14px 16px 16px; }
  .ep-row { flex-direction: column; gap: 2px; }
  .ep-label { flex: none; }
  .ep-overlay { padding: 12px; }

  /* Landing */
  .landing { gap: 20px; }
  .landing-hero h1 { font-size: 22px; }
  .hero-tag { font-size: 15px; }
  #auth-screen { align-items: flex-start; padding: 16px; }

  /* Onboarding + banner stack nicely */
  .ob-steps { flex-direction: column; gap: 10px; }
  #demo-banner .demo-cta { margin-left: 0; }

  /* Comfier tap targets */
  .btn { padding: 6px 12px; }
  .cal-edit { font-size: 15px; padding: 4px 7px; }
  .aw-row-x { font-size: 18px; padding: 2px 6px; }
}
