*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text-1);
  font: 400 var(--fs-14)/1.4 var(--font-sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text-1); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--text-1); outline-offset: 2px; }

.icon {
  display: inline-block;
  flex: none;
  width: var(--size, 16px);
  height: var(--size, 16px);
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--fs-13);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--fast) ease-out;
}
.button.primary { background: var(--primary); color: var(--primary-text); }
.button.primary:hover { background: var(--primary-hover); }
.button.secondary { background: var(--surface); border-color: var(--border); color: var(--text-1); }
.button.secondary:hover { background: var(--nav-hover); }
.button.large { height: 44px; font-size: var(--fs-14); }
.button.block { width: 100%; }
.button:disabled { cursor: progress; }
.button.loading span { display: none; }
.button.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 700ms linear infinite;
}

.input {
  width: 100%;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-input);
  font-size: var(--fs-14);
  transition: border-color var(--fast) ease-out, box-shadow var(--fast) ease-out;
}
.input.large { height: 44px; }
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--text-1); box-shadow: 0 0 0 3px var(--focus-ring); }

.round-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--icon-button);
  color: var(--icon-muted);
  cursor: pointer;
}
.round-button:hover:not(:disabled) { color: var(--text-1); }
.round-button:disabled { opacity: 0.4; cursor: default; }

.section-label {
  margin: var(--space-6) 12px var(--space-2);
  font-size: var(--fs-11);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--section-label);
}

.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--status-off); flex: none; }
.status-dot.on { background: var(--status-on); }

/* Shell */

.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100dvh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 36px 16px 16px;
  border-right: 1px solid var(--hairline);
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; height: 22px; padding-left: 12px; color: var(--text-1); }
.brand:hover { text-decoration: none; }
.brand-name { font-size: var(--fs-15); font-weight: 600; }

.search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  height: 34px;
  margin-top: 20px;
  padding: 0 6px 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--search);
  color: var(--text-3);
  cursor: pointer;
  text-align: left;
}
.search-text { flex: 1; font-size: var(--fs-13); }
.search kbd {
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--kbd);
  font: 500 var(--fs-11)/1.3 var(--font-sans);
  color: var(--text-3);
}

.nav { display: grid; gap: 2px; margin-top: 20px; }
.section-label + .nav { margin-top: 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  color: var(--text-2);
  font-size: var(--fs-14);
  font-weight: 450;
  transition: background-color var(--fast) ease-out;
}
.nav-item:hover { background: var(--nav-hover); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--nav-active); color: var(--text-1); font-weight: 500; }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.spacer { flex: 1; min-height: var(--space-6); }

.agents {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 12px;
  border-radius: 12px;
  background: var(--search);
}
.agents-text { flex: 1; min-width: 0; display: grid; gap: 4px; }
.agents-title { font-size: var(--fs-13); font-weight: 600; }
.agent { display: flex; align-items: center; gap: 6px; font-size: var(--fs-12); color: var(--text-3); }
.agent-name { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-when { white-space: nowrap; }
.agents-open {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
}
.agents-open:hover { color: var(--text-1); }

.main { min-width: 0; padding: 32px 24px 20px 40px; }

.page-header {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-6);
  margin-bottom: var(--space-7);
}
.page-home .page-header { height: 74px; margin-bottom: 0; }

.greeting { min-width: 0; }
.greeting-hello { font-size: var(--fs-22); line-height: 1.2; letter-spacing: -0.02em; color: var(--text-2); }
.greeting-name { font-size: var(--fs-40); font-weight: 700; line-height: 1.05; letter-spacing: -0.02em; color: var(--text-1); }
.greeting-sub { margin-top: 6px; font-size: var(--fs-15); color: var(--text-3); }

.header-right { display: flex; align-items: center; margin-top: -9px; }
.day-nav { display: flex; align-items: center; gap: 8px; margin-right: var(--space-6); }
.date-button {
  margin-right: 4px;
  padding: 4px 2px;
  border: 0;
  background: none;
  font-size: var(--fs-13);
  color: var(--text-3);
  cursor: pointer;
  white-space: nowrap;
}
.date-button:hover { color: var(--text-1); }
.bell { position: relative; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; background: none; color: var(--text-1); cursor: pointer; }
.bell-dot { position: absolute; top: 3px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-orange); }
.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: var(--space-4);
  border-radius: 50%;
  background: linear-gradient(160deg, var(--nav-active), var(--surface-2));
  color: var(--text-1);
}
.avatar:hover { text-decoration: none; }
.avatar-initial { font-size: var(--fs-15); font-weight: 600; }
.avatar-dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: var(--status-off); box-shadow: 0 0 0 2px var(--bg); }
.avatar-dot.on { background: var(--status-on); }

.tabbar { display: none; }

/* Home */

.home {
  display: grid;
  grid-template-columns: minmax(300px, 432px) minmax(0, 1fr);
  grid-template-rows: 482px 275px;
  row-gap: 16px;
}

.hero { position: relative; grid-column: 1; grid-row: 1 / 3; margin-bottom: -20px; min-width: 0; }
.hero-stage { position: absolute; right: 0; bottom: 0; height: min(100%, 640px); aspect-ratio: 420 / 794; max-width: 100%; }

.hero-stage.empty { right: 24px; bottom: 48px; height: min(72%, 520px); aspect-ratio: 300 / 460; }
.hero-mirror {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 0 28px 40px;
  text-align: center;
  border-radius: 999px 999px var(--radius-lg) var(--radius-lg);
  background: radial-gradient(ellipse 80% 55% at 50% 38%, var(--surface), var(--surface-2));
  box-shadow: inset 0 0 0 1px var(--hairline);
  -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent);
  mask-image: linear-gradient(to bottom, #000 72%, transparent);
}
.hero-mirror-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 4px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-card); color: var(--text-2); }
.hero-mirror-title { font-size: var(--fs-15); font-weight: 600; color: var(--text-1); }
.hero-mirror-text { max-width: 200px; font-size: var(--fs-12); line-height: 1.45; color: var(--text-3); }
.hero-mirror-button { margin-top: 8px; height: 32px; font-size: var(--fs-12); }
.hero-mirror-button:hover { text-decoration: none; }
.hero-stats.stacked { position: absolute; left: 0; top: 64px; display: grid; gap: 26px; }
.hero-stats.stacked .hero-stat { position: static; }
.hero-stats.narrow-only { display: none; }
.hero-figure {
  position: absolute;
  inset: 0;
  -webkit-mask-image: radial-gradient(ellipse 62% 70% at 56% 42%, #000 58%, transparent 100%), linear-gradient(to bottom, #000 70%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: radial-gradient(ellipse 62% 70% at 56% 42%, #000 58%, transparent 100%), linear-gradient(to bottom, #000 70%, transparent 100%);
  mask-composite: intersect;
}
.hero-photo { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-photo { object-fit: cover; object-position: right bottom; filter: saturate(0.85) contrast(0.98); }
.hero-haze { position: absolute; inset: 0; background: radial-gradient(ellipse 85% 42% at 50% 100%, var(--hero-haze), transparent 72%); }
.hero-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.hero-dot {
  position: absolute;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: var(--hero-dot-ring);
  box-shadow: inset 0 0 0 1px var(--hero-dot-outline), 0 0 12px var(--hero-dot-glow);
}
.hero-dot::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--hero-dot); }
.hero-stat { position: absolute; }
.hero-stat-name { font-size: var(--fs-12); font-weight: 500; color: var(--text-1); }
.hero-stat-value { margin-top: 2px; font-size: var(--fs-26); font-weight: 500; line-height: 1.2; letter-spacing: -0.02em; white-space: nowrap; }
.hero-stat-value.none { font-size: var(--fs-13); font-weight: 400; line-height: 1.6; letter-spacing: 0; color: var(--text-3); }
.hero-stat-unit { margin-left: 4px; font-size: var(--fs-13); font-weight: 400; letter-spacing: 0; color: var(--text-2); }
.hero-stat-status { font-size: var(--fs-12); color: var(--text-3); }
.hero-caption { position: absolute; left: 0; bottom: 40px; }
.hero-weight { font-size: var(--fs-22); font-weight: 500; line-height: 1.2; letter-spacing: -0.02em; }
.hero-weight-unit { margin-left: 4px; font-size: var(--fs-13); font-weight: 400; letter-spacing: 0; color: var(--text-2); }
.hero-meta { margin-top: 2px; font-size: var(--fs-12); color: var(--text-3); }

.cards {
  position: relative;
  z-index: 1;
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: 256px 210px;
  gap: 16px;
}

.bottom-row {
  position: relative;
  z-index: 1;
  grid-column: 2;
  grid-row: 2;
  margin-left: -77px;
  display: grid;
  grid-template-columns: minmax(0, 410fr) minmax(0, 355fr);
  gap: 16px;
}
.bottom-row > * { height: 100%; }

.day-fade { animation: day-fade var(--day-fade) ease-out; }
@keyframes day-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Pages */

.narrow { max-width: 720px; }
.stack { display: grid; gap: var(--space-4); }
.panel {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.panel-title { font-size: var(--fs-14); font-weight: 600; margin-bottom: 4px; }
.rows > * + * { border-top: 1px solid var(--hairline); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 48px; }
.setting-label { font-size: var(--fs-14); color: var(--text-2); }
.setting-value { font-size: var(--fs-14); color: var(--text-1); text-align: right; }
.muted-line { padding: 14px 0; font-size: var(--fs-13); color: var(--text-3); }
.prose { padding: 12px 0; font-size: var(--fs-14); line-height: 1.55; color: var(--text-2); max-width: 62ch; }

.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-md); background: var(--surface-2); }
.segmented button {
  height: 26px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
}
.segmented button[aria-checked="true"] { background: var(--surface); box-shadow: var(--shadow-card); color: var(--text-1); }

.plugin-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.span-12 { grid-column: span 12; }
.span-6 { grid-column: span 6; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }

.day-view ui-timeline { min-height: 320px; }

/* Overlays */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--backdrop);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.palette {
  position: absolute;
  top: 20%;
  left: 50%;
  width: min(560px, calc(100% - 32px));
  transform: translateX(-50%);
  padding: 6px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}
.palette-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  background: none;
  font-size: var(--fs-15);
  outline: none;
}
.palette-list { max-height: 50vh; overflow-y: auto; padding: 4px 0; }
.palette-group { padding: 10px 10px 4px; font-size: var(--fs-11); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--section-label); }
.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: var(--fs-13);
  color: var(--text-1);
  text-align: left;
  cursor: pointer;
}
.palette-item .icon { color: var(--text-3); }
.palette-item:hover, .palette-item[aria-selected="true"] { background: var(--nav-hover); }
.palette-empty { padding: 16px 10px; font-size: var(--fs-13); color: var(--text-3); }

.popover-layer { position: fixed; inset: 0; z-index: 50; }
.popover {
  position: absolute;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}
.calendar { width: 268px; }
.calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: var(--fs-13); font-weight: 600; }
.calendar-head .round-button { width: 26px; height: 26px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-dow { display: grid; place-items: center; height: 26px; font-size: var(--fs-11); color: var(--text-4); }
.calendar-day {
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: var(--fs-13);
  color: var(--text-1);
  cursor: pointer;
}
.calendar-day:hover:not(:disabled) { background: var(--nav-hover); }
.calendar-day.outside { color: var(--text-4); }
.calendar-day.today { font-weight: 600; }
.calendar-day.selected { background: var(--primary); color: var(--primary-text); }
.calendar-day:disabled { color: var(--text-4); opacity: 0.5; cursor: default; }

.sheet-layer { display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  position: relative;
  width: min(520px, 100%);
  max-height: 80dvh;
  overflow-y: auto;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}
.sheet-handle { position: absolute; top: 8px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: var(--radius-full); background: var(--border); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 4px 12px; }
.sheet-head h2 { font-size: var(--fs-15); font-weight: 600; }
.sheet-list { display: grid; gap: 2px; }
.sheet-list .section-label { margin-top: var(--space-4); }

/* Login */

.login {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  overflow: hidden;
  background: var(--bg);
}
.blob { position: absolute; border-radius: 50%; pointer-events: none; }
.blob.green { width: 480px; height: 480px; left: -120px; top: -140px; background: var(--blob-green); filter: blur(80px); opacity: 0.6; }
.blob.peach { width: 520px; height: 520px; right: -140px; bottom: -160px; background: var(--blob-peach); filter: blur(90px); opacity: 0.55; }
.login-main { position: relative; z-index: 1; display: grid; justify-items: center; gap: var(--space-4); width: min(400px, 100%); }
.login-card {
  width: 100%;
  padding: 32px;
  border-radius: var(--radius-xl);
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-pop);
}
.login-brand { display: flex; align-items: center; gap: 10px; font-size: var(--fs-15); font-weight: 600; }
.login-heading { margin-top: 24px; }
.login-hello { font-size: var(--fs-22); line-height: 1.2; letter-spacing: -0.02em; color: var(--text-2); }
.login-title { font-size: var(--fs-40); font-weight: 700; line-height: 1.05; letter-spacing: -0.02em; }
.login-fields { display: grid; gap: 12px; margin: 24px 0 20px; }
.login-error { min-height: 1.4em; margin-top: 10px; font-size: var(--fs-12); color: var(--error-text); }
.login-footer { font-size: var(--fs-12); color: var(--text-3); }
.consent-text { margin-top: 12px; font-size: var(--fs-14); line-height: 1.5; color: var(--text-2); }
.consent-list { display: grid; gap: 8px; margin: 20px 0; padding: 14px 16px; border-radius: var(--radius-md); background: var(--surface-2); font-size: var(--fs-13); color: var(--text-2); }
.consent-list strong { color: var(--text-1); font-weight: 500; }
.consent-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* 1280 to 1440: hero narrows first, then cards shrink (handled by the grid minimums). */

@media (max-width: 1279px) {
  .page-home .page-header { height: auto; margin-bottom: var(--space-6); }
  .home { grid-template-columns: minmax(0, 1fr); grid-template-rows: 360px auto minmax(275px, auto); }
  .hero { grid-column: 1; grid-row: 1; margin-bottom: 0; }
  .hero-stage { right: 8%; }
  .hero-lines { display: none; }
  .hero-stats { position: absolute; left: 0; top: 0; display: grid; gap: 14px; }
  .hero-stats.narrow-only { display: grid; }
  .hero-stat.placed { display: none; }
  .hero-stat { position: static; }
  .hero-caption { left: auto; right: 0; bottom: 8px; text-align: right; }
  .hero-stage.empty { right: 30%; bottom: 0; height: 100%; }
  .cards { grid-column: 1; grid-row: 2; grid-template-rows: 236px 210px; }
  .bottom-row { grid-column: 1; grid-row: 3; width: 100%; justify-self: stretch; margin-left: 0; }
}

@media (max-width: 1023px) {
  .shell { grid-template-columns: 64px minmax(0, 1fr); }
  .sidebar { padding: 28px 10px 16px; align-items: center; }
  .brand { padding-left: 0; justify-content: center; }
  .brand-name, .search-text, .search kbd, .nav-label, .section-label, .agents-text { display: none; }
  .search { width: 40px; justify-content: center; padding: 0; }
  .nav { width: 100%; }
  .nav-item { justify-content: center; padding: 0; }
  .agents { padding: 8px; background: none; }
  .main { padding: 28px 20px 20px 24px; }
}

@media (max-width: 719px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .main { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }

  .page-header { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: start; gap: 0 4px; margin-bottom: var(--space-6); }
  .page-home .page-header { margin-bottom: var(--space-5); }
  .header-right { display: contents; }
  .greeting { grid-column: 1; grid-row: 1; }
  .greeting-hello { font-size: var(--fs-15); }
  .greeting-name { font-size: 32px; }
  .greeting-sub { font-size: var(--fs-14); }
  .bell { grid-column: 2; grid-row: 1; margin-top: 8px; }
  .avatar { grid-column: 3; grid-row: 1; width: 40px; height: 40px; margin-left: 8px; }
  .day-nav { grid-column: 1 / -1; grid-row: 2; margin: 14px 0 0; }
  .date-button { margin-right: auto; padding-left: 0; }

  .home { grid-template-rows: 320px auto auto; row-gap: 12px; }
  .hero-stat-value { font-size: var(--fs-22); }
  .hero-stage, .hero-stage.empty { right: 0; }
  .hero-stats, .hero-stats.stacked { top: 0; gap: 8px; }
  .hero-caption { left: 0; right: auto; text-align: left; }
  .hero-mirror-text { display: none; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: none; grid-auto-rows: minmax(176px, auto); gap: 12px; }
  .bottom-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .bottom-row > * { min-height: 240px; }

  .plugin-grid { grid-template-columns: minmax(0, 1fr); }
  .plugin-grid > * { grid-column: auto; }

  .tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg);
    border-top: 1px solid var(--hairline);
  }
  .tab {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    padding: 0;
    border: 0;
    background: none;
    font-size: var(--fs-11);
    font-weight: 500;
    color: var(--text-3);
    cursor: pointer;
  }
  .tab:hover { text-decoration: none; }
  .tab[aria-current="page"] { color: var(--text-1); }
  .log-button { display: grid; place-items: center; width: 34px; height: 26px; border-radius: var(--radius-full); background: var(--primary); color: var(--primary-text); }
}

@media (prefers-reduced-motion: reduce) {
  .day-fade, .button.loading::after { animation: none; }
  * { transition: none !important; }
}

/* M1: toasts, switches, plugin rows, keys, sheet forms */

.toasts {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  display: grid;
  gap: 8px;
  justify-items: end;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-13);
  color: var(--text-1);
  animation: day-fade var(--fast) ease-out;
}
.toast .icon { color: var(--good); }
.toast.error .icon { color: var(--error-text); }
.toast-action { margin-left: 6px; padding: 0; border: 0; background: none; font-weight: 600; color: var(--text-1); cursor: pointer; text-decoration: underline; }

.switch {
  appearance: none;
  position: relative;
  flex: none;
  width: 36px;
  height: 22px;
  margin: 0;
  border-radius: var(--radius-full);
  background: var(--track);
  cursor: pointer;
  transition: background-color var(--fast) ease-out;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface-input);
  box-shadow: var(--shadow-card);
  transition: transform var(--fast) ease-out;
}
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(14px); }
.switch:disabled { opacity: 0.6; cursor: progress; }

.plugin-row { display: flex; align-items: flex-start; gap: 12px; min-width: 0; padding: 10px 0; }
.plugin-row .icon { margin-top: 2px; color: var(--text-2); }
.setting-label.strong { display: block; color: var(--text-1); font-weight: 500; }
.setting-hint { display: block; font-size: var(--fs-12); color: var(--text-3); }

.key-form { display: flex; gap: 8px; padding: 12px 0; }
.key-form .input { flex: 1; }
.key-box { display: grid; gap: 6px; padding: 12px; margin-bottom: 8px; border-radius: var(--radius-md); background: var(--surface-2); }
.key-line { display: flex; align-items: center; gap: 8px; }
.key-line code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: var(--fs-13); }

.sheet-forms { display: grid; gap: 12px; }

.plugin-grid > * { min-width: 0; }
.span-8 { grid-column: span 8; }


@media (max-width: 719px) {
  .plugin-grid > * { grid-column: 1 / -1; }
}

@media (max-width: 719px) {
  .plugin-grid > ui-stat { min-height: 210px; }
}

/* Settings */

.narrow { margin-inline: auto; }

.settings-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 760px);
  justify-content: center;
  gap: 40px;
  max-width: 1000px;
  margin-inline: auto;
  align-items: start;
}
.settings-nav { position: sticky; top: 32px; display: grid; gap: 2px; }
.settings-nav a {
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  font-size: var(--fs-14);
  color: var(--text-2);
}
.settings-nav a:hover { background: var(--nav-hover); text-decoration: none; }
.settings-main { display: grid; gap: 20px; min-width: 0; }
.settings-card {
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  scroll-margin-top: 24px;
}
.settings-card-head h2 { font-size: var(--fs-15); font-weight: 600; }
.settings-card-head p { margin-top: 4px; font-size: var(--fs-13); color: var(--text-3); max-width: 60ch; }
.settings-fields { display: grid; margin-top: 12px; }
.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 300px);
  align-items: center;
  gap: 24px;
  padding: 14px 0;
  border-top: 1px solid var(--hairline);
}
.field-row:first-child { border-top: 0; }
.field-text { display: grid; gap: 2px; }
.field-label { font-size: var(--fs-14); font-weight: 500; color: var(--text-1); }
.field-hint { font-size: var(--fs-12); line-height: 1.45; color: var(--text-3); }
.field-value { font-size: var(--fs-14); color: var(--text-1); justify-self: end; }
.field-row > .button, .field-row > .segmented { justify-self: end; }
.field-row .input { width: 100%; }
select.input { appearance: none; padding-right: 32px; background-image: none; }
.time-range { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; font-size: var(--fs-13); color: var(--text-3); }
.input.time { font-variant-numeric: tabular-nums; }
.settings-card-foot { display: flex; justify-content: flex-end; padding-top: 16px; border-top: 1px solid var(--hairline); margin-top: 4px; }

.segment { position: relative; display: inline-flex; }
.segment input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segment span { display: grid; place-items: center; height: 28px; padding: 0 12px; border-radius: 8px; font-size: var(--fs-12); font-weight: 500; color: var(--text-3); }
.segment input:checked + span { background: var(--surface); box-shadow: var(--shadow-card); color: var(--text-1); }
.segment input:focus-visible + span { outline: 2px solid var(--text-1); }

.plugin-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.plugin-card { display: grid; align-content: start; gap: 6px; padding: 16px; border-radius: 12px; background: var(--surface-2); }
.plugin-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.plugin-card-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: color-mix(in oklab, var(--plugin, var(--text-3)) 18%, var(--surface));
  color: var(--text-1);
}
.plugin-card-name { font-size: var(--fs-14); font-weight: 600; }
.plugin-card-text { font-size: var(--fs-12); line-height: 1.45; color: var(--text-3); min-height: 3em; }
.plugin-card-link { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-size: var(--fs-12); font-weight: 500; color: var(--text-1); }
.plugin-card-link.muted { color: var(--text-4); }

@media (max-width: 1023px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .settings-nav { position: static; display: flex; gap: 6px; overflow-x: auto; }
  .settings-nav a { flex: none; background: var(--surface); }
}

@media (max-width: 719px) {
  .field-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .field-value, .field-row > .button, .field-row > .segmented { justify-self: start; }
  .settings-card { padding: 18px; }
}

.page-settings .page-header { max-width: 1000px; margin-inline: auto; }
.page-settings .greeting { padding-left: 220px; }
.page-connections .page-header, .page-knowledge .page-header { max-width: 720px; margin-inline: auto; }

@media (max-width: 1023px) {
  .page-settings .greeting { padding-left: 0; }
}

/* Day view */

.day-view { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.day-summary { display: grid; gap: 12px; }
.day-summary-title { font-size: var(--fs-15); font-weight: 600; }
.day-summary-figure { display: flex; align-items: baseline; gap: 8px; }
.day-summary-value { font-size: 34px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.day-summary-unit { font-size: var(--fs-13); color: var(--text-3); }
.day-summary-note { font-size: var(--fs-13); line-height: 1.5; color: var(--text-2); }
.day-lines { display: grid; margin: 4px 0 0; padding: 0; list-style: none; }
.day-lines li { display: grid; grid-template-columns: 8px 72px minmax(0, 1fr); align-items: baseline; gap: 10px; padding: 10px 0; border-top: 1px solid var(--hairline); font-size: var(--fs-13); }
.day-line-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-4); align-self: center; }
.day-line-dot.hit { background: var(--insight-steady); }
.day-line-plugin { color: var(--text-3); }
.day-line-text { color: var(--text-1); }

.block-form { display: grid; gap: 14px; padding: 0 4px; }
.block-form-note { font-size: var(--fs-13); color: var(--text-3); }
.block-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.block-field { display: grid; gap: 6px; font-size: var(--fs-12); font-weight: 500; color: var(--text-2); }
.block-field.wide { grid-column: 1 / -1; }
.block-field .input { width: 100%; }
.block-form-foot { display: flex; justify-content: flex-end; }

@media (max-width: 1023px) {
  .day-view { grid-template-columns: minmax(0, 1fr); }
}

/* Notifications */

.popover.nudges { width: min(360px, calc(100vw - 32px)); padding: 8px; }
.nudges-head { padding: 8px 8px 6px; font-size: var(--fs-14); font-weight: 600; }
.nudge-list { display: grid; max-height: min(420px, 70vh); overflow-y: auto; }
.nudge { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 8px; border-radius: var(--radius-md); color: inherit; text-decoration: none; }
a.nudge:hover { background: var(--nav-hover); }
.nudge-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); color: var(--text-2); }
.nudge.unread .nudge-icon { background: var(--text-1); color: var(--surface); }
.nudge-body { display: grid; gap: 2px; min-width: 0; }
.nudge-title { font-size: var(--fs-13); font-weight: 600; }
.nudge-text { font-size: var(--fs-13); line-height: 1.4; color: var(--text-2); }
.nudge-when { font-size: var(--fs-11); color: var(--text-3); white-space: nowrap; padding-top: 2px; }
.nudges-empty { padding: 8px 8px 12px; font-size: var(--fs-13); line-height: 1.5; color: var(--text-3); }

.plugin-grid ui-stat { min-height: 200px; }

/* Connections: services */

.services { display: grid; gap: 12px; margin-top: 8px; }
.service { display: grid; gap: 8px; padding: 14px; border-radius: var(--radius-md); background: var(--surface-2); }
.service-head { display: flex; align-items: center; gap: 8px; }
.service-name { font-size: var(--fs-14); font-weight: 600; }
.service-status { margin-left: auto; padding: 2px 8px; border-radius: var(--radius-full); font-size: var(--fs-11); font-weight: 500; background: var(--surface); color: var(--text-2); }
.service-status.connected { background: var(--insight-steady-bg); color: var(--insight-steady); }
.service-status.needs_reconnect { background: var(--chip-warn-bg); color: var(--chip-warn-text); }
.service-detail { font-size: var(--fs-13); line-height: 1.5; color: var(--text-2); }
.service-actions { display: flex; gap: 8px; }
.service-actions .button { height: 32px; font-size: var(--fs-12); }
.service-code { display: block; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface); font-size: var(--fs-12); overflow-wrap: anywhere; }

/* Plugin page tabs */

.plugin-tabs {
  display: flex;
  gap: 2px;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 16px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-2);
  overflow-x: auto;
  scrollbar-width: none;
}
.plugin-tab {
  flex: none;
  padding: 7px 16px;
  border-radius: 9px;
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
}
.plugin-tab:hover { color: var(--text-1); }
.plugin-tab[aria-selected="true"] { background: var(--surface); color: var(--text-1); box-shadow: var(--shadow-card); }
.plugin-tab:focus-visible { outline: 2px solid var(--text-1); outline-offset: 1px; }
.plugin-grid > ui-stat { align-self: start; }
.plugin-grid > ui-stat { height: 210px; }
