:root {
  --bg: #0e0f14;
  --bg-soft: #11131b;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.12);
  --text: #f5f7ff;
  --muted: #b7bdd1;
  --primary: #7c9cff;
  --primary-strong: #5278ff;
  --danger: #ff6b6b;
  --accent: #46e0b3;
  --shadow: 0 10px 30px rgba(0,0,0,0.25);

  --header-footer-bg: var(--bg-soft);
  --header-footer-text: var(--muted);
}

:root.light {
  --bg: #f5f7fb;
  --bg-soft: #eef1f7;
  --card: rgba(255, 255, 255, 0.85);
  --card-border: rgba(0, 0, 0, 0.06);
  --text: #0b0d13;
  --muted: #495066;
  --primary: #3559ff;
  --primary-strong: #2949f0;
  --danger: #d94141;
  --accent: #12b886;

  --header-footer-bg: #fff;
  --header-footer-text: #222;
}

* { box-sizing: border-box; }

/* Base page */
html, body {
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 10% 10%, #1a1f34 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 20%, #1b2a2f 0%, transparent 60%),
    radial-gradient(1000px 500px at 50% 100%, #2e1b36 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.4;
  min-height: 100vh;
}

/* =================
   Header (single)
   ================= */
.app-header {
  background: var(--header-footer-bg);
  color: var(--header-footer-text);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between; /* logo/brand left, pills right */
  border-bottom: 1px solid var(--card-border);
  user-select: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  font-size: 24px;
  line-height: 1;
}

h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.4px;
}

/* Header right side pills */
.header-pills {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 9999px;
  font-size: 14px;
  background: var(--card);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  color: var(--header-footer-text);
  white-space: nowrap;
}

.pill .muted {
  opacity: 0.85;
  font-size: 12px;
}

/* Mantra pill (beside title) */
.mantra-pill {
  margin-left: 10px;
  max-width: 38ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--header-footer-text);
  background: var(--card);
  border: 1px solid var(--card-border);
}
/* Hide mantra on small screens */
@media (max-width: 768px) {
  .mantra-pill { display: none; }
}

/* Mobile header behavior (≤600px): hide weather, keep time pill */
@media (max-width: 600px) {
  #weatherPill { display: none; }

  .app-header {
    flex-direction: row;
    justify-content: space-between;
    flex-wrap: nowrap;
    text-align: left;
  }
  .header-pills { gap: 0; }
}

/* Make pills wrap nicely on ultra-small screens */
@media (max-width: 420px) {
  .header-pills { gap: 8px; }
  .pill { padding: 6px 10px; font-size: 13px; }
}

/* =================
   Canonical layout
   ================= */
main.grid {
  flex: 1;
  display: grid;
  place-content: center;           /* centers block vertically + horizontally */
  grid-template-columns: 1fr;      /* phones: stack */
  gap: 12px;                       /* compact vertical gap */
  padding: 20px;
}

/* Tablet: two columns, natural heights, balanced spacing */
@media (min-width: 700px) and (max-width: 1024px) {
  main.grid {
    display: grid;
    grid-template-columns: minmax(300px, 480px) minmax(280px, 420px);
    justify-content: center;       /* center the two-card block */
    align-items: start;            /* keep cards natural height (no stretch) */
    gap: 14px;                     /* balanced distance between cards */
  }
}

/* Desktop: two columns, centered, slightly tighter gap */
@media (min-width: 1025px) {
  main.grid {
    display: grid;
    grid-template-columns: minmax(320px, 520px) minmax(300px, 420px);
    justify-content: center;
    align-items: start;
    gap: 10px;                     /* close but not touching */
  }
}

/* =================
   Card base
   ================= */
.card {
  width: auto;
  max-width: 520px;                /* timer card’s original feel */
  height: auto;                    /* natural height */
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 30px 24px;
}

/* Card header */
.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

/* =================
   Buttons
   ================= */
.btn, .chip, .icon-btn {
  border: 1px solid var(--card-border);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0));
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .05s ease, background .2s ease, border-color .2s ease;
}

.btn:hover, .chip:hover, .icon-btn:hover {
  border-color: rgba(255,255,255,0.2);
}

.icon-btn:hover {
  border-color: var(--primary);
  background: var(--card);
}

.btn:active, .chip:active, .icon-btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  border-color: transparent;
  color: white;
}

.chip {
  padding: 8px 14px;
  font-size: 13px;
  user-select: none;
}

.chip.active {
  outline: 2px solid var(--primary);
}

.chip.danger {
  color: white;
  background: linear-gradient(180deg, var(--danger), #b83e3e);
  border-color: transparent;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-size: 20px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 50%;
  cursor: pointer;
}

.icon { font-size: 18px; }

/* =================
   Inputs
   ================= */
input[type="text"], input[type="number"], textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
  font-size: 16px;
}

input[type="text"]:focus, input[type="number"]:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(82,120,255,0.25);
}

/* =================
   Timer styles
   ================= */
.timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.timer-presets {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.timer-ring {
  position: relative;
  width: 280px;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring-bg, .ring-progress {
  fill: none;
  stroke-width: 12;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.ring-bg { stroke: rgba(255,255,255,0.15); }

.ring-progress {
  stroke-linecap: round;
  stroke: var(--primary);
  stroke-dasharray: 339.292;
  stroke-dashoffset: 339.292;
  transition: stroke-dashoffset .25s linear;
}

/* Timer readout inside the ring */
.timer-readout {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}

#timeDisplay {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 2px;
}

.timer-edit {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  color: var(--muted);
}

.timer-edit input[type="number"] {
  width: 90px;
  padding: 12px 14px;
  border-radius: 14px;
  text-align: center;
  -moz-appearance: textfield; /* Firefox */
}

.timer-edit input::-webkit-outer-spin-button,
.timer-edit input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.timer-controls {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

/* Inline label styling */
.inline {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
}

/* =================
   Accessibility
   ================= */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Smooth theme transitions */
* { transition: background-color .25s, color .25s, border-color .25s; }

/* =================
   Footer
   ================= */
.app-footer {
  background: var(--header-footer-bg);
  color: var(--header-footer-text);
  text-align: center;
  opacity: 0.9;
  padding: 12px 20px;
  border-top: 1px solid var(--card-border);
  user-select: none;
}

.app-footer a {
  color: white;
  text-decoration: underline; /* optional, to show it’s a link */
}

/* =================
   Tasks styles
   ================= */
.tasks-card .card-header { margin-bottom: 14px; }

.task-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 14px;
}

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.task-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 12px;
}

.task-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.task-title {
  line-height: 1.3;
  word-break: break-word;
}

.task-title.done {
  text-decoration: line-through;
  opacity: 0.6;
}

.task-delete {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--card-border);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.task-delete:hover { border-color: rgba(255,255,255,0.2); }

.task-empty {
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--card-border);
  border-radius: 12px;
  padding: 18px;
  margin-top: 6px;
}
.task-empty-emoji { font-size: 24px; margin-bottom: 6px; }

.task-footer {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
}

.task-filters { display: flex; gap: 8px; }
.task-filters .chip[aria-selected="true"] { outline: 2px solid var(--primary); }

/* Mobile niceties */
@media (max-width: 480px) {
  .task-input-row { grid-template-columns: 1fr auto; }
  .task-delete { width: 34px; height: 34px; }
}

/* Let the task list scroll inside the card if it grows, without stretching the layout */
.tasks-card { display: flex; flex-direction: column; }
.task-list { overflow: auto; max-height: 360px; } /* tweak if you want */

/* Equal height cards on tablet and desktop */
@media (min-width: 700px) {
  main.grid {
    align-items: stretch; /* cards stretch to equal height */
  }
  main.grid > .card {
    height: 100%;
    display: flex;
    flex-direction: column; /* keep content flow inside */
  }
}

/* Center all timer elements perfectly inside the card */
.timer {
  flex: 1;                        /* fill parent card */
  display: flex;
  flex-direction: column;
  justify-content: center;        /* vertical center */
  align-items: center;            /* horizontal center */
  gap: 24px;                      /* keep spacing consistent */
}

.timer-controls,
.timer-presets,
.timer-edit {
  justify-content: center;        /* make sure buttons/inputs are centered too */
  width: 100%;
}

/* Theme toggle pill */
.theme-toggle {
  cursor: pointer;
  user-select: none;
  transition: background 0.3s, color 0.3s;
}
.theme-toggle:hover {
  border-color: var(--primary);
}

/* Fix spacing for theme toggle on mobile */
@media (max-width: 600px) {
  /* Weather pill hidden, keep theme toggle aligned properly */
  .header-pills {
    gap: 6px;              /* small consistent gap */
  }
  #themeTogglePill {
    margin-left: 0;        /* remove any leftover offset */
  }
}

