:root {
  color-scheme: light;
  --bg: #fbfafc;
  --ink: #211d2f;
  --muted: #6f6a7d;
  --line: #d4d5e6;
  --soft-line: #ecebf5;
  --surface: #f4f3fa;
  --surface-alt: #e3eeeb;
  --primary: #7b6ba4;
  --primary-dark: #5f4f86;
  --primary-soft: #a096c8;
  --primary-pale: #d4d5e6;
  --primary-rgb: 123, 107, 164;
  --date: #2f8f79;
  --date-dark: #1f6f5e;
  --date-soft: #dceee9;
  --date-pale: #eef8f5;
  --date-rgb: 47, 143, 121;
  --confirmation-green: #e5f3ed;
  --confirmation-green-strong: #176b55;
  --attention: #85648e;
  --danger: #b04967;
  --meal: #4f7ec7;
  --breakfast: #a995d6;
  --lunch: #7b6ba4;
  --dinner: #574873;
  --snack: #68a7d6;
  --drink: #3b9fb5;
  --wellbeing: #2f8f79;
  --note: #7c8491;
  --medication: #c7839b;
  --radius-xs: 3px;
  --radius-sm: 4px;
  --radius-md: 5px;
  --radius-lg: 6px;
  --shadow: 0 16px 40px rgba(58, 49, 82, 0.1);
  --night-canvas: oklch(23% 0.055 285);
  --night-surface: oklch(28% 0.05 285);
  --night-elevated: oklch(32% 0.045 282);
  --twilight-horizon: oklch(61% 0.105 330);
  --night-event-icon: #f8f7ff;
  --photo-capture-sky:
    radial-gradient(circle at 88% 18%, rgba(104, 215, 189, 0.32), transparent 28%),
    radial-gradient(circle at 14% 112%, rgba(160, 150, 200, 0.38), transparent 38%),
    linear-gradient(135deg, #332b4c, #554879 68%, #306f67);
  --dawn-horizon: oklch(84% 0.075 73);
  --nutrition-protein: oklch(66% 0.12 156);
  --nutrition-fat: oklch(73% 0.13 69);
  --nutrition-carbs: oklch(68% 0.11 323);
  --nrsk-sky-top: oklch(84% 0.055 244);
  --nrsk-sky-bottom: oklch(97% 0.018 82);
}

html[data-theme="night"] {
  color-scheme: dark;
  --bg: var(--night-canvas);
  --ink: oklch(94% 0.025 286);
  --muted: oklch(75% 0.035 286);
  --line: oklch(72% 0.045 285 / 0.28);
  --soft-line: oklch(72% 0.04 285 / 0.16);
  --surface: var(--night-surface);
  --surface-alt: var(--night-elevated);
  --primary: oklch(69% 0.095 292);
  --primary-dark: oklch(84% 0.07 292);
  --primary-soft: oklch(61% 0.08 292);
  --primary-pale: oklch(42% 0.055 289);
  --primary-rgb: 176, 157, 220;
  --date: oklch(72% 0.105 174);
  --date-dark: oklch(82% 0.08 174);
  --date-soft: oklch(38% 0.055 174);
  --date-pale: oklch(31% 0.035 174);
  --date-rgb: 104, 195, 171;
  --danger: oklch(71% 0.12 12);
  --shadow: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
}

.nrsk-object {
  background:
    linear-gradient(180deg, var(--nrsk-sky-top), var(--nrsk-sky-bottom) 72%, var(--bg));
}

.nrsk-object .rhythm-header p:not(.eyebrow),
.nrsk-object .rhythm-author-picker label {
  color: color-mix(in oklch, var(--ink), transparent 22%);
}

html[data-nrsk-sky="morning"] .nrsk-object {
  --nrsk-sky-top: oklch(86% 0.07 236);
  --nrsk-sky-bottom: oklch(97% 0.065 81);
}

html[data-nrsk-sky="day"] .nrsk-object {
  --nrsk-sky-top: oklch(85% 0.075 230);
  --nrsk-sky-bottom: oklch(97% 0.025 205);
}

html[data-nrsk-sky="evening"] .nrsk-object {
  --nrsk-sky-top: oklch(65% 0.095 287);
  --nrsk-sky-bottom: oklch(91% 0.075 48);
}

html[data-nrsk-sky="night"] .nrsk-object {
  --nrsk-sky-top: oklch(62% 0.075 276);
  --nrsk-sky-bottom: oklch(91% 0.045 286);
}

html[data-theme="night"] .nrsk-object {
  --nrsk-sky-top: oklch(21% 0.07 277);
  --nrsk-sky-bottom: oklch(34% 0.065 292);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  border-radius: var(--radius-sm);
}

:focus-visible {
  outline: 3px solid rgba(var(--primary-rgb), 0.35);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(115deg, rgba(12, 12, 25, 0.06), rgba(47, 143, 121, 0.1) 44%, rgba(27, 22, 45, 0.08)),
    url("/static/splash-nebula-bright.webp") center / cover no-repeat,
    #100d1d;
  transition: opacity 240ms ease, visibility 240ms ease;
}

.splash-screen.is-hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.splash-orbit,
.splash-logo {
  opacity: 0;
  transition: opacity 220ms ease;
}

.splash-screen.is-ready .splash-orbit,
.splash-screen.is-ready .splash-logo {
  opacity: 1;
}

.splash-screen::before,
.splash-screen::after {
  position: absolute;
  inset: -12%;
  content: "";
}

.splash-screen::before {
  background:
    radial-gradient(ellipse at 18% 70%, rgba(47, 143, 121, 0.22) 0 9%, transparent 30%),
    radial-gradient(ellipse at 78% 34%, rgba(104, 215, 189, 0.16) 0 12%, transparent 36%),
    radial-gradient(ellipse at 52% 50%, rgba(251, 250, 252, 0.06) 0 22%, rgba(16, 13, 29, 0.12) 66%, rgba(16, 13, 29, 0.22)),
    linear-gradient(180deg, rgba(16, 13, 29, 0.01), rgba(16, 13, 29, 0.16));
  opacity: 0.68;
  transform: scale(1.03);
  animation: nebula-breathe 2.2s ease-in-out infinite alternate;
}

.splash-screen::after {
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.82) 0 1px, transparent 1.4px),
    radial-gradient(circle, rgba(221, 218, 250, 0.58) 0 1px, transparent 1.6px),
    radial-gradient(circle, rgba(104, 215, 189, 0.62) 0 1px, transparent 1.7px);
  background-position: 0 0, 44px 36px, 90px 18px;
  background-size: 118px 118px, 176px 176px, 224px 224px;
  opacity: 0.34;
  mix-blend-mode: screen;
  animation: star-drift 2.4s ease-in-out infinite alternate;
}

.splash-orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: min(620px, 86vw);
  height: min(230px, 34vw);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%) scaleY(0.58);
  animation: orbit-spin 12s linear infinite;
}

.splash-orb {
  position: absolute;
  inset: 0;
  transform-origin: center;
}

.splash-orb i {
  position: absolute;
  top: 50%;
  right: -5px;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #68d7bd;
  box-shadow:
    0 0 16px rgba(104, 215, 189, 0.95),
    -18px 0 18px rgba(104, 215, 189, 0.28);
  content: "";
  transform: translateY(-50%) scaleY(1.72);
}

.splash-orb i::before {
  position: absolute;
  top: 5px;
  right: 7px;
  width: 54px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(104, 215, 189, 0.58));
  content: "";
}

.splash-orb-two {
  transform: rotate(92deg);
}

.splash-orb-two i {
  width: 9px;
  height: 9px;
  background: #a096c8;
  box-shadow:
    0 0 14px rgba(160, 150, 200, 0.9),
    -18px 0 16px rgba(160, 150, 200, 0.25);
}

.splash-orb-three {
  transform: rotate(192deg);
}

.splash-orb-three i {
  width: 7px;
  height: 7px;
  background: #8ee5d1;
  box-shadow:
    0 0 16px rgba(142, 229, 209, 0.88),
    -14px 0 14px rgba(142, 229, 209, 0.24);
}

.splash-orb-four {
  transform: rotate(284deg);
}

.splash-orb-four i {
  width: 6px;
  height: 6px;
  background: rgba(235, 239, 255, 0.95);
  box-shadow:
    0 0 12px rgba(235, 239, 255, 0.82),
    -12px 0 12px rgba(104, 215, 189, 0.18);
}

.splash-logo {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-height: 96px;
  padding: 22px 30px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background:
    linear-gradient(135deg, rgba(251, 250, 252, 0.34), rgba(244, 243, 250, 0.18)),
    rgba(251, 250, 252, 0.08);
  color: var(--primary-dark);
  border-radius: var(--radius-lg);
  box-shadow: 0 22px 70px rgba(16, 13, 29, 0.42);
  backdrop-filter: blur(6px) saturate(118%);
}

.splash-logo strong {
  font-size: 26px;
  line-height: 1.1;
}

.splash-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 2px solid var(--primary);
  color: var(--primary);
  font-weight: 850;
}

@keyframes star-drift {
  from {
    transform: translate3d(-8px, 0, 0) scale(1);
  }

  to {
    transform: translate3d(10px, -8px, 0) scale(1.02);
  }
}

@keyframes nebula-breathe {
  from {
    opacity: 0.75;
    transform: scale(1.02) translate3d(-4px, 0, 0);
  }

  to {
    opacity: 0.95;
    transform: scale(1.05) translate3d(5px, -3px, 0);
  }
}

@keyframes orbit-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: 12px max(18px, env(safe-area-inset-left)) 12px max(18px, env(safe-area-inset-right));
  background: rgba(251, 250, 252, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

html[data-theme="night"] .topbar {
  background: oklch(23% 0.055 285 / 0.94);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  margin-left: auto;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.theme-toggle:hover,
.theme-toggle[aria-pressed="true"] {
  border-color: var(--primary-soft);
  background: var(--surface-alt);
}

.theme-toggle [data-theme-icon] {
  font-size: 19px;
  line-height: 1;
}

html[data-theme="night"] input,
html[data-theme="night"] select,
html[data-theme="night"] textarea,
html[data-theme="night"] .nav-link,
html[data-theme="night"] .secondary-action,
html[data-theme="night"] .icon-link {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 2px solid var(--primary);
  color: var(--primary);
  font-weight: 800;
}

.brand-name {
  color: var(--primary-dark);
  font-size: 20px;
  font-weight: 800;
}

.brand-section {
  padding-left: 8px;
  border-left: 1px solid var(--line);
  font-size: 18px;
  font-weight: 650;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topnav form {
  margin: 0;
}

.nav-nrsk {
  border-color: color-mix(in oklch, var(--primary), transparent 38%);
  background: color-mix(in oklch, var(--primary-pale), var(--bg) 52%);
  color: var(--primary-dark);
}

.nav-quick {
  position: relative;
  min-width: 44px;
  overflow: hidden;
  font-size: 20px;
}

.nav-quick::after {
  position: absolute;
  inset: -80% -35%;
  background: linear-gradient(110deg, transparent 38%, rgba(255, 255, 255, 0.76) 50%, transparent 62%);
  content: "";
  transform: translateX(-60%);
  animation: nav-quick-shimmer 3.8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes nav-quick-shimmer {
  0%, 56% { transform: translateX(-60%); }
  78%, 100% { transform: translateX(60%); }
}

.topnav-logout {
  margin-left: 8px !important;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}

.topnav-logout .nav-button {
  min-height: 36px;
  padding-inline: 9px;
  color: var(--muted);
  font-size: 12px;
}

.nav-label-short {
  display: none;
}

.nav-link,
.secondary-action,
.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 620;
  border-radius: var(--radius-sm);
}

.nav-button {
  cursor: pointer;
}

.page-main {
  width: min(100%, 1180px);
  margin: 0 auto;
}

.workspace-layout {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: calc(100vh - 126px);
}

.rail {
  border-right: 1px solid var(--line);
  padding: 24px 18px;
  background: var(--surface-alt);
}

.person-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.person-row strong,
.person-row small {
  display: block;
}

.person-row small,
.entry-copy small,
.footer,
small {
  color: var(--muted);
}

.workspace-main {
  min-width: 0;
}

.entry-form-section,
.timeline-section,
.auth-panel {
  padding: 28px;
  border-bottom: 1px solid var(--line);
}

.entry-form-section.narrow,
.auth-panel {
  width: min(100%, 720px);
  margin: 0 auto;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.auth-grid-single {
  grid-template-columns: minmax(0, 720px);
  justify-content: center;
}

.auth-grid .auth-panel {
  width: 100%;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1,
h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 22px;
}

.day-switcher,
.button-row,
.filter-form,
.preset-row,
.period-control-row,
.duplicate-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.day-switcher a {
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--muted);
}

.day-switcher a.active {
  border-color: rgba(var(--primary-rgb), 0.35);
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary-dark);
}

.entry-form,
.stack-form {
  display: grid;
  gap: 16px;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-width: 0;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.event-group-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 0;
  gap: 9px;
  margin: 0;
  padding: 0;
  border: 0;
}

.event-group-column {
  display: grid;
  align-content: start;
  gap: 9px;
}

.chip-grid legend,
.event-group-grid legend,
.multi-filter-grid legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.chip input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.chip {
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.chip > span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 7px 11px;
  border: 1px solid var(--primary-pale);
  background: var(--bg);
  color: var(--ink);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

.chip input:checked + span {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 22px rgba(var(--primary-rgb), 0.22);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  padding: 10px 12px;
  font-size: 16px;
}

textarea {
  min-height: 132px;
  resize: vertical;
}

.native-date-input {
  position: absolute;
  width: 1px;
  min-height: 0;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.custom-date-picker {
  position: relative;
}

.date-input-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
}

.date-input-trigger::after {
  width: 18px;
  height: 18px;
  background: var(--primary);
  content: "";
  mask:
    linear-gradient(#000 0 0) 3px 5px / 12px 10px no-repeat,
    linear-gradient(#000 0 0) 5px 2px / 2px 4px no-repeat,
    linear-gradient(#000 0 0) 11px 2px / 2px 4px no-repeat,
    linear-gradient(#000 0 0) 3px 7px / 12px 2px no-repeat;
}

.custom-calendar {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  display: none;
  width: min(336px, calc(100vw - 36px));
  padding: 14px;
  border: 1px solid rgba(var(--primary-rgb), 0.28);
  background: var(--bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

.custom-date-picker.is-open .custom-calendar {
  display: grid;
  gap: 12px;
}

.calendar-header,
.calendar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.calendar-header strong {
  color: var(--ink);
  font-size: 15px;
}

.calendar-nav {
  display: flex;
  gap: 6px;
}

.calendar-nav button,
.calendar-actions button,
.calendar-day {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.calendar-nav button {
  width: 34px;
  height: 34px;
  border-color: rgba(var(--primary-rgb), 0.22);
  background: rgba(var(--primary-rgb), 0.08);
  color: var(--primary-dark);
  font-size: 22px;
  line-height: 1;
}

.calendar-weekdays,
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  text-align: center;
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.calendar-day {
  min-height: 34px;
  font-size: 14px;
  font-weight: 650;
}

.calendar-day:hover,
.calendar-day.is-today {
  border-color: rgba(var(--primary-rgb), 0.35);
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary-dark);
}

.calendar-day.is-muted {
  color: rgba(111, 106, 125, 0.52);
}

.calendar-day.is-selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.calendar-actions {
  justify-content: flex-end;
}

.calendar-actions button {
  min-height: 36px;
  padding: 0 10px;
  color: var(--primary-dark);
  font-weight: 700;
}

.calendar-actions button:hover {
  background: rgba(var(--primary-rgb), 0.1);
}

.chip input[type="radio"],
.chip input[type="checkbox"] {
  width: 1px;
  height: 1px;
  min-height: 0;
}

.date-preset-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.date-preset {
  min-height: 44px;
  height: 44px;
  border: 1px solid rgba(var(--date-rgb), 0.28);
  background: var(--date-pale);
  color: var(--date-dark);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.date-preset.is-active {
  border-color: var(--date);
  background: var(--date-soft);
  color: var(--date-dark);
}

.calendar-field.is-hidden,
.duplicate-notice.is-hidden {
  display: none;
}

.form-grid:has(.calendar-field.is-hidden) {
  grid-template-columns: 1fr;
}

.duplicate-notice {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(var(--date-rgb), 0.34);
  background: rgba(var(--date-rgb), 0.08);
  color: var(--date-dark);
  border-radius: var(--radius-md);
}

.duplicate-notice p {
  margin: 4px 0 0;
  color: var(--ink);
}

.duplicate-notice .secondary-action {
  border-color: rgba(var(--date-rgb), 0.3);
  background: var(--date-pale);
  color: var(--date-dark);
  border-radius: var(--radius-sm);
}

.primary-action,
.danger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  width: 100%;
  border: 0;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 14px;
  text-decoration: none;
  font-weight: 760;
  cursor: pointer;
}

.primary-action:hover {
  background: var(--primary-dark);
}

.primary-action:disabled {
  opacity: 0.66;
  cursor: wait;
}

.danger-action {
  margin-top: 16px;
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(176, 73, 103, 0.35);
}

.notice,
.form-error,
.empty-state {
  margin: 18px 28px 0;
  padding: 12px 14px;
  border: 1px solid rgba(var(--primary-rgb), 0.24);
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary-dark);
}

.form-error {
  margin: 0 0 16px;
  border-color: rgba(176, 73, 103, 0.3);
  background: rgba(176, 73, 103, 0.08);
  color: var(--danger);
}

.empty-state {
  margin: 0;
  color: var(--muted);
  border-color: var(--line);
  background: var(--surface);
}

.entry-save-notice {
  margin: -4px 0 0;
  border-color: rgba(var(--date-rgb), 0.28);
  border-left: 4px solid var(--date);
  background: var(--date-pale);
  color: var(--date-dark);
}

.entry-save-notice.is-hidden {
  display: none;
}

.form-validation-message {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -4px 0 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  padding: 12px 14px;
  border-left: 4px solid var(--date);
  background: var(--date-pale);
}

.form-validation-message.is-hidden {
  display: none;
}

.validation-icon {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  background: var(--date);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 20px;
  font-weight: 850;
  line-height: 1;
}

.timeline {
  list-style: none;
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
}

.timeline-results {
  transition: opacity 160ms ease;
}

.history-workspace {
  transition: opacity 160ms ease;
}

.history-workspace.is-loading {
  opacity: 0.55;
}

.timeline-results.is-loading {
  opacity: 0.55;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 126px 36px minmax(0, 1fr);
  grid-template-areas: "time icon copy";
  gap: 12px;
  align-items: start;
  padding: 13px 0;
  border-bottom: 1px solid var(--soft-line);
}

.timeline-item.has-photo {
  grid-template-columns: 126px 36px minmax(0, 1fr) 84px;
  grid-template-areas: "time icon copy photo";
}

.confirmation-required-entry {
  grid-template-columns: 126px 36px minmax(0, 1fr) 156px;
  grid-template-areas: "time icon copy actions";
  margin: 0 -12px;
  padding: 13px 12px;
  background: var(--confirmation-green);
  border-bottom-color: rgba(var(--date-rgb), 0.22);
}

.confirmation-required-entry.has-photo {
  grid-template-columns: 126px 36px minmax(0, 1fr) 156px 84px;
  grid-template-areas: "time icon copy actions photo";
}

.confirmation-entry-actions {
  position: relative;
  z-index: 2;
  grid-area: actions;
  display: grid;
  gap: 6px;
}

.confirmation-entry-actions form {
  margin: 0;
}

.confirm-entry-action,
.correct-entry-action {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--date);
  background: rgba(255, 255, 255, 0.36);
  color: var(--date-dark);
  text-align: center;
  text-decoration: none;
  font-size: 13px;
  font-weight: 730;
}

.timeline-item.is-editable {
  transition: background 150ms ease;
}

.timeline-item.is-editable:hover {
  background: rgba(var(--primary-rgb), 0.045);
}

.timeline-entry-link {
  position: absolute;
  z-index: 1;
  inset: 0;
  color: inherit;
  text-decoration: none;
}

.timeline-entry-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -3px;
}

.timeline-item time {
  grid-area: time;
  padding-top: 7px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.event-icon {
  grid-area: icon;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: rgba(var(--primary-rgb), 0.08);
  color: var(--primary);
}

.event-icon svg {
  width: 20px;
  height: 20px;
}

.event-icon.entry-breakfast {
  color: var(--breakfast);
}

.event-icon.entry-lunch {
  color: var(--lunch);
}

.event-icon.entry-dinner {
  color: var(--dinner);
}

.event-icon.entry-meal {
  color: var(--meal);
}

.event-icon.entry-snack {
  color: var(--snack);
}

.event-icon.entry-drink {
  color: var(--drink);
}

.event-icon.entry-medication {
  color: var(--medication);
}

.event-icon.entry-wellbeing {
  color: var(--wellbeing);
}

.event-icon.entry-note {
  color: var(--note);
}

.entry-copy {
  grid-area: copy;
}

.entry-copy strong,
.entry-copy p {
  margin: 0;
}

.entry-copy p {
  overflow-wrap: anywhere;
}

.demo-readonly-label {
  display: block;
  width: max-content;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.timeline-view-options {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.photo-visibility-toggle {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid rgba(var(--primary-rgb), 0.22);
  background: rgba(var(--primary-rgb), 0.07);
  color: var(--primary-dark);
  cursor: pointer;
}

.timeline-photo {
  grid-area: photo;
  position: relative;
  display: block;
  width: 84px;
  height: 64px;
  overflow: hidden;
  border: 1px solid var(--soft-line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.timeline-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.timeline-photo > b {
  position: absolute;
  right: 4px;
  bottom: 4px;
  min-width: 28px;
  padding: 3px 6px;
  color: #fff;
  background: rgba(40, 34, 56, 0.78);
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

.timeline-photos-hidden [data-entry-photo] {
  display: none;
}

.timeline-photos-hidden .timeline-item.has-photo {
  grid-template-columns: 126px 36px minmax(0, 1fr);
  grid-template-areas: "time icon copy";
}

.period-filter-form {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.archived-event-filters {
  margin: 2px 0 0;
  padding: 0;
  border: 0;
}

.archived-event-filters legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

.archived-event-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.archived-event-chip {
  min-width: 150px;
  color: var(--muted);
  background: rgba(var(--primary-rgb), 0.035);
}

.filter-actions.history-filter-actions {
  display: grid;
  grid-template-columns: max-content max-content minmax(180px, 1fr);
  align-items: center;
  gap: 12px;
}

.history-switch {
  position: relative;
  display: inline-flex;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(var(--date-rgb), 0.24);
  border-radius: 999px;
  background: var(--date-pale);
  color: var(--date-dark);
  cursor: pointer;
}

.history-switch > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.history-switch > span {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 5px 8px 5px 13px;
}

.history-switch b {
  font-size: 13px;
  font-weight: 680;
}

.history-switch i {
  position: relative;
  display: block;
  width: 34px;
  height: 22px;
  border-radius: 999px;
  background: rgba(var(--date-rgb), 0.18);
}

.history-switch i::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 0 0 1px rgba(var(--date-rgb), 0.2);
  content: "";
  transition: transform 150ms ease;
}

.history-switch input:checked + span i,
.history-switch.is-active i {
  background: rgba(var(--date-rgb), 0.44);
}

.history-switch input:checked + span i::after,
.history-switch.is-active i::after {
  transform: translateX(12px);
}

.history-switch input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 999px;
}

.photo-history-switch {
  font: inherit;
}

.history-filter-actions .export-action {
  justify-self: end;
  min-width: 180px;
}

.filter-control-group {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.filter-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 760;
}

.period-control-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 0.85fr)) minmax(290px, 1.35fr);
  align-items: stretch;
  min-width: 0;
  width: 100%;
}

.date-filter-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  height: 44px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid rgba(var(--date-rgb), 0.3);
  background: var(--date-pale);
  color: var(--date-dark);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 14px;
  font-weight: 680;
  cursor: pointer;
  overflow-wrap: normal;
  text-align: center;
}

.date-filter-action.active,
.date-filter-action:hover {
  border-color: var(--date);
  background: var(--date-soft);
}

.period-picker {
  position: relative;
  min-width: 0;
}

.custom-period-trigger {
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
}

.period-label-mobile {
  display: none;
}

.custom-period-trigger strong {
  font-weight: 780;
}

.custom-period-trigger .is-placeholder {
  color: rgba(31, 111, 94, 0.48);
}

.period-range-panel {
  position: absolute;
  z-index: 10;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  width: min(520px, calc(100vw - 36px));
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(var(--date-rgb), 0.28);
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.period-range-panel.is-hidden {
  display: none;
}

.period-range-panel .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-submit {
  justify-self: start;
}

.multi-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 0;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.author-select-field {
  max-width: 420px;
}

.author-select {
  min-height: 44px;
  border-color: rgba(var(--primary-rgb), 0.28);
  background:
    linear-gradient(45deg, transparent 50%, var(--primary-dark) 50%),
    linear-gradient(135deg, var(--primary-dark) 50%, transparent 50%),
    linear-gradient(180deg, var(--bg), var(--surface));
  background-position:
    calc(100% - 18px) 19px,
    calc(100% - 12px) 19px,
    0 0;
  background-size:
    6px 6px,
    6px 6px,
    100% 100%;
  background-repeat: no-repeat;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  appearance: none;
}

.filter-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-submit {
  justify-self: start;
  min-height: 44px;
  width: auto;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.export-action {
  border-color: rgba(var(--primary-rgb), 0.28);
  background: rgba(var(--primary-rgb), 0.08);
  color: var(--primary-dark);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--soft-line);
  text-align: left;
  vertical-align: top;
}

.admin-layout {
  display: grid;
  gap: 18px;
}

.compact-user-form {
  display: grid;
  gap: 8px;
}

.compact-user-form input {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.admin-role-form,
.admin-action-stack {
  display: grid;
  gap: 10px;
}

.admin-action-stack form {
  margin: 0;
}

.admin-action-stack button,
.admin-role-form button {
  width: 100%;
}

.admin-create-section > h2 {
  margin-bottom: 18px;
}

.edit-submit-notice {
  margin-top: 14px;
}

.quick-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  min-height: calc(100vh - 126px);
}

.quick-composer,
.quick-recent {
  padding: 28px;
}

.quick-composer {
  border-right: 1px solid var(--line);
  background:
    radial-gradient(circle at 86% 8%, rgba(47, 143, 121, 0.12), transparent 28%),
    var(--bg);
}

.quick-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.quick-heading p:not(.eyebrow) {
  max-width: 540px;
  margin: 8px 0 0;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--date-dark);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.quick-form,
.quick-note {
  display: grid;
  gap: 10px;
}

.quick-photo-actions {
  position: relative;
  display: grid;
  gap: 16px;
  overflow: hidden;
  margin-bottom: 8px;
  padding: 20px;
  border: 1px solid rgba(95, 79, 134, 0.28);
  background: var(--photo-capture-sky);
  color: #fff;
  box-shadow: 0 18px 42px rgba(50, 42, 75, 0.18);
}

.quick-photo-actions h2 {
  font-size: 20px;
}

.quick-photo-actions p:not(.eyebrow) {
  max-width: 480px;
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.76);
}

.quick-photo-actions .eyebrow {
  color: #9ce8d6;
}

.quick-photo-actions > small {
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

.quick-photo-buttons {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 10px;
}

.quick-photo-action {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 760;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.quick-photo-camera {
  border-color: #8ee5d1;
  background: #68d7bd;
  color: #173c36;
}

.photo-action-icon {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.quick-photo-action:has(input:focus-visible) {
  outline: 3px solid rgba(142, 229, 209, 0.48);
  outline-offset: 2px;
}

.quick-form.is-photo-uploading {
  pointer-events: none;
}

.quick-form.is-photo-uploading .quick-photo-actions,
.quick-form.is-photo-uploading .quick-note,
.quick-form.is-photo-uploading .quick-tags {
  opacity: 0.58;
}

.quick-note > span,
.quick-tags legend {
  font-weight: 700;
}

.quick-note textarea {
  width: 100%;
  min-height: 112px;
  padding: 16px;
  resize: vertical;
  border: 1px solid var(--line);
  background: rgba(251, 250, 252, 0.92);
  font-size: 18px;
}

.quick-tags {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 4px;
  padding: 0;
  border: 0;
}

.quick-tags legend {
  grid-column: 1 / -1;
  margin-bottom: 8px;
}

.quick-tag {
  position: relative;
  display: grid;
  min-height: 102px;
  place-items: center;
  gap: 5px;
  padding: 12px 8px;
  border: 1px solid var(--soft-line);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
}

.quick-tag input {
  position: absolute;
  opacity: 0;
}

.quick-tag:has(input:checked) {
  border-color: var(--quick-tag-color, var(--primary));
  background: color-mix(in srgb, var(--quick-tag-color, var(--primary)) 13%, var(--bg));
  box-shadow: inset 0 0 0 1px var(--quick-tag-color, var(--primary));
}

.quick-tag:has(input:focus-visible) {
  outline: 3px solid rgba(var(--primary-rgb), 0.35);
  outline-offset: 2px;
}

.quick-tag-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--quick-tag-color, var(--primary));
}

.quick-tag-icon svg {
  width: 38px;
  height: 38px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.quick-tag-food { --quick-tag-color: #b07d3f; }
.quick-tag-snack { --quick-tag-color: #a56d8f; }
.quick-tag-sweet { --quick-tag-color: #b95d87; }
.quick-tag-fruit { --quick-tag-color: #56894e; }
.quick-tag-hot_drink { --quick-tag-color: #a8663d; }
.quick-tag-water { --quick-tag-color: #4e829b; }
.quick-tag-alcohol { --quick-tag-color: #805a96; }
.quick-tag-medication { --quick-tag-color: #2f8f79; }

.quick-save {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  margin-top: 8px;
  padding: 0 18px;
  border: 0;
  background: var(--primary);
  color: #fff;
  font-weight: 760;
  cursor: pointer;
}

.quick-save small {
  color: rgba(255, 255, 255, 0.78);
}

.save-notice {
  padding: 12px 14px;
  background: var(--date-pale);
  color: var(--date-dark);
}

.quick-recent {
  background: var(--surface-alt);
}

.quick-recent-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.quick-recent-list li {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(var(--date-rgb), 0.2);
}

.quick-recent-list li.quick-photo-fact {
  grid-template-columns: 72px 84px minmax(0, 1fr) auto;
}

.quick-photo-thumb {
  display: block;
  width: 72px;
  height: 72px;
  overflow: hidden;
  border: 1px solid rgba(var(--date-rgb), 0.28);
  background: var(--surface);
}

.quick-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.quick-photo-status {
  margin-top: 4px;
  color: var(--date-dark);
}

.photo-analysis-card {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1.2fr);
  gap: clamp(18px, 4vw, 34px);
  align-items: center;
  margin-bottom: 24px;
  padding: clamp(16px, 3vw, 26px);
  overflow: hidden;
  color: #f7f5ff;
  background:
    radial-gradient(circle at 18% 20%, rgb(63 228 177 / 22%), transparent 36%),
    linear-gradient(138deg, #151127, #26213e 58%, #102f2b);
  border: 1px solid rgb(255 255 255 / 13%);
  border-radius: 24px;
  box-shadow: 0 20px 46px rgb(31 25 54 / 18%);
}

.photo-analysis-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 18px;
  box-shadow: 0 14px 30px rgb(0 0 0 / 25%);
}

.entry-photo-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.entry-photo-gallery img {
  width: 100%;
  height: 132px;
  object-fit: cover;
}

.entry-photo-gallery img:only-child {
  grid-column: 1 / -1;
}

.photo-analysis-card h2 {
  margin: 4px 0 8px;
  color: inherit;
}

.photo-analysis-card p,
.photo-analysis-card small {
  color: rgb(247 245 255 / 76%);
}

.photo-nutrition-ranges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.photo-nutrition-ranges strong,
.photo-nutrition-ranges span {
  padding: 8px 11px;
  background: rgb(255 255 255 / 9%);
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 999px;
}

.photo-nutrition-ranges strong {
  color: #74edc5;
}

.quick-recent-list time {
  color: var(--date-dark);
  font-variant-numeric: tabular-nums;
}

.quick-recent-list strong,
.quick-recent-list small {
  display: block;
}

.quick-tags-edit {
  margin-bottom: 16px;
}

.rhythm-page {
  padding: 28px;
}

.rhythm-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.rhythm-header p:not(.eyebrow) {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--muted);
}

.rhythm-switcher {
  display: flex;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.rhythm-switcher a {
  display: grid;
  min-height: 44px;
  place-items: center;
  padding: 0 14px;
  text-decoration: none;
}

.rhythm-switcher a[aria-current="page"] {
  background: var(--primary);
  color: #fff;
}

.rhythm-author-picker {
  display: grid;
  grid-template-columns: auto minmax(180px, 280px);
  gap: 10px 14px;
  align-items: center;
  margin: 0 0 18px;
}

.rhythm-author-picker label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.rhythm-author-picker select {
  min-height: 44px;
}

.rhythm-axis-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 0 0 14px;
}

.rhythm-axis-presets {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rhythm-axis-presets button,
.rhythm-custom-start button {
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.rhythm-axis-presets button[aria-pressed="true"] {
  border-color: var(--date);
  background: var(--date-pale);
  color: var(--date-dark);
}

.rhythm-custom-start {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.rhythm-custom-start.is-hidden {
  display: none;
}

.rhythm-custom-start input {
  width: 64px;
  min-height: 44px;
  border: 1px solid var(--line);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.day-sky {
  position: relative;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid rgba(95, 79, 134, 0.18);
  background: #28243f;
}

.fasting-window {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
  margin: 14px 0;
  padding: 11px 13px;
  border: 1px solid color-mix(in oklch, var(--primary-soft), var(--line) 38%);
  background: color-mix(in oklch, var(--surface), var(--primary-soft) 9%);
}

.fasting-window > span {
  grid-row: 1 / 3;
  color: var(--primary-dark);
  font-size: 27px;
}

.fasting-window div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.fasting-window small,
.fasting-window em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.fasting-window strong,
.fasting-window time {
  font-variant-numeric: tabular-nums;
}

.fasting-window time {
  justify-self: end;
  color: var(--primary-dark);
  font-size: 12px;
}

.fasting-window em {
  grid-column: 2 / -1;
}

.sky-cycle {
  position: absolute;
  inset: 0 auto 0 calc(var(--axis-shift) * -1%);
  width: 200%;
  background-image: linear-gradient(
    90deg,
    #292540 0%,
    #302a4b 13%,
    #5f5877 20%,
    #d4c7cf 25%,
    #eadcc8 31%,
    #e4ecee 43%,
    #dfecef 66%,
    #ead7c4 72%,
    #b88f93 79%,
    #68536f 86%,
    #302a48 94%,
    #292540 100%
  );
  background-repeat: repeat-x;
  background-size: 50% 100%;
}

html[data-theme="night"] .sky-cycle {
  filter: brightness(0.72) saturate(0.92);
}

.sky-cycle::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), transparent 58%, rgba(22, 19, 39, 0.18));
  content: "";
}

.sky-stars span {
  position: absolute;
  top: calc(16% + var(--star-position) * 0.36%);
  left: var(--star-position);
  z-index: 1;
  color: rgba(255, 250, 220, 0.9);
  font-size: clamp(15px, 2vw, 24px);
  text-shadow: 0 0 10px rgba(244, 236, 183, 0.78);
  transform: translateX(-50%);
}

.rhythm-moon {
  position: absolute;
  top: 22px;
  left: var(--moon-position);
  z-index: 3;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1;
  filter: drop-shadow(0 0 12px rgba(247, 234, 170, 0.42));
  transform: translateX(-50%);
}

.rhythm-meridian {
  position: absolute;
  top: 0;
  bottom: 38px;
  left: var(--meridian-position);
  z-index: 1;
  border-left: 1px dashed rgba(52, 45, 72, 0.28);
}

html[data-theme="night"] .rhythm-meridian {
  border-left-color: rgba(234, 229, 247, 0.25);
}

.day-sky-axis {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(251, 250, 252, 0.8);
  color: #5f5a6b;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(6px);
}

.rhythm-point {
  position: absolute;
  top: calc(36% + var(--rhythm-row) * 18%);
  left: clamp(24px, var(--rhythm-position), calc(100% - 24px));
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  transform: translate(-50%, -50%);
}

.rhythm-point > span:first-child {
  width: var(--rhythm-point-size, 20px);
  height: var(--rhythm-point-size, 20px);
  border: 4px solid rgba(251, 250, 252, 0.94);
  background: var(--primary);
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(33, 29, 47, 0.18);
}

.rhythm-point-night {
  color: #fff;
}

.rhythm-point-night > span:first-child {
  background: #e8d98b;
  box-shadow: 0 0 14px rgba(232, 217, 139, 0.72);
}

.rhythm-weight-light > span:first-child {
  border-width: 3px;
}

.rhythm-weight-substantial > span:first-child {
  box-shadow: 0 0 0 2px rgba(48, 42, 72, 0.28), 0 0 22px rgba(255, 255, 255, 0.28);
}

.rhythm-point time {
  padding: 3px 6px;
  background: rgba(251, 250, 252, 0.84);
  color: #211d2f;
  font-size: 12px;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.rhythm-tooltip {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  z-index: 8;
  display: grid;
  width: max-content;
  max-width: min(280px, 72vw);
  gap: 3px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 5px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.rhythm-tooltip b {
  color: var(--primary-dark);
}

.rhythm-point:hover .rhythm-tooltip,
.rhythm-point:focus-visible .rhythm-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.rhythm-detail-list {
  display: grid;
  gap: 0;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.rhythm-detail-list li {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--soft-line);
}

.rhythm-detail-list li.empty-state {
  display: block;
}

.rhythm-detail-list small {
  max-width: 240px;
  color: var(--muted);
  text-align: right;
  overflow-wrap: anywhere;
}

.rhythm-detail-list time {
  color: var(--primary-dark);
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.week-rhythm {
  display: grid;
  gap: 0;
}

.week-rhythm-lane {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 68px;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  border-bottom: 1px dashed var(--line);
}

.week-rhythm-lane > time {
  font-variant-numeric: tabular-nums;
}

.week-lane-sky {
  position: relative;
  height: 48px;
  overflow: visible;
  background: linear-gradient(90deg, #292540, #5f5877 20%, #eadcc8 31%, #e4ecee 43%, #dfecef 66%, #b88f93 79%, #302a48 94%, #292540);
}

.week-lane-sky > .week-rhythm-point {
  position: absolute;
  top: 50%;
  left: var(--rhythm-position);
  z-index: 3;
  width: clamp(12px, var(--rhythm-point-size), 26px);
  height: clamp(12px, var(--rhythm-point-size), 26px);
  background: #f8f5ec;
  border: 3px solid var(--primary-dark);
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.week-lane-sky > .week-rhythm-point.rhythm-weight-light {
  border-width: 2px;
}

.week-lane-sky .rhythm-tooltip {
  bottom: calc(100% + 8px);
}

.week-lane-sky > .week-rhythm-point:hover .rhythm-tooltip,
.week-lane-sky > .week-rhythm-point:focus-visible .rhythm-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.week-moon {
  position: absolute;
  top: 3px;
  right: 4px;
  z-index: 2;
  font-size: 17px;
  line-height: 1;
  filter: drop-shadow(0 0 5px rgba(247, 234, 170, 0.46));
}

.week-rhythm-meridian {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--week-meridian);
  border-left: 1px dashed rgba(51, 45, 73, 0.28);
}

.week-time-axis {
  display: flex;
  justify-content: space-between;
  margin: 0 82px 4px 126px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.week-view-switcher {
  display: inline-flex;
  gap: 4px;
  margin: 0 0 18px;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.week-view-switcher a {
  display: grid;
  min-height: 44px;
  place-items: center;
  padding: 0 14px;
  text-decoration: none;
}

.week-view-switcher a[aria-current="page"] {
  background: var(--primary);
  color: white;
}

.week-card-scroll {
  overflow-x: auto;
  padding: 0 0 12px;
  scroll-snap-type: x proximity;
}

.week-card-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(220px, 1fr));
  align-items: start;
  min-width: 1540px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.week-day-card {
  min-width: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  scroll-snap-align: start;
}

.week-day-card > header {
  position: relative;
  display: grid;
  gap: 2px;
  min-height: 58px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--soft-line);
  background: var(--surface);
}

.week-day-card > header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.week-day-card > header time {
  font-size: 18px;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}

.week-day-card > header .week-moon {
  top: 14px;
  right: 12px;
}

.week-day-glance {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--soft-line);
}

.week-day-glance strong {
  font-size: 17px;
}

.fasting-window-compact {
  grid-template-columns: minmax(0, 1fr) auto;
  margin: 0;
  padding: 7px 11px;
  border-width: 0 0 1px;
  background: color-mix(in oklch, var(--surface), var(--primary-soft) 7%);
}

.fasting-window-compact div {
  display: grid;
  gap: 1px;
}

.fasting-window-compact time {
  align-self: center;
  font-size: 10px;
}

.fasting-window-compact strong,
.fasting-window-compact time {
  white-space: nowrap;
}

.week-day-card .day-kcal {
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
}

.week-day-accordion summary,
.day-nutrition-accordion summary {
  min-height: 44px;
  padding: 10px 11px;
  border-bottom: 1px solid var(--soft-line);
  color: var(--primary-dark);
  cursor: pointer;
  font-weight: 680;
}

.week-day-accordion::details-content {
  block-size: 0;
  overflow: hidden;
  transition: block-size 220ms cubic-bezier(0.25, 1, 0.5, 1), content-visibility 220ms;
  transition-behavior: allow-discrete;
}

.week-day-accordion[open]::details-content {
  block-size: auto;
}

.day-nutrition-accordion {
  border-top: 1px solid var(--soft-line);
}

.day-nutrition-cassette {
  display: grid;
  gap: 8px;
  padding: 10px 11px 12px;
  background: color-mix(in oklch, var(--surface), transparent 18%);
}

.day-energy {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.day-energy strong { font-size: 25px; line-height: 1; }
.day-energy span { color: var(--muted); font-size: 12px; }
.day-energy small { margin-left: auto; color: var(--muted); font-size: 10px; }

.day-nutrition-cassette dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 0;
}

.day-nutrition-cassette dl div {
  padding: 6px;
  border-left: 3px solid var(--nutrition-protein);
  background: var(--bg);
}

.day-nutrition-cassette dl div:nth-child(2) { border-color: var(--nutrition-fat); }
.day-nutrition-cassette dl div:nth-child(3) { border-color: var(--nutrition-carbs); }
.day-nutrition-cassette dt { color: var(--muted); font-size: 9px; }
.day-nutrition-cassette dd { margin: 2px 0 0; font-size: 14px; font-weight: 760; }
.day-nutrition-cassette dd small { font-size: 9px; }

.macro-share {
  display: flex;
  height: 6px;
  overflow: hidden;
  background: var(--soft-line);
}

.macro-share span { display: block; }
.macro-protein { width: var(--protein-share); background: var(--nutrition-protein); }
.macro-fat { width: var(--fat-share); background: var(--nutrition-fat); }
.macro-carbs { width: var(--carbs-share); background: var(--nutrition-carbs); }
.macro-share-label { color: var(--muted); font-size: 9px; }

.week-day-events {
  display: grid;
  border-top: 1px solid var(--soft-line);
}

.week-day-events > a {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--soft-line);
  text-decoration: none;
}

.week-day-events .event-icon,
.week-day-events .event-icon svg {
  width: 28px;
  height: 28px;
}

.week-day-events .event-icon {
  grid-area: auto;
}

.week-day-events time,
.week-day-events b,
.week-day-events small {
  display: block;
}

.week-day-events time {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.week-day-events small {
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.week-totals {
  display: grid;
  grid-template-columns: minmax(190px, 0.55fr) minmax(0, 2fr);
  gap: 16px;
  margin: 24px 0 0;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.week-kpi-trellis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin: 0;
}

.week-kpi-trellis div {
  min-height: 76px;
  padding: 10px 11px;
  border: 1px solid var(--soft-line);
  background: var(--bg);
}

.week-kpi-trellis dt {
  color: var(--muted);
  font-size: 12px;
}

.week-kpi-trellis dd {
  margin: 4px 0 0;
  font-size: 20px;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
}

.week-kpi-trellis dd small { color: var(--muted); font-size: 10px; }
.week-kpi-trellis .week-kpi-energy {
  grid-row: span 2;
  background: linear-gradient(145deg, color-mix(in oklch, var(--primary-pale), var(--bg) 26%), var(--bg));
}
.week-kpi-energy dd { font-size: clamp(28px, 3vw, 40px); }

.month-weekdays,
.month-rhythm {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.month-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 18px;
}

.month-navigation {
  display: inline-flex;
  gap: 4px;
}

.month-navigation a {
  display: grid;
  min-width: 44px;
  min-height: 44px;
  place-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-decoration: none;
}

.month-weekdays {
  margin-bottom: 6px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.month-day,
.month-blank {
  min-height: 118px;
}

.month-day {
  position: relative;
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--soft-line);
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
  width: 100%;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.month-day > span:not(.month-day-details) {
  color: var(--muted);
  font-size: 12px;
}

.month-day > time {
  margin-bottom: auto;
  font-size: 17px;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.month-day-count b {
  color: var(--ink);
  font-size: 15px;
}

.month-day-kcal {
  color: var(--primary-dark) !important;
  font-variant-numeric: tabular-nums;
}

.month-day-delta {
  font-variant-numeric: tabular-nums;
}

.month-day-delta.is-up { color: #8a4c27 !important; }
.month-day-delta.is-down { color: var(--date-dark) !important; }

.month-day > b {
  position: absolute;
  top: 8px;
  right: 9px;
  color: var(--primary-dark);
}

.month-level-1 { background: color-mix(in oklch, var(--date-pale), var(--bg) 76%); }
.month-level-2 { background: color-mix(in oklch, var(--date-pale), var(--date-soft) 18%); }
.month-level-3 { background: color-mix(in oklch, var(--date-pale), var(--date-soft) 34%); }
.month-level-4 { background: color-mix(in oklch, var(--date-pale), var(--date) 28%); }
.month-level-5 { background: color-mix(in oklch, var(--date-soft), #e6d4a5 26%); }
.month-level-6 { background: color-mix(in oklch, var(--date-soft), #dfbd79 42%); }
.month-level-7 { background: color-mix(in oklch, #e4bc73, var(--date-soft) 30%); }
.month-level-8 { background: #e8ad62; }
.month-level-9 { background: #e58d42; }
.month-level-10 { background: #dc6f2f; color: #211d2f; }

.month-level-8 .month-day-delta,
.month-level-9 .month-day-delta,
.month-level-10 .month-day-delta,
.month-level-8 .month-day-count,
.month-level-9 .month-day-count,
.month-level-10 .month-day-count,
.month-level-8 .month-day-kcal,
.month-level-9 .month-day-kcal,
.month-level-10 .month-day-kcal {
  color: #342033 !important;
}

.month-day:hover,
.month-day:focus-visible {
  z-index: 10;
  border-color: var(--primary);
  transform: translateY(-2px);
}

.month-day-reveal {
  width: min(680px, calc(100vw - 28px));
  max-height: min(82vh, 760px);
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(28, 24, 48, 0.3);
}

.month-day-reveal::backdrop {
  background: rgba(31, 28, 48, 0.54);
  backdrop-filter: blur(6px);
}

.month-reveal-close {
  position: sticky;
  top: 10px;
  z-index: 3;
  float: right;
  width: 38px;
  height: 38px;
  margin: 10px 10px -48px 0;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  font-size: 24px;
}

.month-day-summary { display: grid; gap: 16px; padding: 24px; }
.month-day-summary > header { display: flex; justify-content: space-between; gap: 16px; padding-right: 44px; }
.month-day-summary h3 { margin: 2px 0 0; font-size: 24px; }
.month-summary-night { color: var(--primary-dark); font-size: 12px; }
.month-summary-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.month-summary-kpis div { display: grid; gap: 2px; padding: 10px; border: 1px solid var(--soft-line); background: var(--bg); }
.month-summary-kpis strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.month-summary-kpis span { color: var(--muted); font-size: 10px; }
.month-fasting-window {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 3px 10px;
  padding: 10px 12px;
  border-left: 3px solid var(--primary-soft);
  background: var(--bg);
}

.month-fasting-window span,
.month-fasting-window small {
  color: var(--muted);
  font-size: 11px;
}

.month-fasting-window strong,
.month-fasting-window time {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.month-fasting-window time {
  grid-column: 1 / -1;
  color: var(--primary-dark);
  font-size: 12px;
}

.month-fasting-window small {
  grid-column: 1 / -1;
}
.month-summary-events { display: grid; max-height: 260px; overflow: auto; border-block: 1px solid var(--soft-line); }
.month-summary-events > div { display: grid; grid-template-columns: 32px 1fr; gap: 9px; padding: 9px 2px; border-bottom: 1px solid var(--soft-line); }
.month-summary-events .event-icon { width: 30px; height: 30px; grid-area: auto; }
.month-summary-events time, .month-summary-events b, .month-summary-events small { display: block; }
.month-summary-events time { color: var(--muted); font-size: 10px; }
.month-summary-comparison { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.month-day-summary .primary-action { justify-self: start; }

html[data-theme="night"] .month-day-reveal::backdrop {
  background: rgba(10, 9, 24, 0.72);
}

.month-totals {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.7fr);
  gap: 24px;
  margin: 24px 0 0;
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.month-totals dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  background: var(--line);
}

.month-totals dl div {
  padding: 10px;
  background: var(--bg);
}

.month-totals dt {
  color: var(--muted);
  font-size: 12px;
}

.month-totals dd {
  margin: 4px 0 0;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.audit-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.secret-box {
  overflow-x: auto;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 18px;
}

.compact-field {
  min-width: 140px;
}

.compact-field select {
  min-height: 44px;
  font-size: 14px;
}

.footer {
  display: flex;
  justify-content: center;
  padding: 18px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

@media (max-width: 1100px) and (min-width: 821px) {
  .theme-toggle {
    width: 44px;
    padding: 0;
  }

  .theme-toggle-label {
    display: none;
  }

  .brand-section {
    display: none;
  }
}

@media (max-width: 820px) {
  .admin-layout .table-wrap {
    overflow-x: visible;
  }

  .admin-layout table,
  .admin-layout tbody,
  .admin-layout tr,
  .admin-layout td {
    display: block;
    width: 100%;
  }

  .admin-layout thead {
    display: none;
  }

  .admin-layout tr {
    display: grid;
    gap: 16px;
    padding: 18px 0;
    border-bottom: 1px solid var(--line);
  }

  .admin-layout td {
    padding: 0;
    border: 0;
  }

  .admin-layout td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 780;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .admin-action-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .photo-analysis-card {
    grid-template-columns: 1fr;
  }

  .photo-analysis-card img {
    max-height: 280px;
  }

  .topbar {
    position: static;
    display: block;
    min-height: 0;
    padding: 8px 10px;
  }

  .brand {
    display: none;
  }

  .theme-toggle {
    width: 100%;
    margin: 0 0 6px;
  }

  .brand-name {
    font-size: 18px;
  }

  .brand-section {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 17px;
  }

  .topnav {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    overflow-x: visible;
    padding-bottom: 0;
  }

  .topnav-logout {
    margin-left: 0 !important;
    padding-left: 4px;
  }

  .topnav-logout .nav-button {
    min-height: 40px;
  }

  .topnav form,
  .topnav .nav-link {
    width: 100%;
  }

  .topnav .nav-link {
    padding: 0 6px;
    font-size: 13px;
  }

  .nav-label-long {
    display: none;
  }

  .nav-label-short {
    display: inline;
  }

  .workspace-layout {
    display: block;
  }

  .quick-layout {
    grid-template-columns: 1fr;
  }

  .quick-composer {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .rhythm-header {
    flex-direction: column;
  }

  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px 18px;
  }

  .entry-form-section,
  .timeline-section,
  .auth-panel {
    padding: 20px 18px;
  }

  .entry-form-section.narrow,
  .auth-panel {
    border-right: 0;
    border-left: 0;
  }

  .auth-grid {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .chip-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .event-group-grid,
  .multi-filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .timeline-item {
    grid-template-columns: 104px 34px minmax(0, 1fr);
    grid-template-areas: "time icon copy";
  }

  .timeline-item.has-photo {
    grid-template-columns: 104px 34px minmax(0, 1fr) 76px;
    grid-template-areas: "time icon copy photo";
  }

  .timeline-photos-hidden .timeline-item.has-photo {
    grid-template-columns: 104px 34px minmax(0, 1fr);
    grid-template-areas: "time icon copy";
  }

  .timeline-photo {
    width: 76px;
    height: 64px;
  }
}

@media (max-width: 640px) {
  .entry-form-section,
  .timeline-section,
  .auth-panel {
    padding: 18px 14px;
  }

  .date-preset-group {
    gap: 8px;
  }

  .quick-composer,
  .quick-recent {
    padding: 16px 14px;
  }

  .quick-heading {
    gap: 10px;
    margin-bottom: 14px;
    flex-direction: column;
  }

  .quick-heading .secondary-action {
    display: none;
  }

  .quick-heading p:not(.eyebrow) {
    margin-top: 5px;
  }

  .quick-note textarea {
    min-height: 78px;
    padding: 12px;
    font-size: 16px;
  }

  .quick-photo-actions {
    padding: 16px;
  }

  .quick-photo-buttons {
    grid-template-columns: 1fr;
  }

  .quick-tags {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin-top: 6px;
  }

  .quick-tag {
    min-height: 76px;
    gap: 2px;
    padding: 7px 3px;
    font-size: 12px;
  }

  .quick-tag-icon,
  .quick-tag-icon svg {
    width: 30px;
    height: 30px;
  }

  .quick-save {
    min-height: 54px;
  }

  .quick-recent-list li {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .quick-recent-list li.quick-photo-fact {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .quick-photo-fact .quick-photo-thumb {
    grid-row: 1 / span 3;
    width: 64px;
    height: 76px;
  }

  .quick-photo-fact time,
  .quick-photo-fact > div,
  .quick-photo-fact .icon-link {
    grid-column: 2;
  }

  .quick-recent-list .icon-link {
    grid-column: 2;
    justify-self: start;
  }

  .rhythm-page {
    padding: 20px 14px;
  }

  .day-sky {
    min-height: 244px;
  }

  .rhythm-axis-controls,
  .rhythm-axis-presets,
  .rhythm-custom-start {
    width: 100%;
  }

  .rhythm-axis-presets {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .rhythm-axis-presets button {
    min-width: 0;
    padding: 0 6px;
    font-size: 12px;
  }

  .rhythm-custom-start {
    justify-content: flex-end;
  }

  .rhythm-detail-list li {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 6px 16px;
  }

  .rhythm-detail-list small {
    grid-column: 2;
    max-width: none;
    text-align: left;
  }

  .week-rhythm-lane {
    grid-template-columns: 80px minmax(0, 1fr);
    gap: 8px;
  }

  .week-rhythm-lane > small {
    display: none;
  }

  .week-time-axis {
    margin-right: 0;
    margin-left: 88px;
  }

  .week-view-switcher {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .week-totals,
  .month-totals {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .week-kpi-trellis,
  .month-totals dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .week-kpi-trellis .week-kpi-energy {
    grid-row: auto;
    grid-column: 1 / -1;
  }

  .month-summary-kpis {
    grid-template-columns: repeat(3, 1fr);
  }

  .month-header {
    align-items: stretch;
    flex-direction: column;
  }

  .month-navigation {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
  }

  .month-day,
  .month-blank {
    min-height: 80px;
  }

  .month-day {
    padding: 7px;
  }

  .month-day-kcal,
  .month-day-delta {
    display: none;
  }

  .month-day > time {
    font-size: 14px;
  }

  .month-day-count b {
    font-size: 13px;
  }

  .month-day-details {
    display: none;
  }
}

@media (max-width: 430px) {
  .admin-action-stack {
    grid-template-columns: 1fr;
  }

  .brand-name {
    display: none;
  }

  .theme-toggle-label {
    display: inline;
  }

  h1,
  h2 {
    font-size: 20px;
  }

  .chip-grid {
    gap: 8px;
  }

  .chip > span,
  .nav-link,
  .secondary-action,
  .date-preset,
  .date-filter-action {
    padding-right: 10px;
    padding-left: 10px;
    font-size: 14px;
  }

  .event-group-grid,
  .multi-filter-grid {
    gap: 7px;
  }

  .chip > span {
    min-height: 44px;
  }

  .date-preset-group {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .period-control-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow-x: visible;
    padding-bottom: 0;
  }

  .period-picker {
    grid-column: 1 / -1;
  }

  .period-label-desktop {
    display: none;
  }

  .period-label-mobile {
    display: inline;
    line-height: 1.15;
  }

  .custom-period-trigger,
  .date-filter-action {
    min-width: 0;
    width: 100%;
    white-space: normal;
  }

  .period-range-panel {
    right: auto;
    left: 0;
  }

  .edit-photo-upload {
    align-items: stretch;
    flex-direction: column;
  }

  .edit-photo-picker {
    justify-content: center;
    width: 100%;
  }
}

@media (max-width: 430px) {
  .period-control-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .period-control-row .date-filter-action {
    font-size: 13px;
  }

  .timeline-item {
    grid-template-columns: 28px minmax(0, 1fr);
    grid-template-areas:
      "time time"
      "icon copy";
    gap: 8px;
  }

  .timeline-item.has-photo,
  .timeline-photos-hidden .timeline-item.has-photo {
    grid-template-columns: 28px minmax(0, 1fr);
    grid-template-areas:
      "time time"
      "photo photo"
      "icon copy";
  }

  .timeline-photos-hidden .timeline-item.has-photo {
    grid-template-areas:
      "time time"
      "icon copy";
  }

  .event-icon {
    width: 28px;
    height: 28px;
  }

  .event-icon svg {
    width: 17px;
    height: 17px;
  }

  .timeline-item time {
    font-size: 14px;
  }

  .timeline-photo {
    width: 100%;
    height: 156px;
    margin: 2px 0 4px;
  }
}

@media (max-width: 430px) {
  .splash-logo {
    width: calc(100% - 42px);
    justify-content: center;
    padding: 14px 16px;
  }

  .splash-logo strong {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .splash-screen,
  .splash-screen::before,
  .splash-screen::after,
  .splash-orbit {
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
  }
}

/* Entry workspace: a calm observation surface, not a dashboard card grid. */
.entry-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  max-width: 920px;
  margin: 0 auto;
}

.entry-composer,
.entries-page {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 24px;
}

.section-kicker,
.photo-fact-eyebrow {
  margin: 0 0 6px;
  color: var(--date-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-heading > p:last-child {
  max-width: 62ch;
  color: var(--muted);
}

.entry-composer > .section-heading {
  display: block;
}

.entries-page > .section-heading {
  display: block;
}

.entry-composer > .section-heading h1,
.entries-page > .section-heading h1 {
  margin: 0 0 8px;
}

.entry-composer > .entry-save-notice {
  margin: 14px 0 0;
}

.delete-entry-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid rgba(var(--primary-rgb), 0.2);
  background: var(--bg);
  color: var(--ink);
}

.delete-entry-dialog::backdrop {
  background: rgba(34, 29, 45, 0.46);
}

.delete-entry-dialog > div {
  padding: 24px;
}

.delete-entry-dialog h2 {
  margin: 0;
  font-size: 22px;
}

.delete-dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

.confirm-delete-action,
.cancel-delete-action {
  min-height: 44px;
  border: 0;
  color: #fff;
  font-weight: 760;
  cursor: pointer;
}

.confirm-delete-action {
  background: var(--date);
}

.cancel-delete-action {
  background: var(--danger);
}

.photo-fact-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin: 20px 0 18px;
  padding: 20px;
  background: linear-gradient(135deg, #eef7ff 0%, #eee9fb 50%, #e6f4ee 100%);
  border-left: 4px solid #788fc4;
}

.photo-fact-panel h2 {
  margin: 0;
}

.photo-fact-panel p {
  margin: 6px 0 0;
  color: var(--muted);
}

.photo-fact-actions {
  display: grid;
  gap: 8px;
  min-width: 190px;
}

.photo-action {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 16px;
  color: #fff;
  background: #536f82;
  cursor: pointer;
  font-weight: 700;
}

.photo-action-secondary {
  color: #405664;
  background: transparent;
  border: 1px solid #8aa0ad;
}

html[data-theme="night"] .photo-fact-panel {
  border-left-color: #8ee5d1;
  background: var(--photo-capture-sky);
  color: #fff;
}

html[data-theme="night"] .photo-fact-panel p {
  color: rgba(255, 255, 255, 0.76);
}

html[data-theme="night"] .photo-fact-panel .photo-fact-eyebrow {
  color: #9ce8d6;
}

html[data-theme="night"] .photo-fact-panel .photo-action {
  border: 1px solid #8ee5d1;
  background: #68d7bd;
  color: #173c36;
}

html[data-theme="night"] .photo-fact-panel .photo-action-secondary {
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

html[data-theme="night"] .event-chip .event-icon,
html[data-theme="night"] .timeline-item .event-icon {
  color: var(--night-event-icon);
}

.photo-selection {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(83, 111, 130, 0.2);
}

.photo-selection.is-hidden {
  display: none;
}

.photo-preview-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.photo-preview {
  position: relative;
  height: 112px;
  overflow: hidden;
  background: var(--surface);
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 32px;
  min-height: 32px;
  border: 0;
  color: #fff;
  background: rgba(40, 34, 56, 0.78);
  font-size: 22px;
  cursor: pointer;
}

.photo-selection-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.photo-selection-actions > span {
  flex: 1;
  color: var(--muted);
  font-size: 14px;
}

.photo-selection-actions .primary-action {
  min-height: 44px;
  width: auto;
  margin: 0;
  padding: 0 16px;
}

.photo-quick-save {
  width: 100%;
  margin: 0;
}

.event-settings-link {
  min-height: 44px;
  padding: 0;
  border: 0;
  color: #6f638c;
  background: transparent;
  text-decoration: underline;
}

.event-settings-link:disabled {
  cursor: not-allowed;
  opacity: 0.64;
}

.event-settings-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(860px, calc(100vh - 32px));
  padding: 24px;
  border: 1px solid rgba(89, 78, 117, 0.2);
  background: var(--bg);
  color: var(--ink);
  overflow-y: auto;
}

.event-settings-dialog::backdrop {
  background: rgba(34, 29, 45, 0.46);
}

.event-settings-dialog header h2,
.custom-event-settings h3 {
  margin: 0;
}

.event-preference-list,
.custom-event-settings,
[data-custom-event-list] {
  display: grid;
  gap: 8px;
}

.event-preference-list {
  margin: 20px 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.event-preference-row {
  min-width: 0;
}

.event-preference-row > label:first-child {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 9px;
}

.event-preference-row input[type="checkbox"] {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  min-height: 22px;
  margin: 0;
  accent-color: var(--primary);
}

.custom-event-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.custom-event-add-row input {
  width: 100%;
  min-height: 42px;
}

.custom-event-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 4px 8px 4px 10px;
  color: var(--date-dark);
  background: var(--date-pale);
}

.custom-event-item button {
  width: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  color: var(--date-dark);
  background: transparent;
  font-size: 20px;
}

.custom-event-settings {
  padding-top: 18px;
  border-top: 1px solid rgba(89, 78, 117, 0.14);
}

.event-layout-preview {
  display: grid;
  gap: 12px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(89, 78, 117, 0.14);
}

.event-layout-preview h3,
.event-layout-preview p {
  margin: 0;
}

.event-layout-preview p {
  margin-top: 4px;
  color: var(--muted);
}

.event-preview-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.event-preview-column {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 156px;
  padding: 8px;
  border: 1px dashed rgba(var(--primary-rgb), 0.34);
  background: rgba(var(--primary-rgb), 0.05);
  transition: background 150ms ease, border-color 150ms ease;
}

.event-preview-column.is-drop-target {
  border-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.14);
}

.event-preview-column-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.event-preview-item {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 8px 7px;
  border: 1px solid var(--primary-pale);
  border-radius: 999px;
  background: var(--bg);
  cursor: grab;
  font-size: 12px;
  font-weight: 700;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
}

.event-preview-item.is-custom {
  border-color: rgba(var(--date-rgb), 0.3);
  color: var(--date-dark);
  background: var(--date-pale);
}

.event-preview-item.is-dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.event-preview-item.is-pressing {
  transform: scale(1.06);
  box-shadow: 0 8px 18px rgba(var(--primary-rgb), 0.18);
}

.event-preview-item.is-drag-placeholder {
  opacity: 0.2;
}

.event-drag-avatar {
  position: fixed;
  z-index: 10000;
  margin: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.09);
  box-shadow: 0 16px 32px rgba(43, 34, 68, 0.28);
  opacity: 0.98;
}

.event-drag-status {
  min-height: 18px;
  margin: 4px 0 0;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
}

.event-preview-grip {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 16px;
}

.event-chip .event-icon {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
}

.event-chip .event-icon svg {
  width: 27px;
  height: 27px;
}

.event-chip input:checked + span .event-icon {
  color: #fff;
}

.entry-field-label {
  color: var(--ink);
}

.entry-composer textarea::placeholder {
  color: var(--muted);
  font-weight: 400;
}

.edit-photo-upload {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid rgba(var(--primary-rgb), 0.2);
  background: rgba(var(--primary-rgb), 0.055);
}

.edit-photo-upload h2,
.edit-photo-upload p {
  margin: 0;
}

.edit-photo-upload h2 {
  font-size: 16px;
}

.edit-photo-upload p,
.muted-copy {
  color: var(--muted);
  font-size: 13px;
}

.edit-photo-picker {
  flex: 0 0 auto;
  cursor: pointer;
}

.edit-photo-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.compact-action {
  min-height: 38px;
  padding: 7px 12px;
}

.dialog-actions {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

@media (max-width: 760px) {
  .entry-workspace {
    grid-template-columns: 1fr;
  }

  .entry-composer,
  .entries-page {
    padding: 18px;
  }

  .photo-fact-panel {
    grid-template-columns: 1fr;
  }

  .photo-fact-actions {
    min-width: 0;
  }

  .photo-preview-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .photo-selection-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .event-group-grid .chip > span {
    gap: 4px;
    padding: 6px 4px;
    font-size: 12px;
  }

  .event-group-grid .event-icon,
  .event-group-grid .event-icon svg {
    width: 26px;
    height: 26px;
  }

  .event-settings-dialog {
    padding: 18px;
  }

  .event-preference-list {
    grid-template-columns: 1fr;
  }

  .event-preview-columns {
    grid-template-columns: repeat(3, minmax(88px, 1fr));
    overflow-x: auto;
  }

  .event-preview-column {
    min-height: 132px;
  }

  .event-preview-item {
    padding: 7px 6px;
    font-size: 11px;
  }

  .custom-event-add-row {
    grid-template-columns: 1fr;
  }

}

/* Semantic button geometry */
button,
.primary-action,
.secondary-action,
.nav-link,
.photo-action,
.notice,
.form-validation-message,
.save-notice,
.duplicate-notice {
  border-radius: 0;
}

.chip,
.chip > span,
.event-preview-item,
.date-preset,
.date-filter-action,
.rhythm-switcher,
.rhythm-switcher a,
.week-view-switcher,
.week-view-switcher a,
.rhythm-axis-presets button,
.history-switch,
.history-switch > span {
  border-radius: 999px;
}

@media (max-width: 760px) {
  .confirmation-required-entry,
  .confirmation-required-entry.has-photo {
    grid-template-columns: 104px 34px minmax(0, 1fr) 142px;
    grid-template-areas:
      "time icon copy actions"
      "photo photo photo photo";
  }

  .confirmation-required-entry:not(.has-photo) {
    grid-template-areas: "time icon copy actions";
  }

  .confirmation-required-entry .timeline-photo {
    width: 100%;
    height: 176px;
    margin-top: 6px;
  }

  .filter-actions.history-filter-actions {
    grid-template-columns: 1fr 1fr;
  }

  .history-filter-actions .export-action {
    grid-column: 1 / -1;
    justify-self: stretch;
  }
}

@media (max-width: 430px) {
  .confirmation-required-entry,
  .confirmation-required-entry.has-photo,
  .timeline-photos-hidden .confirmation-required-entry.has-photo {
    grid-template-columns: 28px minmax(0, 1fr);
    grid-template-areas:
      "time time"
      "photo photo"
      "icon copy"
      "actions actions";
  }

  .timeline-photos-hidden .confirmation-required-entry.has-photo {
    grid-template-areas:
      "time time"
      "icon copy"
      "actions actions";
  }

  .confirmation-required-entry:not(.has-photo) {
    grid-template-areas:
      "time time"
      "icon copy"
      "actions actions";
  }

  .confirmation-entry-actions {
    grid-template-columns: 1fr 1fr;
    margin-top: 4px;
  }

  .filter-actions.history-filter-actions {
    grid-template-columns: 1fr;
  }

  .history-filter-actions .export-action {
    grid-column: auto;
  }

  .history-switch,
  .history-switch > span {
    width: 100%;
  }

  .history-switch > span {
    justify-content: space-between;
  }
}
