:root {
  --theme-color: #6D8CFF;
  --bg: #0B1020;
  --bg-2: #131A33;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.1);
  --text: #E8ECFF;
  --text-dim: #9AA3C7;
  --accent: #6D8CFF;
  --accent-2: #A78BFA;
  --danger: #FF6B6B;
  --radius: 16px;
  --radius-sm: 10px;
  --space: 16px;
  --touch: 48px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}

[data-theme="dark-cosmic"] {
  --bg: #0B1020;
  --bg-2: #131A33;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.1);
  --text: #E8ECFF;
  --text-dim: #9AA3C7;
  --accent: #6D8CFF;
  --accent-2: #A78BFA;
}

[data-theme="oceanic-calm"] {
  --bg: #062028;
  --bg-2: #0A3340;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-2: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.12);
  --text: #E0F7FA;
  --text-dim: #8FC4CE;
  --accent: #3FB8C9;
  --accent-2: #7FE3D8;
}

[data-theme="minimal-zen"] {
  --bg: #F4EFE6;
  --bg-2: #ECE4D6;
  --surface: rgba(0, 0, 0, 0.04);
  --surface-2: rgba(0, 0, 0, 0.07);
  --border: rgba(0, 0, 0, 0.1);
  --text: #2E2A22;
  --text-dim: #7A7264;
  --accent: #9C8A6A;
  --accent-2: #C2A878;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  background: radial-gradient(ellipse at 50% 0%, var(--bg-2) 0%, var(--bg) 55%);
  min-height: 100dvh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
  max-width: 540px;
  margin: 0 auto;
  padding: var(--space);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px var(--space);
}
.topbar .brand {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 16px var(--accent);
}
.topbar nav { display: flex; gap: 6px; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 0 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, border-color 0.15s;
  font-family: inherit;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost.active { color: var(--accent); font-weight: 600; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 1.1rem; }
.btn-icon { padding: 0; width: var(--touch); height: var(--touch); border-radius: 50%; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space);
}

label { display: block; font-size: 0.82rem; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }

input, select, textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.field { margin-bottom: 14px; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.chip.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-color: transparent;
}

details.advanced {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-top: 12px;
}
details.advanced > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px var(--space);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary::after { content: "▾"; color: var(--text-dim); transition: transform 0.2s; }
details.advanced[open] > summary::after { transform: rotate(180deg); }
details.advanced > .advanced-body { padding: 0 var(--space) var(--space); }

.timer-display {
  font-size: clamp(3.5rem, 18vw, 6rem);
  font-weight: 200;
  text-align: center;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.center-col { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; text-align: center; gap: 12px; }

.muted { color: var(--text-dim); }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.center { text-align: center; }
.mt { margin-top: var(--space); }
.mt-sm { margin-top: 8px; }
.mb { margin-bottom: var(--space); }
.gap { gap: 10px; }
.hidden { display: none; }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  padding: 0;
  border-radius: 3px;
  background: var(--surface-2);
  min-height: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  z-index: 100;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

.starfield {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .starfield { display: none; }
  * { animation: none !important; transition: none !important; }
}

.alert { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: 0.9rem; }
.alert-error { border-color: var(--danger); color: var(--danger); }
.alert-info { color: var(--text-dim); }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px var(--space);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.list-item .meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list-item .title { font-weight: 600; }
.list-item .sub { font-size: 0.8rem; color: var(--text-dim); }
