:root {
  color-scheme: dark;
  --ink: #f3f3f3;
  --muted: #bdbdbd;
  --line: #4a4a4a;
  --paper: #1f1f1f;
  --card: #2a2a2a;
  --bg: #333338;
  --sidebar: #252528;
  --surface: #3a3a3f;
  --surface-2: #2c2c31;
  --field: #1a1a1a;
  --grid: #3d3d42;
  --today: #303036;
  --track: #f2f2f2;
  --knob: #8d8d8d;
  --accent: #2f7cf6;
  --accent-ink: #f5f9ff;
  --danger: #e15b64;
}

:root[data-theme="light"] {
  color-scheme: light;
  --ink: #1f1f22;
  --muted: #5f6068;
  --line: #d4d4da;
  --paper: #f4f4f6;
  --card: #ffffff;
  --bg: #f4f4f6;
  --sidebar: #e9e9ee;
  --surface: #ffffff;
  --surface-2: #f0f0f4;
  --field: #ffffff;
  --grid: #e2e2e8;
  --today: #eef3fe;
  --track: #d4d4da;
  --knob: #ffffff;
  --danger: #d0414b;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 "Avenir Next", "Segoe UI", sans-serif;
}

.panel {
  width: min(100%, 420px);
  padding: 28px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 8px;
  font: 600 34px/1.15 "Avenir Next", "Segoe UI", sans-serif;
}

#detail, .hint, .status { color: var(--muted); }

.field { display: grid; gap: 8px; margin: 0 0 18px; }

.field > span {
  font-size: 13px;
  font-weight: 700;
}

.gate-label { margin: 18px 0 8px; font-size: 16px; font-weight: 700; }

#detail { margin: 0; }

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
}

input:disabled, textarea:disabled, select:disabled {
  opacity: 0.5;
  cursor: default;
}

textarea { resize: vertical; }

.goal-box { position: relative; }

.goal-box textarea { padding-bottom: 44px; }

.goal-count {
  position: absolute;
  left: 12px;
  bottom: 14px;
  color: var(--muted);
  font-size: 12px;
}

.goal-save {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 6px 12px;
  font-size: 13px;
}

.goal-status {
  position: absolute;
  right: 12px;
  bottom: 16px;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.goal-status.error { color: var(--danger); }

.goal-status.ok { color: #2f9e57; }

#monitor-all-row:not([hidden]) + #site-editor:not([hidden]) { margin-top: 22px; }

.row { display: flex; gap: 8px; }

.row input { flex: 1; }

button {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

button:disabled { opacity: 0.5; cursor: default; }

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.actions { display: flex; gap: 8px; margin-top: 8px; }

.choice-actions { margin-top: 16px; }

.actions:not(:has(button:not([hidden]))) { display: none; }

.chips { list-style: none; display: grid; gap: 8px; margin: 4px 0 12px; padding: 0; }

.chips li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 8px 8px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.chips .hint { border: 0; padding: 0; display: block; }

.chips li > span, .suggest-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chips button { padding: 6px 12px; border-radius: 8px; font-size: 13px; }

.site-list {
  list-style: none;
  margin: 8px 0 14px;
  padding: 4px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
}

.site-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 38px;
  padding: 4px 8px 4px 14px;
}

.site-list li:hover { background: var(--surface-2); }

.site-list li > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-list button {
  visibility: hidden;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
}

.site-list li:hover button, .site-list button:focus-visible { visibility: visible; }

.suggest-copy { display: grid; min-width: 0; }

.suggest-copy .hint { font-size: 11px; }

.hint, .status { margin: 0; font-size: 13px; }

.status { min-height: 1.2em; margin-top: 14px; }

.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex: none;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  display: block;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--track);
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--knob);
  transition: transform 0.15s ease;
}

body:not(.ready) .switch-track::after { transition: none; }

.switch input:checked + .switch-track { background: var(--accent); }

.switch input:checked + .switch-track::after {
  transform: translateX(20px);
  background: var(--accent-ink);
}

.switch input:disabled + .switch-track { opacity: 0.5; }

.switch.big { width: 64px; height: 36px; }

.switch.big .switch-track { width: 64px; height: 36px; }

.switch.big .switch-track::after { top: 4px; left: 4px; width: 28px; height: 28px; }

.switch.big input:checked + .switch-track::after { transform: translateX(28px); }

.google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #dadce0;
  font-weight: 650;
}

.google p { margin: 0; }

.stack { display: grid; gap: 8px; margin-top: 12px; }

/* Popup */

body.popup {
  width: 320px;
  min-width: 320px;
  max-height: 560px;
  min-height: 0;
  display: block;
  padding: 0;
  overflow: auto;
  background: var(--card);
}

.popup-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 0;
  border-bottom: 1px solid var(--grid);
  background: transparent;
  color: var(--ink);
}

.popup-head:hover { background: var(--surface-2); }

.popup-section { display: block; width: 100%; border-bottom: 1px solid var(--grid); cursor: pointer; }

.popup-section:hover { background: var(--surface-2); }

.popup-section:last-of-type { border-bottom: 0; }

.popup-label {
  display: block;
  width: 100%;
  margin: 0;
  padding: 12px 14px 4px;
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.popup-label:hover { background: transparent; }

.popup-list {
  width: 100%;
  margin: 0;
  padding: 0 0 8px;
  list-style: none;
}

.popup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 0;
  text-align: left;
}

.popup-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.popup-empty { padding: 4px 8px 8px; }

body.popup #status { padding: 0 14px 12px; }

/* App window */

body.app {
  display: grid;
  grid-template-columns: 190px 1fr;
  place-items: stretch;
  padding: 0;
  background: var(--bg);
}

body.app:not(.ready) { visibility: hidden; }

.sidebar {
  padding: 24px 14px;
  background: var(--sidebar);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 28px;
  font: 700 16px/1.2 "Avenir Next", "Segoe UI", sans-serif;
}

.panel .brand {
  justify-content: flex-start;
  margin: 0 0 8px;
  color: var(--accent);
}

.sidebar nav { display: grid; gap: 6px; }

.sidebar a {
  padding: 8px 14px;
  border-left: 4px solid transparent;
  border-radius: 6px;
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
}

.sidebar a.active {
  border-left-color: var(--accent);
  background: var(--surface);
}

.content {
  min-width: 0;
  padding: 28px 32px;
  overflow-y: auto;
}

.view-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.view-head h1 {
  flex: 1;
  margin: 0;
  font: 700 26px/1.2 "Avenir Next Condensed", "Arial Narrow", sans-serif;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.back { color: var(--muted); text-decoration: none; white-space: nowrap; }

.name-input {
  flex: 1;
  border-color: transparent;
  background: transparent;
  font-size: 22px;
  font-weight: 700;
}

.name-input:focus { border-color: var(--line); background: var(--field); }

.cards { list-style: none; display: grid; gap: 14px; margin: 0; padding: 0; }

.card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 16px 20px;
  border-left: 4px solid var(--sidebar);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.card.on { border-left-color: var(--accent); }

.card > strong { font-size: 20px; }

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-meta {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 650;
}

.card-status {
  width: max-content;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: 14px;
}

.card-status:hover { color: var(--accent); }

.card-delete {
  display: none;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
}

.card:hover .card-delete { display: grid; }

.card-delete:hover { color: var(--danger); }

#confirm-dialog { width: min(420px, 90vw); }

#confirm-dialog p { margin: 8px 0 0; font-size: 18px; text-align: center; }

#confirm-dialog .dialog-actions { justify-content: center; gap: 24px; }

.section-head {
  margin: 22px 0 10px;
  font-size: 15px;
}

#schedule-panel > .section-head:first-child,
#sites-panel > .section-head:first-child { margin-top: 0; }

#password-dialog { width: min(420px, 92vw); }

#password-dialog .field { margin-bottom: 12px; }

body.popup #password-dialog { width: 280px; }

.settings, #subscribe { max-width: 640px; }

#subscribe, #manage-billing { width: 100%; }

#subscribe { margin-bottom: 12px; }

.settings > section { padding: 20px 0; border-top: 1px solid var(--line); }

.settings > section:first-child { padding-top: 0; border-top: 0; }

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.tab {
  border-radius: 6px 6px 0 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  border-bottom-color: var(--accent);
  background: var(--surface);
  color: var(--ink);
}

.tab-panels .box { max-width: 760px; }

.row-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.row-controls input[type="text"] { width: 190px; padding: 6px 10px; }

#for-amount { width: 64px; }

.for-left {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#for-unit { width: auto; padding: 6px 8px; }

.preset-menu { position: relative; display: inline-block; margin-bottom: 12px; }

.preset-list {
  position: absolute;
  z-index: 2;
  display: grid;
  min-width: 160px;
  margin-top: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}

.preset-list button {
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.preset-list button:hover { background: var(--surface-2); }

.box {
  padding: 18px 20px;
  border-radius: 8px;
  background: var(--surface);
}

.box h2, .settings h2 {
  margin: 0 0 14px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.box h3 { margin: 8px 0 2px; font-size: 14px; }

.box .menu-row + .menu-row, .box #break-options + .menu-row { border-top: 1px solid var(--line); }

.box .menu-row .hint { margin-top: 2px; }

#break-options .field { margin-bottom: 10px; }

/* Schedule dialogs */

dialog {
  padding: 24px;
  border: 0;
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}

dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

dialog h2 {
  margin: 0 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  font: 700 22px/1.2 "Avenir Next Condensed", "Arial Narrow", sans-serif;
  text-align: center;
  text-transform: uppercase;
}

dialog.schedule[open] {
  position: fixed;
  inset: 16px 16px 16px 206px;
  display: flex;
  flex-direction: column;
  width: auto;
  max-width: none;
  max-height: calc(100vh - 32px);
  margin: 0;
  overflow: hidden;
}

dialog.schedule .week {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

dialog.schedule .week-body { height: auto; flex: 1; min-height: 0; }

.copy-row input { width: auto; margin: 0 6px 0 0; }

.week-head, .week-body {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
}

.week-head span {
  justify-self: center;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}

.week-head span.today { border-color: var(--muted); color: var(--ink); }

.week-body {
  height: 340px;
  margin-top: 8px;
  overflow-y: auto;
  background: var(--surface-2);
}

.hours span {
  display: block;
  height: 32px;
  padding-right: 6px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.day {
  position: relative;
  height: 768px;
  border-left: 1px solid var(--grid);
  background: repeating-linear-gradient(to bottom, transparent 0 31px, var(--grid) 31px 32px);
  cursor: pointer;
}

.day.today { background-color: var(--today); }

.period-bar {
  position: absolute;
  left: 2px;
  right: 2px;
  display: flex;
  align-items: flex-start;
  padding: 2px 6px;
  overflow: hidden;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 650;
  text-align: left;
}

.now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--danger);
  pointer-events: none;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.dialog-actions button { border-radius: 6px; }

#period-remove { margin-right: auto; color: var(--danger); }

dialog.period { width: min(640px, 90vw); }

.period-times {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.period-times label { display: grid; gap: 6px; font-weight: 650; }

.copy-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.copy-row > span { font-weight: 650; margin-right: 8px; }

.copy-row label { display: flex; align-items: center; }
