/* ============================================================
   prism-layout.css — Kenki Prism Shell & Sidebar Layout
   Extracted from dashboard.html for use on all authenticated pages
   ============================================================ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body, 'Inter', sans-serif);
  background: var(--ink, #1A1614);
  color: var(--prism-text, #F5F0E8);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Global Cormorant Garamond for all headings ── */
h1, h2, h3, h4, .card h2, .card h3 {
  font-family: var(--font-display, 'Cormorant Garamond', serif);
  font-weight: 400;
  font-variant-numeric: lining-nums;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: var(--border-color, #3D3530); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::selection { background: rgba(196,94,58,.3); color: var(--parchment); }

/* ── Global form dark theme ─────────────── */
select, .form-input[type="select"], select.form-input {
  background-color: var(--deep-stone, #1A1614) !important;
  color: var(--parchment, #F5F0E8) !important;
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238A7D70' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem;
}
select option { background: var(--deep-stone, #1A1614); color: var(--parchment, #F5F0E8); }

/* ── Global Kenki checkboxes ────────────── */
input[type="checkbox"] {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  width: 20px; height: 20px; flex-shrink: 0;
  border: 2px solid var(--border-color, #3D3530); border-radius: 50%;
  background: transparent; cursor: pointer; position: relative;
  transition: border-color .2s, background .2s;
}
input[type="checkbox"]:checked {
  background: var(--accent, #C45E3A); border-color: var(--accent, #C45E3A);
}
input[type="checkbox"]:checked::after {
  content: ''; position: absolute; top: 3px; left: 6px;
  width: 5px; height: 9px; border: solid var(--parchment, #F5F0E8);
  border-width: 0 2px 2px 0; transform: rotate(45deg);
}
input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent, #C45E3A); outline-offset: 2px; }

/* ── Global input teal borders ────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="tel"],
input[type="url"],
input[type="search"],
select,
textarea {
  border: 1px solid rgba(74,155,142,.3) !important;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="datetime-local"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  border-color: #4A9B8E !important;
  outline: none;
}

/* ── Global action buttons ──────────────── */
.btn-edit, .btn-del,
button[class*="edit"], button[class*="delete"],
button[onclick*="delete"], button[onclick*="Delete"] {
  background: transparent !important;
  border: 1px solid var(--border-color, #3D3530) !important;
  border-radius: 6px !important;
  font-size: 0.72rem !important;
  padding: 0.25rem 0.6rem !important;
  cursor: pointer !important;
  font-family: inherit !important;
  line-height: 1.4 !important;
  transition: background .15s, border-color .15s !important;
}
button[class*="edit"], .btn-edit { color: var(--sub, #8A7D70) !important; }
button[class*="delete"], .btn-del,
button[onclick*="delete"], button[onclick*="Delete"] { color: var(--sub, #8A7D70) !important; }
button[class*="edit"]:hover, .btn-edit:hover { background: rgba(196,94,58,.08) !important; border-color: var(--accent, #C45E3A) !important; }
button[class*="delete"]:hover, .btn-del:hover,
button[onclick*="delete"]:hover, button[onclick*="Delete"]:hover { background: rgba(231,76,60,.08) !important; border-color: rgba(231,76,60,.4) !important; }

/* ══════════════════════════════════════════
   LAYOUT SHELL
   ══════════════════════════════════════════ */
.prism-shell { display: flex; height: 100vh; overflow: hidden; }

/* ══════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════ */
.prism-sidebar {
  width: var(--sidebar-w, 240px);
  min-width: var(--sidebar-w, 240px);
  height: 100vh;
  background: var(--deep-stone, #231F1C);
  border-right: 1px solid var(--border-color, #3D3530);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  overflow: hidden;
  flex-shrink: 0;
}
[data-theme="light"] .prism-sidebar { background: #1A1614; border-right-color: #3D3530; }
[data-theme="light"] .prism-sidebar .sidebar-logo-text,
[data-theme="light"] .prism-sidebar .sidebar-nav-btn,
[data-theme="light"] .prism-sidebar .sidebar-user-name { color: #F5F0E8; }
[data-theme="light"] .prism-sidebar .sidebar-nav-btn { color: #A89B8C; }
[data-theme="light"] .prism-sidebar .sidebar-nav-btn.active { color: #F5F0E8; }
[data-theme="light"] .prism-sidebar .sidebar-user-plan { color: #6B5E53; }

.sidebar-logo { padding: 0 24px; margin-bottom: 40px; display: flex; align-items: center; gap: 12px; text-decoration: none; }
.sidebar-logo-text { font-family: var(--font-display); font-weight: 600; font-size: 20px; letter-spacing: 0.04em; color: var(--parchment); }
.sidebar-logo-gradient,
#kenki-gradient-text {
  font-family: 'Cormorant Garamond', serif !important;
  font-weight: 600 !important; font-size: 22px !important;
  letter-spacing: 0.04em !important;
  background: linear-gradient(90deg, #C45E3A 0%, #7A8B6F 50%, #4A9B8E 100%) !important;
  -webkit-background-clip: text !important; -webkit-text-fill-color: transparent !important;
  background-clip: text !important; color: transparent !important;
  display: inline-block !important;
}

.sidebar-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; }
.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

/* Module list */
.sidebar-modules-divider {
  padding: 12px 24px 6px; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.25em; color: var(--muted); font-family: var(--font-body); font-weight: 500;
  border-top: 1px solid var(--border-color); margin: 8px 12px 0; padding-top: 12px;
}
.sidebar-modules { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 1px; }
.sidebar-module-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; border-radius: 6px; border: none;
  background: transparent; color: var(--sub); font-size: 13px;
  font-family: var(--font-body); font-weight: 400; cursor: pointer;
  transition: all 0.2s ease; text-align: left; text-decoration: none;
}
.sidebar-module-btn:hover { background: rgba(245,240,232,0.05); color: var(--accent-light); }
.sidebar-module-btn .mod-icon { font-size: 14px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-module-btn.active { background: rgba(196,94,58,0.12); color: var(--parchment) !important; font-weight: 500; }
[data-theme="light"] .sidebar-module-btn { color: #A89B8C; }
[data-theme="light"] .sidebar-module-btn:hover { color: var(--accent-light); }
[data-theme="light"] .sidebar-modules-divider { color: #6B5E53; border-top-color: #3D3530; }

/* Nav buttons */
.sidebar-nav { padding: 0 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav-btn {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-radius: 6px; border: none;
  background: transparent; color: var(--sub); font-size: 13px;
  font-family: var(--font-body); font-weight: 400; cursor: pointer;
  transition: all 0.2s ease; text-align: left; position: relative;
  text-decoration: none;
}
.sidebar-nav-btn:hover { background: rgba(245,240,232,0.05); }
.sidebar-nav-btn.active { background: rgba(196,94,58,0.12); color: var(--parchment); font-weight: 500; }
.sidebar-nav-btn.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 2px 2px 0; background: var(--accent);
}
.sidebar-nav-btn .nav-icon { font-size: 16px; width: 24px; text-align: center; opacity: 0.6; }
.sidebar-nav-btn.active .nav-icon { opacity: 1; }

/* User section */
.sidebar-user {
  padding: 16px 24px; border-top: 1px solid var(--border-color); margin-top: auto;
  display: flex; align-items: center; gap: 10px;
}
[data-theme="light"] .sidebar-user { border-top-color: #3D3530; }
.sidebar-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(196,94,58,0.15); border: 1px solid rgba(196,94,58,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 500; color: var(--accent-light); font-family: var(--font-display);
}
.sidebar-user-name { font-size: 12px; font-weight: 500; color: var(--parchment); }
.sidebar-user-plan { font-size: 10px; color: var(--muted); }

/* ══════════════════════════════════════════
   MAIN CONTENT AREA
   ══════════════════════════════════════════ */
.prism-main { flex: 1; height: 100vh; overflow: auto; background: var(--ink); }

.prism-header {
  padding: 20px 32px; border-bottom: 1px solid var(--border-color);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--ink); position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(12px);
}
.prism-header h1 {
  font-family: var(--font-display); font-size: 24px; font-weight: 400;
  color: var(--prism-text); margin: 0;
  font-variant-numeric: lining-nums;
}
.prism-header .header-date { font-size: 11px; color: var(--muted); margin-top: 2px; }
.prism-header-right { display: flex; align-items: center; gap: 12px; }

.sync-badge {
  padding: 6px 14px; border-radius: 20px;
  background: rgba(122,139,111,0.12); border: 1px solid rgba(122,139,111,0.25);
  font-size: 11px; color: var(--sage); font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.sync-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--sage); }

.theme-toggle-btn {
  background: transparent; border: 1px solid var(--border-color);
  color: var(--sub); width: 34px; height: 34px; border-radius: 6px;
  cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.theme-toggle-btn:hover { border-color: var(--accent); color: var(--prism-text); }

.signout-btn {
  padding: 6px 14px; background: transparent; border: 1px solid var(--border-color);
  border-radius: 6px; color: var(--sub); font-size: 11px; font-family: var(--font-body);
  cursor: pointer; transition: all 0.2s;
}
.signout-btn:hover { border-color: #EF4444; color: #EF4444; }

.prism-content { padding: 32px; }

/* ── Tab views ── */
.tab-view { display: none; }
.tab-view.active { display: block; }

/* ══════════════════════════════════════════
   PRISM CARD SYSTEM
   ══════════════════════════════════════════ */
.p-card {
  background: var(--stone); border-radius: 8px;
  border: 1px solid var(--border-color); padding: 24px;
}
.p-card-title {
  font-family: var(--font-display); font-size: 18px; font-weight: 500;
  color: var(--prism-text); margin: 0 0 20px 0;
  font-variant-numeric: lining-nums;
}
.p-card-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.p-card-header .p-card-title { margin-bottom: 0; }
.p-card-meta { font-size: 10px; color: var(--muted); }

/* ── Stat cards ── */
.p-stat {
  background: var(--stone); border-radius: 8px;
  border: 1px solid var(--border-color); padding: 20px 24px;
  flex: 1; min-width: 0;
}
.p-stat-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.p-stat-label {
  font-size: 10px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.12em; font-family: var(--font-body);
}
.p-stat-icon { font-size: 14px; opacity: 0.5; }
.p-stat-value {
  font-size: 28px; font-weight: 300; color: var(--prism-text);
  font-family: var(--font-display); display: flex; align-items: baseline; gap: 4px;
  font-variant-numeric: lining-nums;
}
.p-stat-unit { font-size: 12px; color: var(--muted); }
.p-stat-sub { font-size: 11px; margin-top: 6px; font-weight: 400; }

/* ── Grids ── */
.stat-row { display: flex; gap: 16px; margin-bottom: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.grid-sidebar { display: grid; grid-template-columns: 280px 1fr; gap: 24px; margin-bottom: 24px; }

/* ── Chart containers ── */
.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap canvas { width: 100% !important; max-height: 160px; }
.chart-empty-msg {
  display: none; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.85rem; text-align: center;
  min-height: 120px;
}
.chart-empty-msg a { color: var(--accent); font-size: 0.8rem; }

/* ── Progress bars ── */
.p-progress { height: 6px; border-radius: 3px; background: var(--deep-stone); overflow: hidden; }
.p-progress-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }

/* ── Insight cards ── */
.insight-card {
  padding: 12px 14px; border-radius: 6px;
  background: var(--deep-stone); border-left: 3px solid var(--accent);
}
.insight-cat { font-size: 8px; text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 4px; }
.insight-title { font-size: 12px; color: var(--prism-text); line-height: 1.5; font-weight: 400; }
.insight-time { font-size: 9px; color: var(--muted); margin-top: 4px; }

/* ── Nav cards grid (overview module links) ── */
.nav-cards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; margin-top: 24px;
}
.module-card {
  background: var(--stone); border: 1px solid var(--border-color);
  border-radius: 8px; padding: 20px; text-decoration: none;
  color: var(--prism-text); transition: border-color 0.2s, transform 0.15s;
  display: block; position: relative;
}
.module-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.module-card-icon { font-size: 1.6rem; margin-bottom: 8px; }
.module-card h3 { font-size: 13px; font-weight: 600; margin-bottom: 4px; font-family: var(--font-body); }
.module-card p { font-size: 11px; color: var(--sub); }

/* ══════════════════════════════════════════
   RESPONSIVE — 900px (tablet / mobile)
   ══════════════════════════════════════════ */
/* Burger: visible only on mobile (lives inside .sidebar-logo-row) */
.sidebar-burger {
  display: none;
  background: none;
  border: 1px solid var(--border-color);
  color: var(--prism-text);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.sidebar-burger:hover { background: var(--stone); }

@media (max-width: 900px) {
  .prism-header { display: none !important; }

  /* Collapsed-by-default mobile nav: only the logo+burger row shows.
     Tightened from the original — small logo + small burger sit on a
     compact, no-padding row so the dashboard heading rides high. */
  .prism-sidebar--dashboard .sidebar-logo-row {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 2px 14px;
  }
  .sidebar-burger { display: inline-flex; padding: 2px 10px; font-size: 16px; }
  /* Hide the scroll body until the user taps the burger */
  .prism-sidebar--dashboard .sidebar-scroll {
    display: none;
  }
  body.mobile-nav-open .prism-sidebar--dashboard .sidebar-scroll {
    display: block;
    padding-top: 6px;
  }

  .prism-sidebar {
    display: flex; width: 100%; min-width: unset; height: auto;
    flex-direction: column; border-right: none;
    border-bottom: 1px solid rgba(61, 53, 48, 0.5); padding: 6px 0;
  }
  [data-theme="light"] .prism-sidebar { border-right: none; border-bottom: 1px solid rgba(61, 53, 48, 0.5); }
  html, body { height: auto; overflow: auto; }
  .prism-shell { flex-direction: column; height: auto; overflow: visible; }
  .prism-main { height: auto; overflow: visible; }

  /* Compact logo on mobile: smaller image + smaller wordmark */
  .sidebar-logo { margin-bottom: 0; padding: 0; gap: 8px; }
  .sidebar-logo img { height: 22px !important; }
  .sidebar-logo-text,
  .sidebar-logo #kenki-gradient-text { font-size: 17px; }
  .sidebar-user { padding: 8px 24px; }

  /* Main nav: horizontal scroll, with a mobile-friendly active state.
     Suppress the desktop left-edge accent bar (vertical) and replace it
     with a calm bottom underline that fits a horizontal tab pattern.
     A right-edge fade-mask hints that more items live off-screen. */
  .sidebar-nav {
    flex-direction: row; overflow-x: auto; gap: 4px; padding: 0 12px;
    -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
            mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
  .sidebar-nav::-webkit-scrollbar { display: none; }
  .sidebar-nav-btn { width: auto; flex-shrink: 0; white-space: nowrap; padding: 8px 14px; font-size: 12px; border-radius: 6px; }
  .sidebar-nav-btn.active { background: rgba(196,94,58,0.08); }
  .sidebar-nav-btn.active::before {
    left: 14px; right: 14px;
    top: auto; bottom: 4px;
    transform: none;
    width: auto; height: 2px;
    border-radius: 1px;
  }

  /* Hide sub-page sidebars on mobile — dashboard hamburger handles nav */
  .prism-sidebar:not(.prism-sidebar--dashboard) { display: none !important; }

  /* Dashboard sidebar stays visible and collapses horizontally */
  .prism-sidebar--dashboard .sidebar-modules-divider { margin: 4px 12px 0; padding: 8px 12px 4px; font-size: 9px; }
  .prism-sidebar--dashboard .sidebar-modules {
    flex-direction: row; overflow-x: auto; flex-wrap: nowrap; gap: 2px; padding: 0 12px 8px;
    -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
            mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
  .prism-sidebar--dashboard .sidebar-modules::-webkit-scrollbar { display: none; }
  .prism-sidebar--dashboard .sidebar-module-btn { width: auto; white-space: nowrap; padding: 6px 12px; font-size: 11px; flex-shrink: 0; }

  .sidebar-scroll { overflow-y: visible; overflow-x: hidden; }

  /* Compact stat cards */
  .stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .stat-row .p-stat { min-width: 0; }
  .p-stat { padding: 14px 16px; }
  .p-stat-top { margin-bottom: 8px; }
  .p-stat-value { font-size: 22px; }
  .p-stat-sub { font-size: 10px; }

  /* Tighter card padding + grid gaps */
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }
  .grid-sidebar { grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }
  .p-card { overflow: hidden; word-wrap: break-word; padding: 16px; }
  .p-card-title { font-size: 16px; margin-bottom: 12px; }
  .prism-content { padding: 16px 14px; }
}

/* ══════════════════════════════════════════
   RESPONSIVE — 768px (small mobile)
   ══════════════════════════════════════════ */
@media (max-width: 768px) {
  .prism-sidebar {
    position: sticky; top: 0; z-index: 100;
    background: var(--deep-stone);
  }
  [data-theme="light"] .prism-sidebar { background: #1A1614; }

  .sidebar-logo { display: none; }
  .sidebar-user { display: none; }

  .prism-main { margin-left: 0; width: 100%; padding: 0; }
  .prism-content { padding: 12px; }

  .prism-header h1 { font-size: 20px; }
  .prism-header { padding: 12px 16px; }
  .prism-header-right { gap: 8px; }
  .signout-btn { font-size: 10px; padding: 4px 10px; }
}

/* ══════════════════════════════════════════
   RESPONSIVE — 480px (small phones)
   ══════════════════════════════════════════ */
@media (max-width: 480px) {
  .sidebar-nav-btn { padding: 6px 10px; font-size: 11px; }
  .sidebar-nav-btn .nav-icon { font-size: 14px; width: 18px; }
  .sidebar-module-btn { padding: 5px 10px; font-size: 10px; }
  .sidebar-module-btn .mod-icon { font-size: 12px; }

  .stat-row { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .p-stat { padding: 12px; }
  .p-stat-value { font-size: 20px; }
  .p-stat-label { font-size: 9px; }
  .p-card { padding: 14px; }
  .p-card-title { font-size: 14px; margin-bottom: 10px; }
  .grid-sidebar { gap: 12px; }

  .chart-empty-msg { min-height: 80px !important; font-size: 0.78rem !important; }
  .chart-wrap canvas { max-height: 120px !important; }

  .nav-cards-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .module-card { padding: 14px; }
  .module-card-icon { font-size: 1.3rem; margin-bottom: 4px; }
  .module-card h3 { font-size: 12px; }
  .module-card p { font-size: 10px; }
}

/* ── Global small action buttons ── */
.btn-sm { background:transparent; border:1px solid var(--border-color); color:var(--sub); border-radius:6px; padding:4px 10px; font-size:.72rem; cursor:pointer; font-family:var(--font-body); transition:opacity .15s; }
.btn-sm:hover { opacity:.8; }
.btn-sm-edit { color:var(--accent); border-color:var(--accent); }
.btn-sm-success { color:#34d399; border-color:#34d399; }
.btn-sm-danger { color:#ef4444; border-color:#ef4444; }
.btn-sm-ghost { color:var(--sub); border-color:var(--border-color); background:transparent; }

/* ── Tri-color accent bars (copper/sage/teal) ── */
.p-card:nth-child(3n+1) { border-left: 3px solid #C45E3A; }
.p-card:nth-child(3n+2) { border-left: 3px solid #7A8B6F; }
.p-card:nth-child(3n+3) { border-left: 3px solid #4A9B8E; }

.p-stat:nth-child(3n+1) { border-left: 3px solid #C45E3A; }
.p-stat:nth-child(3n+2) { border-left: 3px solid #7A8B6F; }
.p-stat:nth-child(3n+3) { border-left: 3px solid #4A9B8E; }

.module-card:nth-child(3n+1) { border-left: 3px solid #C45E3A; }
.module-card:nth-child(3n+2) { border-left: 3px solid #7A8B6F; }
.module-card:nth-child(3n+3) { border-left: 3px solid #4A9B8E; }

.insight-card:nth-child(3n+1) { border-left-color: #C45E3A; }
.insight-card:nth-child(3n+2) { border-left-color: #7A8B6F; }
.insight-card:nth-child(3n+3) { border-left-color: #4A9B8E; }

/* ══════════════════════════════════════════
   MOBILE BOTTOM TABBAR
   ═════════════════════════════════════════
   Hidden by default; turned on inside the @media (max-width: 768px) block
   below. The dashboard markup ships the elements unconditionally; CSS gates
   visibility so desktop never sees them.

   Layout: 4 equal slots. Slot 2 is a raised FAB (Log) that opens a fan of
   5 quick-add tiles above it. Slot 4 (More) opens a bottom sheet listing
   every module + Profile/Settings/Sign-out. Active state = copper accent
   on the icon + a 2px copper underline (matches existing
   .sidebar-nav-btn.active treatment).
*/
.kenki-tabbar,
.kenki-fab-fan,
.kenki-fab-backdrop,
.kenki-sheet,
.kenki-sheet-backdrop {
  display: none;
}

@media (max-width: 768px) {
  /* ── Hide the existing burger row + horizontal-scroll sidebar ──
     The bottom nav owns navigation now. Page header (h1, view-title,
     theme toggle) lives inside .prism-content and stays visible. */
  .prism-sidebar--dashboard,
  .prism-sidebar--dashboard .sidebar-logo-row,
  .prism-sidebar { display: none !important; }

  /* Make sure the main column reclaims the space the sidebar left and
     leaves room at the bottom so the tabbar doesn't cover content. */
  .prism-main { margin-top: 0 !important; }
  .prism-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }

  /* The page-header "+ Quick log" button is redundant once the bottom
     tabbar's Log FAB is the primary quick-add. Hide on mobile; desktop
     (≥769px) keeps it since the tabbar isn't shown there. */
  #quick-log-btn,
  #quick-log-menu { display: none !important; }

  /* ── Tabbar shell ── */
  .kenki-tabbar {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 50;
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 0 8px env(safe-area-inset-bottom);
    background: rgba(35, 31, 28, 0.92);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
            backdrop-filter: blur(14px) saturate(140%);
    border-top: 1px solid rgba(196, 94, 58, 0.18);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
    align-items: stretch;
    justify-content: space-between;
    overflow: visible;          /* let the FAB poke above the bar */
    font-family: var(--font-body, 'Inter', sans-serif);
  }
  [data-theme="light"] .kenki-tabbar {
    background: rgba(245, 240, 232, 0.94);
    border-top: 1px solid rgba(196, 94, 58, 0.20);
  }

  /* ── Plain tab cell (Today / Insights / More) ── */
  .kenki-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: 0;
    padding: 8px 4px 6px;
    color: rgba(245, 240, 232, 0.55);
    font: inherit;
    cursor: pointer;
    transition: color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    position: relative;
  }
  [data-theme="light"] .kenki-tab { color: rgba(35, 31, 28, 0.55); }
  .kenki-tab__icon {
    font-size: 19px;
    line-height: 1;
    color: inherit;
  }
  .kenki-tab__label {
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: inherit;
    font-weight: 500;
  }
  .kenki-tab.is-active { color: var(--copper, #C45E3A); }
  .kenki-tab.is-active::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 30%;
    right: 30%;
    height: 2px;
    border-radius: 1px;
    background: var(--copper, #C45E3A);
  }

  /* ── Per-tab color identity ──────────────────────────────────────────
     Each tab adopts a Kenki brand color so the bar reads at a glance.
     Inactive tabs render at ~65% alpha so they recede behind the active
     selection; the active tab gets full alpha + the underline. Light
     theme uses the same hues — the tokens already account for legibility
     against the cream background. Specificity beats the generic
     `.kenki-tab.is-active` rule above because we add an attribute. */
  .kenki-tab[data-tab="today"]    { color: rgba(196, 94, 58, 0.65); }   /* copper  */
  .kenki-tab[data-tab="log"]      { color: rgba(122, 139, 111, 0.65); } /* sage    */
  .kenki-tab[data-tab="insights"] { color: rgba(74, 155, 142, 0.65); }  /* teal    */
  .kenki-tab[data-tab="more"]     { color: rgba(201, 162, 39, 0.75); }  /* gold    */

  .kenki-tab[data-tab="today"].is-active    { color: var(--k-copper, #C45E3A); }
  .kenki-tab[data-tab="log"].is-active,
  .kenki-tab--fab[data-tab="log"].kenki-fab--open { color: var(--k-sage, #7A8B6F); }
  .kenki-tab[data-tab="insights"].is-active { color: var(--k-teal, #4A9B8E); }
  .kenki-tab[data-tab="more"].is-active     { color: var(--k-gold, #C9A227); }

  /* Underline color follows the tab's brand color when active. */
  .kenki-tab[data-tab="today"].is-active::after    { background: var(--k-copper, #C45E3A); }
  .kenki-tab[data-tab="log"].is-active::after,
  .kenki-tab--fab[data-tab="log"].kenki-fab--open::after { background: var(--k-sage, #7A8B6F); }
  .kenki-tab[data-tab="insights"].is-active::after { background: var(--k-teal, #4A9B8E); }
  .kenki-tab[data-tab="more"].is-active::after     { background: var(--k-gold, #C9A227); }

  /* ── FAB cell (Log) — visually identical to the other tabs.
     Tapping opens a fan of 5 quick-add tiles above; while the fan is
     open the tab adopts the same active treatment as Today/Insights
     (copper text + underline) and the + glyph rotates to ×. ── */
  .kenki-tab--fab .kenki-tab__icon {
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .kenki-tab--fab.kenki-fab--open { color: var(--copper, #C45E3A); }
  .kenki-tab--fab.kenki-fab--open .kenki-tab__icon { transform: rotate(45deg); }
  .kenki-tab--fab.kenki-fab--open::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 30%; right: 30%;
    height: 2px;
    border-radius: 1px;
    background: var(--copper, #C45E3A);
  }

  /* ── FAB fan-out menu ── */
  .kenki-fab-backdrop {
    display: block;
    position: fixed; inset: 0;
    z-index: 60;
    background: rgba(0, 0, 0, 0.32);
    -webkit-tap-highlight-color: transparent;
    animation: kenki-fade-in 0.18s ease both;
  }
  .kenki-fab-backdrop[hidden] { display: none; }
  .kenki-fab-fan {
    display: flex;
    position: fixed;
    z-index: 70;
    bottom: calc(80px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    gap: 10px;
    padding: 12px 14px;
    /* Cap to viewport so longer labels (Supplements, Measurements,
       Appointments) can't push the bubble off-screen. Horizontal
       scroll inside the bubble is the safety fallback when even
       wrapped labels overflow on tiny screens. */
    max-width: calc(100vw - 16px);
    overflow-x: auto;
    scrollbar-width: none;
    background: rgba(35, 31, 28, 0.96);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
            backdrop-filter: blur(18px) saturate(150%);
    border: 1px solid rgba(196, 94, 58, 0.22);
    border-radius: 36px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.50);
    animation: kenki-fan-in 0.24s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }
  .kenki-fab-fan::-webkit-scrollbar { display: none; }
  [data-theme="light"] .kenki-fab-fan {
    background: rgba(245, 240, 232, 0.96);
    border: 1px solid rgba(196, 94, 58, 0.22);
  }
  .kenki-fab-fan[hidden] { display: none; }
  .kenki-fab-mini {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: 0;
    padding: 4px 2px;
    /* Fixed width so all 5 minis stay aligned regardless of label
       length — long labels wrap (or ellipsis-truncate) inside this
       footprint instead of stretching the row. */
    width: 60px;
    flex: 0 0 60px;
    color: rgba(245, 240, 232, 0.85);
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  [data-theme="light"] .kenki-fab-mini { color: rgba(35, 31, 28, 0.85); }
  .kenki-fab-mini__icon {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(196, 94, 58, 0.14);
    border: 1px solid rgba(196, 94, 58, 0.30);
    color: var(--copper, #C45E3A);
    font-size: 19px;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s ease, background 0.15s ease;
  }
  .kenki-fab-mini:active .kenki-fab-mini__icon {
    transform: scale(0.92);
    background: rgba(196, 94, 58, 0.22);
  }
  .kenki-fab-mini__label {
    font-size: 9px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(245, 240, 232, 0.7);
    font-weight: 500;
    /* Wrap to 2 lines max so "MEASUREMENTS" / "SUPPLEMENTS" /
       "APPOINTMENTS" stack cleanly under the icon without pushing
       the row width. */
    width: 100%;
    text-align: center;
    line-height: 1.15;
    word-break: break-word;
    hyphens: auto;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-height: 22px;
  }
  [data-theme="light"] .kenki-fab-mini__label { color: rgba(35, 31, 28, 0.65); }

  /* ── More bottom sheet ── */
  .kenki-sheet-backdrop {
    display: block;
    position: fixed; inset: 0;
    z-index: 60;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.22s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .kenki-sheet-backdrop[hidden] { display: none; }
  .kenki-sheet-backdrop.is-open { opacity: 1; }
  .kenki-sheet {
    display: flex;
    flex-direction: column;
    position: fixed;
    z-index: 70;
    left: 0; right: 0; bottom: 0;
    max-height: 80vh;
    padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
    background: rgba(35, 31, 28, 0.98);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
            backdrop-filter: blur(18px) saturate(150%);
    border-top: 1px solid rgba(196, 94, 58, 0.22);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.55);
    transform: translateY(100%);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden;
  }
  [data-theme="light"] .kenki-sheet {
    background: rgba(245, 240, 232, 0.98);
    border-top: 1px solid rgba(196, 94, 58, 0.22);
  }
  .kenki-sheet[hidden] { display: none; }
  .kenki-sheet.is-open { transform: translateY(0); }
  /* Drag handle — tap area is wider than the visible bar so it's an
     easy target even with fat fingers. The bar itself is 44px wide. */
  .kenki-sheet__handle {
    position: relative;
    width: 100%;
    height: 22px;
    margin: 0 0 4px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .kenki-sheet__handle::before {
    content: '';
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 44px; height: 4px;
    border-radius: 2px;
    background: rgba(245, 240, 232, 0.30);
  }
  [data-theme="light"] .kenki-sheet__handle::before { background: rgba(35, 31, 28, 0.22); }
  /* Close button — top-right of the sheet. Always visible while sheet
     is open. Generous tap target (44×44) regardless of glyph size. */
  .kenki-sheet__close {
    position: absolute;
    top: 8px; right: 10px;
    width: 36px; height: 36px;
    background: rgba(245, 240, 232, 0.06);
    border: 1px solid rgba(245, 240, 232, 0.10);
    border-radius: 50%;
    color: rgba(245, 240, 232, 0.70);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, color 0.15s ease;
    z-index: 1;
  }
  [data-theme="light"] .kenki-sheet__close {
    background: rgba(35, 31, 28, 0.06);
    border-color: rgba(35, 31, 28, 0.12);
    color: rgba(35, 31, 28, 0.70);
  }
  .kenki-sheet__close:active {
    background: rgba(196, 94, 58, 0.18);
    color: var(--copper, #C45E3A);
  }
  .kenki-sheet__title {
    font-family: var(--font-display, 'Cormorant Garamond', serif);
    font-size: 22px;
    font-weight: 400;
    font-style: italic;
    color: var(--parchment, #F5F0E8);
    text-align: center;
    margin-bottom: 12px;
  }
  [data-theme="light"] .kenki-sheet__title { color: #231F1C; }
  .kenki-sheet__list {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-bottom: 8px;
  }
  .kenki-sheet__row {
    display: flex;
    align-items: center;
    gap: 14px;
    background: none;
    border: 0;
    padding: 12px 14px;
    border-radius: 10px;
    color: rgba(245, 240, 232, 0.88);
    /* Match the italic Cormorant of the .kenki-sheet__title above —
     * Kaiser wanted the row labels in the same voice as the "More"
     * heading, so the whole sheet reads as one typographic family. */
    font-family: var(--font-display, 'Cormorant Garamond', serif);
    font-style: italic;
    font-size: 17px;
    font-weight: 400;
    letter-spacing: 0.005em;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }
  [data-theme="light"] .kenki-sheet__row { color: rgba(35, 31, 28, 0.85); }
  .kenki-sheet__row:active,
  .kenki-sheet__row:hover { background: rgba(196, 94, 58, 0.10); }
  .kenki-sheet__glyph {
    flex: 0 0 24px;
    width: 24px;
    text-align: center;
    color: var(--copper, #C45E3A);
    font-size: 16px;
  }
  .kenki-sheet__divider {
    height: 1px;
    background: rgba(245, 240, 232, 0.10);
    margin: 2px 14px;
  }
  [data-theme="light"] .kenki-sheet__divider { background: rgba(35, 31, 28, 0.10); }
  .kenki-sheet__row--danger { color: #ef4444; }
  .kenki-sheet__row--danger .kenki-sheet__glyph { color: #ef4444; }

  /* Lock body scroll while sheet/fan is open */
  body:has(.kenki-sheet:not([hidden])),
  body:has(.kenki-fab-fan:not([hidden])) {
    overflow: hidden;
  }
}

@keyframes kenki-fan-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px) scale(0.92); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@keyframes kenki-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
