/* ============ Reset & base ============ */
* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: #0e0e11;
  color: #f2f2f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  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);
  min-height: 100vh;
}

:root {
  --accent: #74f994;
  --accent-dim: rgba(116, 249, 148, 0.16);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --surface: #17171b;
  --surface-2: #1d1d22;
  --amber: #f9c574;
  --warn: #ff9f43;
  --warn-dim: rgba(255, 159, 67, 0.14);
  --text-dim: rgba(242, 242, 240, 0.55);
  --text-dimmer: rgba(242, 242, 240, 0.32);
}

button {
  font-family: inherit;
}

input {
  font-family: inherit;
}

/* ============ Layout ============ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 8px;
  max-width: 640px;
  margin: 0 auto;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 20px 48px;
}

.panel[hidden] {
  display: none;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 12px;
}

/* ============ Setup ============ */

.section-label {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.wb-preset-btn {
  grid-column: span 1;
}

#wb-setup .preset-grid {
  grid-template-columns: repeat(2, 1fr);
}

.wb-preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 88px;
  padding: 16px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: #f2f2f0;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.wb-preset-btn.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.preset-title {
  font-size: 17px;
  font-weight: 700;
}

.preset-sub {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

/* ============ Buttons ============ */

.primary-btn {
  min-height: 56px;
  border-radius: 16px;
  border: none;
  background: var(--accent);
  color: #06130a;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.primary-btn:active {
  transform: scale(0.98);
}

.primary-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.secondary-btn {
  min-height: 56px;
  flex: 1;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: #f2f2f0;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.secondary-btn:active {
  transform: scale(0.98);
}

.ghost-btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.ghost-btn[aria-pressed="true"] {
  color: var(--amber);
  border-color: rgba(249, 197, 116, 0.4);
}

.accent-outline-btn {
  min-height: 52px;
  border-radius: 16px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.accent-outline-btn:active {
  transform: scale(0.98);
  background: var(--accent-dim);
}

.accent-outline-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.controls {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.controls .ghost-btn {
  flex: 0 0 auto;
  min-width: 96px;
}

/* ============ Whiteboard running ============ */

.wb-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
}

.wb-header-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0; /* allow the phase name to wrap instead of overflowing */
}

.wb-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  flex-shrink: 0;
}

.wb-phase-eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.wb-phase-name {
  margin: 0;
  font-size: 26px;
  font-weight: 650;
  color: #fff;
  line-height: 1.15;
  overflow-wrap: break-word;
}

/* the ahead/behind/on-pace pill */
.wb-ahead-line {
  margin: 0;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  font-variant-numeric: tabular-nums;
}

.wb-ahead-line.ahead {
  color: var(--accent);
  background: rgba(116, 249, 148, 0.12);
}

.wb-ahead-line.behind {
  color: var(--warn);
  background: var(--warn-dim);
}

.wb-phase-timer {
  margin: 0;
  font-size: 44px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.wb-phase-timer.over {
  color: var(--warn);
}

.wb-phase-timer-sub {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}

.wb-phase-timer-sub.over {
  color: var(--warn);
}

.wb-overall-line {
  margin: 0;
  font-size: 12px;
  color: var(--text-dimmer);
  font-variant-numeric: tabular-nums;
}

.wb-overall-line.over {
  color: var(--warn);
}

.segments {
  display: flex;
  gap: 6px;
}

.segment {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

.segment-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
}

.segment.done .segment-fill {
  width: 100%;
}

.carryover {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(249, 197, 116, 0.1);
  border: 1px solid rgba(249, 197, 116, 0.3);
}

.carryover[hidden] {
  display: none;
}

.carryover-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--amber);
}

.carryover-item {
  font-size: 13px;
  color: rgba(249, 197, 116, 0.85);
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.checklist-item.checked {
  border-color: rgba(116, 249, 148, 0.35);
  background: var(--accent-dim);
}

.checkbox {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
}

.checklist-item.checked .checkbox {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox svg {
  width: 16px;
  height: 16px;
  opacity: 0;
}

.checklist-item.checked .checkbox svg {
  opacity: 1;
}

.checklist-item-label {
  font-size: 15px;
  line-height: 1.35;
}

.checklist-item.checked .checklist-item-label {
  color: var(--text-dim);
  text-decoration: line-through;
  text-decoration-color: rgba(116, 249, 148, 0.5);
}

.upcoming {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
}

.upcoming-item {
  font-size: 13px;
  color: var(--text-dimmer);
}

/* ============ Done states ============ */

.done-title {
  font-size: 24px;
  font-weight: 800;
  margin: 24px 0 0;
  text-align: center;
}

.wb-done-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wb-done-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 14px;
}

.wb-done-row .count {
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

.wb-done-row .count.all-done {
  color: var(--accent);
}

.wb-done-row.wb-done-early {
  justify-content: center;
  border-color: rgba(116, 249, 148, 0.35);
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
}

/* ============ Responsive ============ */

@media (max-width: 420px) {
  .preset-grid {
    gap: 8px;
  }

  .wb-phase-name {
    font-size: 22px;
  }

  .wb-phase-timer {
    font-size: 36px;
  }
}

@media (min-width: 720px) {
  main {
    padding-top: 24px;
  }
}
