:root {
  --bg: #f6f1e6;
  --surface: #fffdf9;
  --surface2: #efe7d6;
  --ink: #33271b;
  --ink2: #8c7c65;
  --accent: #b8863a;
  --accent-soft: #f1e3c4;
  --accent-ink: #7a5a22;
  --accent2: #d4b06a;
  --sleep: #5b7fa8;
  --sleep-soft: #e7edf4;
  --walk: #6b8c5a;
  --walk-soft: #eaf0e3;
  --feed: #a05a72;
  --feed-soft: #f4e2e7;
  --mood: #7a6a9e;
  --mood-soft: #e9e5f2;
  --border: #e4dac6;
  --radius: 16px;
  --shadow: 0 4px 16px rgba(51,39,27,0.08);
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--serif); min-height: 100vh; }

/* ── Header ── */
header {
  background: var(--bg);
  border-bottom: 1.5px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 12px rgba(58,46,34,0.07);
}
header .logo-svg { height: 38px; width: auto; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.baby-switcher-btn, .lang-btn {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.72rem;
  cursor: pointer;
  color: var(--ink2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all 0.15s;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.baby-switcher-btn:hover, .lang-btn:hover { background: var(--border); color: var(--ink); }

/* ── Day nav ── */
.day-nav {
  position: relative;
  background: var(--surface2);
  border-bottom: 1.5px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.day-nav button {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--ink2);
  transition: all 0.15s;
}
.day-nav button:hover { background: var(--border); color: var(--ink); }
.day-nav button:disabled { opacity: 0.3; cursor: default; }
.day-nav .day-label {
  flex: 1;
  text-align: center;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.85rem;
  color: var(--ink);
  letter-spacing: 0.04em;
  cursor: pointer;
}
.date-picker-hidden {
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* ── Tab bar ── */
.tab-bar {
  display: flex;
  border-top: 1.5px solid var(--border);
  background: var(--surface);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -2px 12px rgba(58,46,34,0.07);
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 9px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--ink2);
  cursor: pointer;
  border-top: 2.5px solid transparent;
  transition: all 0.15s;
}
.tab-btn .tab-ic { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab-btn .tab-lbl { font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em; }
.tab-btn.active { color: var(--accent-ink); border-top-color: var(--accent); }

/* ── Main layout ── */
.main { max-width: 700px; margin: 0 auto; padding: 0 0 calc(150px + env(safe-area-inset-bottom, 0px)); }
.tab-page { display: none; }
.tab-page.active { display: block; }

/* ── Birthday banner ── */
.birthday-banner {
  margin: 16px 20px 0;
  background: linear-gradient(135deg, #c9963f 0%, #a3722a 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 8px 20px rgba(184,134,58,0.32);
  position: relative;
  overflow: hidden;
}
.birthday-banner.major {
  background: linear-gradient(135deg, var(--accent) 0%, #8a5a1c 100%);
  box-shadow: 0 10px 24px rgba(138,90,28,0.36);
}
.birthday-banner .bd-speck {
  position: absolute;
  background: rgba(255,255,255,0.45);
  border-radius: 1px;
  pointer-events: none;
}
.birthday-banner .bd-icon {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
}
.birthday-banner .bd-icon .ic { width: 21px; height: 21px; stroke: #fff; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.birthday-banner .bd-info { flex: 1; min-width: 0; }
.birthday-banner .bd-label {
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: rgba(255,255,255,0.78);
}
.birthday-banner .bd-headline { font-size: 1.05rem; font-weight: 600; margin-top: 2px; }

/* ── Sleep / walk banner ── */
.sleep-banner {
  margin: 16px 20px 0;
  background: linear-gradient(135deg, var(--sleep) 0%, #4d6f96 100%);
  color: white;
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 8px 20px rgba(91,127,168,0.32);
}
.sleep-banner.walk { background: linear-gradient(135deg, var(--walk) 0%, #567849 100%); box-shadow: 0 8px 20px rgba(107,140,90,0.32); }
.sleep-banner .sl-icon {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%;
  background: rgba(255,255,255,0.16);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.sleep-banner .sl-icon .ic { width: 20px; height: 20px; stroke: #fff; }
.sleep-banner .sl-icon .sl-dot {
  position: absolute; top: -1px; right: -1px; width: 9px; height: 9px;
  border-radius: 50%; background: #8fd18a; border: 2px solid var(--sleep);
  animation: pulse 2s ease-in-out infinite;
}
.sleep-banner.walk .sl-icon .sl-dot { border-color: var(--walk); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.sleep-banner .sl-info { flex: 1; }
.sleep-banner .sl-label { font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.85; }
.sleep-banner .sl-since { font-size: 0.95rem; }
.sleep-banner .wake-btn {
  background: white;
  color: var(--sleep);
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.sleep-banner.walk .wake-btn { color: var(--walk); }

/* ── Entry list ── */
.day-entries { padding: 16px 20px 0; }
.entry-group { margin-bottom: 4px; }
.entry-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
  cursor: pointer;
}
.entry-item:hover { border-color: var(--ink2); }
.entry-icon {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
}
.entry-icon .ic { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.entry-icon.tint-accent { background: var(--accent-soft); color: var(--accent-ink); }
.entry-icon.tint-feed { background: var(--feed-soft); color: var(--feed); }
.entry-icon.tint-mood { background: var(--mood-soft); color: var(--mood); }
.entry-icon.tint-sleep { background: var(--sleep-soft); color: var(--sleep); }
.entry-icon.tint-walk { background: var(--walk-soft); color: var(--walk); }
.entry-body { flex: 1; min-width: 0; }
.entry-type {
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink2);
  margin-bottom: 1px;
}
.entry-time { font-size: 0.9rem; color: var(--ink); line-height: 1.3; }
.entry-meta { font-size: 0.78rem; color: var(--accent2); font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace; }
.entry-note { font-size: 0.78rem; color: var(--ink2); font-style: italic; margin-top: 2px; }
.ip-badge {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.del-btn {
  background: none;
  border: none;
  color: var(--border);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s;
  flex-shrink: 0;
  display: flex;
}
.del-btn .ic { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.del-btn:hover { color: #c03030; }
.empty { text-align: center; color: var(--ink2); font-style: italic; padding: 48px 0; font-size: 0.9rem; }

/* ── Stats ── */
.stats-wrap { padding: 16px 20px 0; }
.settings-wrap { padding: 16px 20px 0; }
.baby-actions { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 18px; }
.baby-row { padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px dashed var(--border); }
.baby-row:last-child { border-bottom: none; }
.btn-small {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.72rem;
  cursor: pointer;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.btn-small.secondary { background: var(--surface2); color: var(--ink); border: 1.5px solid var(--border); }
.range-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.view-toggle { display: flex; align-items: center; gap: 8px; padding: 14px 20px 0; }
.tl-legend-slot { display: flex; flex-wrap: wrap; gap: 10px; margin-left: auto; justify-content: flex-end; }
.tl-legend-slot:empty { display: none; }
.timeline-wrap { padding: 16px 20px 20px; }
.tl-legend { display: flex; gap: 16px; margin-bottom: 10px; }
.tl-legend-item { display: flex; align-items: center; gap: 5px; }
.tl-legend-swatch { width: 12px; height: 2px; display: inline-block; }
.tl-lane-header { display: flex; align-items: center; justify-content: center; gap: 5px; }
.timeline-wrap .ic { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* Edge-of-day stretches drawn at a reduced scale — hatched so the squeeze is
   visible rather than silently distorting the timeline. */
.tl-squeezed {
  position: absolute;
  pointer-events: none;
  background: repeating-linear-gradient(
    -45deg,
    rgba(140,124,101,0.07) 0 4px,
    transparent 4px 9px
  );
}
.range-pill {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 20px;
  padding: 7px 14px; font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.72rem; color: var(--ink2); cursor: pointer; transition: all 0.15s;
}
.range-pill.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.custom-range { display: none; align-items: center; gap: 8px; margin-bottom: 14px; }
.custom-range.visible { display: flex; }
.custom-range input { flex: 1; min-width: 0; padding: 9px 10px; border: 1.5px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 0.85rem; background: var(--surface); color: var(--ink); }
.custom-range span { color: var(--ink2); }
.export-actions { display: flex; gap: 10px; }
.section-title {
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink2);
  margin: 20px 0 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.section-title:first-child { margin-top: 0; }
.section-title.with-action { display: flex; align-items: center; justify-content: space-between; }
.btn-tiny {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent-ink);
  padding: 3px 9px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.65rem;
  letter-spacing: 0.03em;
  text-transform: none;
  cursor: pointer;
}
.stats-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  margin-bottom: 4px;
}
.stat-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-card .s-label { display: flex; align-items: center; gap: 6px; font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--ink2); margin-bottom: 6px; }
.stat-card .s-label .ic { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.stat-card .s-val { font-size: 1.6rem; font-weight: 600; color: var(--accent-ink); line-height: 1; }
.stat-card .s-sub { font-size: 0.73rem; color: var(--ink2); margin-top: 4px; font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace; }
.stat-card.tint-sleep { background: var(--sleep-soft); }
.stat-card.tint-sleep .s-label, .stat-card.tint-sleep .s-val { color: var(--sleep); }
.stat-card.tint-walk { background: var(--walk-soft); }
.stat-card.tint-walk .s-label, .stat-card.tint-walk .s-val { color: var(--walk); }
.sleep-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.sleep-bar-bg { flex: 1; height: 9px; background: var(--surface2); border-radius: 5px; overflow: hidden; }
.sleep-bar { height: 100%; background: linear-gradient(90deg, var(--sleep), #7fa0c4); border-radius: 5px; }
.sleep-dur { font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace; font-size: 0.7rem; color: var(--ink2); width: 46px; text-align: right; }
.sleep-time { font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace; font-size: 0.68rem; color: var(--ink2); width: 88px; }

.growth-chart { margin-bottom: 18px; }
.growth-chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.growth-chart-label { font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.growth-chart-val { font-size: 1.1rem; font-weight: 600; color: var(--accent-ink); }
.growth-svg { width: 100%; height: 80px; display: block; }
.growth-chart-range { display: flex; justify-content: space-between; font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace; font-size: 0.68rem; color: var(--ink2); margin-top: 2px; }

/* ── FAB ── */
body:not(.log-active) .fab, body:not(.log-active) .quick-actions { display: none; }
.fab {
  position: fixed;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  right: 24px;
  width: 58px;
  height: 58px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(184,134,58,0.4);
  transition: all 0.2s;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fab .ic { width: 24px; height: 24px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; }
.fab:hover { transform: scale(1.08) rotate(90deg); background: var(--accent-ink); }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(42,31,20,0.55);
  z-index: 300;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px 20px 40px;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-header h2 { font-size: 1.1rem; font-weight: 300; }
.close-btn { background: var(--surface2); border: none; border-radius: 50%; width: 32px; height: 32px; cursor: pointer; color: var(--ink2); display: flex; align-items: center; justify-content: center; }
.close-btn .ic { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

/* Type picker */
.type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.type-tile {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px 8px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.type-tile:hover { border-color: var(--accent2); transform: translateY(-1px); }
.type-tile.selected { border-color: var(--accent); background: var(--accent-soft); }
.type-tile .t-icon { display: flex; align-items: center; justify-content: center; }
.type-tile .t-icon .ic { width: 22px; height: 22px; stroke: var(--ink2); fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.type-tile.selected .t-icon .ic { stroke: var(--accent-ink); }
.type-tile .t-label { font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink2); margin-top: 4px; }

/* Form fields */
.form-fields { display: none; }
.form-fields.visible { display: block; }
.field { margin-bottom: 14px; }
.field label { display: block; font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink2); margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); }
.dt-row { display: flex; gap: 8px; }
.dt-row input { flex: 1; min-width: 0; }
.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 13px 28px;
  border-radius: 9px;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.82rem;
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: all 0.15s;
  width: 100%;
  margin-top: 4px;
}
.btn:hover { background: var(--accent-ink); }

/* ── Quick actions ── */
.quick-actions {
  position: fixed;
  right: 96px;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: row-reverse;
  flex-wrap: wrap-reverse;
  align-content: flex-end;
  gap: 10px;
  max-width: calc(100vw - 106px);
  z-index: 100;
}
.quick-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(42,31,20,0.15);
  transition: all 0.15s;
}
.quick-btn:hover { border-color: var(--accent2); transform: translateY(-1px); }
.quick-btn .ic { width: 19px; height: 19px; stroke: var(--ink2); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.quick-btn.tint-sleep { background: var(--sleep-soft); border-color: var(--sleep); }
.quick-btn.tint-sleep .ic { stroke: var(--sleep); }
.quick-btn.tint-walk { background: var(--walk-soft); border-color: var(--walk); }
.quick-btn.tint-walk .ic { stroke: var(--walk); }

.quick-overlay { align-items: center; }
.quick-modal { max-width: 380px; border-radius: 20px; align-self: center; }
.quick-opt-row { display: flex; gap: 10px; flex-wrap: wrap; }
.quick-opt-btn {
  flex: 1;
  min-width: 90px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px 8px;
  cursor: pointer;
  text-align: center;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.78rem;
  color: var(--ink);
  transition: all 0.15s;
}
.quick-opt-btn:hover { border-color: var(--accent2); background: var(--accent-soft); }
.baby-switch-row { margin-bottom: 8px; text-align: left; }
.baby-switch-row.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.quick-emoji-btn {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 4px;
  cursor: pointer;
  text-align: center;
  font-size: 1.7rem;
  line-height: 1;
  transition: all 0.15s;
}
.quick-emoji-btn:hover { border-color: var(--accent2); background: var(--accent-soft); }

/* IP legend */
.ip-legend { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 20px 0; }
.ip-legend-item { display: flex; align-items: center; gap: 5px; font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace; font-size: 0.68rem; color: var(--ink2); }
.diaper-count { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 20px 0; }
.count-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 20px;
  padding: 6px 12px;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.72rem; color: var(--ink);
}
.count-chip .ic { width: 14px; height: 14px; stroke: var(--ink2); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ip-dot { width: 9px; height: 9px; border-radius: 50%; }

/* Toast */
.toast {
  position: fixed;
  bottom: calc(146px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: var(--ink);
  color: var(--bg);
  padding: 9px 20px;
  border-radius: 20px;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.78rem;
  opacity: 0;
  transition: all 0.25s;
  z-index: 999;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Login / register page ── */
.login-body { background: var(--bg); display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-wrap { width: 100%; max-width: 380px; }
.login-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 32px 24px;
  box-shadow: 0 8px 30px rgba(58,46,34,0.1);
}
.login-logo { display: block; height: 42px; width: auto; margin: 0 auto 24px; }
.login-error { color: #c03030; font-size: 0.82rem; text-align: center; margin-bottom: 12px; min-height: 1em; }
.login-error:empty { margin-bottom: 0; }
.login-info { color: #2a7a4a; font-size: 0.82rem; text-align: center; margin-bottom: 12px; min-height: 1em; }
.login-info:empty { margin-bottom: 0; }
.secondary-btn { background: var(--surface2); color: var(--ink); border: 1.5px solid var(--border); }
.secondary-btn:hover { background: var(--border); }
.login-switch { text-align: center; font-size: 0.82rem; color: var(--ink2); margin-top: 16px; }
.login-switch a { color: var(--accent-ink); text-decoration: none; }
.login-switch a:hover { text-decoration: underline; }
.field-hint { font-size: 0.72rem; color: var(--ink2); margin: -8px 0 12px; }
#totp-code { text-align: center; letter-spacing: 0.4em; font-size: 1.3rem; font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace; }

/* ── Security (Settings) ── */
.security-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.security-row:last-child { border-bottom: none; }
.security-row .s-name { font-size: 0.88rem; }
.security-row .s-sub { font-size: 0.72rem; color: var(--ink2); }
.totp-qr { display: flex; justify-content: center; margin: 14px 0; }
.totp-qr svg { width: 160px; height: 160px; background: #fff; padding: 8px; border-radius: 8px; }
.totp-secret { text-align: center; font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace; font-size: 0.78rem; color: var(--ink2); word-break: break-all; margin-bottom: 14px; }

/* ── Settings: tabbed layout ── */
.settings-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.settings-tab {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink2);
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}
.settings-tab.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.settings-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; position: relative; }
.settings-card.current { border-color: var(--accent2); }
.settings-card.add-card { border-style: dashed; border-color: var(--accent2); background: transparent; box-shadow: none; }
.settings-card-title { font-family: var(--serif); font-size: 1.02rem; font-weight: 500; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.pill-current {
  position: absolute; top: -9px; left: 16px;
  background: var(--accent); color: #fff;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.6rem; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 20px;
}
.count-pill {
  background: var(--accent-soft); color: var(--accent-ink);
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.66rem; letter-spacing: 0.04em; padding: 4px 10px; border-radius: 20px; flex-shrink: 0;
}
.ghost-add {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px; border: 1.5px dashed var(--accent2); border-radius: 12px;
  background: transparent; color: var(--accent-ink);
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.74rem; letter-spacing: 0.05em; text-transform: uppercase; cursor: pointer;
}
.avatar-circle {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 1rem; flex-shrink: 0;
}
.avatar-circle.sm { width: 30px; height: 30px; font-size: 0.82rem; }
.avatar-circle .ic { width: 19px; height: 19px; stroke: var(--accent-ink); fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.settings-card-title .ic { width: 18px; height: 18px; stroke: var(--accent-ink); fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.badge-role {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.62rem; letter-spacing: 0.04em; text-transform: uppercase; flex-shrink: 0;
}
.badge-role.owner { background: var(--accent-soft); color: var(--accent-ink); }
.badge-role.editor { background: var(--sleep-soft); color: var(--sleep); }
.badge-role.viewer { background: var(--mood-soft); color: var(--mood); }
.tile-check {
  position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(51,39,27,0.25);
}
.tile-check svg { width: 11px; height: 11px; stroke: #fff; stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
