/* ==================================================================
   PLOP — modern dashboard styling (Inter + bento grid + sidebar)
================================================================== */

/* ============ THEME TOKENS ============ */
:root {
  --bg:           #F7F2EA;
  --bg-elev:      #FFFFFF;
  --bg-soft:      #FDF9F3;
  --bg-sunken:    #EFE6D6;
  --surface:      #FFFFFF;
  --surface-alt:  #FAF4EB;

  --ink:          #1E1611;
  --ink-soft:     #5A4A3C;
  --ink-mute:     #8C7B6B;
  --ink-faint:    #B8A898;

  --accent:       #8B5E3C;
  --accent-2:     #C58558;
  --accent-soft:  #F2E0CC;
  --accent-fade:  rgba(139, 94, 60, 0.08);

  --good:  #4C8C5C;
  --warn:  #C97A3A;
  --bad:   #B4463A;
  --info:  #5B8DCF;

  --line:         #ECDFCB;
  --line-strong:  #D9C7AB;

  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius:    14px;
  --radius-sm: 10px;

  --shadow-sm: 0 1px 2px rgba(70, 45, 25, 0.04), 0 1px 3px rgba(70, 45, 25, 0.06);
  --shadow:    0 4px 12px rgba(70, 45, 25, 0.06), 0 2px 4px rgba(70, 45, 25, 0.05);
  --shadow-lg: 0 14px 40px rgba(70, 45, 25, 0.12), 0 4px 12px rgba(70, 45, 25, 0.06);

  --transition: 0.2s cubic-bezier(.2,.8,.2,1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Instrument Serif', Georgia, serif;

  --sidebar-w: 248px;
}

:root[data-theme="dark"] {
  --bg:           #16120E;
  --bg-elev:      #1F1A14;
  --bg-soft:      #1A1611;
  --bg-sunken:    #120E0A;
  --surface:      #221C15;
  --surface-alt:  #2A2219;

  --ink:          #F5ECE0;
  --ink-soft:     #C9BAA8;
  --ink-mute:     #8C7D6C;
  --ink-faint:    #5C4F40;

  --accent:       #D8A27A;
  --accent-2:     #E8B88B;
  --accent-soft:  #3C2E20;
  --accent-fade:  rgba(216, 162, 122, 0.12);

  --good:  #7BC08A;
  --warn:  #E3A571;
  --bad:   #E57262;
  --info:  #8AB3E3;

  --line:         #2F271E;
  --line-strong:  #3E3224;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow:    0 4px 12px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.icon-moon { display: none; }
[data-theme="dark"] .icon-moon { display: inline-block; }
[data-theme="dark"] .icon-sun  { display: none; }

/* ============ RESET ============ */
* { box-sizing: border-box; }
*, *::before, *::after { -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
}

input, select, textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-fade);
}
textarea { resize: vertical; min-height: 60px; }

::selection { background: var(--accent-soft); color: var(--accent); }

/* ============ SHELL ============ */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 16px;
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.side-logo {
  font-size: 22px;
  width: 38px;
  height: 38px;
  background: var(--accent-soft);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.side-brand-text h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.5px;
  line-height: 1;
}
.side-brand-text p {
  margin: 2px 0 0;
  font-size: 10.5px;
  color: var(--ink-mute);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-weight: 500;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  width: 100%;
  text-align: left;
}
.side-item:hover {
  background: var(--surface-alt);
  color: var(--ink);
}
.side-item.active {
  background: var(--accent);
  color: #fff;
}
[data-theme="dark"] .side-item.active { color: #1E1611; }
.side-item svg { flex-shrink: 0; }

.side-footer {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ============ MAIN ============ */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main-inner {
  padding: 36px 40px 60px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* Mobile topbar (hidden on desktop) */
.mobile-top {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 20;
  border-bottom: 1px solid var(--line);
}
.mobile-brand { display: flex; align-items: center; gap: 10px; }
.mobile-logo {
  font-size: 22px;
  width: 40px; height: 40px;
  background: var(--accent-soft);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.mobile-brand h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.5px;
  line-height: 1;
}
.mobile-tag {
  margin: 2px 0 0;
  font-size: 10px;
  color: var(--ink-mute);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.mobile-actions { display: flex; gap: 8px; }

/* ============ BOTTOM NAV (mobile) ============ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  justify-content: space-around;
  align-items: center;
  gap: 4px;
  z-index: 50;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.04);
}
.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  font-size: 10px;
  color: var(--ink-mute);
  font-weight: 500;
  transition: color var(--transition);
  border-radius: 10px;
}
.bnav-item.active { color: var(--accent); }
.bnav-item.active:not(.bnav-fab) svg { transform: scale(1.1); }
.bnav-item svg { transition: transform var(--transition); }
.bnav-fab {
  flex: 0;
  background: var(--accent);
  color: #fff !important;
  width: 52px; height: 52px;
  border-radius: 16px;
  margin-top: -18px;
  box-shadow: var(--shadow-lg);
}
[data-theme="dark"] .bnav-fab { color: #1E1611 !important; }

/* ============ VIEWS ============ */
.view { display: none; animation: fadeIn 0.3s ease; }
.view.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.view-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}
.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.view-title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 34px;
  letter-spacing: -1px;
  line-height: 1.1;
  color: var(--ink);
}
.view-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ BUTTONS ============ */
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 16px;
  transition: background var(--transition), transform var(--transition), border-color var(--transition);
}
.icon-btn:hover { background: var(--surface-alt); border-color: var(--line-strong); color: var(--ink); }
.icon-btn:active { transform: scale(0.95); }

.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
}
.btn-pill:hover { background: var(--surface-alt); border-color: var(--line-strong); transform: translateY(-1px); }
.btn-pill.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
[data-theme="dark"] .btn-pill.primary { color: #1E1611; }
.btn-pill.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-pill span { font-size: 15px; line-height: 1; }

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  padding: 13px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 15px;
  margin-top: 4px;
  letter-spacing: -0.01em;
  transition: background var(--transition), transform var(--transition);
}
[data-theme="dark"] .btn-primary { color: #1E1611; }
.btn-primary:hover { background: var(--accent-2); }
.btn-primary:active { transform: scale(0.99); }

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 9px 14px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  transition: background var(--transition);
}
.btn-secondary:hover { background: var(--line); }

.btn-danger {
  background: transparent;
  color: var(--bad);
  padding: 10px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  border: 1px solid var(--bad);
  width: 100%;
  margin-top: 10px;
  transition: background var(--transition);
}
.btn-danger:hover { background: var(--bad); color: #fff; }

.btn-row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.btn-row .btn-secondary { flex: 1; min-width: 120px; }

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 999px;
  gap: 2px;
}
.seg-btn {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-mute);
  transition: background var(--transition), color var(--transition);
}
.seg-btn.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ============ BENTO GRID ============ */
.bento {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto auto;
  gap: 14px;
  margin-bottom: 24px;
}
.bento-cell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition);
}
.bento-cell:hover { border-color: var(--line-strong); }
.bento-hero {
  grid-column: 1 / 3;
  grid-row: 1 / 3;
  background:
    radial-gradient(circle at 120% -20%, rgba(255,255,255,0.2), transparent 50%),
    radial-gradient(circle at -10% 120%, rgba(255,255,255,0.1), transparent 50%),
    linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  border-color: transparent;
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 280px;
  box-shadow: var(--shadow);
}
[data-theme="dark"] .bento-hero { color: #1E1611; }

.hero-meta-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.hero-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.85;
  font-weight: 600;
}
.hero-badge {
  padding: 5px 10px;
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(6px);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
[data-theme="dark"] .hero-badge { background: rgba(30,22,17,0.15); }

.hero-time {
  font-family: var(--font-serif);
  font-size: 56px;
  font-weight: 400;
  letter-spacing: -2px;
  line-height: 1;
  margin-bottom: 6px;
}
.hero-countdown {
  font-size: 15px;
  opacity: 0.95;
  font-weight: 500;
  margin-bottom: 20px;
}

.hero-progress { margin-bottom: 18px; }
.hero-progress-track {
  height: 6px;
  background: rgba(255,255,255,0.22);
  border-radius: 999px;
  overflow: hidden;
}
[data-theme="dark"] .hero-progress-track { background: rgba(30,22,17,0.18); }
.hero-progress-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(.2,.8,.2,1);
}
[data-theme="dark"] .hero-progress-fill { background: #1E1611; }
.hero-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  margin-top: 8px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  opacity: 0.8;
}

.hero-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.meta-chip {
  background: rgba(255,255,255,0.16);
  backdrop-filter: blur(8px);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
}
[data-theme="dark"] .meta-chip { background: rgba(30,22,17,0.12); border-color: rgba(30,22,17,0.1); }
.meta-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.85;
  margin-bottom: 3px;
  font-weight: 600;
}
.meta-value { display: block; font-size: 14px; font-weight: 600; }

/* Stat bento cells */
.stat-cell {
  display: flex;
  flex-direction: column;
  min-height: 132px;
}
.stat-cell .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--ink-mute);
  font-weight: 600;
  margin-bottom: 8px;
}
.stat-cell .stat-value {
  font-family: var(--font-serif);
  font-size: 42px;
  font-weight: 400;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -1.5px;
  margin-bottom: 4px;
}
.stat-cell .stat-trend {
  font-size: 12px;
  color: var(--ink-mute);
  font-weight: 500;
}
.stat-cell-accent {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
}
.stat-cell-accent .stat-value { color: var(--accent); }
.stat-spark {
  width: 100%;
  height: 28px;
  margin-top: auto;
  padding-top: 10px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============ TWO-COLUMN ============ */
.twocol {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 24px;
}
.twocol-cal { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--line-strong); }
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}
.card h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.2px;
  color: var(--ink);
}
.card-sub {
  font-size: 11.5px;
  color: var(--ink-mute);
  font-weight: 500;
}

.empty {
  color: var(--ink-mute);
  font-size: 13.5px;
  margin: 0;
  text-align: center;
  padding: 28px 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.hint { color: var(--ink-mute); font-size: 12.5px; margin: 4px 0 0; line-height: 1.5; }
.hint.tiny { font-size: 11px; margin-top: 20px; line-height: 1.5; opacity: 0.8; }

/* ============ FIELDS ============ */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.field-row .field { margin-bottom: 14px; }

.range-value {
  display: inline-block;
  font-size: 11.5px;
  color: var(--ink-mute);
  margin-top: 4px;
  font-weight: 500;
}

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  margin: 8px 0 4px;
  height: 22px;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--accent-soft);
  border-radius: 999px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px; height: 20px;
  background: var(--accent);
  border: 3px solid var(--surface);
  border-radius: 50%;
  margin-top: -7px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
input[type="range"]::-moz-range-track {
  height: 6px;
  background: var(--accent-soft);
  border-radius: 999px;
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  background: var(--accent);
  border: 3px solid var(--surface);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

/* ============ SUGGESTIONS ============ */
.suggestions {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 6px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}
.suggestions:empty { display: none; border: none; margin-top: 0; }
.suggestion {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--transition);
}
.suggestion:last-child { border-bottom: none; }
.suggestion:hover { background: var(--surface-alt); }
.suggestion .sug-name { font-weight: 500; font-size: 14px; }
.suggestion .sug-tags { font-size: 11px; color: var(--ink-mute); }

/* ============ SELECTED FOODS ============ */
.selected-foods {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 4px;
  margin-bottom: 14px;
}
.selected-foods:empty { margin-bottom: 0; }
.food-pill {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  animation: fadeIn 0.2s ease;
}
.food-pill button {
  color: var(--accent);
  font-weight: 700;
  padding: 0 0 0 4px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  opacity: 0.7;
  transition: opacity var(--transition);
}
.food-pill button:hover { opacity: 1; }

/* ============ BRISTOL SCALE ============ */
.bristol-scale {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 6px;
}
.bristol-opt {
  background: var(--surface-alt);
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  padding: 12px 6px;
  text-align: center;
  transition: all var(--transition);
}
.bristol-opt:hover { border-color: var(--line-strong); }
.bristol-opt span {
  display: block;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--accent);
  margin-bottom: 2px;
  line-height: 1;
}
.bristol-opt small {
  font-size: 10px;
  color: var(--ink-soft);
  line-height: 1.25;
  display: block;
}
.bristol-opt.selected {
  background: var(--accent);
  border-color: var(--accent);
}
.bristol-opt.selected span,
.bristol-opt.selected small { color: #fff; }
[data-theme="dark"] .bristol-opt.selected span,
[data-theme="dark"] .bristol-opt.selected small { color: #1E1611; }

/* ============ CHIPS ============ */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  transition: all var(--transition);
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.selected, .chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
[data-theme="dark"] .chip.selected,
[data-theme="dark"] .chip.active { color: #1E1611; }

/* ============ LISTS ============ */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.log-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
  transition: border-color var(--transition), background var(--transition);
}
.log-item:hover { border-color: var(--line-strong); }
.log-item .log-ico {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.log-item .log-body { flex: 1; min-width: 0; }
.log-item .log-title {
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}
.log-item .log-sub {
  font-size: 11.5px;
  color: var(--ink-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.log-item .log-del {
  color: var(--ink-mute);
  font-size: 16px;
  padding: 4px 8px;
  opacity: 0.5;
  border-radius: 6px;
  transition: all var(--transition);
}
.log-item .log-del:hover { opacity: 1; color: var(--bad); background: var(--accent-fade); }

/* ============ CALENDAR ============ */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.cal-header h3 { font-family: var(--font-serif); font-weight: 400; font-size: 20px; letter-spacing: -0.5px; margin: 0; }
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 6px;
}
.cal-weekdays span {
  text-align: center;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 0;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day {
  aspect-ratio: 1;
  background: var(--surface-alt);
  border: 1px solid transparent;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  position: relative;
  transition: all var(--transition);
  cursor: pointer;
  color: var(--ink);
}
.cal-day:hover:not(.empty) { border-color: var(--line-strong); }
.cal-day.empty { background: transparent; cursor: default; }
.cal-day.today { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.cal-day.selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-fade);
}
[data-theme="dark"] .cal-day.selected { color: #1E1611; }
.cal-day.predicted {
  background:
    repeating-linear-gradient(45deg, var(--accent-soft) 0, var(--accent-soft) 4px, var(--bg-soft) 4px, var(--bg-soft) 8px);
}
.cal-day .cal-dots {
  position: absolute;
  bottom: 4px;
  display: flex;
  gap: 2px;
}
.cal-day .dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  display: inline-block;
}
.dot-meal { background: var(--info); }
.dot-poop { background: var(--accent); }
.dot-pred { background: var(--warn); }
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 16px;
  font-size: 11.5px;
  color: var(--ink-soft);
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.cal-legend .dot { width: 8px; height: 8px; margin-right: 6px; }

/* ============ HISTORY ============ */
.history-day-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 18px 0 8px;
  padding-left: 4px;
}
.history-day-header:first-child { margin-top: 0; }

/* ============ INSIGHTS ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--line-strong); }
.stat-card .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--ink-mute);
  font-weight: 600;
  margin-bottom: 10px;
}
.stat-card .stat-value {
  font-family: var(--font-serif);
  font-size: 36px;
  font-weight: 400;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
  letter-spacing: -1px;
}
.stat-card .stat-sub { font-size: 11.5px; color: var(--ink-mute); font-weight: 500; }

.bristol-dist-wrap { display: flex; flex-direction: column; }
.bristol-dist {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  align-items: end;
  height: 140px;
}
.bristol-bar {
  background: linear-gradient(180deg, var(--accent-2) 0%, var(--accent) 100%);
  border-radius: 6px 6px 2px 2px;
  position: relative;
  min-height: 4px;
  transition: height 0.4s cubic-bezier(.2,.8,.2,1);
}
.bristol-bar span {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 600;
}
.bristol-bar.empty-bar { background: var(--surface-alt); border: 1px solid var(--line); }
.bristol-axis {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 8px;
}
.bristol-bar-label {
  text-align: center;
  font-size: 11px;
  color: var(--ink-mute);
  font-weight: 600;
}

.pattern-list, .impact-list { display: flex; flex-direction: column; gap: 6px; }
.pattern-item, .impact-item {
  padding: 11px 14px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  transition: border-color var(--transition);
}
.pattern-item:hover, .impact-item:hover { border-color: var(--line-strong); }
.pattern-item strong, .impact-item strong { color: var(--accent); font-weight: 600; }

/* ============ TIP CARD ============ */
.tip-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--surface-alt) 100%);
  border-color: var(--accent-soft);
}
.tip-ico {
  font-size: 22px;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.tip-card h3 { margin: 0 0 4px; color: var(--accent); }
.tip-card p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--ink); }

/* ============ MODAL ============ */
.modal {
  position: fixed; inset: 0;
  background: rgba(30, 22, 17, 0.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.25s ease;
}
.modal[hidden] { display: none; }
.modal-body {
  background: var(--bg-elev);
  border-radius: 24px 24px 0 0;
  padding: 24px 24px 30px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(.2,.8,.2,1);
  border: 1px solid var(--line);
  border-bottom: none;
}
@media (min-width: 600px) {
  .modal { align-items: center; }
  .modal-body { border-radius: var(--radius-xl); border-bottom: 1px solid var(--line); }
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.modal-header h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 24px;
  letter-spacing: -0.5px;
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s cubic-bezier(.2,.8,.2,1);
  letter-spacing: -0.01em;
}
.toast[hidden] { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
  .main-inner { padding: 28px 28px 40px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .bento { grid-template-columns: repeat(2, 1fr); }
  .bento-hero { grid-column: 1 / 3; grid-row: auto; }
}

@media (max-width: 820px) {
  :root { --sidebar-w: 0; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-top { display: flex; }
  .bottom-nav { display: flex; }
  .main-inner { padding: 20px 16px 100px; }
  .view-title { font-size: 28px; }
  .view-header { margin-bottom: 20px; }
  .hero-time { font-size: 44px; }
  .bento-hero { min-height: 240px; padding: 22px; }
  .twocol { grid-template-columns: 1fr; }
  .twocol-cal { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .bento { grid-template-columns: 1fr; }
  .bento-hero { grid-column: auto; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .hero-time { font-size: 38px; }
  .view-title { font-size: 24px; }
  .main-inner { padding: 16px 14px 100px; }
  .card { padding: 18px; }
  .bento-cell { padding: 18px; }
  .field-row { grid-template-columns: 1fr; }
  .btn-row .btn-secondary { min-width: 0; }
  .view-header { flex-direction: column; align-items: flex-start; }
  .view-actions { width: 100%; }
  .btn-pill { flex: 1; justify-content: center; }
}
