/* =========================================================
   Planr — global styles + theme system
   Themes are pure CSS variable blocks selected via
   document.documentElement.dataset.theme (see script.js).
   ========================================================= */

:root {
  --bg: #fff5f7;
  --card: #ffe4ea;
  --card-strong: #ffd1dc;
  --primary: #ff8fab;
  --primary-dark: #ff6b95;
  --text: #4a3540;
  --text-muted: #8a7480;
  --border: #ffd1dc;
  --shadow: rgba(255, 143, 171, 0.18);
  --success: #7fc99b;
  --danger: #e57373;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --sidebar-w: 220px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="blue"] {
  --bg: #f0f7ff;
  --card: #dceeff;
  --card-strong: #c9e4ff;
  --primary: #6fb3ff;
  --primary-dark: #4a9aff;
  --text: #26374a;
  --text-muted: #6c8299;
  --border: #c9e4ff;
  --shadow: rgba(111, 179, 255, 0.2);
}

[data-theme="lavender"] {
  --bg: #f5f0ff;
  --card: #e7dcff;
  --card-strong: #ddd0ff;
  --primary: #b99cff;
  --primary-dark: #a37fff;
  --text: #4b4163;
  --text-muted: #8577a3;
  --border: #ddd0ff;
  --shadow: rgba(185, 156, 255, 0.2);
}

[data-theme="sage"] {
  --bg: #f2f7f0;
  --card: #dfeedb;
  --card-strong: #c9e0c4;
  --primary: #7fa87f;
  --primary-dark: #63915f;
  --text: #33402f;
  --text-muted: #75907a;
  --border: #c9e0c4;
  --shadow: rgba(127, 168, 127, 0.2);
}

[data-theme="dark"] {
  --bg: #16162a;
  --card: #212140;
  --card-strong: #2b2b52;
  --primary: #b99cff;
  --primary-dark: #a37fff;
  --text: #ece9f7;
  --text-muted: #9d97b5;
  --border: #33335a;
  --shadow: rgba(0, 0, 0, 0.35);
  --success: #6fbf8f;
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: background 0.25s ease, color 0.25s ease;
}
button, input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

/* ---------- App shell ---------- */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-size: 1.3rem;
  font-weight: 700;
  padding: 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
  transition: background 0.15s ease, transform 0.1s ease;
}
.nav-link:hover { background: var(--card-strong); }
.nav-link.active {
  background: var(--primary);
  color: #fff;
}
.nav-icon { font-size: 1.1rem; }

.sidebar-pet {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.sidebar-pet .pet-emoji { font-size: 1.6rem; }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 2rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.topbar-title { font-size: 1.15rem; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }

.icon-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { transform: translateY(-1px); background: var(--card-strong); }

.theme-picker { position: relative; }
.theme-menu {
  position: absolute;
  right: 0;
  top: 48px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem;
  display: flex;
  gap: 0.5rem;
  box-shadow: 0 8px 24px var(--shadow);
  z-index: 10;
}
.theme-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  outline: 1px solid var(--border);
  background: var(--sw);
  cursor: pointer;
}
.theme-swatch.active { outline: 2px solid var(--primary-dark); }

.coin-balance {
  background: var(--card-strong);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}

.page-content {
  padding: 1.75rem 2rem 3rem;
  flex: 1;
}

/* ---------- Cards & generic components ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  box-shadow: 0 4px 16px var(--shadow);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.92rem;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--card-strong); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.82rem; }

.badge {
  display: inline-block;
  background: var(--card-strong);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
}

input[type="text"], input[type="date"], input[type="time"], input[type="number"],
input[type="email"], input[type="password"], input[type="url"], textarea, select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.92rem;
}
textarea { resize: vertical; min-height: 70px; }
label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: 0.3rem; }
.field { margin-bottom: 0.9rem; }
.field-row { display: flex; gap: 0.75rem; }
.field-row .field { flex: 1; }

.empty-state {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 1rem 0;
  text-align: center;
}

/* Generic visibility utility — used to toggle any element (buttons, fields,
   overlays, menus) regardless of its own display value. */
.hidden { display: none !important; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.modal h2 { font-size: 1.2rem; margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.6rem; margin-top: 1.2rem; }
.modal-actions .btn { flex: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--card-strong);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.85rem 1.4rem;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: 0 10px 30px var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Floating focus/music widget (public/js/floating-widget.js) ---------- */
.floating-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 230px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px var(--shadow);
  overflow: hidden;
  z-index: 500;
}
.floating-widget-header {
  cursor: grab;
  user-select: none;
  touch-action: none;
  padding: 0.5rem 0.75rem;
  background: var(--card-strong);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
}
.floating-widget-header.dragging { cursor: grabbing; }
.floating-widget-body {
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.floating-widget-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.floating-widget-label { font-size: 0.75rem; color: var(--text-muted); }
.floating-widget-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}
.floating-widget-controls { display: flex; gap: 0.35rem; }
.floating-widget-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
}
.floating-widget-btn:hover { background: var(--card-strong); }
.floating-widget-music iframe { display: block; }

/* ---------- Dashboard ---------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}
.dashboard-grid .span-full { grid-column: 1 / -1; }
.greeting h1 { font-size: 1.6rem; margin-bottom: 0.35rem; }
.greeting p { color: var(--text-muted); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.stat-tile {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}
.stat-tile .stat-value { font-size: 1.4rem; font-weight: 800; }
.stat-tile .stat-label { font-size: 0.78rem; color: var(--text-muted); }

.schedule-list { display: flex; flex-direction: column; gap: 0.6rem; }
.schedule-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border-left: 5px solid var(--primary);
}
.schedule-item .time { font-size: 0.8rem; color: var(--text-muted); min-width: 95px; }
.schedule-item .subject { font-weight: 600; }

.pet-card, .focus-card { text-align: center; }
.pet-card .pet-emoji-lg { font-size: 3.2rem; }
.pet-card .pet-name, .focus-pet .pet-name { font-weight: 700; margin-top: 0.4rem; }
.pet-card .pet-quote, .focus-pet .pet-quote { color: var(--text-muted); font-size: 0.85rem; margin: 0.5rem 0 1rem; min-height: 2.4em; }

.focus-card .timer-preview { font-size: 2.2rem; font-weight: 800; margin: 0.5rem 0 1rem; }

@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}

/* ---------- Timetable ---------- */
.timetable-wrap { overflow-x: auto; }
.timetable-grid {
  display: grid;
  grid-template-columns: 60px repeat(7, minmax(120px, 1fr));
  min-width: 900px;
}
.tt-corner { background: transparent; }
.tt-day-header {
  text-align: center;
  font-weight: 700;
  padding: 0.6rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
.tt-time-col {
  display: flex;
  flex-direction: column;
}
.tt-time-label {
  height: 60px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: right;
  padding-right: 0.5rem;
  transform: translateY(-0.6em);
}
.tt-day-col {
  position: relative;
  border-left: 1px solid var(--border);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 59px,
    var(--border) 59px,
    var(--border) 60px
  );
  cursor: crosshair;
}
.tt-block {
  position: absolute;
  left: 4px;
  right: 4px;
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  color: #fff;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--shadow);
}
.tt-block .tt-block-subject { font-weight: 700; display: block; }
.tt-block .tt-block-time { opacity: 0.85; font-size: 0.7rem; }

.color-swatches { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.color-swatch.selected { border-color: var(--text); }

/* ---------- Rich-text notes editor (contenteditable, no library) ---------- */
.richtext-toolbar { display: flex; gap: 0.35rem; margin-bottom: 0.4rem; }
.richtext-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
}
.richtext-btn:hover { background: var(--card-strong); }
.richtext-input {
  min-height: 70px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.92rem;
  overflow-y: auto;
}
.richtext-input:empty::before { content: attr(data-placeholder); color: var(--text-muted); }
.richtext-input ul { padding-left: 1.2rem; margin: 0.3rem 0; }

/* ---------- Tasks ---------- */
.task-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.task-form .field { flex: 1; min-width: 140px; margin-bottom: 0; }

.task-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin: 1.5rem 0 0.6rem;
}
.task-list { display: flex; flex-direction: column; gap: 0.5rem; }
.task-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
}
.task-item.done { opacity: 0.55; }
.task-item.done .task-title { text-decoration: line-through; }
.task-item input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 600; }
.task-meta { font-size: 0.78rem; color: var(--text-muted); display: flex; gap: 0.5rem; flex-wrap: wrap; }
.task-actions { display: flex; gap: 0.4rem; }

/* ---------- Focus timer ---------- */
.focus-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
}
.mode-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.mode-tab {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--card);
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-size: 0.85rem;
}
.mode-tab.active { background: var(--primary); color: #fff; }

.timer-ring {
  width: 260px;
  height: 260px;
  border-radius: 50%;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: conic-gradient(var(--primary) 0deg, var(--card-strong) 0deg);
  transition: background 0.3s linear;
}
.timer-ring-inner {
  width: 84%;
  height: 84%;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.timer-display { font-size: 2.6rem; font-weight: 800; }
.timer-mode-label { color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }

.timer-controls { display: flex; gap: 0.6rem; justify-content: center; }
.custom-minutes { max-width: 160px; margin: 0 auto 1.25rem; }

.focus-pet { text-align: center; }
.focus-pet .pet-emoji-lg { font-size: 3.5rem; transition: transform 0.2s ease; }
.focus-pet.celebrate .pet-emoji-lg { animation: bounce 0.6s ease infinite; }
@keyframes bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-14px) scale(1.08); }
}

.focus-extras {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

@media (max-width: 900px) {
  .focus-layout { grid-template-columns: 1fr; }
  .focus-extras { grid-template-columns: 1fr; }
}

/* ---------- Pet page ---------- */
.pet-hero { text-align: center; padding: 2rem 1rem; }
.pet-hero .pet-emoji-xl { font-size: 5rem; }
.pet-hero .pet-hero-name { font-size: 1.3rem; font-weight: 800; margin: 0.6rem 0 0.3rem; }

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}
.item-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.item-card .item-emoji { font-size: 2.2rem; }
.item-card .item-name { font-weight: 700; font-size: 0.9rem; }
.item-card .item-price { color: var(--text-muted); font-size: 0.82rem; }
.item-card.locked { opacity: 0.7; }
.item-card.active-item { outline: 2px solid var(--primary); }

/* ---------- Shop ---------- */
.shop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ---------- Settings ---------- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}
.theme-card {
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  background: var(--card);
}
.theme-card.active { border-color: var(--primary); }
.theme-preview {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-sm);
  margin-bottom: 0.6rem;
}

/* ---------- Onboarding ---------- */
.onboard-step { display: none; }
.onboard-step.active { display: block; }
.onboard-progress {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}
.onboard-progress span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--card-strong);
}
.onboard-progress span.active { background: var(--primary); }
.onboard-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.75rem; margin: 1rem 0; }
.onboard-option {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 0.5rem;
  text-align: center;
  cursor: pointer;
  background: var(--card);
}
.onboard-option.selected { border-color: var(--primary); background: var(--card-strong); }
.onboard-option .opt-emoji { font-size: 1.8rem; display: block; margin-bottom: 0.3rem; }

/* ---------- Unlockable wallpapers (applied to <body>) ---------- */
body.wallpaper-pink-clouds {
  background: radial-gradient(circle at 20% 20%, #ffe4ea 0%, #fff5f7 45%, #ffd1dc 100%);
}
body.wallpaper-night-room {
  background: radial-gradient(circle at 80% 10%, #2b2b52 0%, #1b1b34 45%, #16162a 100%);
}

/* ---------- Auth page (login/signup, no sidebar shell) ---------- */
.auth-page {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-divider { text-align: center; margin: 1rem 0; color: var(--text-muted); font-size: 0.85rem; }
.auth-switch { text-align: center; margin-top: 1rem; font-size: 0.85rem; color: var(--text-muted); }
.auth-switch a { color: var(--primary-dark); font-weight: 600; }

/* ---------- Landing page (public/index.html, no sidebar shell) ---------- */
/* Always forced to the sage theme (see index.html's inline script) — this is the
   pre-login marketing page, not a themed app screen a user has customized. */
.landing-page { background: var(--bg); }

.btn-lg { padding: 0.85rem 1.6rem; font-size: 1rem; border-radius: var(--radius-sm); }

.landing-hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 1.5rem 2rem 5rem;
}
.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto 3rem;
}
.landing-hero .btn-ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.55);
}
.landing-hero .btn-ghost:hover { background: rgba(255, 255, 255, 0.15); }

/* Inverted (white-on-green) so the main CTA pops against the hero gradient,
   instead of blending into it like the default green-on-green .btn-primary. */
.landing-hero .btn-primary { background: #fff; color: var(--primary-dark); }
.landing-hero .btn-primary:hover { background: #f2f7f0; }

.landing-hero-content {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}
.landing-hero-content h1 {
  font-size: 2.6rem;
  line-height: 1.15;
  margin-bottom: 1.1rem;
}
.landing-hero-content p {
  font-size: 1.05rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: 2rem;
}
.landing-hero-actions {
  display: flex;
  justify-content: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.landing-features {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}
.landing-features h2 {
  text-align: center;
  font-size: 1.6rem;
  margin-bottom: 2rem;
  color: var(--text);
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.25rem;
}
.landing-feature-card {
  display: block;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.landing-feature-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px var(--shadow);
}
.landing-feature-icon { font-size: 2rem; margin-bottom: 0.6rem; }
.landing-feature-card .card-title {
  text-transform: none;
  font-size: 1.05rem;
  letter-spacing: normal;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.landing-feature-card p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.55; }

.landing-cta-footer { text-align: center; margin-top: 3rem; }

@media (max-width: 640px) {
  .landing-hero { padding: 1.5rem 1.25rem 3.5rem; }
  .landing-hero-content h1 { font-size: 2rem; }
  .landing-features { padding: 2.5rem 1.25rem 3rem; }
}

/* ---------- Responsive shell ---------- */
@media (max-width: 768px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    flex-direction: row;
    align-items: center;
    padding: 0.5rem 0.75rem;
    z-index: 50;
    border-right: none;
    border-top: 1px solid var(--border);
  }
  .sidebar .brand, .sidebar-pet { display: none; }
  .nav { flex-direction: row; justify-content: space-around; width: 100%; }
  .nav-link { flex-direction: column; gap: 0.15rem; padding: 0.4rem; font-size: 0.65rem; }
  .nav-label { font-size: 0.62rem; }
  .main { padding-bottom: 4.5rem; }
  .page-content { padding: 1.25rem 1rem 2rem; }
  .topbar { padding: 1rem; }
}

/* ---------- Toolkit (calculator / notebook / mindmap) ---------- */

.toolkit-toolbar-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.toolkit-drawing-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
}
.toolkit-tool-group { display: flex; gap: 0.25rem; }
.toolkit-tool-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--card-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.95rem;
}
.toolkit-tool-btn.active { background: var(--primary); }
.toolkit-color-input {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
}
.toolkit-size-input { width: 100px; }

/* ---- Calculator ---- */
.toolkit-calc { max-width: 320px; margin: 0 auto; }
.toolkit-calc-display {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem 1.2rem;
  text-align: right;
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  overflow-x: auto;
  white-space: nowrap;
}
.toolkit-calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.6rem; }
.toolkit-calc-btn {
  border: none;
  background: var(--card-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 1.1rem 0;
  font-size: 1.15rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.1s ease;
}
.toolkit-calc-btn:hover { transform: translateY(-1px); }
.toolkit-calc-btn:active { transform: translateY(0); opacity: 0.85; }
.toolkit-calc-op { background: var(--primary); color: #fff; }
.toolkit-calc-wide { grid-column: span 2; }

/* ---- Shared draggable box (text box / sticky note / frame) ---- */
.toolkit-box {
  position: absolute;
  box-sizing: border-box;
  z-index: 1;
}
.toolkit-box-handle {
  position: absolute;
  top: -12px;
  left: 6px;
  width: 22px;
  height: 12px;
  border-radius: 4px 4px 0 0;
  background: var(--card-strong);
  border: 1px solid var(--border);
  border-bottom: none;
  cursor: grab;
}
.toolkit-box-delete {
  position: absolute;
  top: -12px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toolkit-box-body { width: 100%; height: 100%; }
.toolkit-box-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--text-muted) 50%);
  opacity: 0.6;
}
.toolkit-box-header { display: flex; align-items: center; gap: 0.35rem; padding: 0.25rem 0.35rem; }
.toolkit-box-swatch {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}

.toolkit-textbox {
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}
.toolkit-textbox-input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  resize: none;
  font-family: var(--font);
  padding: 0.5rem;
  box-sizing: border-box;
}
.toolkit-textbox-input:focus { outline: 1px solid var(--primary); }

.toolkit-sticky {
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 16px var(--shadow);
  display: flex;
  flex-direction: column;
}
.toolkit-sticky .toolkit-box-body { display: flex; flex-direction: column; }
.toolkit-sticky-input {
  flex: 1;
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  font-family: var(--font);
  padding: 0 0.6rem 0.6rem;
  box-sizing: border-box;
  color: #3a3a2a;
}
.toolkit-sticky-input:focus { outline: none; }

.toolkit-frame {
  border: 2px dashed;
  border-radius: var(--radius-sm);
  pointer-events: none;
}
.toolkit-frame .toolkit-box-handle,
.toolkit-frame .toolkit-box-delete,
.toolkit-frame .toolkit-box-resize,
.toolkit-frame .toolkit-box-header { pointer-events: auto; }
.toolkit-frame-label {
  border: none;
  background: transparent;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  flex: 1;
  min-width: 0;
}
.toolkit-frame-label:focus { outline: none; }

.toolkit-drawing-canvas {
  position: absolute;
  top: 0;
  left: 0;
  touch-action: none;
  /* Always the top layer regardless of DOM insertion order — a box added mid-
     session (after the canvas already exists) would otherwise land later in
     the DOM and unintentionally sit above the canvas, blocking drawing/ink in
     that area. See toolkit-drawing.js/toolkit-mindmap.js. */
  z-index: 5;
}

/* ---- Notebook page (ruled by default, grid on odd-indexed pages) ---- */
.toolkit-notebook-viewport {
  overflow: auto;
  max-height: 75vh;
  padding: 1.5rem;
  background: var(--card-strong);
  border-radius: var(--radius);
}
.toolkit-notebook-page {
  position: relative;
  margin: 0 auto;
  background-color: #fffdf7;
  background-image: repeating-linear-gradient(to bottom, transparent, transparent 31px, #cfe0ea 31px, #cfe0ea 32px);
  box-shadow: 0 4px 20px var(--shadow);
  border-radius: 4px;
}
.toolkit-notebook-page.toolkit-page-grid {
  background-image:
    repeating-linear-gradient(to bottom, transparent, transparent 27px, #d7e6de 27px, #d7e6de 28px),
    repeating-linear-gradient(to right, transparent, transparent 27px, #d7e6de 27px, #d7e6de 28px);
}

/* ---- Mindmap board ---- */
.toolkit-mindmap-viewport {
  overflow: auto;
  max-height: 75vh;
  padding: 1rem;
  background: var(--card-strong);
  border-radius: var(--radius);
}
.toolkit-mindmap-board {
  position: relative;
  background-color: var(--bg);
  background-image:
    linear-gradient(to bottom, var(--border) 1px, transparent 1px),
    linear-gradient(to right, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
}

@media (max-width: 768px) {
  .toolkit-notebook-viewport, .toolkit-mindmap-viewport { max-height: 60vh; }
}
