/* Deep Focus — see docs/frontend.md for the design language this file implements. */

:root {
  color-scheme: light;

  --bg: #faf6f0;
  --bg-elevated: #fffdfa;
  --bg-sunken: #f2ebe1;
  --border: #e0d5c6;
  --border-strong: #c9bba6;

  --text: #2c2621;
  --text-muted: #5f5648;
  --text-faint: #6b6254;

  --accent: #a1522a;
  --accent-hover: #8a4522;
  --accent-soft: #f6e7db;
  --accent-contrast: #ffffff;

  --break: #2f6b52;
  --danger: #a02a24;

  --ring-track: #e6dccd;
  --ring-focus: #a1522a;
  --ring-break: #2f6b52;

  --heat-0: #efe7db;
  --heat-1: #e6cdb4;
  --heat-2: #d3a37a;
  --heat-3: #b9754a;
  --heat-4: #94441f;

  --focus-ring: #1f5fbf;

  --shadow-sm: 0 1px 2px rgba(60, 44, 28, 0.06);
  --shadow-md: 0 6px 24px rgba(60, 44, 28, 0.08);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --wrap: 1120px;
  --header-h: 60px;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #000000;
  --bg-elevated: #101010;
  --bg-sunken: #0a0a0a;
  --border: #2a2a2a;
  --border-strong: #3d3d3d;

  --text: #f2efea;
  --text-muted: #b3aca2;
  --text-faint: #a49d93;

  --accent: #e59a63;
  --accent-hover: #f0ae7c;
  --accent-soft: #241a12;
  --accent-contrast: #1a1108;

  --break: #6fc79c;
  --danger: #f08a83;

  --ring-track: #262626;
  --ring-focus: #e59a63;
  --ring-break: #6fc79c;

  --heat-0: #151515;
  --heat-1: #3d2716;
  --heat-2: #6b4021;
  --heat-3: #a4632e;
  --heat-4: #e59a63;

  --focus-ring: #7db1ff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.6);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  max-width: 100%;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -60px;
  z-index: 60;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: var(--space-3);
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}
a:hover {
  color: var(--accent-hover);
}

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  font-weight: 650;
  font-size: 17px;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}
.brand-mark {
  color: var(--accent);
  flex: none;
}

.header-nav {
  display: flex;
  gap: var(--space-4);
  margin-left: auto;
  font-size: 14px;
}
.header-nav a {
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}
.header-nav a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.header-actions {
  display: flex;
  gap: var(--space-2);
}

/* ---------- buttons and controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  min-width: 44px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    transform 0.1s ease;
}
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  min-width: 128px;
  height: 48px;
  padding: 0 var(--space-6);
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 16px;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-contrast);
}

.btn-secondary {
  height: 44px;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  border-color: var(--border-strong);
}

.btn-icon {
  width: 40px;
  min-width: 40px;
  padding: 0;
}
.btn-icon-glyph {
  font-size: 17px;
  line-height: 1;
}

.btn-sm {
  height: 36px;
  padding: 0 var(--space-3);
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ---------- hero and timer ---------- */

.hero {
  padding: var(--space-7) 0 var(--space-6);
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.15;
  letter-spacing: -0.025em;
  font-weight: 680;
}

.tagline {
  max-width: 60ch;
  margin: var(--space-3) auto 0;
  color: var(--text-muted);
  font-size: 16px;
}

.timer-card {
  max-width: 520px;
  margin: var(--space-6) auto 0;
  padding: var(--space-6) var(--space-5) var(--space-5);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.timer-mode {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.timer-card[data-mode="short"] .timer-mode,
.timer-card[data-mode="long"] .timer-mode {
  color: var(--break);
}

.ring-wrap {
  position: relative;
  width: min(320px, 76vw);
  margin: var(--space-4) auto 0;
  aspect-ratio: 1 / 1;
}

.ring {
  display: block;
  width: 100%;
  height: 100%;
}
.ring-track {
  stroke: var(--ring-track);
}
.ring-progress {
  stroke: var(--ring-focus);
  transition: stroke-dashoffset 0.4s linear, stroke 0.3s ease;
}
.timer-card[data-mode="short"] .ring-progress,
.timer-card[data-mode="long"] .ring-progress {
  stroke: var(--ring-break);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  pointer-events: none;
}

.countdown {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(44px, 11vw, 64px);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}

.countdown-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.timer-controls {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-5);
  flex-wrap: wrap;
}

.timer-meta {
  margin: var(--space-4) 0 0;
  color: var(--text-muted);
  font-size: 13px;
}
.timer-meta .dot {
  margin: 0 var(--space-2);
  color: var(--border-strong);
}

.kbd-hint {
  margin: var(--space-3) 0 0;
  color: var(--text-faint);
  font-size: 12px;
}

/* ---------- panels ---------- */

.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-5);
  margin-top: var(--space-6);
}

.panel {
  padding: var(--space-5);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.panel-wide {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.panel h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.panel-count {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.panel-hint,
.field-note {
  margin: 0 0 var(--space-3);
  color: var(--text-muted);
  font-size: 13px;
}

.empty-state {
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

.subhead {
  margin: var(--space-5) 0 var(--space-3);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.subhead-note {
  color: var(--text-muted);
  font-weight: 450;
}

/* ---------- session queue ---------- */

.queue-list {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.queue-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 48px;
}
.queue-item[data-current="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.queue-item.dragging {
  opacity: 0.5;
}
.queue-item.drop-target {
  border-color: var(--accent);
  border-style: dashed;
}

.queue-grip {
  color: var(--text-faint);
  cursor: grab;
  font-size: 14px;
  line-height: 1;
  flex: none;
  user-select: none;
}

.queue-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-length {
  color: var(--text-muted);
  font-weight: 450;
  font-family: var(--font-mono);
  font-size: 13px;
}

.queue-actions {
  display: flex;
  gap: var(--space-1);
  flex: none;
}
.queue-actions .btn {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.queue-add .field-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: 13px;
  font-weight: 550;
  color: var(--text-muted);
}

/* ---------- forms ---------- */

.field {
  margin-bottom: var(--space-3);
}
.field label,
.field-label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: 13px;
  font-weight: 550;
  color: var(--text-muted);
}
.field-value {
  float: right;
  font-family: var(--font-mono);
  font-weight: 450;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
input[type="text"]:hover,
input[type="number"]:hover,
select:hover {
  border-color: var(--accent);
}

.field-narrow input,
.field-narrow select {
  max-width: 200px;
}

input[type="range"] {
  width: 100%;
  max-width: 260px;
  height: 24px;
  accent-color: var(--accent);
  cursor: pointer;
}

.check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  font-size: 14px;
  cursor: pointer;
}
.check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex: none;
  cursor: pointer;
}

.task-form {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.task-form .field {
  flex: 1 1 200px;
  margin-bottom: 0;
}
.task-form .field-narrow {
  flex: 0 0 130px;
}
.task-form .field-narrow input {
  max-width: none;
}

/* ---------- task list ---------- */

.task-list,
.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.task-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 48px;
}
.task-item[data-active="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.task-item[data-done="true"] .task-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-check {
  flex: none;
}

.task-body {
  flex: 1 1 auto;
  min-width: 0;
}
.task-name {
  display: block;
  font-size: 14px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-progress {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
}

.task-actions {
  display: flex;
  gap: var(--space-1);
  flex: none;
}
.task-actions .btn {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.log-item {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-1) 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.log-time {
  flex: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}
.log-text {
  flex: 1 1 auto;
  min-width: 0;
}

/* ---------- stats ---------- */

.stat-row {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--space-3);
}

.stat {
  padding: var(--space-3);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
}
.stat-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  display: block;
  margin-top: var(--space-1);
  color: var(--text-muted);
  font-size: 12px;
}

.heatmap-scroll {
  overflow-x: auto;
  padding-bottom: var(--space-2);
}

.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 13px);
  gap: 3px;
  min-width: max-content;
}
.heat-cell {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: var(--heat-0);
}
.heat-cell[data-level="1"] {
  background: var(--heat-1);
}
.heat-cell[data-level="2"] {
  background: var(--heat-2);
}
.heat-cell[data-level="3"] {
  background: var(--heat-3);
}
.heat-cell[data-level="4"] {
  background: var(--heat-4);
}
.heat-cell[data-empty="true"] {
  background: transparent;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-3) 0 0;
  color: var(--text-muted);
  font-size: 12px;
}
.legend-cell {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: var(--heat-0);
}
.legend-cell[data-level="1"] {
  background: var(--heat-1);
}
.legend-cell[data-level="2"] {
  background: var(--heat-2);
}
.legend-cell[data-level="3"] {
  background: var(--heat-3);
}
.legend-cell[data-level="4"] {
  background: var(--heat-4);
}

.stat-summary {
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  height: 120px;
  padding-top: var(--space-2);
}
.bar {
  flex: 1 1 0;
  min-width: 8px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
}
.bar-fill {
  width: 100%;
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  background: var(--accent);
  transition: height 0.3s ease;
}
.bar-fill[data-zero="true"] {
  background: var(--ring-track);
}
.bar-label {
  margin-top: var(--space-1);
  color: var(--text-faint);
  font-size: 10px;
  text-align: center;
  font-family: var(--font-mono);
}

/* ---------- settings ---------- */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
}

.fieldset {
  margin: 0;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-sunken);
}
.fieldset legend {
  padding: 0 var(--space-2);
  font-size: 13px;
  font-weight: 650;
  color: var(--text-muted);
}

/* ---------- prose sections ---------- */

.prose {
  max-width: 74ch;
  margin: var(--space-7) auto 0;
}
.prose h2 {
  margin: 0 0 var(--space-3);
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.015em;
}
.prose h3 {
  margin: var(--space-5) 0 var(--space-2);
  font-size: 17px;
  font-weight: 620;
}
.prose p {
  margin: 0 0 var(--space-3);
  color: var(--text-muted);
}
.prose li {
  margin-bottom: var(--space-2);
  color: var(--text-muted);
}
.prose strong {
  color: var(--text);
}
.prose ol,
.prose ul {
  padding-left: 1.3em;
}

/* ---------- footer ---------- */

.site-footer {
  margin-top: var(--space-7);
  padding: var(--space-5) 0 var(--space-6);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
}
.site-footer p {
  margin: 0 0 var(--space-2);
}
.footer-links {
  display: flex;
  gap: var(--space-4);
}

/* ---------- distraction-free mode ---------- */

body.zen .site-header,
body.zen .site-footer,
body.zen .panels,
body.zen .prose,
body.zen .tagline,
body.zen h1 {
  display: none;
}
body.zen main.wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding-top: 0;
}
body.zen .hero {
  width: 100%;
  padding: 0;
}
body.zen .timer-card {
  margin-top: 0;
  border: none;
  box-shadow: none;
  background: transparent;
}
body.zen .ring-wrap {
  width: min(420px, 72vmin);
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  .wrap {
    padding: 0 var(--space-4);
  }
  .header-nav {
    display: none;
  }
  .header-actions {
    margin-left: auto;
  }
  .hero {
    padding: var(--space-6) 0 var(--space-5);
  }
  .panel {
    padding: var(--space-4);
  }
  .bar-label {
    font-size: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .site-header,
  .timer-controls,
  .site-footer {
    display: none;
  }
}
