/* PreMed Copilot — modern app shell + auth (youth-friendly, accessible) */
:root {
  --font: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "DM Sans", var(--font);
  --bg: #f4f2ff;
  --bg-elevated: #ffffff;
  --text: #16132a;
  --text-muted: #5c5678;
  --border: rgba(22, 19, 42, 0.08);
  --shadow: 0 4px 24px rgba(45, 30, 120, 0.08);
  --shadow-hover: 0 12px 40px rgba(45, 30, 120, 0.12);
  --radius: 1rem;
  --radius-lg: 1.35rem;
  --primary: #5b3df5;
  --primary-2: #7c3aed;
  --accent: #06d6a0;
  --accent-2: #f72585;
  --danger: #e11d48;
  --focus: 0 0 0 3px rgba(91, 61, 245, 0.35);
  --header-h: 4rem;
  --content-max: 68rem;
  --grad-mesh: radial-gradient(1200px 800px at 10% -10%, rgba(91, 61, 245, 0.16), transparent 50%),
    radial-gradient(900px 600px at 100% 0%, rgba(6, 214, 160, 0.12), transparent 45%),
    radial-gradient(700px 500px at 50% 100%, rgba(247, 37, 133, 0.08), transparent 40%),
    linear-gradient(180deg, #f4f2ff 0%, #f8f6ff 40%, #f1f0fb 100%);
  --grad-brand: linear-gradient(125deg, #5b3df5 0%, #7c3aed 40%, #f72585 100%);
  --grad-cta: linear-gradient(125deg, #5b3df5, #6d28d9);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--grad-mesh);
  min-height: 100dvh;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0.5rem;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--text);
  color: #fff;
  border-radius: 0.5rem;
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus {
  left: 0.5rem;
  outline: none;
  box-shadow: var(--focus);
}

a {
  color: var(--primary);
  text-decoration: none;
  text-underline-offset: 0.12em;
}
a:hover {
  text-decoration: underline;
  color: var(--primary-2);
}

h1, h2, h3, .headline {
  font-family: var(--font);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h1 { font-size: clamp(1.6rem, 3vw, 2rem); margin: 0 0 0.5rem; }
h2 { font-size: 1.2rem; margin: 0 0 0.75rem; }
h3 { font-size: 1.05rem; font-weight: 600; }

.muted, .text-muted {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ——— App layout ——— */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-top {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset;
}

.app-top__inner {
  max-width: calc(var(--content-max) + 3rem);
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand__mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.6rem;
  background: var(--grad-cta);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  box-shadow: 0 4px 16px rgba(91, 61, 245, 0.35);
}
.brand__text span { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Nav */
.app-nav {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}
@media (max-width: 640px) {
  .app-nav {
    width: 100%;
    order: 3;
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
  }
}
.nav-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.nav-pill:hover {
  background: rgba(91, 61, 245, 0.08);
  color: var(--primary);
  text-decoration: none;
}
.nav-pill.is-active {
  background: #fff;
  color: var(--primary);
  border-color: rgba(91, 61, 245, 0.25);
  box-shadow: 0 2px 12px rgba(91, 61, 245, 0.12);
}

.app-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}
.user-chip {
  display: none;
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (min-width: 900px) {
  .user-chip { display: block; }
}

/* Shell main */
.app-main {
  flex: 1;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
}

/* Page title row */
.page-head {
  margin-bottom: 1.5rem;
}
.page-head h1 { margin-bottom: 0.35rem; }
.page-eyebrow {
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--primary);
  margin: 0 0 0.25rem;
}

/* Cards */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
.card--lift:hover {
  box-shadow: var(--shadow-hover);
  transition: box-shadow 0.2s;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}
.feature-card {
  text-decoration: none;
  color: inherit;
  display: block;
  padding: 1.35rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
  position: relative;
  overflow: hidden;
}
.feature-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--grad-brand);
  opacity: 0.9;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}
.feature-card:hover {
  text-decoration: none;
  color: inherit;
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(91, 61, 245, 0.2);
}
.feature-card:hover::before { transform: scaleX(1); }
.feature-card__icon { font-size: 1.75rem; line-height: 1; margin-bottom: 0.5rem; }
.feature-card h3 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.feature-card p { margin: 0; color: var(--text-muted); font-size: 0.92rem; line-height: 1.45; }
.feature-card .arrow { margin-top: 0.75rem; font-size: 0.85rem; font-weight: 600; color: var(--primary); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.15rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  color: #fff;
  background: var(--grad-cta);
  box-shadow: 0 4px 16px rgba(91, 61, 245, 0.35);
}
.btn-primary:hover {
  filter: brightness(1.05);
  box-shadow: 0 6px 20px rgba(91, 61, 245, 0.45);
}
.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.btn-secondary:hover {
  border-color: rgba(91, 61, 245, 0.35);
  color: var(--primary);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
}
.btn-ghost:hover { color: var(--primary); }
.btn-ghost--danger { color: var(--danger); }
.btn-ghost--danger:hover { color: #be123c; }
.btn-block { width: 100%; }
.btn-lg { padding: 0.7rem 1.35rem; font-size: 1rem; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

/* Forms */
.form-card {
  max-width: 40rem;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1rem;
}
@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr; }
}
.form-grid .full { grid-column: 1 / -1; }
label, .label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  max-width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: #9b96b0; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: rgba(91, 61, 245, 0.5);
  box-shadow: 0 0 0 3px rgba(91, 61, 245, 0.2);
}
textarea {
  min-height: 8rem;
  resize: vertical;
  line-height: 1.5;
}
.form-actions { margin-top: 1.25rem; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.form-hint { font-size: 0.85rem; color: var(--text-muted); margin: 0.5rem 0 0; }

/* Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  margin-top: 0.5rem;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  background: linear-gradient(180deg, rgba(91, 61, 245, 0.06), rgba(255, 255, 255, 0));
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--text-muted);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(91, 61, 245, 0.04); }
.data-table a { font-weight: 600; }
.cell-date { color: var(--text-muted); font-size: 0.88rem; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge--pending { background: rgba(245, 158, 11, 0.15); color: #b45309; }
.badge--succeeded, .badge--success { background: rgba(6, 214, 160, 0.15); color: #047857; }
.badge--failed, .badge--error { background: rgba(225, 29, 72, 0.12); color: #be123c; }
.badge--neutral { background: rgba(92, 86, 120, 0.12); color: var(--text-muted); }

/* Insight / prose */
.prose-block {
  white-space: pre-wrap;
  line-height: 1.65;
  color: #2d2a3d;
  margin: 0;
}
.insight-block {
  margin: 0.75rem 0 0;
  padding: 0.9rem 1rem;
  background: linear-gradient(135deg, rgba(91, 61, 245, 0.06) 0%, rgba(6, 214, 160, 0.06) 100%);
  border-radius: 0.75rem;
  border: 1px solid rgba(91, 61, 245, 0.12);
}
.insight-block strong { color: var(--text); }
.meta-line { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.75rem; }

/* Score board */
.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.75rem;
}
.score-tile {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  text-align: center;
  box-shadow: var(--shadow);
}
.score-tile__value {
  font-family: var(--font);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
}
.score-tile__label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 0.35rem;
}
.timeline-pill {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  background: #fff;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-family: ui-monospace, monospace;
  color: var(--primary-2);
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert--error {
  background: rgba(225, 29, 72, 0.08);
  border-color: rgba(225, 29, 72, 0.25);
  color: #9f1239;
}

/* ——— Auth pages ——— */
body.auth-page {
  min-height: 100dvh;
  background: var(--grad-mesh);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1.25rem 3rem;
}
.auth-surface {
  width: 100%;
  max-width: 24rem;
}
.auth-brand {
  text-align: center;
  margin-bottom: 1.5rem;
  text-decoration: none;
  color: inherit;
  display: block;
}
.auth-brand:hover { text-decoration: none; }
.auth-logo-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}
.auth-title {
  font-family: var(--font);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.04em;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 0;
}
.auth-sub { margin: 0.25rem 0 0; font-size: 0.9rem; color: var(--text-muted); }
.auth-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.4rem 1.4rem;
  box-shadow: var(--shadow);
}
.auth-card h2 { margin: 0 0 0.2rem; font-size: 1.15rem; }
.auth-form label { display: block; margin-top: 1rem; }
.auth-form input {
  width: 100%;
  margin-top: 0.4rem;
}
.auth-form .btn-primary { width: 100%; margin-top: 1.25rem; }
.auth-foot {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 1.15rem;
}
.auth-foot a { font-weight: 600; }
.code-block {
  display: block;
  padding: 0.6rem 0.75rem;
  background: #f0eef8;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  word-break: break-all;
  margin: 0.5rem 0;
  font-family: ui-monospace, monospace;
}

/* Links row */
.link-row { margin-top: 1.25rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; font-size: 0.9rem; }

/* ——— Code inline ——— */
code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.86em;
  background: rgba(91, 61, 245, 0.08);
  padding: 0.15em 0.4em;
  border-radius: 0.35rem;
  color: var(--primary-2);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--text-muted);
}
.empty-state p { max-width: 20rem; margin: 0.5rem auto 0; }

/* Hero (dashboard) */
.hero-strip {
  background: linear-gradient(125deg, rgba(91, 61, 245, 0.12) 0%, rgba(6, 214, 160, 0.1) 50%, rgba(247, 37, 133, 0.08) 100%);
  border: 1px solid rgba(91, 61, 245, 0.15);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 24px rgba(91, 61, 245, 0.08);
}
.hero-strip h1 { font-size: 1.4rem; margin: 0 0 0.25rem; }
.hero-strip p { margin: 0; color: var(--text-muted); }

/* ——— Timeline (plan view) ——— */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1.4rem;
  border-left: 2px solid rgba(91, 61, 245, 0.18);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.timeline__item {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.timeline__item:hover {
  box-shadow: 0 4px 18px rgba(91, 61, 245, 0.08);
  transform: translateY(-1px);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.timeline__dot {
  position: absolute;
  left: -1.95rem;
  top: 1rem;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 999px;
  background: var(--grad-brand);
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px rgba(91, 61, 245, 0.18);
}
.timeline__item--milestone .timeline__dot { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.timeline__item--task .timeline__dot { background: linear-gradient(135deg, #06d6a0, #5b3df5); }
.timeline__item--reflection .timeline__dot { background: linear-gradient(135deg, #5b3df5, #f72585); }
.timeline__item--clinical_attempt .timeline__dot { background: linear-gradient(135deg, #2563eb, #06d6a0); }
.timeline__item--simulation .timeline__dot { background: linear-gradient(135deg, #f72585, #f59e0b); }
.timeline__item--prediction .timeline__dot { background: linear-gradient(135deg, #5b3df5, #2563eb); }
.timeline__item--recommendation .timeline__dot { background: linear-gradient(135deg, #f59e0b, #f72585); }

/* ——— Pills (timeline badges) ——— */
.pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(91, 61, 245, 0.08);
  color: var(--primary-2);
  border: 1px solid rgba(91, 61, 245, 0.18);
}
.pill--done { background: rgba(6, 214, 160, 0.15); color: #047857; border-color: rgba(6, 214, 160, 0.35); }
.pill--milestone { background: rgba(245, 158, 11, 0.15); color: #b45309; border-color: rgba(245, 158, 11, 0.35); }
.pill--task { background: rgba(6, 214, 160, 0.12); color: #047857; border-color: rgba(6, 214, 160, 0.3); }
.pill--reflection { background: rgba(91, 61, 245, 0.12); color: var(--primary-2); border-color: rgba(91, 61, 245, 0.3); }
.pill--clinical_attempt { background: rgba(37, 99, 235, 0.12); color: #1d4ed8; border-color: rgba(37, 99, 235, 0.3); }
.pill--simulation { background: rgba(247, 37, 133, 0.12); color: #be185d; border-color: rgba(247, 37, 133, 0.3); }
.pill--prediction { background: rgba(91, 61, 245, 0.12); color: var(--primary-2); border-color: rgba(91, 61, 245, 0.3); }
.pill--recommendation { background: rgba(245, 158, 11, 0.12); color: #b45309; border-color: rgba(245, 158, 11, 0.3); }
