/*
 * Hoje — direction: a calm, punctual pocket day.
 * World: a wristwatch and a paper planner at dawn. Graphite neutrals; the only accent is the
 * amber of a watch hand, and it means "now" (the dial, the now line, the current block).
 * Visual cleanup guided by unslop by Damir Sokolovsky (@heydamir), CC BY 4.0.
 */
:root {
  --deep: #0f0f10;
  --bg: #141415;
  --card: #19191b;
  --raised: #232325;
  --line: rgba(237, 237, 237, 0.08);
  --line-strong: rgba(237, 237, 237, 0.14);
  --text: #ededed;
  --text-2: #a1a1a6;
  --muted: #85858b;
  --now: #f2a93b;            /* the watch hand: only for "now" */
  --now-soft: rgba(242, 169, 59, 0.12);
  --done: #4cc38a;
  --late: #e5484d;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 400 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--text); text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--text-2); outline-offset: 2px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 0.92em; }

.i { width: 18px; height: 18px; flex: none; }

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(16px + var(--safe-top)) 16px calc(48px + var(--safe-bottom));
}

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.top h1 { font-size: 28px; font-weight: 500; line-height: 1.15; margin: 0; }
.top .date { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.sync { color: var(--muted); font: 12px/16px var(--mono); font-variant-numeric: tabular-nums; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--card); color: var(--text-2); border-radius: 10px;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn:active { transform: scale(0.97); }
.icon-btn.small { width: 36px; height: 36px; border-radius: 8px; }
.icon-btn.spin .i { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Now — the moment of the screen */
.now { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 32px; }
.now-main { display: flex; align-items: center; gap: 16px; }
.now-text { min-width: 0; flex: 1; }
.now .label { font-size: 13px; font-weight: 500; color: var(--now); }
.now h2 { margin: 4px 0; font-size: 22px; font-weight: 500; line-height: 1.25; overflow-wrap: anywhere; }
.now .sub { color: var(--text-2); font-size: 14px; }
.now .next {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px;
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--text-2); font-size: 14px;
}
.now .next b { color: var(--text); font-weight: 500; }
.now .next span:first-child { color: var(--muted); }
.dial { width: 64px; height: 64px; flex: none; }
.dial-track { fill: none; stroke: var(--raised); stroke-width: 4; }
.dial-arc { fill: none; stroke: var(--now); stroke-width: 4; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 32px 32px; }
.dial-num { fill: var(--text); font: 500 18px var(--mono); text-anchor: middle; }
.dial-unit { fill: var(--muted); font: 400 10px var(--mono); text-anchor: middle; }

.bar { height: 4px; border-radius: 4px; background: var(--raised); overflow: hidden; margin-top: 12px; }
.bar > i { display: block; height: 100%; background: var(--done); transform-origin: left; transition: transform 300ms var(--ease); }

/* Sections */
.section { display: flex; align-items: baseline; justify-content: space-between; margin: 32px 0 12px; }
.section h3 { margin: 0; font-size: 15px; font-weight: 500; color: var(--text); }
.section .count { color: var(--muted); font: 12px/16px var(--mono); }

/* Timeline: an hour ruler with the watch hand for "now" */
.timeline { position: relative; padding-left: 56px; }
.timeline::before { content: ""; position: absolute; left: 44px; top: 8px; bottom: 8px; width: 1px; background: var(--line-strong); }
.t-item { position: relative; margin-bottom: 12px; }
.t-time {
  position: absolute; left: -56px; top: 16px; width: 40px; text-align: right;
  font: 12px/16px var(--mono); font-variant-numeric: tabular-nums; color: var(--muted);
}
.t-dot { position: absolute; left: -16px; top: 20px; width: 8px; height: 8px; border-radius: 50%; background: var(--raised); box-shadow: 0 0 0 3px var(--bg); }
.t-item.current .t-dot { background: var(--now); }
.t-item.current .t-time { color: var(--now); }
.t-item.past .block { opacity: 0.6; }

.block {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px 8px;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease), opacity 150ms var(--ease);
}
.block.current { border-color: rgba(242, 169, 59, 0.45); }
.block-head { display: flex; align-items: flex-start; gap: 12px; }
.block-title { flex: 1; min-width: 0; }
.block-title .name { font-size: 16px; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.block-title .meta { color: var(--muted); font: 12px/16px var(--mono); font-variant-numeric: tabular-nums; margin-top: 4px; }
.tag-now { color: var(--now); }
.more { border: 0; background: none; color: var(--muted); padding: 4px; margin: -4px -8px 0 0; border-radius: 8px; display: grid; place-items: center; }
.more:hover { color: var(--text); background: var(--raised); }

.pri { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 8px; }
.pri.p1 { background: var(--late); }
.pri.p2 { background: var(--text-2); }
.pri.p3 { background: var(--muted); opacity: 0.6; }
.pri.p4 { display: none; }

/* Checklist */
.checklist { list-style: none; margin: 8px 0 0; padding: 0; }
.check {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 0;
  border-top: 1px solid var(--line); cursor: pointer;
}
.check:first-child { border-top: 0; }
.box {
  width: 20px; height: 20px; flex: none; border-radius: 6px; border: 1.5px solid var(--muted);
  display: grid; place-items: center; transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}
.check.done .box { background: var(--done); border-color: var(--done); }
.check.done .box::after { content: ""; width: 5px; height: 10px; border: solid #0f2a1e; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.check .txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.check.done .txt { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.check.pending { opacity: 0.5; }
.add-row { margin: 4px 0 8px; }
.add-row input {
  width: 100%; height: 40px; background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; color: var(--text);
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.add-row input::placeholder { color: var(--muted); }
.add-row input:focus { outline: none; border-color: var(--line-strong); background: var(--deep); }

/* Agenda */
.notice {
  display: flex; align-items: center; gap: 8px; margin: -16px 0 24px; padding: 12px 16px;
  border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--text-2); font-size: 14px;
}
.notice .i { color: var(--muted); }
.block.free { background: transparent; border-style: dashed; border-color: var(--line-strong); cursor: pointer; }
.block.free:hover { background: var(--card); }

/* Free time and the now line */
.gap {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px;
  border: 1px dashed var(--line-strong); border-radius: 14px; padding: 8px 16px; color: var(--muted); font-size: 13px; cursor: pointer;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.gap span:last-child { font: 12px/16px var(--mono); }
.gap:hover { background: var(--card); }
.now-line { position: relative; height: 0; margin: 4px 0 16px; }
.now-line::before { content: ""; position: absolute; left: -16px; right: 0; top: 0; border-top: 1.5px solid var(--now); }
.now-line::after { content: ""; position: absolute; left: -19px; top: -3.5px; width: 7px; height: 7px; border-radius: 50%; background: var(--now); }
.now-line span { position: absolute; left: -56px; top: -8px; width: 40px; text-align: right; font: 500 12px/16px var(--mono); color: var(--now); }
[data-drop].drop-ok { border-color: var(--text-2) !important; border-style: solid !important; background: var(--raised) !important; }

/* Cards: untimed and late */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; margin-bottom: 8px; }
.card-row { display: flex; align-items: center; gap: 12px; }
.card .pri { margin-top: 0; }
.card .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.card .meta { color: var(--muted); font-size: 13px; }
.card.is-done .name { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.card.late .pri.p4 { display: block; background: var(--late); opacity: 0.5; }
.handle {
  touch-action: none; user-select: none; -webkit-user-select: none; border: 0; background: none; color: var(--muted);
  width: 28px; height: 36px; margin-left: -8px; display: grid; place-items: center; cursor: grab; border-radius: 8px;
}
.handle:active { cursor: grabbing; color: var(--text); }
.card-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.card-actions .btn-s { justify-content: center; white-space: nowrap; }
.card-actions .btn-s:only-child { grid-column: 1 / -1; justify-self: start; }
.btn-s {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px;
  border: 1px solid var(--line); background: var(--raised); border-radius: 8px; color: var(--text); font-size: 14px;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}
.btn-s .i { width: 16px; height: 16px; color: var(--text-2); }
.btn-s:hover { border-color: var(--line-strong); }
.btn-s:active { transform: scale(0.98); }
.toggle-sub { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--text-2); font-size: 13px; padding: 8px 0 0; }
.toggle-sub .i { width: 16px; height: 16px; }

.empty { color: var(--muted); font-size: 14px; margin: 8px 0; }

/* Drag */
.ghost {
  position: fixed; z-index: 50; pointer-events: none; transform: translate(-50%, -60%);
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5); max-width: 80vw; font-weight: 500;
}
body.dragging { user-select: none; -webkit-user-select: none; }
.card.lifted { opacity: 0.4; }

/* Sheet */
.backdrop { position: fixed; inset: 0; background: rgba(8, 8, 9, 0.64); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade 200ms var(--ease); }
.sheet {
  width: 100%; max-width: 640px; background: var(--card); border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + var(--safe-bottom)); max-height: 85vh; overflow: auto; animation: rise 300ms var(--ease);
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.sheet h4 { margin: 0 0 4px; font-size: 18px; font-weight: 500; }
.sheet .hint { color: var(--text-2); font-size: 14px; margin: 0 0 16px; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--text-2); }
.field input, .field select, .field textarea {
  height: 44px; background: var(--deep); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; width: 100%;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.durations { display: flex; gap: 8px; flex-wrap: wrap; }
.durations .chip {
  height: 36px; padding: 0 12px; border: 1px solid var(--line); background: var(--raised); border-radius: 8px;
  font: 13px var(--mono); color: var(--text-2);
}
.durations .chip.on { border-color: var(--text-2); color: var(--text); }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.sheet-actions .grow { flex: 1; }
.btn {
  display: inline-flex; align-items: center; gap: 12px; height: 44px; padding: 0 16px;
  border: 1px solid var(--line); background: var(--raised); border-radius: 10px; font-weight: 500; color: var(--text); text-decoration: none;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}
.btn .i { color: var(--text-2); }
.btn:hover { border-color: var(--line-strong); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--text); border-color: var(--text); color: #141415; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.btn.danger { color: var(--late); }
.btn.wide { width: 100%; justify-content: center; }
.pick { display: flex; flex-direction: column; gap: 8px; }
.pick .btn { justify-content: flex-start; }
.pick .btn .mono { color: var(--text-2); }

/* Login */
.login { padding-top: 12vh; }
.login h1 { font-size: 36px; font-weight: 500; margin: 0 0 8px; }
.login p, .login ol { color: var(--text-2); }
.login ol { padding-left: 20px; }
.login input {
  width: 100%; height: 48px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0 16px; margin: 12px 0;
  font-family: var(--mono);
}
.login .fine { color: var(--muted); font-size: 13px; }

#toast {
  position: fixed; left: 50%; bottom: calc(16px + var(--safe-bottom)); transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 12px;
  background: var(--raised); border: 1px solid var(--line-strong); padding: 8px 8px 8px 16px; min-height: 44px; border-radius: 12px; font-size: 14px; max-width: 92vw;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
#toast[hidden] { display: none; }
#toast.err { border-color: rgba(229, 72, 77, 0.5); }
#toast .chip { height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); background: var(--card); border-radius: 8px; margin-left: 0 !important; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Layout: timeline first, Todoist tasks on the side */
.layout { position: relative; }
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.side-head h2 { margin: 0; font-size: 20px; font-weight: 500; }
.col-side .section:first-of-type { margin-top: 16px; }
.side-toggle { position: relative; }
.count-dot {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--text); color: var(--bg); font: 500 11px/18px var(--mono); text-align: center;
}

/* Phone and narrow screens: the tasks live in a drawer from the right */
@media (max-width: 899px) {
  .col-side {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 35; width: min(88vw, 400px); overflow-y: auto;
    background: var(--deep); border-left: 1px solid var(--line);
    padding: calc(16px + var(--safe-top)) 16px calc(32px + var(--safe-bottom));
    transform: translateX(100%); visibility: hidden;
    transition: transform 300ms var(--ease), visibility 0s linear 300ms;
  }
  .col-side.open { transform: none; visibility: visible; transition: transform 300ms var(--ease), visibility 0s; }
  .side-backdrop { position: fixed; inset: 0; z-index: 34; background: rgba(8, 8, 9, 0.6); opacity: 0; pointer-events: none; transition: opacity 200ms var(--ease); }
  .side-backdrop.open { opacity: 1; pointer-events: auto; }
  body.dragging .col-side { transition: none; }
}

/* Wide screens: two columns, the tasks stay in view */
@media (min-width: 900px) {
  #app { max-width: 1120px; padding-left: 32px; padding-right: 32px; }
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; align-items: start; }
  .col-side {
    position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto;
    background: var(--deep); border: 1px solid var(--line); border-radius: 20px; padding: 16px;
  }
  .side-toggle, .side-head .icon-btn, .side-backdrop { display: none; }
}

/* Delete: quiet until touched, red only on intent */
.icon-btn.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.icon-btn.danger:hover, .icon-btn.danger:focus-visible { color: var(--late); background: var(--raised); }
.btn.danger .i { color: var(--late); }

/* New task */
.new-task { display: flex; gap: 8px; margin: 12px 0 0; }
.new-task input {
  flex: 1; min-width: 0; height: 40px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; color: var(--text);
  transition: border-color 150ms var(--ease);
}
.new-task input::placeholder { color: var(--muted); }
.new-task input:focus { outline: none; border-color: var(--line-strong); }
.new-task .icon-btn { width: 40px; height: 40px; }
