:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --card-2: #fafafa;
  --border: rgba(0,0,0,0.08);
  --text: #1d1d1f;
  --text-2: #3a3a3c;
  --muted: #86868b;
  --accent: #0071e3;
  --danger: #ff3b30;
  --up: #0a7d2a;
  --down: #c0392b;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
  --radius: 20px;
  --radius-sm: 12px;
  --font-sans-system: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
                      "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-sans-rounded: ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --font-sans-inter: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
                     Roboto, Helvetica, Arial, sans-serif;
  --font-sans-karla: "Karla", -apple-system, BlinkMacSystemFont, "Segoe UI",
                     Roboto, Helvetica, Arial, sans-serif;
  --font-serif-newsreader: "Newsreader", "Iowan Old Style", "Palatino Linotype",
                           "Georgia", "Times New Roman", serif;
  --font-serif-plex: "IBM Plex Serif", "Iowan Old Style", "Georgia",
                     "Times New Roman", serif;
  --font-serif-spectral: "Spectral", "Iowan Old Style", "Palatino Linotype",
                         "Georgia", "Times New Roman", serif;
  --font-mono-sf: "Geist Mono", "SF Mono", "SFMono-Regular", "Menlo", "Consolas",
                  "Liberation Mono", "Courier New", monospace;
  --font-mono-plex: "IBM Plex Mono", "SF Mono", "Menlo", "Consolas",
                    "Courier New", monospace;
  --font-mono-chivo: "Chivo Mono", "SF Mono", "Menlo", "Consolas",
                     "Courier New", monospace;
  --font: var(--font-sans-system);
}

[data-theme="dark"] {
  --bg: #000000;
  --card: #1c1c1e;
  --card-2: #242426;
  --border: rgba(255,255,255,0.1);
  --text: #f5f5f7;
  --text-2: #d1d1d6;
  --muted: #8e8e93;
  --accent: #0a84ff;
  --up: #30d158;
  --down: #ff453a;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 16px;
  line-height: 1.5;
}
/* Text size preference — scales the whole UI uniformly via CSS zoom
   (16px × 1.125 = 18px effective body text in Larger) */
body.text-larger { zoom: 1.125; }

/* ---------- top bar ---------- */
.topbar {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.brand { display:flex; align-items:center; }
.brand-logo { height: 16px; width: auto; }
[data-theme="dark"] .brand-logo { filter: invert(1) brightness(2); }
.iconbtn svg { width: 20px; height: 20px; stroke-width: 2; }
[data-lucide] { display: inline-flex; }
.brand .title { font-size: 16px; letter-spacing: -0.01em; }
.clock { display:flex; align-items:baseline; gap:10px; }
.clock .time { font-weight:600; font-size:20px; font-variant-numeric: tabular-nums; letter-spacing:-0.02em; color: var(--text); }
.clock .date { color: var(--muted); font-size: 13px; }
.search input {
  width: 100%;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 0 14px;
  font-size: 15px;
  outline: none;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.controls { display:flex; gap:8px; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.iconbtn:hover { background: var(--card-2); }

/* ---------- footer ---------- */
.site-footer {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 20px 28px 32px;
  color: var(--muted); font-size: 12px;
  letter-spacing: .01em;
  flex-wrap: wrap;
}
.footer-dot { opacity: .5; }

/* ---------- grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  padding: 24px 28px 60px;
  max-width: 1600px;
  margin: 0 auto;
}

.card {
  grid-column: span 4;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 20px 22px;
  min-height: 240px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card.span-6 { grid-column: span 6; }
.card.span-8 { grid-column: span 8; }
.card.span-12 { grid-column: span 12; }
.card.tall { min-height: 360px; }

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
  flex-shrink: 0;
}
.card-title {
  font-size: 12px; font-weight: 600; color: var(--muted);
  letter-spacing: .08em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 6px;
}
.card-icon { width: 12px; height: 12px; stroke-width: 2; }
/* Brand-logo variant — uses CSS mask so the SVG silhouette inherits card color in both themes */
.card-icon-mask {
  display: inline-block;
  background: currentColor;
  -webkit-mask: var(--mask-url) center/contain no-repeat;
  mask: var(--mask-url) center/contain no-repeat;
}
/* Per-brand optical nudges so logos sit on the text baseline correctly */
[data-key="apple"] .card-icon-mask { transform: translateY(-2px); }
[data-key="producthunt"] .card-icon-mask { transform: translateY(-1px); }
.card-body { flex: 1; min-height: 0; }
.drag-handle { display: none; }
/* Placeholder where the dragged row will drop — faint */
.sortable-ghost { opacity: .2; }
/* Stationary original during drag — no transform (transforms on the original break the fallback clone's position:fixed coordinates) */
.sortable-chosen { opacity: .5; }
/* The cloned preview that follows the finger — lifted look */
.sortable-drag {
  background: var(--card) !important;
  box-shadow: 0 12px 28px rgba(0,0,0,0.3) !important;
  border-radius: 10px !important;
  transform: scale(1.03);
  opacity: 0.98 !important;
  cursor: grabbing;
  z-index: 10000 !important;
}
[data-theme="dark"] .sortable-drag { box-shadow: 0 12px 28px rgba(0,0,0,0.6) !important; }

/* Lock page/panel scroll while dragging so the drag preview stays under the finger */
body.sort-dragging { overflow: hidden; touch-action: none; }
body.sort-dragging #settings { overflow: hidden; touch-action: none; }

/* Sports league cycle & quote shuffle buttons — small muted icon in the card head */
.sports-cycle, .quote-shuffle {
  width: auto; height: auto; padding: 0;
  border: none; background: transparent;
  color: var(--muted); opacity: .5; transition: opacity .15s, color .15s;
}
.sports-cycle:hover, .quote-shuffle:hover { opacity: 1; color: var(--accent); }
.sports-cycle svg, .quote-shuffle svg { width: 14px; height: 14px; stroke-width: 2; }

/* ---------- Quote of the Day (full-width hero) ---------- */
/* Quotes card overrides the shared 240px min-height — it's a short hero, not a list */
.card[data-key="quotes"] { min-height: 0; padding-top: 14px; padding-bottom: 16px; }
.quote-hero {
  margin: 0;
  padding: 4px 20px 2px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.quote-text {
  margin: 0;
  max-width: 860px;
  font-family: var(--font-serif-newsreader);
  font-size: clamp(17px, 2.4vw, 30px);
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.quote-text::before { content: "\201C"; margin-right: 2px; }
.quote-text::after  { content: "\201D"; margin-left: 2px; }
.quote-author {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ---------- news / list items ---------- */
.news-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.news-item a {
  display: block;
  color: var(--text);
  text-decoration: none;
  padding: 10px 8px;
  margin: 0 -8px;
  border-bottom: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 500;
  transition: background-color .12s;
}
.news-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.news-item:last-child a { border-bottom: none; }
.news-item a:hover { background: var(--card-2); }
.news-desc {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 400;
  margin-top: 2px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.news-meta {
  display:flex; gap:8px; color: var(--muted);
  font-size: 12px; margin-top: 4px; font-weight: 400;
}

/* ---------- weather ---------- */
.weather-main { display:flex; align-items:center; gap:18px; margin-top: 4px; }
.weather-temp-row { display:flex; align-items:center; gap:10px; }
.weather-icon { font-size: 42px; line-height: 1; position: relative; top: 3px; }
.weather-temp {
  font-size: 48px; font-weight: 600;
  letter-spacing: -0.03em; line-height: 1; color: var(--text);
}
.weather-desc { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.weather-grid {
  display:grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin-top: 16px;
}
.weather-grid .cell {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--card-2);
  border: 1px solid var(--border);
}
.weather-grid .cell b {
  display:block; font-weight:600; font-size: 28px;
  letter-spacing: -0.02em;
  color: var(--text); margin-bottom: 6px;
}
.weather-grid .cell span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }

.forecast {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.fc-day {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
}
.fc-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.fc-icon { font-size: 22px; line-height: 1; }
.fc-temps { display: flex; gap: 6px; align-items: baseline; }
.fc-temps b { font-weight: 600; font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.fc-temps span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.weather-more {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; margin-top: 10px; padding: 8px 0;
  background: var(--card-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); font-size: 12px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; text-decoration: none;
  cursor: pointer; transition: color .12s, border-color .12s;
}
.weather-more:hover { color: var(--accent); border-color: var(--accent); }
.weather-more-icon { width: 12px; height: 12px; }

/* ---------- stocks ---------- */
.stocks { display: flex; flex-direction: column; gap: 2px; }
.stock {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items:center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.stock:last-child { border-bottom: none; }
.stock .sym { font-weight: 600; color: var(--text); }
.stock .px { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; }
.stock .chg {
  font-variant-numeric: tabular-nums; font-size: 12px;
  padding: 3px 8px; border-radius: 6px; font-weight: 600;
}
.chg.up { color: var(--up); background: color-mix(in srgb, var(--up) 14%, transparent); }
.chg.down { color: var(--down); background: color-mix(in srgb, var(--down) 14%, transparent); }

/* ---------- photo ---------- */
.card.photo { padding: 0; }
.card.photo .card-body { position: absolute; inset: 0; }
.card.photo img { width: 100%; height: 100%; object-fit: cover; display:block; }
.card.photo .card-head {
  position: absolute; top: 16px; left: 18px; right: 18px; z-index: 2; margin: 0;
}
.card.photo .card-title { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.apod-refresh {
  position: absolute; top: 12px; right: 12px; z-index: 3;
  width: 28px; height: 28px; display: grid; place-items: center;
  border: 0; border-radius: 8px; padding: 0; cursor: pointer;
  background: rgba(0,0,0,.25); color: rgba(255,255,255,.7);
  opacity: 0; transition: opacity .15s, background .15s, color .15s;
}
.apod-refresh svg { width: 14px; height: 14px; stroke-width: 2; }
.card.photo:hover .apod-refresh { opacity: 1; }
.apod-refresh:hover { background: rgba(0,0,0,.5); color: #fff; }
.card.photo .caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 40px 20px 18px;
  background: linear-gradient(to top, rgba(0,0,0,.85) 0%, rgba(0,0,0,.4) 60%, transparent 100%);
  color: #fff; font-size: 13px; line-height: 1.45;
}
.card.photo .caption b { display:block; margin-bottom: 4px; font-size: 15px; font-weight: 600; }

/* ---------- sports ---------- */
.sports-list { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap: 2px; }
.game {
  display:grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items:center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.game:last-child { border-bottom: none; }
.game .team { display:flex; align-items:center; gap: 10px; font-weight: 600; color: var(--text); min-width: 0; }
.team-logo { width: 24px; height: 24px; object-fit: contain; flex-shrink: 0; }
[data-theme="dark"] .team-logo { filter: brightness(1.05); }
.game .team.right { justify-content: flex-end; }
.game .score { font-weight:600; font-variant-numeric: tabular-nums; color: var(--text); }
.game .status {
  font-size: 11px; color: var(--muted); text-align:center;
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}

/* ---------- world clock ---------- */
.clocks-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; overflow: hidden; }
.card[data-key="clocks"] { container-type: inline-size; }
@container (max-width: 320px) {
  .clocks-row { grid-template-columns: repeat(2, 1fr); row-gap: 14px; }
}
.clock-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0; min-width: 0; }
.clock-face { width: 100%; max-width: 100px; aspect-ratio: 1; }
.clock-face .face { fill: var(--card-2); stroke: var(--border); stroke-width: 1; }
.clock-face .tick { stroke: var(--muted); stroke-width: 1.2; stroke-linecap: round; }
.clock-face .num {
  font-size: 8px; font-weight: 600; fill: var(--text);
  text-anchor: middle; dominant-baseline: central;
  font-family: var(--font);
}
.clock-face .hand { stroke: var(--text); stroke-linecap: round; }
.clock-face .hand.hour { stroke-width: 4; }
.clock-face .hand.minute { stroke-width: 2.5; }
.clock-face .hand.second { stroke: var(--accent); stroke-width: 1.2; }
.clock-face .center { fill: var(--accent); }
.clock-info { display: flex; flex-direction: column; align-items: center; gap: 1px; text-align: center; min-width: 0; width: 100%; }
.clock-label { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.clock-time { font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 500; letter-spacing: -0.01em; color: var(--text); white-space: nowrap; }
.clock-sub { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.clock-wx { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ---------- on this day ---------- */
.otd-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.otd-item a {
  display: grid; grid-template-columns: 56px 1fr; gap: 12px;
  align-items: baseline;
  padding: 10px 8px;
  margin: 0 -8px;
  border-bottom: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text); text-decoration: none;
  font-size: 14px; line-height: 1.4;
  transition: background-color .12s;
}
.otd-item:last-child a { border-bottom: none; }
.otd-item a:hover { background: var(--card-2); }
.otd-year { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; font-size: 14px; }
.otd-text { font-weight: 500; }
.otd-more {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; margin-top: 10px; padding: 8px 0;
  background: var(--card-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); font-size: 12px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
  cursor: pointer; transition: color .12s, border-color .12s;
}
.otd-more:hover { color: var(--accent); border-color: var(--accent); }
.otd-more-icon { width: 12px; height: 12px; }

/* ---------- states ---------- */
.loading, .error, .muted-block {
  color: var(--muted); font-size: 13px; padding: 8px 0;
}
.error { color: var(--danger); }

/* ---------- settings drawer ---------- */
.settings {
  position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 90vw;
  background: var(--card);
  border-left: 1px solid var(--border);
  padding: 22px 24px; overflow-y: auto;
  transform: translateX(0); transition: transform .25s ease;
  z-index: 20;
  box-shadow: -10px 0 40px rgba(0,0,0,.12);
}
.settings.hidden { transform: translateX(105%); }

/* ---------- Popup modals (What's New, Welcome) ---------- */
.popup-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 30;
}
.popup {
  position: fixed;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(440px, 92vw); max-height: 85vh; overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  padding: 24px 26px;
  z-index: 31;
}
.popup.hidden, .popup-backdrop.hidden { display: none; }
.popup-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.popup h3 { margin: 0; font-size: 18px; font-weight: 600; }
.popup-sub { color: var(--muted); font-size: 12px; margin-bottom: 16px; font-variant-numeric: tabular-nums; }
.popup-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.popup-list li {
  font-size: 14px; line-height: 1.45; color: var(--text);
  padding-left: 18px; position: relative;
}
.popup-list li::before {
  content: ""; position: absolute; left: 4px; top: 8px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.popup-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.popup-foot .btn { min-width: 80px; }

/* Welcome-specific extras */
.welcome-hero { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 20px; }
.welcome-logo { width: auto; height: 18px; margin-bottom: 12px; }
.welcome-hero h3 { font-size: 22px; margin-bottom: 4px; }
.welcome-hero .popup-sub { margin-bottom: 0; font-size: 14px; }
.settings-head { display:flex; justify-content:space-between; align-items:center; margin-bottom: 6px; }
.settings h3 { margin: 0; font-size: 18px; font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.toggles { display:flex; flex-direction:column; gap: 6px; margin: 14px 0; }
.toggle-row {
  display:flex; align-items:center; gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--card-2);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
}
.toggle-drag {
  width: 14px; height: 14px;
  color: var(--muted); cursor: grab; flex-shrink: 0; opacity: .5;
  padding: 12px;
  margin: -12px -6px -12px -12px;
  box-sizing: content-box;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .15s, color .15s, transform .15s;
}
.toggle-drag:active { cursor: grabbing; opacity: 1; color: var(--text); transform: scale(1.25); }
.toggle-label { flex: 1; }
.switch { position:relative; width: 34px; height: 20px; flex-shrink: 0; }
.switch input { display:none; }
.switch .slider {
  position:absolute; inset:0; background: #d1d1d6; border-radius: 999px;
  transition: background .15s;
  cursor: pointer;
}
[data-theme="dark"] .switch .slider { background: #3a3a3c; }
.switch .slider::before {
  content:""; position:absolute; top:2px; left:2px; width:16px; height:16px;
  background:#fff; border-radius:50%; transition: transform .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: #34c759; }
.switch input:checked + .slider::before { transform: translateX(14px); }

.settings-section {
  margin-top: 18px; display:flex; flex-direction:column; gap: 8px;
  padding-top: 18px; border-top: 1px solid var(--border);
}
.settings-section label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em;
}
.settings-section .row { display:flex; gap:8px; align-items:center; }
.settings-inline {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.settings-inline label { margin: 0; white-space: nowrap; flex-shrink: 0; }
.settings-inline select { flex: 0 0 auto; width: auto; min-width: 110px; }
.clock-inputs { display: flex; flex-direction: column; gap: 5px; }
.clock-inputs .row { display: grid; grid-template-columns: 90px 1fr; gap: 6px; }
.settings-section input, .settings-section select {
  flex: 1; height: 34px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card-2);
  color: var(--text); padding: 0 10px; font-size: 13px; outline: none;
  font-family: inherit;
}
.settings-section input:focus, .settings-section select:focus {
  border-color: var(--accent);
}
.btn {
  height: 34px; padding: 0 14px; border-radius: 8px;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  font-weight: 500; font-size: 13px; white-space: nowrap;
  font-family: inherit;
}
.save-btn { flex-shrink: 0; width: 60px; }
.btn:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); }
.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:hover { background: var(--card-2); filter: none; }
/* ---------- bookmarks card ---------- */
.bookmarks-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.bookmark-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 8px; border-radius: 12px; text-decoration: none;
  background: var(--card-2); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; font-weight: 500; text-align: center;
  line-height: 1.2;
  transition: background .15s;
}
.bookmark-tile:hover { background: var(--border); }
.bookmark-tile img { width: 36px; height: 36px; border-radius: 8px; }

/* ---------- calendar card ---------- */
.cal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.cal-item {
  display: grid; grid-template-columns: 42px 1fr; gap: 10px; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--border);
}
.cal-item:last-child { border-bottom: none; }
.cal-date { display: flex; flex-direction: column; align-items: center; }
.cal-mon { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.cal-item.is-holiday .cal-mon { color: var(--up); }
.cal-day { font-size: 20px; font-weight: 700; line-height: 1; color: var(--text); }
.cal-title { font-size: 13px; font-weight: 500; color: var(--text); }
.cal-time { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ---------- bookmarks settings ---------- */
.bookmark-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.bookmark-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px;
  border-radius: 8px; background: var(--card-2);
}
.bookmark-row img { width: 18px; height: 18px; border-radius: 4px; flex-shrink: 0; }
.bookmark-row-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-drag { color: var(--muted); cursor: grab; flex-shrink: 0; width: 16px; height: 16px; }
.bm-drag:active { cursor: grabbing; }
.bookmark-add-row { display: flex; flex-direction: column; gap: 6px; }
.icon-upload-btn {
  display: grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 8px; border: 1px solid var(--border); background: var(--card-2);
  cursor: pointer; color: var(--muted); transition: background .15s;
}
.icon-upload-btn:hover { background: var(--border); }
.icon-upload-btn svg { width: 15px; height: 15px; }

.settings-version {
  margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--muted); text-align: center; letter-spacing: .04em;
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .card { grid-column: span 6; }
  .card.span-8 { grid-column: span 12; }
}
@media (max-width: 720px) {
  .topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 8px 10px;
    padding: 10px 14px;
  }
  .topbar .brand { grid-column: 1; grid-row: 1; }
  .topbar .controls { grid-column: 2; grid-row: 1; display: flex; gap: 4px; }
  .topbar .controls .iconbtn svg { width: 16px; height: 16px; }
  .topbar .clock { display: none; }
  .topbar .search { grid-column: 1 / -1; grid-row: 2; }
  .topbar .search input { height: 36px; font-size: 14px; }
  .grid { padding: 12px; grid-template-columns: 1fr; gap: 12px; }
  .card, .card.span-6, .card.span-8, .card.span-12 { grid-column: 1 / -1; }
  .clocks-row { gap: 6px; }
  .clock-face { width: 80px; height: 80px; }
  .clock-label { font-size: 13px; }
  .clock-time { font-size: 12px; }
  .clock-sub { font-size: 9px; }
  .clock-wx { font-size: 11px; }
}

/* ---------- iOS PWA bottom tab bar ---------- */
.tabbar { display: none; }
body.ios-standalone .tabbar {
  display: flex;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  padding: 8px 12px calc(24px + env(safe-area-inset-bottom));
  gap: 4px;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border);
}
.tabbtn {
  flex: 1;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  transition: background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.tabbtn:active { background: var(--card-2); transform: scale(0.96); }
.tabbtn svg { width: 24px; height: 24px; stroke-width: 2; }
.tabbtn.spinning svg { animation: tabbar-spin 600ms ease-out; }
@keyframes tabbar-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* When in iOS standalone mode: hide duplicate top-bar buttons, center brand, pad for the tab bar */
body.ios-standalone .topbar #themeToggle,
body.ios-standalone .topbar #editToggle { display: none; }
body.ios-standalone .topbar {
  grid-template-columns: 1fr;
  grid-template-rows: auto auto;
  gap: 8px 10px;
}
body.ios-standalone .topbar .brand { grid-column: 1; grid-row: 1; justify-self: center; }
body.ios-standalone .topbar .clock { display: none; }
body.ios-standalone .topbar .search { grid-column: 1; grid-row: 2; }
body.ios-standalone main.grid { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
body.ios-standalone .site-footer { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
body.ios-standalone .settings { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  padding: 10px 16px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 1;
  transition: opacity .2s;
  pointer-events: none;
}
.toast.hidden { opacity: 0; visibility: hidden; }
body:not(.ios-standalone) .toast { bottom: 24px; }
