:root {
  --bg: #000;
  --card: #101010;
  --card-2: #1b1b1b;
  --card-3: #262626;
  --line: #2a2a2a;
  --text: #fff;
  --muted: #8b8b8b;
  --faint: #5a5a5a;
  --accent: #ff5a1f;
  --accent-soft: rgba(255, 90, 31, .14);
  --break: #3ee0a0;
  --break-soft: rgba(62, 224, 160, .13);
  --radius: 18px;
  --inset: 18px;     /* one horizontal inset for every card */
  --inset-y: 16px;   /* one vertical inset for top/bottom-pinned details */
  --gap: 6px;
  --pad-t: max(8px, env(safe-area-inset-top));
  --pad-r: max(8px, env(safe-area-inset-right));
  --pad-b: max(8px, env(safe-area-inset-bottom));
  --pad-l: max(8px, env(safe-area-inset-left));
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); }
body {
  font-family: "Inter Tight", -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  overflow: hidden;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }

/* ---------------------------------------------------------- layout: phone landscape (default) */
#app {
  height: 100dvh;
  padding: var(--pad-t) var(--pad-r) var(--pad-b) var(--pad-l);
  display: grid;
  gap: var(--gap);
  grid-template-columns: minmax(0, 38fr) minmax(0, 62fr);
  grid-template-rows: 1.2fr 1.05fr 1fr;
  grid-template-areas:
    "clock tasks"
    "pomo  tasks"
    "flight tasks";
}
.clock  { grid-area: clock; }
.pomo   { grid-area: pomo; }
.flight { grid-area: flight; }
.tasks  { grid-area: tasks; }
.radar  { grid-area: radar; display: none; }

.card {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  container-type: size;
  overflow: hidden;
  min-height: 0;
}

/* ---------------------------------------------------------- clock */
.clock {
  display: flex; justify-content: center; align-items: center;
  padding: var(--inset-y) var(--inset);
  cursor: pointer;
}
/* The zone row takes exactly the width of the time above it, so both share left and right edges. */
.clock-inner { display: inline-flex; flex-direction: column; align-items: stretch; max-width: 100%; }
.clock-time {
  font-size: min(26.5cqw, 64cqh);
  font-weight: 500;
  letter-spacing: -.055em;
  line-height: .9;
  white-space: nowrap;
}
.clock-time .sep { opacity: .9; margin: 0 -.01em; position: relative; top: -.06em; }
.clock-row {
  display: flex; justify-content: space-between; width: 100%;
  margin-top: max(6px, 6cqh);
  padding: 0 .1em 0 .2em; /* optical: digits have side bearing, labels don't */
  font-size: clamp(10px, min(5.2cqw, 10cqh), 22px);
  letter-spacing: -.01em;
  color: var(--muted);
  white-space: nowrap;
}
.clock-row b { font-weight: 500; color: var(--faint); margin-right: .3em; }
.clock-row sup { font-size: .65em; color: var(--accent); margin-left: .1em; }
.clock-info { justify-content: space-between; gap: 1em; }
.clock-info .temp { color: var(--text); }
.gear {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; color: var(--faint); opacity: 0; transition: opacity .2s;
}
@media (hover: hover) { .clock:hover .gear { opacity: 1; } .gear:hover { color: var(--text); background: var(--card-2); } }

/* ---------------------------------------------------------- pomodoro */
.pomo { cursor: pointer; transition: transform .15s var(--ease); outline: none; }
.pomo:active { transform: scale(.99); }
/* Progress = the lighter block. Anchored right, full card height, same radius as the card. */
.pomo-fill {
  position: absolute; top: 0; right: 0; bottom: 0; width: 100%;
  background: var(--card-2);
  border-radius: var(--radius);
  transition: width 1s linear, background .5s;
}
.pomo.is-break .pomo-fill { background: #12241d; }
.pomo-count {
  position: absolute; left: var(--inset); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  z-index: 1;
}
.pomo-num { font-size: clamp(13px, 13cqh, 26px); font-weight: 500; letter-spacing: -.02em; line-height: 1; transition: transform .4s var(--ease), color .4s; transform-origin: left center; }
.pomo-num.bump { transform: scale(1.35); color: var(--accent); }
.pomo-dots { display: flex; gap: 4px; }
.pomo-dots i { width: 4px; height: 4px; border-radius: 50%; background: #3a3a3a; transition: background .4s; }
.pomo-dots i.on { background: var(--accent); }
.pomo.is-break .pomo-dots i.on { background: var(--break); }
.pomo-label {
  position: absolute; top: var(--inset-y); right: var(--inset); z-index: 1;
  font-size: clamp(9px, 8cqh, 12px); letter-spacing: .14em; text-transform: uppercase; line-height: 1;
  color: var(--muted); font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.pomo-label::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); transition: background .3s; }
.pomo.is-running .pomo-label::before { background: var(--accent); animation: pulse 2s infinite; }
.pomo.is-running.is-break .pomo-label::before { background: var(--break); }
.pomo.is-break .pomo-label { color: var(--break); }
.pomo-time {
  position: absolute; right: var(--inset); bottom: var(--inset-y); z-index: 1;
  font-size: min(26cqw, 56cqh);
  font-weight: 500; letter-spacing: -.055em; line-height: .76;
  margin-right: -.04em; /* optical: tight tracking leaves a gap after the last digit */
  transition: opacity .3s, color .3s;
}
.pomo:not(.is-running) .pomo-time { color: #a5a5a5; }
.pomo.is-paused .pomo-time { animation: blink 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes blink { 50% { opacity: .45; } }

/* ---------------------------------------------------------- flight */
.flight {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  padding: 0 var(--inset); cursor: pointer;
}
.flight-main { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 3cqh; }
.flight-route { display: flex; align-items: center; gap: .45em; font-size: clamp(11px, 13cqh, 22px); letter-spacing: .02em; font-weight: 450; }
.flight-route .arrow { width: 1.2em; height: 1.2em; color: var(--muted); }
.flight-cs {
  font-size: clamp(22px, 32cqh, 64px); font-weight: 450; letter-spacing: -.045em; line-height: .95;
  color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.flight-meta { font-size: clamp(9px, 9.5cqh, 15px); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@container (max-height: 112px) { .flight-meta { display: none; } }
.flight-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 6cqh; padding-left: 12px; }
.plane { width: clamp(34px, 34cqh, 76px); height: clamp(34px, 34cqh, 76px); color: #e8e8e8; transition: transform 1.2s var(--ease); }
.flight-eta { font-size: clamp(11px, 13cqh, 22px); letter-spacing: -.01em; white-space: nowrap; text-align: right; }
.flight-eta small { display: block; font-size: .62em; color: var(--muted); letter-spacing: .04em; margin-top: 2px; }
.flight-dots { position: absolute; top: var(--inset-y); left: 50%; transform: translateX(-50%); display: flex; gap: 3px; }
.flight-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--card-3); }
.flight-dots i.on { background: var(--text); }
.flight.swap .flight-main, .flight.swap .flight-eta { animation: swapIn .45s var(--ease); }
@keyframes swapIn { from { opacity: 0; transform: translateY(6px); } }

/* ---------------------------------------------------------- radar */
.radar svg { width: 100%; height: 100%; display: block; }
.radar .ring { fill: none; stroke: #222; stroke-width: .4; }
.radar .ring-label { fill: #4a4a4a; font-size: 4.2px; }
.radar .axis { stroke: #1a1a1a; stroke-width: .4; }
.radar .sweep { fill: url(#sweepGrad); transform-origin: 0 0; animation: sweep 6s linear infinite; }
@keyframes sweep { to { transform: rotate(360deg); } }
.radar .me { fill: var(--text); }
.radar .ac { fill: #9a9a9a; cursor: pointer; transition: fill .3s; }
.radar .ac.sel { fill: var(--accent); }
.radar .ac-label { fill: #8b8b8b; font-size: 4.4px; letter-spacing: .02em; pointer-events: none; }
.radar .ac-label.sel { fill: var(--accent); font-weight: 600; }
.radar-caption { position: absolute; left: var(--inset); top: var(--inset-y); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); font-weight: 500; }

/* ---------------------------------------------------------- tasks */
.tasks { position: relative; min-height: 0; display: flex; flex-direction: column; }
.task-list {
  list-style: none; flex: 1; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  display: flex; flex-direction: column; gap: var(--gap);
  --row: max(64px, calc((100dvh - var(--pad-t) - var(--pad-b) - 3 * var(--gap)) / 4));
  mask-image: linear-gradient(to bottom, #000 calc(100% - 14px), transparent);
}
.task-list::-webkit-scrollbar { display: none; }
.task {
  position: relative; flex: 0 0 var(--row); height: var(--row);
  border-radius: var(--radius);
  background: #2a0d02;
  overflow: hidden;
  touch-action: pan-y;
}
.task-del {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end;
  padding-right: var(--inset); color: var(--accent); font-size: 15px; font-weight: 500; letter-spacing: .02em;
}
.task-body {
  position: absolute; inset: 0;
  background: var(--card);
  display: flex; align-items: center; gap: clamp(14px, 2.4vw, 26px);
  padding: 0 var(--inset);
  cursor: pointer;
  transition: transform .35s var(--ease), background .2s;
  will-change: transform;
}
.task-body:active { background: #141414; }
.task.dragging .task-body { transition: none; }
.check {
  flex: 0 0 auto; width: clamp(30px, calc(var(--row) * .44), 42px); aspect-ratio: 1; border-radius: 50%;
  border: 1.6px solid #e6e6e6; display: grid; place-items: center; position: relative;
  transition: background .3s var(--ease), border-color .3s, transform .3s var(--ease);
}
.check svg { width: 56%; height: 56%; }
.check path { fill: none; stroke: #fff; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .35s .08s var(--ease); }
.task.done .check { background: var(--accent); border-color: var(--accent); }
.task.done .check path { stroke-dashoffset: 0; }
.task.pop .check { animation: pop .45s var(--ease); }
@keyframes pop { 40% { transform: scale(1.18); } }
.task-text {
  flex: 1; min-width: 0;
  font-size: clamp(19px, calc(var(--row) * .34), 32px);
  font-weight: 400; letter-spacing: -.035em; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .3s;
}
.task.done .task-text { color: #7a7a7a; }
.task-input {
  flex: 1; min-width: 0; background: none; border: 0; outline: none;
  font-size: clamp(19px, calc(var(--row) * .34), 32px); letter-spacing: -.035em;
  -webkit-user-select: text; user-select: text;
}
.task-input::placeholder { color: #4d4d4d; }
.task.add { background: transparent; }
.task.add .task-body { background: transparent; border: 1.5px dashed #262626; }
.task.add .check { border: 1.6px dashed #444; }
.task.add .check svg path { stroke: #777; stroke-dasharray: none; stroke-dashoffset: 0; }
.task.add .task-text { color: #555; }
.task.add.editing .task-body { background: var(--card); border-color: transparent; }
.task.add.editing .check { border-style: solid; border-color: #444; }
.task.leaving { animation: leave .3s var(--ease) forwards; }
@keyframes leave { to { flex-basis: 0; height: 0; margin-bottom: calc(-1 * var(--gap)); opacity: 0; } }
.task.entering { animation: enter .4s var(--ease); }
@keyframes enter { from { opacity: 0; transform: translateY(8px) scale(.98); } }

[hidden] { display: none !important; }
.toast {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  background: #1f1f1f; border: 1px solid #2c2c2c; color: #ddd;
  padding: 9px 9px 9px 16px; border-radius: 999px; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
  animation: toastIn .35s var(--ease);
  z-index: 5;
}
.toast button { background: var(--accent); color: #000; font-weight: 600; padding: 5px 12px; border-radius: 999px; font-size: 13px; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------------------------------------------------------- night dim */
.dim { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 3s; z-index: 50; }
.dim.on { opacity: .55; }

/* ---------------------------------------------------------- settings sheet */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.6); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: grid; place-items: center;
  padding: var(--pad-t) var(--pad-r) var(--pad-b) var(--pad-l);
  animation: fade .25s;
}
.sheet-backdrop[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: min(560px, 100%); max-height: 100%; overflow-y: auto;
  background: #0e0e0e; border: 1px solid #222; border-radius: 22px;
  padding: 18px 20px 20px;
  display: flex; flex-direction: column; gap: 16px;
  animation: rise .35s var(--ease);
  -webkit-user-select: text; user-select: text;
}
@keyframes rise { from { transform: translateY(16px) scale(.98); opacity: 0; } }
.sheet header { display: flex; justify-content: space-between; align-items: center; position: sticky; top: -18px; background: #0e0e0e; padding: 4px 0; z-index: 1; }
.sheet h2 { font-size: 22px; font-weight: 500; letter-spacing: -.03em; }
.sheet fieldset { border: 0; display: flex; flex-direction: column; gap: 8px; }
.sheet legend { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; font-weight: 500; }
.sheet legend small { text-transform: none; letter-spacing: 0; color: var(--faint); margin-left: 6px; font-size: 12px; }
.sheet select, .sheet input[type=text], .sheet input[type=number] {
  background: #181818; border: 1px solid #262626; border-radius: 12px; padding: 10px 12px; font-size: 16px; outline: none; width: 100%;
  -webkit-appearance: none; appearance: none;
}
.sheet select:focus, .sheet input:focus { border-color: #444; }
.zones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.row2 { flex-direction: row !important; gap: 10px !important; }
.row2 label { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.row2 label span { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--faint); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { background: var(--text); color: #000; font-weight: 600; font-size: 14px; padding: 8px 16px; border-radius: 999px; }
.pill.ghost { background: #1c1c1c; color: var(--text); }
.toggles label { display: flex; align-items: center; gap: 10px; font-size: 15px; padding: 4px 0; cursor: pointer; }
.toggles input { width: 20px; height: 20px; accent-color: var(--accent); }
.hint { font-size: 13px; color: var(--faint); line-height: 1.5; }
.hint.ok { color: var(--break); }
.hint.err { color: var(--accent); }

/* ---------------------------------------------------------- portrait phone */
@media (orientation: portrait) and (max-width: 820px) {
  body { overflow: auto; }
  #app {
    height: auto; min-height: 100dvh;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
    grid-template-areas:
      "clock clock"
      "pomo pomo"
      "tasks tasks"
      "flight flight"
      "radar radar";
  }
  :root { --inset: 20px; }
  .clock { height: 34vw; }
  .pomo { height: 30vw; }
  .flight { height: 30vw; }
  .radar { display: block; height: calc(100vw - 16px); }
  .task-list { --row: 76px; overflow: visible; mask-image: none; }
}

/* ---------------------------------------------------------- desktop / large screens */
@media (min-width: 1024px) and (min-height: 600px) {
  :root { --gap: 12px; --radius: 26px; --inset: 28px; --inset-y: 24px; }
  #app {
    --p: clamp(12px, 1.6vw, 28px);
    padding: var(--p);
    max-width: 1800px; margin: 0 auto;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-rows: 1.15fr 1fr 1fr;
    grid-template-areas:
      "clock clock tasks"
      "pomo  flight tasks"
      "pomo  radar  tasks";
  }
  .radar { display: block; }
  .pomo-count { top: var(--inset-y); transform: none; flex-direction: row; align-items: center; gap: 14px; }
  .pomo-num { font-size: 22px; }
  .pomo-num::after { content: " today"; color: var(--faint); font-size: 14px; letter-spacing: 0; }
  .pomo-dots i { width: 6px; height: 6px; }
  .pomo-label { font-size: 12px; }
  .pomo-time { font-size: min(28cqw, 46cqh); }
  .clock-time { font-size: min(19cqw, 52cqh); }
  .clock-row { font-size: clamp(12px, min(2.4cqw, 9cqh), 22px); padding: 0 6cqw; }
  .flight-cs { font-size: clamp(22px, 26cqh, 64px); }
  .task-list { --row: clamp(72px, 10.5vh, 96px); }
  .task-text, .task-input { font-size: clamp(20px, calc(var(--row) * .3), 30px); }
}
