:root {
  --bg: #fef4fa;
  --bg-accent: #fed2e2;
  --surface: rgba(255, 250, 255, 0.9);
  --surface-strong: #fff8ff;
  --surface-alt: #f7e9ff;
  --line: rgba(143, 135, 241, 0.2);
  --text: #28193d;
  --muted: #65577d;
  --accent: #b13bff;
  --accent-strong: #8f87f1;
  --accent-soft: #e9a5f1;
  --accent-hot: #ff2df1;
  --success: #6b48d8;
  --warning: #c68efd;
  --shadow: 0 18px 45px rgba(143, 135, 241, 0.16);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 45, 241, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(198, 142, 253, 0.24), transparent 32%),
    linear-gradient(180deg, #fff8fe 0%, #f7e6ff 100%);
}

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

.shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
  align-items: start;
}

.sidebar {
  padding: 28px 22px;
  background: linear-gradient(180deg, rgba(143, 135, 241, 0.98), rgba(177, 59, 255, 0.98));
  color: #fff7ff;
  border-right: 1px solid rgba(255, 244, 255, 0.18);
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  z-index: 6;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-close-button {
  display: none;
  margin-left: auto;
  margin-bottom: 14px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.12);
  color: #fff8ff;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.brand h1 {
  margin: 8px 0 10px;
  font-family: "Fraunces", serif;
  font-size: 2rem;
  line-height: 1;
}

.brand-copy {
  margin: 0 0 22px;
  color: rgba(255, 242, 255, 0.82);
  line-height: 1.55;
}

.eyebrow {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 230, 255, 0.78);
}

.main {
  padding: 28px;
  position: relative;
  z-index: 1;
}

.hero,
.panel {
  backdrop-filter: blur(12px);
  background: var(--surface);
  border: 1px solid rgba(138, 104, 74, 0.14);
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  padding: 26px;
  border-radius: 22px;
  margin-bottom: 22px;
}

.hero h2 {
  margin: 8px 0 10px;
  font-family: "Fraunces", serif;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1;
  max-width: 12ch;
}

.hero-copy {
  max-width: 56ch;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  align-items: center;
}

.app-status {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 251, 255, 0.94);
  box-shadow: var(--shadow);
  line-height: 1.5;
}

.app-status.is-success {
  border-color: rgba(107, 72, 216, 0.24);
  background: rgba(245, 238, 255, 0.98);
}

.app-status.is-info {
  border-color: rgba(143, 135, 241, 0.22);
  background: rgba(251, 247, 255, 0.98);
}

.app-status.is-error {
  border-color: rgba(255, 45, 241, 0.24);
  background: rgba(255, 240, 248, 0.98);
}

.dashboard-grid,
.content-grid {
  display: grid;
  gap: 22px;
  margin-bottom: 22px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
}

.content-grid {
  grid-template-columns: minmax(340px, 1.05fr) minmax(0, 0.95fr);
}

.panel {
  border-radius: 20px;
  padding: 20px;
}

.sidebar-panel {
  background: rgba(255, 247, 255, 0.1);
  border-color: rgba(255, 240, 255, 0.14);
  box-shadow: none;
}

.shortcut-drawer {
  margin-bottom: 18px;
  border: 1px solid rgba(255, 240, 255, 0.14);
  border-radius: 18px;
  background: rgba(255, 247, 255, 0.1);
  overflow: hidden;
}

.shortcut-summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  font-weight: 700;
  color: #fff8ff;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.shortcut-summary::-webkit-details-marker {
  display: none;
}

.shortcut-summary::after {
  content: "+";
  font-size: 1.1rem;
  margin-left: auto;
}

.shortcut-summary-icon {
  width: 22px;
  min-width: 22px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  color: #fff8ff;
  font-size: 1rem;
}

.shortcut-summary-label {
  min-width: 0;
}

.shortcut-drawer[open] .shortcut-summary::after {
  content: "-";
}

.shortcut-nav {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.shortcut-link {
  display: block;
  padding: 11px 12px;
  border-radius: 12px;
  color: #fff8ff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.shortcut-link:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.22);
}

.setup-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 240, 255, 0.16);
  background: rgba(255, 248, 255, 0.1);
}

.auth-setup-card {
  margin-bottom: 14px;
}

.supabase-drawer {
  margin-top: 10px;
  border-top: 1px solid rgba(255, 240, 255, 0.12);
  padding-top: 10px;
}

.supabase-drawer summary {
  cursor: pointer;
  font-weight: 700;
  color: #fff8ff;
  list-style: none;
}

.supabase-drawer summary::-webkit-details-marker {
  display: none;
}

.supabase-drawer summary::after {
  content: "+";
  float: right;
}

.supabase-drawer[open] summary::after {
  content: "-";
}

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

.panel-heading h2 {
  margin: 0;
  font-size: 1rem;
}

.people-list,
.stack {
  display: grid;
  gap: 12px;
}

.person-card,
.summary-card,
.insight-card,
.history-card,
.upcoming-card,
.advice-card,
.calendar-day {
  border: 1px solid var(--line);
  border-radius: 14px;
}

.person-card {
  padding: 14px;
  background: rgba(255, 246, 255, 0.08);
  color: #fff8ff;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.person-card:hover,
.person-card.is-active {
  transform: translateY(-1px);
  border-color: rgba(255, 231, 255, 0.45);
  background: rgba(255, 246, 255, 0.18);
}

.person-card strong,
.summary-card strong,
.insight-card strong,
.history-card strong,
.upcoming-card strong,
.advice-card strong {
  display: block;
}

.person-meta,
.summary-meta,
.card-copy,
.mini-copy {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.sidebar .person-meta,
.sidebar .mini-copy {
  color: rgba(255, 240, 255, 0.78);
}

.stats-panel {
  display: grid;
  gap: 14px;
}

.drawer-panel {
  margin-top: 0;
}

.stat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.95rem;
}

.stat-button {
  width: 100%;
  padding: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.stat-button:hover,
.stat-button.is-active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
}

.stat-label {
  color: rgba(255, 235, 255, 0.8);
}

.spotlight-panel select {
  max-width: 220px;
}

.selected-summary {
  min-height: 180px;
}

.summary-card,
.insight-card,
.history-card,
.upcoming-card,
.advice-card {
  background: var(--surface-strong);
  padding: 14px 15px;
}

.insight-button {
  width: 100%;
  text-align: left;
  background: var(--surface-strong);
  color: inherit;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.insight-button:hover {
  transform: translateY(-1px);
  border-color: rgba(143, 135, 241, 0.34);
  box-shadow: 0 10px 24px rgba(143, 135, 241, 0.1);
}

.summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
}

.summary-chip {
  background: var(--surface-alt);
  border-radius: 12px;
  padding: 12px;
}

.summary-chip span {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
}

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

.ai-input-grid {
  margin-bottom: 16px;
}

#followupPanel {
  padding-top: 4px;
}

.form-grid label {
  display: grid;
  gap: 7px;
}

.inline-field-group {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
}

.form-grid label span {
  font-size: 0.88rem;
  color: var(--muted);
}

.full {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid rgba(98, 70, 45, 0.18);
  background: rgba(255, 252, 247, 0.95);
  color: var(--text);
}

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

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(177, 59, 255, 0.18);
  border-color: rgba(177, 59, 255, 0.42);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.compact-actions {
  margin-top: 0;
  gap: 8px;
  justify-content: flex-end;
}

.edit-banner {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(198, 142, 253, 0.18);
  border: 1px solid rgba(143, 135, 241, 0.22);
  color: var(--text);
  font-size: 0.92rem;
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  border: 0;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease, background 180ms ease;
}

.primary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  padding: 0 16px;
  border-radius: 999px;
  color: #fff8ff;
  background: linear-gradient(135deg, var(--accent), var(--accent-hot));
}

.ghost-button {
  padding: 0 14px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 248, 255, 0.88);
  border: 1px solid var(--line);
}

.danger-button {
  color: #8b174d;
  border-color: rgba(255, 45, 241, 0.24);
  background: rgba(255, 235, 247, 0.96);
}

.icon-button {
  width: 40px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 248, 255, 0.92);
  border: 1px solid var(--line);
}

.calendar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.month-label {
  min-width: 140px;
  text-align: center;
  font-weight: 700;
}

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

.calendar-day {
  min-height: 104px;
  padding: 8px;
  background: rgba(255, 251, 255, 0.82);
}

.calendar-day.is-muted {
  background: rgba(233, 165, 241, 0.16);
}

.calendar-day-number {
  font-weight: 700;
  margin-bottom: 6px;
}

.calendar-event {
  display: block;
  margin-top: 5px;
  padding: 5px 7px;
  border-radius: 9px;
  font-size: 0.74rem;
  background: rgba(198, 142, 253, 0.38);
  color: var(--text);
  width: 100%;
  border: 0;
  text-align: left;
  cursor: pointer;
}

.calendar-event.is-support {
  background: rgba(254, 210, 226, 0.95);
}

.advice-title {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.advice-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.advice-list li + li {
  margin-top: 6px;
}

.message-list {
  display: grid;
  gap: 10px;
}

.message-option {
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-alt);
  color: var(--text);
  line-height: 1.55;
}

.empty-state {
  color: var(--muted);
  line-height: 1.6;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(143, 135, 241, 0.14);
  color: var(--success);
  font-size: 0.82rem;
  font-weight: 700;
}

.status-chip.is-warm {
  background: rgba(198, 142, 253, 0.18);
  color: var(--warning);
}

.status-chip.is-sample {
  background: rgba(254, 210, 226, 0.74);
  color: #8b174d;
}

.calendar-panel {
  margin-bottom: 22px;
  overflow-x: auto;
}

.notification-panel .panel-heading h2 {
  font-size: 0.96rem;
}

.notification-panel .stack {
  gap: 10px;
}

.notification-card {
  padding: 10px 12px;
}

.notification-card .card-copy {
  font-size: 0.86rem;
}

.notification-panel .ghost-button {
  min-height: 38px;
  padding: 0 12px;
}

@media (max-width: 1120px) {
  .dashboard-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .shell {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .sidebar {
    width: 78px;
    padding: 14px 8px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    max-height: 100vh;
    min-height: 100vh;
    border-right: 1px solid rgba(255, 244, 255, 0.18);
    transition: width 220ms ease, padding 220ms ease;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar:focus-within,
  .sidebar:has(.shortcut-drawer[open]) {
    width: 320px;
    padding: 28px 22px;
  }

  .sidebar:focus-within .sidebar-close-button,
  .sidebar:has(.shortcut-drawer[open]) .sidebar-close-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar .brand {
    margin-bottom: 14px;
  }

  .sidebar .brand-copy,
  .sidebar .brand h1,
  .sidebar .brand .eyebrow {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    margin: 0;
    pointer-events: none;
    transition: opacity 140ms ease, max-height 180ms ease;
  }

  .sidebar:has(.shortcut-drawer[open]) .brand-copy,
  .sidebar:has(.shortcut-drawer[open]) .brand h1,
  .sidebar:has(.shortcut-drawer[open]) .brand .eyebrow,
  .sidebar:focus-within .brand-copy,
  .sidebar:focus-within .brand h1,
  .sidebar:focus-within .brand .eyebrow {
    opacity: 1;
    max-height: 220px;
    pointer-events: auto;
  }

  .sidebar .shortcut-drawer {
    margin-bottom: 10px;
  }

  .sidebar .shortcut-summary {
    padding: 10px 12px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 48px;
    font-size: 0.86rem;
  }

  .sidebar:not(:focus-within):not(:has(.shortcut-drawer[open])) .shortcut-summary {
    padding: 0;
    justify-content: center;
    min-height: 52px;
    border-radius: 16px;
  }

  .sidebar:not(:focus-within):not(:has(.shortcut-drawer[open])) .shortcut-summary-icon {
    width: 44px;
    min-width: 44px;
    height: 44px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.14);
    font-size: 1rem;
  }

  .sidebar:not(:focus-within):not(:has(.shortcut-drawer[open])) .shortcut-summary-label,
  .sidebar:not(:focus-within):not(:has(.shortcut-drawer[open])) .shortcut-summary::after {
    display: none;
  }

  .sidebar:not(:focus-within):not(:has(.shortcut-drawer[open])) .shortcut-drawer[open] > :not(summary) {
    display: none;
  }

  .sidebar:not(:focus-within):not(:has(.shortcut-drawer[open])) .shortcut-drawer {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    margin-bottom: 8px;
  }

  .sidebar:not(:focus-within):not(:has(.shortcut-drawer[open])) .sidebar-close-button {
    display: none;
  }

  .sidebar .drawer-panel {
    margin-top: 0;
  }

  .main {
    padding: 22px;
  }
}

@media (max-width: 720px) {
  .shell {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .sidebar {
    width: 72px;
    padding: 16px 8px;
  }

  .sidebar:focus-within,
  .sidebar:has(.shortcut-drawer[open]) {
    width: 280px;
    padding: 22px 18px;
  }

  .sidebar:focus-within .sidebar-close-button,
  .sidebar:has(.shortcut-drawer[open]) .sidebar-close-button {
    width: 34px;
    height: 34px;
    margin-bottom: 10px;
  }

  .hero {
    padding: 20px;
    border-radius: 18px;
    flex-direction: column;
    align-items: flex-start;
  }

  .hero h2 {
    max-width: none;
    font-size: 2.25rem;
  }

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

  .calendar-grid {
    grid-template-columns: repeat(7, minmax(64px, 1fr));
    min-width: 476px;
    gap: 4px;
  }

  .calendar-day {
    min-height: 60px;
    padding: 5px;
  }

  .calendar-event {
    margin-top: 4px;
    padding: 2px 4px;
    font-size: 0.62rem;
  }
}
