/* 30/30 — visual design inspired by the original Binary Hammer app:
 * bold saturated pill colors, white text, dark background, thick dial ring. */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: transparent; }
html {
  /* Safe-area padding for PWA standalone on notched phones */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, system-ui, "Segoe UI", Helvetica, sans-serif;
  background: #0d0d1a;
  color: #f0f0f5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
  overscroll-behavior: none;
  transition: background-color 0.6s ease;
  min-height: 100vh;
  min-height: 100dvh;
  user-select: none;
  -webkit-user-select: none;
}
body.tinted {
  background-color: hsl(var(--tint-hue, 200), var(--theme-tint-sat, 35%), var(--theme-tint-lit, 10%));
}

/* ---- Theme system ---- */
:root {
  --theme-bg: #0d0d1a;
  --theme-text: #f0f0f5;
  --theme-pill-sat: 65%;
  --theme-pill-lit: 50%;
  --theme-tint-sat: 35%;
  --theme-tint-lit: 10%;
  --theme-ring-sat: 65%;
  --theme-ring-lit: 55%;
  --theme-muted: #333;
  --theme-dim: 0.4;
}

/* Dark Academia: warm browns, muted golds, sage greens */
body.theme-academia {
  --theme-bg: #1a1410;
  --theme-text: #e8dcc8;
  --theme-pill-sat: 35%;
  --theme-pill-lit: 42%;
  --theme-tint-sat: 25%;
  --theme-tint-lit: 8%;
  --theme-ring-sat: 40%;
  --theme-ring-lit: 45%;
  --theme-muted: #3a3020;
  --theme-dim: 0.35;
  background: var(--theme-bg);
  color: var(--theme-text);
}

/* Pink Girly Pop: vivid pinks, magentas, mints */
body.theme-pink {
  --theme-bg: #1a0d18;
  --theme-text: #fce4f0;
  --theme-pill-sat: 70%;
  --theme-pill-lit: 55%;
  --theme-tint-sat: 40%;
  --theme-tint-lit: 10%;
  --theme-ring-sat: 65%;
  --theme-ring-lit: 60%;
  --theme-muted: #3a1a30;
  --theme-dim: 0.35;
  background: var(--theme-bg);
  color: var(--theme-text);
}

/* Easy Pastels: soft muted colors, slightly lighter background */
body.theme-pastel {
  --theme-bg: #141820;
  --theme-text: #e0e4ef;
  --theme-pill-sat: 45%;
  --theme-pill-lit: 60%;
  --theme-tint-sat: 20%;
  --theme-tint-lit: 12%;
  --theme-ring-sat: 45%;
  --theme-ring-lit: 58%;
  --theme-muted: #2a2e3a;
  --theme-dim: 0.45;
  background: var(--theme-bg);
  color: var(--theme-text);
}
#app {
  max-width: 520px;
  margin: 0 auto;
  padding: 8px 14px 120px;
  padding-top: max(8px, env(safe-area-inset-top));
  user-select: none;
  -webkit-user-select: none;
}

/* Remove focus outlines on interactive elements for touch feel; keyboard
   users get the default browser ring via :focus-visible fallback. */
button:focus:not(:focus-visible),
.task:focus:not(:focus-visible),
.divider-row:focus:not(:focus-visible),
.dial:focus:not(:focus-visible),
.adjust:focus:not(:focus-visible) {
  outline: none;
}

header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 0 4px;
  border-bottom: 1px solid #333;
}
header h1 {
  font-size: 18px;
  margin: 0;
}

.list-title-btn {
  background: none;
  border: none;
  color: inherit;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex: 1;
  padding: 0;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}
.list-title-btn .chev {
  color: #888;
  font-size: 12px;
}
header .end-time {
  font-size: 12px;
  color: #888;
}
header button {
  background: none;
  border: none;
  color: #aaa;
  font-size: 18px;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

/* Dial section: fixed height so the task list never jumps. */
.dial-section {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 270px;
  margin: 4px 0 8px;
  position: relative;
}
.dial-container {
  position: relative;
  width: 240px;
  height: 240px;
}

/* SVG progress ring — clockwise arc from 12 o'clock */
.progress-ring {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  filter: drop-shadow(0 0 12px hsla(var(--task-hue, 200), 60%, 50%, 0.3));
}
.progress-track {
  stroke: hsla(var(--task-hue, 200), 20%, 25%, 0.5);
  transition: stroke 0.4s;
}
.progress-arc {
  stroke: hsl(var(--task-hue, 200), var(--theme-ring-sat, 65%), var(--theme-ring-lit, 55%));
  transition: stroke 0.4s, stroke-dashoffset 0.3s linear;
  stroke-dasharray: 659.73;
  stroke-dashoffset: 659.73;
  filter: drop-shadow(0 0 6px hsla(var(--task-hue, 200), var(--theme-ring-sat, 65%), var(--theme-ring-lit, 55%), 0.5));
}

/* Center dial button */
.dial {
  --task-hue: 200;
  position: absolute;
  top: 20px; left: 20px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: hsl(var(--task-hue), 18%, 9%);
  border: none;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
  cursor: default;
  z-index: 1;
  transition: background 0.4s;
  user-select: none;
  -webkit-user-select: none;
}
.dial.tapped {
  background: hsla(var(--task-hue), 30%, 20%, 1);
  transition: background 0.05s;
}
.dial-icon {
  font-size: 26px;
  line-height: 1;
  margin-bottom: 2px;
}
.dial-time {
  font-size: 42px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -1px;
}
.dial-action {
  margin-top: 6px;
  line-height: 1;
  color: rgba(255,255,255,0.5);
}

/* CSS-drawn play/pause icons — consistent across all platforms. */
.icon-play {
  display: inline-block;
  width: 0; height: 0;
  border-style: solid;
  border-width: 10px 0 10px 18px;
  border-color: transparent transparent transparent rgba(255,255,255,0.6);
}
.icon-pause {
  display: inline-flex;
  gap: 4px;
  height: 18px;
}
.icon-pause::before,
.icon-pause::after {
  content: '';
  display: block;
  width: 5px;
  height: 18px;
  background: rgba(255,255,255,0.6);
  border-radius: 1px;
}

/* Buttons mounted on the ring — absolute positioned around the circle */
.ring-btn {
  position: absolute;
  z-index: 2;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: opacity 0.25s, background 0.2s;
  user-select: none;
  -webkit-user-select: none;
  background: rgba(20, 20, 40, 0.85);
  color: #ccc;
}
.ring-btn:active { background: rgba(60, 60, 100, 0.9); }
/* ±m at 9 and 3 o'clock — always visible */
.ring-pos-left  { left: -20px; top: 50%; transform: translateY(-50%); font-size: 12px; }
.ring-pos-right { right: -20px; top: 50%; transform: translateY(-50%); font-size: 12px; }
/* Run-only buttons — hidden when idle */
.ring-run-only { opacity: 0; pointer-events: none; color: #eee; font-size: 16px; }
.dial-section.active .ring-run-only { opacity: 1; pointer-events: auto; }
/* ✓ done at ~10 o'clock */
.ring-pos-tl { left: 6px; top: 10px; }
/* 🗑 delete at ~2 o'clock */
.ring-pos-tr { right: 6px; top: 10px; }
/* ↓ skip at 6 o'clock */
.ring-pos-bottom { left: 50%; bottom: -14px; transform: translateX(-50%); }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.task.done { opacity: var(--theme-dim, 0.4); }
.task.done .task-content { filter: saturate(0.5) brightness(0.7); }

/* Outer wrapper: holds swipe backgrounds + content. Cannot show overflow,
 * so the backgrounds stay clipped to its borders. pan-y lets vertical
 * scrolls through to the browser; horizontal gestures are ours. */
.task {
  position: relative;
  min-height: 64px;
  border-radius: 10px;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.12s;
  animation: fadeSlideIn 0.15s ease-out;
}

/* Task pill — full saturated fill like the original 30/30. Pure white text
 * on a vivid background. No border, just color. */
.task-content {
  --task-col:      hsl(var(--task-hue, 200), var(--theme-pill-sat, 65%), var(--theme-pill-lit, 50%));
  --task-col-dark: hsl(var(--task-hue, 200), calc(var(--theme-pill-sat, 65%) - 15%), calc(var(--theme-pill-lit, 50%) - 15%));
  position: relative;
  z-index: 1;
  background: var(--task-col);
  border: none;
  border-radius: 14px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  gap: 1px 12px;
  min-height: 68px;
  box-sizing: border-box;
  transition: transform 0.15s ease-out;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}
.task.current .task-content {
  box-shadow: 0 0 0 2px rgba(255,255,255,0.5), 0 4px 16px rgba(0,0,0,0.4);
}
.task .task-icon {
  grid-column: 1;
  grid-row: 1 / 3;
  align-self: center;
  font-size: 24px;
  line-height: 1;
  width: 30px;
  text-align: center;
  opacity: 0.9;
}
.task .title {
  grid-column: 2;
  grid-row: 1;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
}
.task .duration {
  grid-column: 3;
  grid-row: 1;
  font-variant-numeric: tabular-nums;
  color: rgba(255,255,255,0.85);
  font-size: 15px;
  font-weight: 600;
}
.task .times {
  grid-column: 2 / 4;
  grid-row: 2;
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  font-variant-numeric: tabular-nums;
}

/* Swipe backgrounds revealed as the content translates. Each is a solid
 * block positioned on one side of the row; only one is shown at a time
 * based on the swiping-left / swiping-right class so they never bleed
 * into each other. Labels hug the outer edge. */
.swipe-bg {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  display: none;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  z-index: 0;
  box-sizing: border-box;
  gap: 10px;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}
.swipe-bg-left {
  justify-content: flex-start;
  padding-left: 20px;
  background: #d53f3f;
}
.swipe-bg-right {
  justify-content: flex-end;
  padding-right: 20px;
  background: #3a6fa0;
}
.task.done .swipe-bg-right {
  background: #3182ce;
}
.task.swiping-right .swipe-bg-left { display: flex; }
.task.swiping-left .swipe-bg-right { display: flex; }
.swipe-bg-icon {
  font-size: 18px;
}

/* When a drag is in progress we disable all touch gestures on the body so
 * the browser does not try to scroll underneath. The JS also preventDefaults
 * touchmove as a belt-and-suspenders. */
body.drag-in-progress {
  touch-action: none;
}
body.drag-in-progress .task {
  touch-action: none;
}
/* Original row while its ghost is being dragged — dim in place so layout
 * stays stable. */
.task.dragging-source,
.divider-row.dragging-source {
  opacity: 0.18;
  pointer-events: none;
}

/* Floating clone that follows the finger during drag. Positioned fixed,
 * pointer-events disabled so the gesture layer still sees the real rows. */
.ghost {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
  border-color: #aaa !important;
  transition: none;
  margin: 0;
  opacity: 0.7;
  backdrop-filter: blur(2px);
}
.ghost.task {
  background: rgba(38, 38, 38, 0.85);
}
.ghost.divider-row {
  color: #6cf;
}
.ghost.divider-row::before {
  background: #6cf;
}

/* Line shown at the drop target while dragging. */
.drop-indicator {
  position: fixed;
  height: 3px;
  background: #6cf;
  border-radius: 2px;
  pointer-events: none;
  z-index: 999;
  box-shadow: 0 0 10px rgba(100, 200, 255, 0.8);
  transition: top 80ms ease-out;
}

/* Legacy .dragging class (kept for tests/selectors; no visual effect now). */
.task.dragging { opacity: 0.85; }
.task.pinned { cursor: default; }
.task.swiping-right { transform: translateX(60px); opacity: 0.7; }
.task.swiping-left { transform: translateX(-60px); opacity: 0.7; }

/* Divider is a row in the task list — draggable like any task row but
 * always visible as a clear handle. Larger touch target (24px min) than
 * the visual line suggests. */
.divider-row {
  list-style: none;
  text-align: center;
  color: #7a7a88;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  position: relative;
  padding: 14px 0;
  margin: 6px 0;
  min-height: 28px;
  touch-action: none;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  transition: color 0.12s;
}
.divider-row::before {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 2px;
  background: #333;
  border-radius: 1px;
  transition: background 0.12s, height 0.12s;
}
.divider-row span {
  position: relative;
  background: #111;
  padding: 0 12px;
}
/* Press / long-press feedback: brighten line while the finger is on it. */
.divider-row:active,
.divider-row.pressing {
  color: #9ad;
}
.divider-row:active::before,
.divider-row.pressing::before {
  background: #4a6a8a;
  height: 3px;
}
.divider-row.dragging-source { opacity: 0.2; }

.stub-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(8, 8, 8, 0.95);
  border-top: 1px solid #1a1a1a;
  padding: 8px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  display: flex;
  gap: 6px;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}
.stub-controls[hidden] { display: none !important; }
.stub-controls button {
  background: #141414;
  border: 1px solid #2a2a2a;
  color: #999;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

.toast {
  position: fixed;
  bottom: 68px;
  left: 50%;
  transform: translateX(-50%);
  background: #1c1c1c;
  border: 1px solid #444;
  color: #eee;
  padding: 10px 14px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  z-index: 900;
  box-shadow: 0 6px 24px rgba(0,0,0,0.6);
  animation: toast-in 0.2s ease-out;
}
.toast[hidden] { display: none; }
.toast button {
  background: none;
  border: none;
  color: #6cf;
  font-size: 14px;
  font-weight: 600;
  cursor: default;
  padding: 2px 4px;
  user-select: none;
  -webkit-user-select: none;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

dialog {
  background: #1a1a1a;
  color: #eee;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 20px;
  min-width: 280px;
}
dialog::backdrop { background: rgba(0,0,0,0.7); }
dialog label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: #aaa;
}
dialog input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  background: #0a0a0a;
  border: 1px solid #333;
  color: #eee;
  border-radius: 6px;
  font-size: 15px;
}
dialog menu {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 0;
  margin: 16px 0 0;
}
dialog button {
  background: #222;
  border: 1px solid #444;
  color: #eee;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: default;
}
dialog button[type="submit"] { background: #333; border-color: #666; }

dialog h2 {
  margin: 0 0 12px;
  font-size: 18px;
  color: #eee;
}

.list-picker-items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 50vh;
  overflow-y: auto;
}
.list-picker-items li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
}
.list-picker-items li.active {
  border-color: #4a6a8a;
  background: #162028;
}
.list-picker-items input[type="text"] {
  flex: 1;
  background: transparent;
  border: none;
  color: #eee;
  font-size: 15px;
  padding: 4px 0;
}
.list-picker-items .grip {
  color: #555;
  font-size: 16px;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}
.list-picker-items .delete {
  background: none;
  border: none;
  color: #c66;
  font-size: 18px;
  cursor: default;
}
.list-picker-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  gap: 10px;
}
.list-picker-actions button {
  background: #222;
  border: 1px solid #444;
  color: #eee;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: default;
}
dialog .toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 15px;
  color: #ddd;
  cursor: default;
}
dialog .toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: default;
}
dialog .hint {
  font-size: 12px;
  color: #888;
  margin: 8px 0 0;
  min-height: 14px;
}
.app-footer {
  text-align: center;
  font-size: 11px;
  color: #333;
  padding: 32px 0 16px;
  letter-spacing: 0.5px;
}

.duration-native-input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 14px 16px;
  background: #0a0a0a;
  border: 1px solid #333;
  color: #eee;
  border-radius: 8px;
  font-size: 28px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.duration-native-input::-webkit-inner-spin-button,
.duration-native-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: default;
  padding: 0;
}
.color-swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px #0a0a0a inset;
}
.icon-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin-top: 6px;
  max-height: 200px;
  overflow-y: auto;
}
.icon-swatch {
  background: #0a0a0a;
  border: 1px solid #333;
  color: #eee;
  font-size: 20px;
  padding: 8px 0;
  border-radius: 6px;
  cursor: default;
  min-width: 34px;
}
.icon-swatch.selected {
  border-color: #9ad;
  background: #1a2838;
}

.theme-picker {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.theme-swatch {
  width: 48px;
  height: 48px;
  border: 2px solid transparent;
  border-radius: 10px;
  font-size: 22px;
  cursor: default;
  background: #141414;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
}
.theme-swatch.selected {
  border-color: #9ad;
}
.theme-swatch[data-theme=""] { background: #0d0d1a; }
.theme-swatch[data-theme="academia"] { background: #1a1410; }
.theme-swatch[data-theme="pink"] { background: #1a0d18; }
.theme-swatch[data-theme="pastel"] { background: #141820; }

/* Onboarding overlay */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.onboarding-overlay[hidden] { display: none; }
.onboarding-content {
  text-align: center;
  color: #fff;
  max-width: 320px;
  padding: 32px 24px;
}
.onboarding-content h2 {
  font-size: 22px;
  margin: 0 0 20px;
}
.onboarding-hints {
  list-style: none;
  padding: 0;
  margin: 0 0 28px;
  font-size: 15px;
  line-height: 2;
  color: rgba(255, 255, 255, 0.85);
}
.onboarding-btn {
  background: hsl(200, 65%, 50%);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 36px;
  font-size: 16px;
  font-weight: 600;
  cursor: default;
}

/* Floating action button */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: hsl(var(--task-hue, 200), 65%, 50%);
  color: #fff;
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  cursor: default;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.3s, transform 0.15s;
}
.fab:active {
  transform: scale(0.92);
}

.debug {
  position: fixed;
  bottom: 80px;
  left: 8px;
  right: 8px;
  max-width: 520px;
  margin: 0 auto;
  background: rgba(0,0,0,0.85);
  color: #6cf;
  border: 1px solid #244;
  border-radius: 6px;
  padding: 8px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.4;
  white-space: pre-wrap;
  z-index: 100;
  pointer-events: none;
}
