:root {
  color-scheme: light;
  --paper: #eef3f7;
  --panel: #f8fbfd;
  --ink: #102b3f;
  --muted: #637989;
  --line: #cad6de;
  --signal: #f05a36;
  --night: #173952;
  --day: #b8dce8;
  --work: #64a4ad;
  --shadow: 0 12px 30px rgba(15, 43, 63, 0.09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(rgba(16, 43, 63, 0.035) 1px, transparent 1px) 0 0 / 100% 24px,
    var(--paper);
  color: var(--ink);
  font-family: "Segoe UI Variable", "Aptos", "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }
select { font: inherit; color: inherit; }

.shell { padding: 22px 18px 48px; }
.masthead, .section-heading, .dialog-heading, .now-row, .clock-card { display: flex; align-items: center; justify-content: space-between; }
.masthead { align-items: flex-start; margin-bottom: 20px; }

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
}

h1, h2 { margin: 0; font-weight: 620; letter-spacing: -.04em; }
h1 { font-family: "Georgia", serif; font-size: 29px; line-height: .98; font-weight: 500; }
h2 { font-size: 18px; }

.icon-button, .round-button, .text-button, .scan-button, .remove-clock {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; font-weight: 700; }
.round-button { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: white; font-size: 23px; line-height: 1; }
.text-button { color: var(--signal); font-size: 12px; font-weight: 700; }
.scan-button { border-bottom: 1px solid var(--ink); padding: 4px 0; font-size: 12px; font-weight: 700; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(240, 90, 54, .28); outline-offset: 2px; }

.now-card {
  padding: 16px;
  border: 1px solid rgba(16, 43, 63, .1);
  border-radius: 17px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.now-label { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 11px; font-weight: 600; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 4px rgba(240, 90, 54, .12); }
.now-row { margin-top: 9px; align-items: flex-end; }
.now-row time { font-family: "Cascadia Mono", "Consolas", monospace; font-size: clamp(38px, 13vw, 55px); line-height: .92; letter-spacing: -.08em; font-variant-numeric: tabular-nums; }
.now-row div { display: grid; text-align: right; font-size: 11px; line-height: 1.35; }
.now-row span { color: var(--muted); }

.time-ribbon, .zones, .page-times { margin-top: 27px; }
.section-heading { margin-bottom: 12px; align-items: flex-end; }

input[type="range"] {
  width: 100%; height: 36px; margin: 0; appearance: none; background: transparent; cursor: ew-resize;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 12px; border-radius: 9px;
  background: repeating-linear-gradient(90deg, var(--night) 0 4.17%, var(--day) 4.17% 10.42%, var(--night) 10.42% 12.5%);
  box-shadow: inset 0 0 0 1px rgba(16, 43, 63, .12);
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 5px; height: 24px; margin-top: -6px; border: 0; border-radius: 2px; background: var(--signal); box-shadow: 0 0 0 3px var(--paper);
}
.ribbon-labels { display: flex; justify-content: space-between; color: var(--muted); font: 10px "Cascadia Mono", monospace; }
.ribbon-labels strong { color: var(--signal); }
.planning-tools { display: grid; grid-template-columns: 1fr 1.35fr; gap: 8px; margin-top: 13px; }
.planning-tools label { display: grid; gap: 4px; color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.planning-tools select, .find-time-button { min-height: 36px; padding: 0 9px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.68); font-size: 11px; }
.find-time-button { align-self: end; background: var(--ink); color: white; font-weight: 700; cursor: pointer; }

.overlap { min-height: 19px; margin: -4px 0 8px; color: var(--muted); font-size: 11px; }
.clock-list { display: grid; gap: 8px; }
.clock-card { position: relative; min-height: 82px; padding: 13px 14px; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: rgba(248, 251, 253, .8); }
.clock-place, .clock-reading { display: grid; gap: 4px; z-index: 1; }
.clock-place strong { max-width: 130px; overflow: hidden; text-overflow: ellipsis; font-size: 13px; white-space: nowrap; }
.clock-place span, .clock-date { color: var(--muted); font-size: 10px; }
.clock-reading { text-align: right; }
.clock-reading time { font: 700 20px "Cascadia Mono", "Consolas", monospace; letter-spacing: -.06em; font-variant-numeric: tabular-nums; }
.clock-actions { position: absolute; top: 3px; right: 4px; z-index: 2; display: flex; align-items: center; opacity: 0; }
.edit-clock, .remove-clock { border: 0; background: transparent; color: var(--muted); font-size: 9px; cursor: pointer; }
.remove-clock { font-size: 14px; }
.clock-card:hover .clock-actions, .clock-actions:focus-within { opacity: 1; }
@media (hover: none) { .clock-actions { opacity: 1; } }
.day-track { position: absolute; inset: auto 0 0; height: 4px; background: var(--night); }
.day-track span { display: block; height: 100%; width: 33.33%; margin-left: 33.33%; background: var(--work); }
.clock-card.is-worktime { border-color: rgba(100, 164, 173, .65); }
.clock-card.is-night { background: rgba(215, 226, 234, .66); }

.section-note { margin: -4px 0 13px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.quick-convert { display: grid; grid-template-columns: 1fr 38px; margin-bottom: 11px; }
.quick-convert input { min-width: 0; padding: 10px 11px; border: 1px solid var(--line); border-right: 0; border-radius: 10px 0 0 10px; background: white; color: var(--ink); }
.quick-convert button { border: 0; border-radius: 0 10px 10px 0; background: var(--ink); color: white; font-size: 17px; cursor: pointer; }
.scan-results { display: grid; gap: 8px; }
.empty-state { padding: 17px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: 12px; text-align: center; }
.time-mention { padding: 12px; border-left: 3px solid var(--signal); border-radius: 0 10px 10px 0; background: var(--panel); box-shadow: 0 5px 16px rgba(16,43,63,.06); }
.mention-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.mention-source { font-size: 12px; font-weight: 700; }
.mention-meta { margin: 3px 0 8px; color: var(--muted); font-size: 9px; }
.confidence { flex: 0 0 auto; padding: 3px 6px; border-radius: 99px; background: #dceced; color: #306b72; font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.confidence.assumption-made { background: #f7e5c7; color: #875c13; }
.confidence.needs-clarification { background: #ffe0d9; color: #9a3520; }
.mention-conversions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 5px 8px; color: var(--muted); font-size: 10px; }
.mention-conversions .outside::after { content: " · late"; color: var(--signal); }
.time-mention details { margin-top: 9px; color: var(--muted); font-size: 9px; }
.time-mention details p { margin: 5px 0 0; line-height: 1.4; }
.ambiguity-picker { display: grid; gap: 5px; margin-top: 9px; color: var(--muted); font-size: 9px; font-weight: 700; }
.ambiguity-picker select { width: 100%; padding: 7px; border: 1px solid var(--line); border-radius: 7px; background: white; font-size: 10px; }
.mention-actions { display: flex; gap: 12px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.mention-actions button, .mention-actions a { padding: 0; border: 0; background: transparent; color: var(--ink); font-size: 9px; font-weight: 750; cursor: pointer; }

dialog { width: min(94vw, 400px); max-height: 84vh; padding: 0; border: 0; border-radius: 18px; background: var(--panel); box-shadow: 0 30px 80px rgba(16,43,63,.3); }
dialog::backdrop { background: rgba(16, 43, 63, .35); backdrop-filter: blur(3px); }
.dialog-card { padding: 20px; }
.dialog-heading { margin-bottom: 18px; align-items: flex-start; }
.dialog-card label { display: grid; gap: 7px; margin-top: 13px; color: var(--muted); font-size: 11px; font-weight: 600; }
.dialog-card input[type="search"], .dialog-card input[type="text"], .dialog-card input[type="number"], #collectionName {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); outline: none;
}
.zone-matches { max-height: 52vh; margin-top: 10px; overflow: auto; }
.zone-option { display: block; width: 100%; padding: 10px 8px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.zone-option strong, .zone-option span { display: block; }
.zone-option span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.check-row { grid-template-columns: auto 1fr; align-items: center; }
.dialog-card fieldset { margin: 15px 0 0; padding: 0; border: 0; }
.dialog-card legend { margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 600; }
.weekday-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.weekday-grid label { position: relative; display: block; margin: 0; }
.weekday-grid input { position: absolute; opacity: 0; }
.weekday-grid span { height: 31px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--muted); font-size: 10px; cursor: pointer; }
.weekday-grid input:checked + span { border-color: var(--ink); background: var(--ink); color: white; }
.primary-button { width: 100%; margin-top: 20px; padding: 12px; border: 0; border-radius: 10px; background: var(--ink); color: white; font-weight: 700; cursor: pointer; }

@media (prefers-reduced-motion: no-preference) {
  .pulse { animation: breathe 2.4s ease-in-out infinite; }
  .clock-card { transition: transform .16s ease, border-color .16s ease; }
  .clock-card:hover { transform: translateY(-1px); }
  @keyframes breathe { 50% { box-shadow: 0 0 0 7px rgba(240, 90, 54, 0); } }
}
