:root {
  --bg: #0c1220;
  --panel: #141a28;
  --border: #252d3d;
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #7c9cff;
  --ok: #6bcf9b;
  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.25s ease, color 0.25s ease;
}

body { min-height: 100dvh; }

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
  min-height: 100dvh;
}

.loading {
  text-align: center;
  color: var(--muted);
  padding: 4rem 1rem;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  gap: 0.75rem;
}

.top-bar h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.theme-controls {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.theme-controls select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  font-family: inherit;
}

.dim-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
}

.quote {
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.45;
  margin: 0 0 0.35rem;
}

.quote-author {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.timer-display {
  font-size: 2.6rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin: 0.4rem 0 1rem;
  font-weight: 300;
}

.timer-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.habit-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem;
}

.habit-list li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0;
}

.habit-list input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--ok);
  flex-shrink: 0;
}

.habit-list .label {
  flex: 1;
  cursor: pointer;
  user-select: none;
}

.habit-list .done {
  text-decoration: line-through;
  color: var(--muted);
}

.habit-list .del-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  font-family: inherit;
}

.habit-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.habit-actions input,
.links-edit input {
  flex: 1;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 80%, black);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}

textarea {
  width: 100%;
  min-height: 90px;
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 80%, black);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
}

textarea:focus, input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 340px;
  overflow-y: auto;
}

.history-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

.history-item:last-child { border-bottom: none; }

.history-date {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.history-text {
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.5rem 0;
}

.links-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.links-list li {
  margin-bottom: 0.5rem;
}

.links-list a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
}

.links-list a:active {
  opacity: 0.7;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  border: none;
  font-size: 0.9rem;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.7rem;
  flex-wrap: wrap;
}

.btn-row .btn { flex: 1; min-width: 90px; }

.footer {
  text-align: center;
  padding: 1.5rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.footer button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
  font-family: inherit;
  margin-top: 0.4rem;
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.screen-header h1 {
  font-size: 1.2rem;
  margin: 0;
  font-weight: 600;
}

body.dim {
  filter: brightness(0.72);
}
