/* ── Timer Screen ── */
.timer-wrap { cursor: pointer; text-align: center; padding: 60px; border-radius: var(--r-lg); transition: transform 0.2s; }
.timer-wrap:hover { transform: scale(1.02); }
.timer-digits { font-family: 'JetBrains Mono', monospace; font-size: 96px; font-weight: 300; letter-spacing: -2px; color: var(--text); line-height: 1; }
.timer-hint { font-size: 11px; letter-spacing: 2px; color: var(--text); opacity: 0.5; text-transform: uppercase; margin-top: 16px; }
#durationEditor { display: flex; align-items: center; gap: 12px; margin-top: 24px; opacity: 0.4; transition: opacity 0.2s; }
#durationEditor:hover, #durationEditor:focus-within { opacity: 1; }
#durationEditor input { width: 60px; text-align: center; padding: 8px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-family: 'JetBrains Mono', monospace; font-size: 16px; outline: none; }
#durationEditor input:focus { border-color: var(--accent); }

/* Status row */
.status-row { min-height: 20px; margin-top: 24px; display: flex; align-items: center; gap: 8px; font-size: 12px; opacity: 0.6; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 2s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 var(--accent-soft)} 70%{box-shadow:0 0 0 10px transparent} 100%{box-shadow:0 0 0 0 transparent} }

/* ══════════════════════════════════════════════════════════════════════════
   Timer modes (Practice | Stopwatch | Countdown) - one timer on #screen-main,
   mode-switched. Practice uses the rules above; Stopwatch/Countdown use the
   study-timer card below (folded in from the old, removed css/timerscreen.css).
   ══════════════════════════════════════════════════════════════════════════ */
:root { --timer-warn: #EF4444; --timer-done: #10B981; }
[data-dark] { --timer-warn: #F87171; --timer-done: #34D399; }

/* `safe center` so the taller study mode (card + recent list) top-aligns and
   scrolls instead of clipping off the top on short viewports; when content
   fits it still centers exactly like the practice timer always did. */
#screen-main { justify-content: safe center; }
.timer-modes { width: 100%; max-width: 600px; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.timer-mode-pane { width: 100%; display: flex; flex-direction: column; align-items: center; }

/* ── Mode toggle ────────────────────────────────────────────────────────── */
.tmode-toggle {
  display: flex; gap: 4px; width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px;
}
.tmode {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: none; background: transparent; cursor: pointer; border-radius: 999px;
  padding: 10px 12px; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--dim);
  transition: all 0.18s;
}
.tmode:hover { color: var(--text); }
.tmode .ti { font-size: 17px; }
.tmode.active { background: var(--text); color: var(--bg); box-shadow: 0 2px 8px rgba(17,17,17,0.14); }
[data-dark] .tmode.active { box-shadow: 0 2px 8px rgba(0,0,0,0.5); }
/* Locked while a timer is running - can't switch mode mid-run (js/studytimer.js) */
.tmode.tmode-locked { opacity: 0.35; pointer-events: none; }

/* ── Study card (Stopwatch / Countdown) ─────────────────────────────────── */
.timer-card {
  width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 28px 24px; box-shadow: 0 1px 3px rgba(17,17,17,0.03);
  display: flex; flex-direction: column; align-items: center; gap: 22px;
}
[data-dark] .timer-card { box-shadow: 0 1px 3px rgba(0,0,0,0.2); }

/* Countdown setup */
.timer-cd-setup { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; width: 100%; }
.tpresets { display: flex; gap: 7px; }
.tpreset {
  border: 1px solid var(--border); background: var(--bg); cursor: pointer; border-radius: 999px;
  padding: 7px 15px; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--body-text); transition: all 0.15s;
}
.tpreset:hover { border-color: var(--dim); color: var(--text); }
.tpreset.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.tcustom { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); }
.tcustom-input {
  width: 64px; text-align: center; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: 7px 8px;
}
.tcustom-input:focus { outline: none; border-color: var(--accent); }

/* Big display */
.timer-display-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.timer-display {
  font-family: 'JetBrains Mono', monospace; font-size: 68px; font-weight: 500; letter-spacing: -1px;
  color: var(--text); line-height: 1; font-variant-numeric: tabular-nums; transition: color 0.3s;
}
.timer-display.warn { color: var(--timer-warn); animation: timer-pulse 1s ease-in-out infinite; }
@keyframes timer-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.timer-display-sub { font-size: 12px; font-weight: 500; color: var(--dim); text-transform: uppercase; letter-spacing: 0.6px; }

/* Controls */
.timer-controls { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.tbtn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-md);
  padding: 12px 20px; font-family: inherit; font-size: 14px; font-weight: 600; color: var(--text); transition: all 0.15s;
}
.tbtn:hover { border-color: var(--dim); background: var(--bg); }
.tbtn:active { transform: scale(0.97); }
.tbtn .ti { font-size: 17px; }
.tbtn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.tbtn-primary:hover { background: var(--primary-active); }
[data-dark] .tbtn-primary { color: #111; }
.tbtn-stop { border-color: var(--timer-done); color: var(--timer-done); }
.tbtn-stop:hover { background: color-mix(in srgb, var(--timer-done) 10%, transparent); }
.tbtn-ghost { padding: 12px 14px; color: var(--dim); }
.tbtn-ghost:hover { color: var(--timer-warn); border-color: var(--timer-warn); }

/* Subject tag */
.timer-tag-row { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 420px; }
.timer-tag-row > .ti { font-size: 16px; color: var(--dim); flex-shrink: 0; }
.timer-tag-row select {
  flex: 1; min-width: 0; font-family: inherit; font-size: 12.5px; color: var(--body-text);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px 10px; cursor: pointer;
}
.timer-tag-row select:focus { outline: none; border-color: var(--accent); }
/* Flash the subject select when Start is tapped without a subject picked. */
.timer-tag-row select.needs-attention { border-color: var(--timer-warn); animation: tagShake 0.45s ease; }
@keyframes tagShake { 0%,100%{ transform: translateX(0); } 25%{ transform: translateX(-4px); } 75%{ transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce){ .timer-tag-row select.needs-attention { animation: none; } }

/* ── Today + recent ─────────────────────────────────────────────────────── */
.timer-summary { display: grid; grid-template-columns: 160px 1fr; gap: 14px; margin-top: 20px; width: 100%; }
.timer-today {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px; display: flex; flex-direction: column; gap: 6px; justify-content: center;
}
.timer-today-label { font-size: 12px; color: var(--dim); font-weight: 500; }
.timer-today-val { font-size: 30px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.timer-recent { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; min-width: 0; }
.timer-recent-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--dim); margin-bottom: 8px; }
.trecent-list { display: flex; flex-direction: column; }
.trecent-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--border-soft); }
.trecent-row:last-child { border-bottom: none; }
.trecent-row > .ti { font-size: 16px; color: var(--dim); flex-shrink: 0; }
.trecent-main { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.trecent-dur { font-size: 13px; font-weight: 600; color: var(--text); }
.trecent-tag { font-size: 10.5px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 2px 6px; white-space: nowrap; }
.trecent-when { font-size: 11px; color: var(--dim); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.trecent-del { border: none; background: transparent; cursor: pointer; color: var(--dim); padding: 3px; border-radius: 4px; opacity: 0; transition: all 0.15s; flex-shrink: 0; }
.trecent-row:hover .trecent-del { opacity: 1; }
.trecent-del:hover { color: var(--timer-warn); }
.tlap-empty { font-size: 12.5px; color: var(--dim); padding: 6px 4px; }

@media (max-width: 540px){
  .timer-display { font-size: 54px; }
  .tmode { font-size: 12px; gap: 5px; }
  .timer-summary { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce){
  .timer-display.warn { animation: none; }
  .tmode, .tbtn, .tpreset { transition: none; }
}

/* ── Break / Log Screen ── */
/* A single flowing column, not a form grid: one big decision up top, then
   only the fields that decision actually requires reveal underneath it. */

.break-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 600px;
  margin-bottom: 28px;
}
.break-strip-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px 8px 14px;
  font-size: 12px;
}
.break-strip-item i { font-size: 14px; color: var(--accent); opacity: 0.8; }
.break-strip-item.dim i { color: var(--dim); }
.break-strip-label { color: var(--dim); font-weight: 500; }
.break-strip-val { font-family: 'JetBrains Mono', monospace; font-weight: 500; color: var(--text); margin-left: 2px; }

.log-flow {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── The fork: the one real decision, asked first and asked big ── */
.fork-row { display: flex; gap: 12px; }
.fork-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 16px;
  border-radius: var(--r-lg);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.fork-btn i { font-size: 19px; opacity: 0.55; transition: opacity 0.2s ease; }
.fork-btn:hover { border-color: var(--dim); transform: translateY(-1px); }
.fork-yes.on { border-color: #10B981; background: rgba(16, 185, 129, 0.08); color: #10B981; }
.fork-yes.on i { opacity: 1; }
.fork-no.on { border-color: #EF4444; background: rgba(239, 68, 68, 0.08); color: #EF4444; }
.fork-no.on i { opacity: 1; }

/* ── Everything below the fork: hidden until answered, then flows in ── */
.reveal-block {
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}
.reveal-block.show { max-height: 2000px; opacity: 1; overflow: visible; }

.reveal-sub {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.reveal-sub.show { display: flex; }

.field-compact { display: flex; flex-direction: column; gap: 10px; }
.field-optional .flabel { display: flex; align-items: center; gap: 8px; }
.opt-tag {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--dim);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 7px;
}

.action-row { display: flex; gap: 12px; margin-top: 4px; }

/* Required pill-groups get a soft highlight if still unanswered when the
   user tries to submit, so the form never feels like it's silently judging */
.pills.needs-attention { animation: needShake 0.4s ease; }
@keyframes needShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ── Pills ── */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { padding: 8px 16px; border-radius: 6px; font-size: 12px; cursor: pointer; background: var(--bg); border: 1px solid var(--border); color: var(--text); font-family: inherit; transition: all 0.2s; }
.pill:hover { border-color: var(--accent); }
.pill.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 500; }

/* ── Quick notes ── */
.quick-notes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.qnote-chip { padding: 6px 12px; border-radius: 6px; font-size: 11px; cursor: pointer; background: transparent; border: 1px dashed var(--border); color: var(--text); opacity: 0.7; transition: all 0.2s; }
.qnote-chip:hover { border-color: var(--accent); opacity: 1; color: var(--accent); }

/* ── Custom resource row ── */
.cus-row { display: flex; gap: 8px; margin-top: 12px; }
.cus-row .neu-input { flex: 1; }
.cus-row .neu-btn { width: 42px; padding: 0; }