:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #15283a;
  background: #f4f7f8;
  font-size: 16px;
  --ink: #15283a;
  --muted: #5a6c7c;
  --navy: #102d44;
  --blue: #315f78;
  --blue-dark: #274c61;
  --line: #d6e0e6;
  --surface: #ffffff;
  --soft: #edf4f7;
  --focus: #ffbf47;
  --danger: #a72f3d;
  --shadow: 0 10px 30px rgb(21 40 58 / 8%);
}

* { box-sizing: border-box; }
html { min-width: 280px; }
body { margin: 0; min-width: 280px; background: linear-gradient(180deg, #eef4f6 0, #f8fafb 20rem, #f4f7f8 100%); }
a { color: #0e5f93; text-underline-offset: .15em; }
h1, h2, h3 { color: var(--navy); line-height: 1.16; overflow-wrap: anywhere; }
h1 { margin: .15rem 0 .7rem; font-size: clamp(2rem, 4vw, 3.15rem); letter-spacing: -.035em; }
h2 { font-size: 1.25rem; }
p { line-height: 1.55; }
time { font-variant-numeric: tabular-nums; }

header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .8rem max(1rem, calc((100vw - 1240px) / 2));
  background: rgb(16 45 68 / 96%);
  border-bottom: 1px solid rgb(255 255 255 / 12%);
  color: white;
  backdrop-filter: blur(14px);
}
header a, header button { color: white; }
.brand { display: inline-flex; align-items: center; gap: .65rem; font-weight: 760; text-decoration: none; white-space: nowrap; }
.brand-mark { display: grid; width: 2.15rem; height: 2.15rem; place-items: center; border-radius: .65rem; background: #72c5e8; color: #0e3048; font-weight: 900; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 1rem; }
.header-actions a { text-decoration: none; }
.header-actions form { margin: 0; }
.count { font-variant-numeric: tabular-nums; }

main { max-width: 1240px; margin: 2rem auto 4rem; padding: 0 1.25rem; }
.page-hero { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(20rem, .8fr); align-items: end; gap: 2rem; margin-bottom: 1.5rem; }
.hero-copy { max-width: 48rem; margin-bottom: 0; color: var(--muted); font-size: 1.05rem; }
.eyebrow { margin: 0 0 .25rem; color: #25759f; font-size: .75rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; margin: 0; }
.summary-grid div { padding: .75rem .9rem; border: 1px solid var(--line); border-radius: .75rem; background: rgb(255 255 255 / 70%); }
.summary-grid dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.summary-grid dd { margin-top: .2rem; text-align: left; font-size: .88rem; }

.notice, .flash, .empty-state { padding: .9rem 1rem; margin: 1rem 0; border: 1px solid #b9d7e5; border-radius: .75rem; background: #e8f5fa; color: #17445d; }
.flash { position: relative; border-color: #a8dcc0; background: #e8f7ee; color: #155c35; font-weight: 700; }
.empty-state { padding: 2.5rem; text-align: center; background: white; }

.grade-guide, .filter-panel, .panel, .login-card, .detail-hero {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.grade-guide { padding: 1rem 1.15rem; margin: 1.25rem 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.section-heading h2, .section-heading p { margin-top: 0; }
.section-heading h2 { margin-bottom: .35rem; }
.grade-guide-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.grade-guide-grid > div { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: .65rem; padding: .75rem; border-radius: .75rem; background: #f6f9fa; }
.grade-guide-grid p { margin: 0; color: var(--muted); font-size: .85rem; }
.grade-guide-grid strong { color: var(--ink); }

.filter-panel { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding: .9rem 1rem; margin: 1rem 0; box-shadow: none; }
.filter-label { display: block; margin-bottom: .4rem; color: var(--muted); font-size: .75rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.filters { display: flex; flex-wrap: wrap; gap: .4rem; }
.filters a, .button, button {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  padding: .58rem .9rem;
  border: 1px solid #55758b;
  border-radius: .6rem;
  background: white;
  color: #17445f;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}
.filters a { min-height: 2.3rem; padding: .4rem .72rem; font-size: .9rem; }
.filters .active, button:not(.secondary, .danger, .help-trigger, .link-button), .button.primary { border-color: var(--blue); background: var(--blue); color: white; }
.button.secondary, button.secondary { border-color: #7992a3; background: white; color: #17445f; }
button.danger { border-color: var(--danger); background: var(--danger); color: white; }
button:disabled { opacity: .58; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); align-items: start; gap: 1rem; }
.card { display: flex; min-width: 0; flex-direction: column; padding: 1rem; border: 1px solid var(--line); border-top: .38rem solid #72808b; border-radius: .9rem; background: white; box-shadow: var(--shadow); }
.card.grade-A { border-top-color: #3d7158; }
.card.grade-B { border-top-color: #476b82; }
.card.grade-C { border-top-color: #7a6740; }
.card.grade-D { border-top-color: #82535a; }
.card h2 { margin: .9rem 0 .25rem; font-size: 1.16rem; }
.card h2 a { color: #103f60; }
.card-top, .badge-row, .hero-actions, .toggle-form, .action-with-help { display: flex; align-items: center; gap: .55rem; }
.card-top { justify-content: space-between; }
.badge-row { flex-wrap: wrap; }
.grade { display: inline-grid; min-width: 2.2rem; min-height: 2.2rem; place-items: center; border-radius: 50%; background: #405465; color: white; font-weight: 900; }
.grade-A { background: #3d7158; }
.grade-B { background: #476b82; }
.grade-C { background: #75613a; }
.grade-D { background: #82535a; }
.source-badge, .status-badge, .viewing-badge { display: inline-flex; min-height: 1.8rem; align-items: center; padding: .23rem .55rem; border-radius: 999px; background: #e9f0f4; color: #355469; font-size: .78rem; font-weight: 800; }
.viewing-badge { background: #e3f4ea; color: #166039; }
.viewing-badge.past { background: #f1ece1; color: #6b5322; }
.location { margin: 0 0 .75rem; color: var(--muted); }
.cost-highlight { position: relative; display: grid; grid-template-columns: 1fr auto; gap: .12rem .75rem; padding: .8rem; margin: .2rem 0 .75rem; border-radius: .7rem; background: #eaf4f8; }
.cost-highlight span { color: #3c647a; font-size: .78rem; font-weight: 800; text-transform: uppercase; }
.cost-highlight strong { grid-row: span 2; align-self: center; color: #103f60; font-size: 1.22rem; }
.cost-highlight small { color: var(--muted); }
.cost-highlight .help-trigger { position: absolute; top: -.45rem; right: -.45rem; }
dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .42rem 1rem; }
dt { min-width: 0; color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; text-align: right; font-weight: 650; }
.card-facts { margin: .15rem 0 .7rem; font-size: .9rem; }
.appointment, .note-preview, .duplicate-note { padding: .65rem .75rem; margin: .6rem 0 0; border-radius: .6rem; background: #eef7f2; color: #265a40; overflow-wrap: anywhere; }
.appointment.past { background: #f4f0e7; color: #665328; }
.note-preview { background: #f5f1fb; color: #584171; white-space: pre-line; }
.duplicate-note { background: #fff4d5; color: #685214; }
.progress-row { padding: .35rem 0; margin-top: auto; border-top: 1px solid #edf1f3; }
.toggle-form { flex-wrap: wrap; }
.toggle-form label { display: inline-flex; min-height: 2.75rem; align-items: center; gap: .55rem; font-weight: 750; cursor: pointer; }
.toggle-form input[type="checkbox"] { width: 1.35rem; height: 1.35rem; margin: 0; accent-color: var(--blue); }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .7rem; }
.card-actions .action-with-help:last-child { grid-column: 1 / -1; }
.action-with-help { min-width: 0; }
.action-with-help > :first-child { flex: 1; }
.action-with-help form, .action-with-help form button { width: 100%; }
.inline-form { display: inline-flex; margin: 0; }

.help-trigger { position: relative; display: inline-grid; width: 2.3rem; min-width: 2.3rem; height: 2.3rem; min-height: 2.3rem; padding: 0; place-items: center; border: 1px solid #8aa1b0; border-radius: 50%; background: white; color: #345c72; font-weight: 900; }
.help-small { width: 1.9rem; min-width: 1.9rem; height: 1.9rem; min-height: 1.9rem; font-size: .8rem; }
.tooltip-bubble { position: fixed; z-index: 100; width: min(19rem, calc(100vw - 1.5rem)); padding: .72rem .8rem; border-radius: .6rem; background: #102d44; color: white; box-shadow: 0 10px 35px rgb(0 0 0 / 24%); font-size: .86rem; line-height: 1.45; }
.tooltip-bubble[hidden] { display: none; }

.back-link { display: inline-block; margin-bottom: 1rem; font-weight: 750; text-decoration: none; }
.detail-hero { position: relative; padding: clamp(1.2rem, 3vw, 2rem); margin-bottom: 1rem; overflow: hidden; background: linear-gradient(135deg, #fff, #edf7fa); }
.detail-hero h1 { max-width: 58rem; margin-top: .8rem; }
.detail-hero p { color: var(--muted); }
.hero-actions { flex-wrap: wrap; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(19rem, .85fr); align-items: start; gap: 1rem; }
.panel { padding: 1.15rem; margin-bottom: 1rem; }
.panel > :first-child { margin-top: 0; }
.detail-sidebar { position: sticky; top: 5rem; }
.cost-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem; margin: .75rem 0 1rem; }
.cost-cards div { display: grid; gap: .2rem; padding: .8rem; border: 1px solid var(--line); border-radius: .7rem; background: #f7fafb; }
.cost-cards span { color: var(--muted); font-size: .8rem; }
.cost-cards strong { color: #153f59; font-size: 1.1rem; }
.cost-cards .emphasis { border-color: #aad2e3; background: #e9f6fa; }
.detail-grid { grid-template-columns: minmax(9rem, 1fr) minmax(0, 2.2fr); }
.detail-grid dd { text-align: left; }
.link-list { padding-left: 1.25rem; }
.link-list li { margin: .5rem 0; }
.separated { padding-top: 1rem; margin-top: 1rem; border-top: 1px solid var(--line); }
.stacked-form { display: grid; gap: .65rem; }
.stacked-form > label { font-weight: 750; }
.workflow-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.workflow-actions form, .workflow-actions button { width: 100%; }
.split-actions { display: grid; grid-template-columns: 1fr auto; gap: .55rem; }
.danger-zone { border-color: #e4bdc2; }
.danger-zone p { color: var(--muted); }

textarea, input, select { width: 100%; min-height: 2.75rem; padding: .7rem .75rem; border: 1px solid #8099aa; border-radius: .55rem; background: white; color: var(--ink); font: inherit; }
textarea { margin-bottom: .3rem; resize: vertical; }
.field-meta { display: flex; justify-content: space-between; gap: .75rem; color: var(--muted); }
.field-error, .error { color: #922534; font-weight: 750; }
.success { padding: .8rem; margin: 1rem 0; border-radius: .55rem; background: #e5f5eb; color: #145c32; }
.narrow-panel { max-width: 46rem; margin-inline: auto; }
.login-card { max-width: 28rem; padding: 1.25rem; margin: 10vh auto; }
.login-card form { display: grid; gap: .8rem; }
.link-button { min-height: auto; padding: .25rem; border: 0; background: transparent; }
.signed-in { padding-left: .75rem; border-left: 1px solid rgb(255 255 255 / 25%); color: #dce8ee; font-size: .9rem; }
.notification-link { display: inline-flex; align-items: center; gap: .35rem; }
.notification-count { display: inline-grid; min-width: 1.45rem; min-height: 1.45rem; padding: .1rem .35rem; place-items: center; border-radius: 999px; background: #f0c974; color: #253442; font-size: .75rem; font-weight: 900; }
.compact-hero { align-items: center; }
.muted { color: var(--muted); }
.commute-form { display: grid; grid-template-columns: minmax(10rem, 1fr) minmax(10rem, 1fr) auto auto; align-items: end; gap: .65rem; }
.commute-form label { display: block; margin-bottom: .35rem; font-weight: 750; }
.chat-thread { display: grid; gap: .75rem; margin: 1rem 0; }
.chat-message { max-width: 88%; padding: .8rem .9rem; border: 1px solid #cdd9df; border-radius: .8rem .8rem .8rem .2rem; background: #f3f6f7; }
.chat-message.own { justify-self: end; border-color: #bdd2dc; border-radius: .8rem .8rem .2rem .8rem; background: #e9f1f4; }
.chat-message p { margin: .45rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; color: var(--muted); font-size: .8rem; }
.inline-review { display: flex; align-items: center; gap: .5rem; margin-top: .75rem; }
.user-list, .notification-list { display: grid; gap: .65rem; }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem; border: 1px solid var(--line); border-radius: .7rem; background: #f7f9fa; }
.notification-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem 1rem; padding: .85rem; border: 1px solid var(--line); border-radius: .7rem; color: var(--ink); text-decoration: none; }
.notification-item span { grid-column: 1; }
.notification-item time { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--muted); font-size: .82rem; }
.notification-item.unread { border-left: .35rem solid #476b82; background: #edf4f7; }
.secret-panel { border-color: #bda766; background: #fffaf0; }
.workflow-steps { padding-left: 1.25rem; line-height: 1.7; }
kbd { padding: .08rem .32rem; border: 1px solid #aebac1; border-radius: .25rem; background: #f3f5f6; box-shadow: 0 1px 0 #9aa8b0; font: inherit; font-size: .85em; }

@media (max-width: 980px) {
  .grade-guide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-sidebar { position: static; }
}

@media (max-width: 760px) {
  header { position: static; align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; justify-content: flex-start; overflow-x: auto; padding-bottom: .2rem; }
  .header-actions > * { flex: 0 0 auto; }
  main { margin-top: 1.2rem; padding-inline: .8rem; }
  .page-hero { grid-template-columns: 1fr; gap: 1rem; }
  .filter-panel { align-items: stretch; flex-direction: column; }
  .filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .25rem; }
  .filters a { flex: 0 0 auto; }
  .cost-cards { grid-template-columns: 1fr; }
  .commute-form { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; gap: .12rem; }
  .detail-grid dd { margin-bottom: .65rem; }
  .hero-actions .button { flex: 1; }
}

@media (max-width: 480px) {
  :root { font-size: 15px; }
  .brand span:last-child { max-width: 13.5rem; overflow: hidden; text-overflow: ellipsis; }
  .grade-guide-grid, .summary-grid { grid-template-columns: 1fr; }
  .card, .panel, .login-card, .grade-guide, .filter-panel { padding: .85rem; border-radius: .75rem; }
  .card-actions { grid-template-columns: 1fr; }
  .card-actions .action-with-help:last-child { grid-column: auto; }
  .card-actions .button, .card-actions form { width: 100%; }
  .card-facts { grid-template-columns: minmax(0, 1fr) minmax(8rem, auto); gap: .35rem .55rem; }
  .cost-highlight { grid-template-columns: 1fr; }
  .cost-highlight strong { grid-row: auto; }
  .field-meta { flex-direction: column; gap: .2rem; }
  .split-actions { grid-template-columns: 1fr; }
  .commute-form { grid-template-columns: 1fr; }
  .chat-message { max-width: 96%; }
  .user-row { align-items: stretch; flex-direction: column; }
  .user-row form, .user-row button { width: 100%; }
  .notification-item { grid-template-columns: 1fr; }
  .notification-item time { grid-column: 1; grid-row: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
