/* Themes */
:root {
  color-scheme: light;
  scrollbar-gutter: stable;
  --status-icon: #555;
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
}
html[data-theme="dark"] { color-scheme: dark; --status-icon: #bdbdbd; }

body {
  --background: #edf3f0;
  --surface: #fcfefa;
  --surface-raised: #e6f1eb;
  --field: #f1f7f3;
  --text: #18322b;
  --muted: #4b655a;
  --line: #cadbd1;
  --accent: #235b46;
  --primary: #235b46;
  --primary-ink: #fff;
  --focus: #297254;
  --business: #236d4d;
  --overtime: #885613;
  --personal: #963e42;
  --sleep: #536783;
  --business-fill: #e5f2e9;
  --overtime-fill: #f7eddd;
  --personal-fill: #f7e9e7;
  --sleep-fill: #e8eef5;
  --glow: #dcefe5;
  --ruler-ink: #436d5a;
  --shadow: #23433513;
}
html[data-theme="dark"] body {
  --background: #101917;
  --surface: #1a2622;
  --surface-raised: #223630;
  --field: #14201c;
  --text: #eff7f1;
  --muted: #aebfb4;
  --line: #354a41;
  --accent: #a3d4ba;
  --primary: #a3d4ba;
  --primary-ink: #142c21;
  --focus: #b9e2cc;
  --business: #97d9b5;
  --overtime: #efc58b;
  --personal: #f4aeac;
  --sleep: #b7c6df;
  --business-fill: #253e31;
  --overtime-fill: #413224;
  --personal-fill: #4a2c31;
  --sleep-fill: #2c3746;
  --glow: #1b332b;
  --ruler-ink: #8eb09e;
  --shadow: #0005;
}

html[data-palette="classic2"][data-theme="dark"] body {
  --background: #0a0a0b;
  --surface: #141416;
  --surface-raised: #1e1e22;
  --field: #101012;
  --text: #ededed;
  --muted: #a5a5af;
  --line: #2b2b31;
  --accent: #ff6861;
  --primary: #c91c15;
  --primary-ink: #fff;
  --focus: #ff827d;
  --business: #80d9b4;
  --overtime: #f5c28a;
  --personal: #9ebdf7;
  --sleep: #a6acc4;
  --business-fill: #235344;
  --overtime-fill: #60462e;
  --personal-fill: #293e66;
  --sleep-fill: #273047;
  --glow: var(--background);
  --ruler-ink: var(--muted);
  --shadow: #0005;
}

html[data-palette="classic2"][data-theme="light"] body {
  --background: #f5f5f6;
  --surface: #fff;
  --surface-raised: #f1eff0;
  --field: #fbfafb;
  --text: #212023;
  --muted: #5d5a64;
  --line: #dcd9df;
  --accent: #b61b14;
  --primary: #b81d16;
  --primary-ink: #fff;
  --focus: #b61b14;
  --business: #1b7251;
  --overtime: #875213;
  --personal: #3257a2;
  --sleep: #505c7a;
  --business-fill: #a7e0c9;
  --overtime-fill: #f0d19e;
  --personal-fill: #b9cdf3;
  --sleep-fill: #dbe3f1;
  --glow: var(--background);
  --ruler-ink: var(--muted);
  --shadow: #0002;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html.app-initializing main { visibility: hidden; }
body { margin: 0; color: var(--text); background: var(--background); min-height: 100vh; }

button, input, select { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; opacity: .42; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
h1, h2, p, ul { margin: 0; }
.shell { margin-inline: auto; }
.masthead-inner, .header-actions { display: flex; align-items: center; justify-content: flex-end; }
.masthead-inner { min-height: 66px; }
.header-actions { gap: 8px; flex-wrap: wrap; }
.theme-control { position: relative; display: inline-flex; align-items: center; }
.theme-control::after {
  content: "";
  pointer-events: none;
  position: absolute;
  width: 5px;
  height: 5px;
  right: 12px;
  top: 16px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
}
.theme-control select {
  appearance: none;
  min-height: 42px;
  padding: 0 26px 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: .875rem;
  font-weight: 650;
  cursor: pointer;
}
.button, .icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 13px;
  min-height: 42px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: .875rem;
  font-weight: 650;
  white-space: nowrap;
}
.button:hover, .icon-button:hover:not(:disabled) { background: var(--surface-raised); }
.button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); padding-inline: 15px; }
.button.primary:hover { filter: brightness(1.12); }
.link-icon, .plus-icon, .now-icon { position: relative; width: 16px; height: 16px; flex: none; }
.link-icon { transform: rotate(-40deg); }
.link-icon::before, .link-icon::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 5px;
  top: 5px;
  border: 1.5px solid currentColor;
  border-radius: 5px;
}
.link-icon::before { left: 0; border-right-color: transparent; }
.link-icon::after { right: 0; border-left-color: transparent; }
.plus-icon::before, .plus-icon::after { content: ""; position: absolute; inset: 7px 2px; background: currentColor; border-radius: 1px; }
.plus-icon::after { transform: rotate(90deg); }
.now-icon { border: 1.5px solid currentColor; border-radius: 50%; color: var(--accent); }
.now-icon::after { content: ""; position: absolute; width: 4px; height: 5px; left: 6px; top: 2px; border-left: 1px solid; border-bottom: 1px solid; }

.theme-control select:hover { background: var(--surface-raised); }

.view-switch { display: inline-flex; gap: 2px; padding: 4px; border: 1px solid var(--line); background: var(--field); border-radius: 10px; margin-top: 14px; }
.view-switch button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 11px;
  background: transparent;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 650;
}
.view-switch button:hover { color: var(--text); }
.view-switch button[aria-pressed="true"] { color: var(--text); background: var(--surface-raised); border-color: var(--line); }
.view-icon { position: relative; width: 14px; height: 14px; color: var(--accent); }
.timeline-icon { background: linear-gradient(currentColor, currentColor) 1px 2px / 9px 1px, linear-gradient(currentColor, currentColor) 4px 6px / 9px 1px, linear-gradient(currentColor, currentColor) 2px 10px / 8px 1px; background-repeat: no-repeat; }
.table-icon { border: 1px solid currentColor; border-radius: 2px; background: repeating-linear-gradient(transparent 0 3px, currentColor 3px 4px); }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.clock-icon { border: 1px solid currentColor; border-radius: 50%; }
.clock-icon::after { content: ""; position: absolute; inset: 3px 5px 5px; border-left: 1px solid currentColor; border-bottom: 1px solid currentColor; }

.field { display: grid; gap: 6px; color: var(--muted); font-size: .875rem; font-weight: 600; min-width: 0; }
.field input, .field select, .city-search, #share-url {
  min-width: 0;
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
  padding: 0 12px;
  font-size: 1rem;
}
.field select { appearance: none; padding-right: 34px; }
.reference-field { position: relative; }
.reference-field::after { content: ""; position: absolute; pointer-events: none; width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); right: 16px; bottom: 18px; transform: rotate(45deg); }
.now-button[aria-pressed="true"] { color: var(--accent); background: var(--surface-raised); }
.moment-error { grid-column: 1 / -1; color: var(--overtime); font-size: .875rem; }

body {
  --radius: 19px;
  background: radial-gradient(ellipse 40rem 24rem at 50% 230px, var(--glow), transparent 92%), var(--background);
}
.masthead-inner { width: min(1040px, calc(100% - 48px)); }
main.shell { width: min(640px, calc(100% - 32px)); padding: 20px 0 24px; }
.classic-intro { text-align: center; margin: 0 0 24px; }
.classic-intro h1 { font: 500 clamp(2.15rem, 5.5vw, 3.65rem)/1.03 Georgia, serif; letter-spacing: -.055em; }
.classic-intro p { margin-top: 9px; color: var(--muted); }
.comparison { overflow: hidden; box-shadow: 0 14px 46px var(--shadow); }
.time-ruler { padding: 13px 22px 10px; background: var(--surface-raised); border-bottom: 1px solid var(--line); }
.ruler-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ruler-heading label { font-size: .875rem; font-weight: 650; color: var(--muted); }
#relative-shift { margin-inline-start: 6px; color: var(--accent); font-size: .875rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.ruler-heading .now-button { min-height: 34px; background: var(--surface); }
.ruler-heading .now-button:hover { background: var(--field); }
.relative-range {
  appearance: none;
  display: block;
  width: 100%;
  height: 32px;
  margin: 3px 0 0;
  background: repeating-linear-gradient(90deg, var(--ruler-ink) 0 1px, transparent 1px 100%) 0 7px / 12.5% 20px no-repeat,
    repeating-linear-gradient(90deg, var(--ruler-ink) 0 1px, transparent 1px calc(100% / 48)) center 12px / 100% 10px no-repeat;
  background-repeat: repeat-x, no-repeat;
  border: 0;
  color: var(--accent);
  cursor: ew-resize;
}
.relative-range::-webkit-slider-thumb { appearance: none; width: 17px; height: 26px; border-radius: 5px; background: var(--primary); border: 2px solid var(--surface); }
.relative-range::-moz-range-thumb { width: 13px; height: 22px; border-radius: 5px; background: var(--primary); border: 2px solid var(--surface); }
.ruler-labels { display: flex; justify-content: space-between; font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.city-cards { display: block; }
.city-card {
  display: grid;
  grid-template: "identity time remove" auto "period date remove" auto / minmax(0, 1fr) auto 36px;
  align-items: center;
  gap: 2px 12px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 10px 15px 10px 22px;
  border-radius: 0;
}
.card-heading { display: contents; }
.card-identity { grid-area: identity; align-self: end; }
.card-heading .city-name { margin: 0; font-size: 1.125rem; letter-spacing: -.02em; }
.card-identity .city-zone { margin: 1px 0; }
.card-heading .icon-button { grid-area: remove; margin: 0; }
.city-card .city-time {
  grid-area: time;
  margin: 0;
  text-align: right;
  font-size: clamp(1.55rem, 4.5vw, 2.25rem);
  line-height: 1.05;
  font-weight: 550;
  letter-spacing: -.045em;
}
.city-card .city-date { grid-area: date; margin: 0; text-align: right; }
.city-card .time-period { grid-area: period; justify-self: start; padding: 2px 7px; font-size: .75rem; }
.comparison-add { display: grid; }
body:not([data-view="clock"]) .comparison-add { border-top: 1px solid var(--line); }
.comparison-add .primary {
  background: transparent;
  color: var(--accent);
  border: 0;
  border-radius: 0;
  min-height: 47px;
}
.comparison-add .primary:hover { background: var(--surface-raised); filter: none; }
.comparison-add .primary:focus-visible { outline-offset: -4px; }
.exact-moment { border-top: 1px solid var(--line); margin-top: 5px; padding-block: 9px; }
.exact-moment summary { cursor: pointer; font-size: .875rem; font-weight: 650; color: var(--accent); padding: 4px 0; }
.moment { display: grid; gap: 14px; align-items: end; grid-template-columns: 1.1fr 1fr .9fr; padding: 9px 0 0; margin: 0; }


body:not([data-view="clock"]) main.shell { width: min(1040px, calc(100% - 32px)); }
.comparison-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 22px; }
.comparison-heading h2 { font-size: 1.125rem; }
.comparison-heading .now-button { min-height: 34px; }
.timeline-label, .axis-track, .timeline-actions { grid-row: 1; }
.timeline-label, .timeline-city { grid-column: 1; }
.axis-track, .timeline-zone-track { grid-column: 2; }
.timeline-actions, .timeline-remove { grid-column: 3; }

.timeline-scroll { overflow-x: auto; }
.timeline-grid {
  display: grid;
  grid-template-columns: 224px minmax(480px, 1fr) 42px;
  padding: 0 18px;
  align-items: stretch;
}
.timeline-rows { display: contents; }
.timeline-label { align-content: end; padding: 0 8px 8px; color: var(--muted); font-size: .875rem; font-weight: 600; }
.axis-track { height: 48px; align-content: end; position: relative; }
.track-labels { display: flex; position: relative; height: 25px; color: var(--muted); font-size: .8125rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.track-labels span { position: absolute; left: var(--tick); transform: translateX(-50%); }
.track-labels span:first-child { transform: none; }
.track-labels span:last-child { transform: translateX(-100%); }
.cursor-time {
  position: absolute;
  top: 1px;
  left: var(--cursor);
  transform: translateX(var(--bubble-offset));
  z-index: 2;
  border-radius: 5px;
  padding: 3px 7px;
  color: var(--primary-ink);
  background: var(--primary);
  font-size: .8125rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}
.timeline-city, .timeline-zone-track, .timeline-remove { min-height: 59px; border-top: 1px solid var(--line); }
.timeline-city { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-content: center; align-items: baseline; gap: 4px 8px; padding: 7px 12px 7px 8px; }
.city-name { font-weight: 700; overflow-wrap: anywhere; }
.city-time { font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.city-zone, .city-date { font-size: .8125rem; color: var(--muted); }
.timeline-city .city-date { text-align: right; }
.timeline-zone-track { display: grid; align-items: center; }
.band { height: 29px; position: relative; border-radius: 5px; overflow: hidden; background: var(--sleep-fill); }
.band span { position: absolute; inset: 0 auto 0 var(--start); width: var(--span); background: color-mix(in srgb, var(--period) 26%, var(--period-fill)); }
.band span + span { border-left: 1px solid var(--surface); }
.timeline-remove { display: grid; align-items: center; justify-content: end; }
.icon-button { position: relative; min-height: 36px; width: 36px; padding: 0; color: var(--muted); background: transparent; border-color: transparent; }
.remove-button::before, .remove-button::after { content: ""; position: absolute; width: 12px; height: 1.5px; border-radius: 2px; background: currentColor; transform: rotate(45deg); }
.remove-button::after { transform: rotate(-45deg); }
.scrubber-layer { grid-column: 2; grid-row: 1 / span var(--rows, 5); z-index: 1; position: relative; margin-top: 24px; cursor: ew-resize; }
.playhead { position: absolute; pointer-events: none; left: var(--cursor); top: -6px; bottom: 0; width: 2px; background: var(--primary); transform: translateX(-50%); }
.scrubber { width: 100%; accent-color: var(--accent); cursor: ew-resize; }
.timeline-range { position: absolute; inset: 0; height: 100%; opacity: 0; margin: 0; pointer-events: none; }
.scrubber-layer:focus-within { outline: 2px solid var(--focus); outline-offset: 3px; }

.business { --period: var(--business); --period-fill: var(--business-fill); }
.overtime { --period: var(--overtime); --period-fill: var(--overtime-fill); }
.personal { --period: var(--personal); --period-fill: var(--personal-fill); }
.sleep { --period: var(--sleep); --period-fill: var(--sleep-fill); }

.legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 14px; padding: 14px 0 10px; color: var(--muted); list-style: none; font-size: .8125rem; }
.legend li { display: flex; align-items: center; gap: 4px; }
.legend li::before { content: ""; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; background: var(--period); }

.summary-view { padding: 0 22px 20px; }
.summary-scrubber { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 14px 4px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--field); font-size: .875rem; color: var(--muted); }
.summary-scrubber label { font-weight: 650; }
#summary-time { color: var(--accent); font-weight: 750; }
.summary-scrubber input, .summary-scrubber .track-labels { grid-column: 1 / -1; margin: 0; }
.summary-scrubber input { min-height: 25px; }

.time-period { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; background: var(--period-fill); color: var(--period); border-radius: 5px; font-size: .8125rem; font-weight: 650; white-space: nowrap; }
.time-period::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: none;
  background: var(--status-icon);
  clip-path: var(--period-icon);
}
.time-period.business { --period-icon: path(evenodd, "M4 3V2Q4 1 5 1H9Q10 1 10 2V3H12Q13 3 13 4V11Q13 12 12 12H2Q1 12 1 11V4Q1 3 2 3ZM5.2 3V2.2H8.8V3ZM2.2 7H11.8V10.8H2.2Z"); }
.time-period.overtime { --period-icon: path(evenodd, "M7 .6a6.4 6.4 0 1 0 0 12.8A6.4 6.4 0 0 0 7 .6Zm0 1.3a5.1 5.1 0 1 1 0 10.2A5.1 5.1 0 0 1 7 1.9ZM6.4 3.2h1.2v3.2h2.6v1.2H6.4Z"); }
.time-period.personal { --period-icon: path(evenodd, "M1 3h9v1h1a2.3 2.3 0 0 1 0 4.6H9.6A4.5 4.5 0 0 1 1 6.7Zm9 2.2v1.5q0 .4-.1 .7H11a1.1 1.1 0 0 0 0-2.2ZM1 12h10v1.2H1Z"); }
.time-period.sleep { --period-icon: path("M13 9.1A6 6 0 0 1 4.9 1 6.3 6.3 0 1 0 13 9.1Z"); }
.city-table { position: relative; overflow-x: auto; }
.city-table table { border-collapse: collapse; width: 100%; font-size: .875rem; text-align: left; white-space: nowrap; }
.city-table thead th { color: var(--muted); background: var(--surface-raised); font-weight: 650; }
.city-table tbody th { font-weight: 400; }
.city-table th, .city-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.city-table th:first-child { border-top-left-radius: 6px; }
.city-table th:last-child { border-top-right-radius: 6px; }
.city-table td:last-child { text-align: right; }
.city-table .city-zone { margin-top: 2px; }
.city-table .city-time { font-size: 1.05rem; }

.share-feedback { display: grid; gap: 6px; margin-top: 14px; color: var(--muted); font-size: .875rem; }
.status { margin: 12px 0; color: var(--muted); font-size: .875rem; }
dialog { max-width: min(460px, calc(100% - 32px)); width: 100%; padding: 18px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 18px 70px #0005; }
dialog::backdrop { background: #060c18b5; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.dialog-header h2 { font-size: 1.25rem; }
.city-results { list-style: none; padding: 3px; margin: 8px -3px 0; max-height: min(50vh, 350px); overflow-y: auto; }
.city-results button { width: 100%; padding: 9px 10px; display: grid; gap: 3px; text-align: left; background: transparent; border: 0; border-radius: 6px; }
.city-results button:hover { background: var(--surface-raised); }
.search-empty { padding: 15px 0 0; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }


@media (max-width: 820px) {
  .timeline-grid { grid-template-columns: 190px minmax(0, 1fr) 42px; }
  .track-labels [data-minor] { display: none; }
}
@media (max-width: 560px) {
  .masthead-inner { width: calc(100% - 24px); min-height: 61px; }
  .share-button .share-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .share-button { padding-inline: 11px; }
  main.shell { padding-top: 17px; }
  .classic-intro { margin-bottom: 19px; }
  .time-ruler, .comparison-heading { padding-inline: 12px; }
  .city-card { padding-inline: 12px 5px; gap: 1px 6px; }
  .moment { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .reference-field { grid-column: 1 / -1; }
  .timeline-grid { padding-inline: 10px; grid-template-columns: minmax(99px, .8fr) minmax(110px, 1fr) 32px; }
  .timeline-label, .timeline-city { padding-left: 3px; }
  .timeline-city { display: flex; flex-direction: column; align-items: start; gap: 2px; justify-content: center; }
  .timeline-city .city-zone { display: none; }
  .timeline-city .city-date { text-align: left; }
  .timeline-remove .icon-button { width: 32px; }
  .track-labels { font-size: .75rem; }
  .summary-view { padding: 0 12px 12px; }
}
@media (max-width: 359px) {
  .track-labels span:nth-child(3), .track-labels span:nth-child(7) { display: none; }
}
