/* ── icons: self-hosted SVG sprite, referenced via <svg class="icon"><use href="/icons/sprite.svg#icon-x"/></svg> ── */
.icon {
  width: 1.15em; height: 1.15em;
  stroke: currentColor; fill: none;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -0.2em;
  flex-shrink: 0;
}
.icon-lg { width: 1.6rem; height: 1.6rem; }
.icon-xl { width: 2.75rem; height: 2.75rem; stroke-width: 1.3; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  min-height: 100vh;
  transition: background var(--dur-med) var(--ease), color var(--dur-med) var(--ease);
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { letter-spacing: -0.01em; font-weight: 700; margin: 0; }

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

.sidebar {
  width: 220px;
  flex-shrink: 0;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 1.02rem;
  font-weight: 700;
  padding: 0 0.75rem 1.25rem;
  color: var(--ink);
}
.sidebar .brand .icon { color: var(--accent); }
.sidebar a {
  display: flex; align-items: center; gap: 0.65rem;
  color: var(--ink-soft);
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.sidebar .nav-section {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-soft); opacity: 0.65; padding: 0.9rem 0.75rem 0.3rem;
}
.sidebar a:hover { background: var(--accent-soft); color: var(--ink); }
.sidebar a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar .spacer { flex: 1; }

.main { flex: 1; padding: 2rem 2.5rem; max-width: 1100px; }
.main-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.75rem; }
.main-header h1 { font-size: 1.6rem; }

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 999px;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.theme-toggle:hover { box-shadow: var(--shadow-sm); }
.theme-toggle:active { transform: scale(0.92); }

.card {
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.4rem;
  transition: box-shadow var(--dur-med) var(--ease), transform var(--dur-med) var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); }

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { opacity: 0.9; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--accent-soft); }

input, select, textarea {
  font-family: inherit;
  background: var(--bg-elevated);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.widget { cursor: grab; }
.widget.sortable-ghost { opacity: 0.4; }
.widget-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.widget-title { font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; }
.widget-actions button {
  background: none; border: none; cursor: pointer; color: var(--ink-soft); font-size: 0.85rem; padding: 2px 5px;
}
.widget-metric { font-size: 2rem; font-weight: 700; }
.widget-sub { font-size: 0.82rem; color: var(--ink-soft); }

.habit-row, .list-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0; border-bottom: 1px solid var(--border);
}
.habit-row:last-child, .list-row:last-child { border-bottom: none; }
.habit-check {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.habit-check:active { transform: scale(0.9); }
.habit-check.done { background: var(--success); border-color: var(--success); color: white; }

.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 100; }
.toast {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.7rem 1rem; box-shadow: var(--shadow-md); font-size: 0.88rem;
  animation: toast-in var(--dur-med) var(--ease);
}
.toast.error { border-color: var(--danger); color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── progress ring: a single reusable radial-progress component ──
   usage: <div class="ring" style="--pct:72; --ring-color:var(--accent)">
            <svg viewBox="0 0 44 44"><circle class="ring-track" .../><circle class="ring-fill" .../></svg>
            <div class="ring-label">72%</div>
          </div> -- see js/components.js renderRing() which emits this markup. */
.ring { position: relative; width: 64px; height: 64px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--border); stroke-width: 3.5; }
.ring-fill {
  fill: none; stroke: var(--ring-color, var(--accent)); stroke-width: 3.5; stroke-linecap: round;
  stroke-dasharray: 113.1; /* 2*pi*18 */
  stroke-dashoffset: calc(113.1 - (113.1 * var(--pct, 0) / 100));
  transition: stroke-dashoffset 600ms var(--ease);
}
.ring-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 700; }
.ring-sm { width: 44px; height: 44px; }
.ring-sm .ring-label { font-size: 0.7rem; }

/* ── skeleton loading states: swap real content for these while a widget's data is in flight ── */
.skeleton {
  background: linear-gradient(100deg, var(--border) 30%, rgba(120,120,128,0.18) 50%, var(--border) 70%);
  background-size: 200% 100%;
  animation: skeleton-sheen 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-sheen { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.skeleton-text { height: 0.85em; margin: 0.3em 0; width: 100%; }
.skeleton-title { height: 1.4rem; width: 55%; margin-bottom: 0.6rem; }
.skeleton-circle { border-radius: 50%; }

/* ── empty states: every "nothing here yet" moment gets an icon, an explanation, and an action ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 0.6rem; padding: 2.5rem 1.5rem; color: var(--ink-soft);
}
.empty-state .icon-xl { color: var(--ink-soft); opacity: 0.55; }
.empty-state h3 { font-size: 1rem; color: var(--ink); }
.empty-state p { font-size: 0.88rem; max-width: 32ch; margin: 0; line-height: 1.5; }
.empty-state .btn { margin-top: 0.4rem; }

/* ── achievement / motivational cards ── */
.achievement-card {
  display: flex; align-items: center; gap: 0.85rem;
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
}
.achievement-card .icon-xl { color: var(--accent); }
.achievement-card h4 { font-size: 0.92rem; margin: 0 0 0.15rem; }
.achievement-card p { font-size: 0.82rem; color: var(--ink-soft); margin: 0; }

/* ── badges / tags (category chips, difficulty labels) ── */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  padding: 0.2rem 0.55rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.badge-neutral { background: var(--border); color: var(--ink-soft); }
.badge-success { background: rgba(30,142,62,0.14); color: var(--success); }
.badge-danger { background: rgba(217,48,37,0.12); color: var(--danger); }

.tag-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* ── section headers used throughout module pages ── */
.section-title {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-soft); margin: 0 0 0.75rem;
}

/* ── content grid + content cards (recipes, articles, exercises, products, oils) ── */
.content-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.content-card {
  display: flex; flex-direction: column; gap: 0.5rem;
  cursor: pointer;
}
.content-card-media {
  height: 120px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-soft), var(--border));
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft);
}
.content-card h4 { font-size: 0.95rem; }
.content-card p { font-size: 0.82rem; color: var(--ink-soft); margin: 0; line-height: 1.45; }

/* ── stat grid (dashboard "today" numbers) ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.9rem; }
.stat-cell { display: flex; flex-direction: column; gap: 0.2rem; }
.stat-cell .stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-cell .stat-label { font-size: 0.76rem; color: var(--ink-soft); }

/* ── search ── */
.search-box { position: relative; }
.search-box .icon { position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%); color: var(--ink-soft); }
.search-box input { padding-left: 2.2rem; width: 100%; }
.search-results { margin-top: 0.5rem; }
.search-result-group + .search-result-group { margin-top: 1rem; }

/* fade/slide transitions for content swaps */
[x-cloak] { display: none !important; }
.fade-enter { animation: fade-in var(--dur-med) var(--ease); }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { padding: 1.25rem; }
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}
