/* ====== PulseCheck — Design System ====== */

:root {
  --bg:         #0a0a0a;
  --surface:    #141414;
  --surface2:   #1c1c1c;
  --border:     #2a2a2a;
  --border2:    #222;
  --text:       #f0f0f0;
  --text2:      #999;
  --text3:      #555;
  --accent:     #4ade80;
  --accent-dim: #162a1e;
  --accent-mid: #1f3d2a;
  --danger:     #f87171;
  --danger-dim: #2a1010;
  --warn:       #fbbf24;
  --r:          14px;
  --r-sm:       9px;
  --nav-h:      64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ====== Layout ====== */
#app-main {
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + 16px);
}

.view-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 20px 20px;
}

/* ====== Bottom Nav ====== */
#app-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  backdrop-filter: blur(12px);
}

#app-nav[hidden] { display: none; }

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0;
  border: none;
  background: none;
  color: var(--text3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.15s;
}

.nav-btn .nav-icon {
  font-size: 18px;
  line-height: 1;
  transition: color 0.15s;
}

.nav-btn.active { color: var(--accent); }

/* ====== Brand ====== */
.brand {
  text-align: center;
  padding: 20px 0 32px;
}

.brand-name {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-tagline {
  font-size: 14px;
  color: var(--text2);
  margin-top: 6px;
  font-style: italic;
}

/* ====== Section Labels ====== */
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 10px;
}

/* ====== Setup View ====== */
.setup-task {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 6px;
  animation: slideIn 0.15s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.setup-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--text3);
  min-width: 18px;
  text-align: center;
}

.setup-name {
  flex: 1;
  font-size: 15px;
  color: var(--text);
}

.setup-remove {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}

.setup-remove:hover { color: var(--danger); }

.add-task-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.task-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s;
}

.task-input:focus { border-color: var(--accent); }
.task-input::placeholder { color: var(--text3); }

.btn-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.btn-icon:hover { background: var(--accent-dim); border-color: var(--accent); }

.limit-msg {
  font-size: 12px;
  color: var(--warn);
  margin-top: 6px;
  padding: 8px 12px;
  background: rgba(251,191,36,0.08);
  border-radius: var(--r-sm);
}

/* ====== Interval Slider ====== */
.interval-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.interval-display {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 80px;
}

#interval-val {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.interval-unit {
  font-size: 13px;
  color: var(--text2);
}

.interval-hint {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 24px;
  min-height: 18px;
}

/* ====== Slider base ====== */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--accent-dim);
  transition: box-shadow 0.15s;
}

.slider:active::-webkit-slider-thumb {
  box-shadow: 0 0 0 6px var(--accent-dim);
}

.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

/* ====== Buttons ====== */
.btn-primary {
  display: block;
  padding: 15px 24px;
  border-radius: var(--r);
  border: none;
  background: var(--accent);
  color: #0a0a0a;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-align: center;
}

.btn-primary:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-primary:not(:disabled):hover { opacity: 0.9; }
.btn-primary:not(:disabled):active { transform: scale(0.98); }

.btn-primary.btn-full, .btn-ghost.btn-full { width: 100%; margin-top: 16px; }

.btn-ghost {
  display: block;
  padding: 14px 24px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  text-align: center;
}

.btn-ghost:hover { border-color: var(--text2); color: var(--text); }

.btn-danger {
  padding: 12px 20px;
  border-radius: var(--r-sm);
  border: none;
  background: var(--danger);
  color: #0a0a0a;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-danger:hover { opacity: 0.85; }

/* ====== Permission note ====== */
.permission-note {
  font-size: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  line-height: 1.5;
}

.permission-note.info { color: var(--text2); background: var(--surface); }
.permission-note.warn { color: var(--warn); background: rgba(251,191,36,0.06); }
.permission-note.danger { color: var(--danger); background: rgba(248,113,113,0.06); }
.permission-note.ok { color: var(--accent); background: var(--accent-dim); }

/* ====== Active Day ====== */
.active-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 12px;
}

#active-date {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.countdown-box {
  text-align: right;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  min-width: 110px;
}

.countdown-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3);
}

#countdown-time {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.active-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}

.active-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}

.active-task-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.active-task-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  flex-shrink: 0;
}

.active-task-pct.done { color: var(--accent); }

.progress-bar {
  height: 4px;
  background: var(--border2);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.active-card-meta {
  font-size: 11px;
  color: var(--text3);
}

.done-btn {
  margin-top: 24px;
  color: var(--text3);
  border-color: var(--border2);
}

/* ====== Checkpoint Overlay (THE LOCK) ====== */
#checkpoint-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #050505;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#checkpoint-overlay[hidden] { display: none; }

.cp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 0;
  flex-shrink: 0;
}

.cp-brand {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text3);
  text-transform: uppercase;
}

#cp-progress {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.cp-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 24px 32px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.cp-question-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 8px;
}

#cp-task-name {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 32px;
}

.cp-slider-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.cp-slider-row .slider { flex: 1; }

#cp-pct {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
  min-width: 60px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cp-comment-section { margin-top: 24px; }

.cp-comment-label {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 8px;
}

#cp-comment {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14px;
  padding: 12px 14px;
  resize: none;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
  line-height: 1.5;
}

#cp-comment:focus { border-color: var(--text3); }
#cp-comment::placeholder { color: var(--text3); }

#cp-char-count {
  font-size: 11px;
  color: var(--text3);
  text-align: right;
  margin-top: 4px;
}

.cp-actions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
}

.btn-remove {
  flex: 0 0 auto;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text3);
  border-color: var(--border);
}

.btn-remove:hover { color: var(--danger); border-color: var(--danger); }

.cp-actions .btn-primary { flex: 1; }

/* ====== Remove Confirm Modal ====== */
#remove-confirm {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(4px);
}

#remove-confirm[hidden] { display: none; }

.modal-box {
  background: var(--surface2);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 24px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.modal-sub {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 14px;
}

#remove-comment {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14px;
  padding: 12px 14px;
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
  margin-bottom: 16px;
}

#remove-comment::placeholder { color: var(--text3); }

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .btn-ghost { flex: 1; }
.modal-actions .btn-danger { flex: 1; }

/* ====== Journal / Progress ====== */
.view-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 20px;
}

.journal-task {
  margin-bottom: 24px;
}

.journal-task.removed .jt-name { opacity: 0.5; }

.jt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}

.jt-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.jt-final {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.journal-entries {
  border-left: 2px solid var(--border);
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.journal-entry {
  display: flex;
  gap: 12px;
}

.je-time {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  min-width: 50px;
  padding-top: 3px;
  font-variant-numeric: tabular-nums;
}

.je-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.je-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.je-bar {
  height: 8px;
  background: var(--accent);
  border-radius: 4px;
  min-width: 4px;
  max-width: 160px;
  opacity: 0.8;
}

.je-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.je-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.je-badge.removed { background: var(--danger-dim); color: var(--danger); }

.je-comment {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
  font-style: italic;
}

.je-empty {
  font-size: 12px;
  color: var(--text3);
  padding: 4px 0;
}

/* ====== History ====== */
.history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.hc-date {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.hc-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 12px;
  color: var(--text2);
}

/* ====== Summary ====== */
.summary-hero {
  text-align: center;
  padding: 32px 0 28px;
}

.summary-check {
  font-size: 40px;
  display: block;
  margin-bottom: 12px;
  filter: grayscale(0);
}

.summary-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

#summary-date {
  font-size: 14px;
  color: var(--text2);
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 28px;
}

.ss-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 10px;
  text-align: center;
}

.ss-num {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.ss-label {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
}

.summary-task {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.summary-task.removed { opacity: 0.5; }

.st-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.st-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.st-bar {
  flex: 1;
  height: 6px;
  background: var(--accent);
  border-radius: 3px;
  max-width: 200px;
  opacity: 0.8;
}

.st-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
}

/* ====== Shared ====== */
.empty-state {
  font-size: 14px;
  color: var(--text3);
  padding: 32px 0;
  text-align: center;
  line-height: 1.7;
}

[hidden] { display: none !important; }

/* ====== Scrollbar ====== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
