:root {
  color-scheme: light;
  --accent: #16a34a;
  --accent-active: #15803d;
  --on-accent: #ffffff;
  --bg: #f5f5f4;
  --card: #ffffff;
  --text: #1c1c1c;
  --muted: #8a8a8a;
  --border: #e5e5e5;
  --danger: #dc2626;
}

/* ---- themes (ids must match THEMES in src/routes/api.js and the <select> in index.html) ---- */

:root[data-theme="nord"] {
  color-scheme: dark;
  --accent: #88c0d0;
  --accent-active: #81a1c1;
  --on-accent: #2e3440;
  --bg: #2e3440;
  --card: #3b4252;
  --text: #eceff4;
  --muted: #aeb7c7;
  --border: #4c566a;
  --danger: #bf616a;
}

:root[data-theme="dracula"] {
  color-scheme: dark;
  --accent: #bd93f9;
  --accent-active: #a67cf0;
  --on-accent: #282a36;
  --bg: #282a36;
  --card: #343746;
  --text: #f8f8f2;
  --muted: #9ea8c7;
  --border: #44475a;
  --danger: #ff5555;
}

:root[data-theme="catppuccin-mocha"] {
  color-scheme: dark;
  --accent: #cba6f7;
  --accent-active: #b4befe;
  --on-accent: #1e1e2e;
  --bg: #181825;
  --card: #1e1e2e;
  --text: #cdd6f4;
  --muted: #a6adc8;
  --border: #313244;
  --danger: #f38ba8;
}

:root[data-theme="catppuccin-latte"] {
  color-scheme: light;
  --accent: #8839ef;
  --accent-active: #7287fd;
  --on-accent: #eff1f5;
  --bg: #e6e9ef;
  --card: #eff1f5;
  --text: #4c4f69;
  --muted: #6c6f85;
  --border: #ccd0da;
  --danger: #d20f39;
}

:root[data-theme="pastel"] {
  color-scheme: light;
  --accent: #c9a7eb;
  --accent-active: #b892e0;
  --on-accent: #3d3350;
  --bg: #fdf6f0;
  --card: #ffffff;
  --text: #4a4458;
  --muted: #8d859c;
  --border: #f0e4ec;
  --danger: #e5737f;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

input, button {
  font-family: inherit;
  font-size: 16px;
}

input {
  background: var(--card);
  color: var(--text);
}

input::placeholder {
  color: var(--muted);
}

/* ---- login page ---- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--card);
  border-radius: 16px;
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.login-card h1 {
  margin: 0 0 24px;
  font-size: 22px;
  text-align: center;
}

.login-card label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.login-card input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.login-card button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  cursor: pointer;
}

.login-card button:active {
  background: var(--accent-active);
}

.login-error {
  color: var(--danger);
  font-size: 14px;
  text-align: center;
  margin: -8px 0 16px;
}

/* ---- app shell ---- */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.tabs {
  flex: 1;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.icon-btn {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}

/* Native <select> stretched invisibly over the icon, so phones get their own picker UI. */
.theme-picker {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-picker select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  font-size: 16px;
}

.items {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 90px;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.item-check {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: transparent;
}

.item-check.done {
  background: var(--accent);
}

.item-body {
  flex: 1;
  min-width: 0;
}

.item-text {
  font-size: 16px;
  word-break: break-word;
}

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

.item-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.item-delete {
  flex: 0 0 auto;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 20px;
  padding: 4px 8px;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  font-size: 14px;
}

.add-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--border);
}

.add-bar input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.add-bar button {
  padding: 0 18px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
