:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #6b7280;
  --line: #e4e8ef;
  --surface: #ffffff;
  --surface-soft: #f7f8fb;
  --brand: #3157d5;
  --brand-dark: #213c9d;
  --available: #16835b;
  --full: #64748b;
  --school: #c2410c;
  --shadow: 0 10px 28px rgba(26, 36, 58, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #eef1f6;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.muted,
.field-help,
.demo-hint {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--brand);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.25rem;
  font-size: clamp(1.35rem, 2vw, 1.85rem);
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 15% 10%, rgba(49, 87, 213, 0.22), transparent 35%),
    radial-gradient(circle at 85% 80%, rgba(22, 131, 91, 0.16), transparent 35%),
    #eef1f6;
}

.login-card {
  width: min(100%, 760px);
  padding: 2.25rem;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 2rem;
  letter-spacing: -0.04em;
}

.login-card .muted {
  line-height: 1.55;
}

.login-access-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  max-width: 480px;
  margin: 1.75rem auto 0;
}

.login-access-section {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfcff;
}

.login-access-section h2 {
  margin-bottom: 0.55rem;
}

.login-access-section .muted {
  min-height: 2.45rem;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.admin-login-section {
  border-color: #d8d2c8;
  background: #fffdf8;
}

.login-switch {
  margin: 1rem 0 0;
  font-size: 0.72rem;
  text-align: right;
}

.login-switch a {
  color: var(--muted);
}

.login-replace-prompt {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.9rem;
  padding: 0.8rem;
  border: 1px solid #f0b9b2;
  border-radius: 9px;
  background: #fff8f7;
  color: #8f2118;
  font-size: 0.78rem;
  line-height: 1.45;
}

.login-replace-prompt p {
  margin: 0;
}

.demo-hint {
  margin: 1.25rem 0 0;
  font-size: 0.75rem;
  line-height: 1.5;
}

.stack-form {
  display: grid;
  gap: 0.85rem;
}

label,
legend {
  color: #3b4657;
  font-size: 0.79rem;
  font-weight: 750;
}

label {
  display: grid;
  gap: 0.35rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d8deea;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 0.65rem 0.72rem;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(49, 87, 213, 0.12);
}

textarea {
  resize: vertical;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 0.4rem;
}

.primary-button,
.secondary-button,
.quiet-button,
.icon-button {
  border: 0;
  border-radius: 9px;
  font-weight: 750;
  transition: background 120ms ease, transform 120ms ease;
}

.primary-button {
  padding: 0.68rem 0.9rem;
  background: var(--brand);
  color: white;
}

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

.secondary-button {
  padding: 0.55rem 0.75rem;
  background: #e8edff;
  color: var(--brand-dark);
}

.quiet-button {
  padding: 0.55rem 0.75rem;
  background: transparent;
  color: #596579;
}

.quiet-button:hover {
  background: #eef1f6;
}

.icon-button {
  width: 32px;
  height: 32px;
  background: #f0f2f6;
  color: #566174;
  font-size: 1.25rem;
  line-height: 1;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem clamp(1rem, 3vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-chip {
  max-width: 260px;
  overflow: hidden;
  color: #546073;
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(360px, 0.85fr);
  gap: 1rem;
  max-width: 1800px;
  margin: 0 auto;
  padding: 1rem;
}

.publisher-section {
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 1rem 1rem;
}

.publisher-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid #d9e0ec;
  border-radius: 14px;
  background: #e8edf5;
}

.publisher-heading h2 {
  margin: 0;
}

.publisher-intro {
  max-width: 700px;
  margin: 0.35rem 0 0;
  color: #536074;
  font-size: 0.8rem;
  line-height: 1.5;
}

.publisher-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

#editor-panel,
#admin-panel {
  grid-column: 1 / -1;
}

#editor-panel {
  order: -1;
}

.site-footer {
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 1rem 1.5rem;
  color: var(--muted);
  text-align: center;
}

.site-footer p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.55;
}

.site-footer a {
  color: var(--brand-dark);
  font-weight: 700;
}

.map-column {
  min-width: 0;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(26, 36, 58, 0.035);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.7rem;
  margin-bottom: 0.75rem;
  padding: 0.75rem;
}

.toolbar-field {
  min-width: 140px;
  flex: 1 1 145px;
}

.toolbar-field.location-field {
  flex-basis: 210px;
}

.toolbar label {
  display: grid;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 38px;
  padding: 0 0.25rem;
  white-space: nowrap;
}

.check-field input,
.weekday-grid input {
  width: auto;
}

.toolbar-button {
  min-height: 38px;
  white-space: nowrap;
}

.map-shell {
  position: relative;
  min-height: 650px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #dbe4ed;
  box-shadow: var(--shadow);
}

#map {
  position: absolute;
  inset: 0;
}

.drawing-toolbar {
  position: absolute;
  z-index: 4;
  top: 0.75rem;
  right: 4.5rem;
  left: 0.75rem;
  max-width: 680px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(49, 87, 213, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 4px 14px rgba(26, 36, 58, 0.16);
  pointer-events: none;
}

.drawing-toolbar-copy {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
  color: #536074;
  font-size: 0.75rem;
}

.drawing-toolbar-copy strong {
  color: var(--brand);
  font-size: 0.78rem;
}

.drawing-toolbar-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawing-toolbar .button-row {
  flex: 0 0 auto;
  pointer-events: auto;
}

.draft-points-list {
  display: grid;
  gap: 0.35rem;
  padding-top: 0.2rem;
}

.draft-point-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.draft-point-row .quiet-button {
  padding: 0.25rem 0.45rem;
  font-size: 0.68rem;
}

.map-message {
  position: absolute;
  top: 1rem;
  left: 1rem;
  max-width: 320px;
  padding: 0.6rem 0.75rem;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 14px rgba(26, 36, 58, 0.12);
  color: #556174;
  font-size: 0.8rem;
  pointer-events: none;
}

.map-legend {
  position: absolute;
  right: 0.8rem;
  bottom: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 4px 14px rgba(26, 36, 58, 0.12);
  color: #536074;
  font-size: 0.72rem;
  pointer-events: none;
}

.legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 0.2rem;
  border-radius: 50%;
  background: var(--available);
}

.legend-swatch.full {
  background: var(--full);
}

.legend-swatch.draft {
  background: #8b5cf6;
}

.legend-swatch.school {
  background: var(--school);
}

.route-marker {
  width: 15px;
  height: 15px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--available);
  box-shadow: 0 2px 7px rgba(24, 33, 47, 0.35);
}

.route-marker.full {
  background: var(--full);
}

.draft-point-marker {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #8b5cf6;
  box-shadow: 0 2px 7px rgba(24, 33, 47, 0.35);
  color: #fff;
  cursor: grab;
  font-size: 0.65rem;
  font-weight: 800;
  user-select: none;
}

.draft-point-marker.origin {
  background: var(--brand);
}

.draft-point-marker:active {
  cursor: grabbing;
}

.school-marker {
  display: grid;
  min-width: 27px;
  height: 27px;
  padding: 0 0.25rem;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 9px;
  background: var(--school);
  box-shadow: 0 2px 7px rgba(24, 33, 47, 0.35);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 900;
}

.sidebar {
  display: grid;
  align-content: start;
  gap: 0.75rem;
  min-width: 0;
}

.summary-panel,
#route-list-panel,
#details-panel,
#my-plans-panel,
#profile-panel,
#editor-panel,
#admin-panel {
  padding: 1rem;
}

.summary-panel {
  background: linear-gradient(135deg, #f8faff, #fff);
}

.summary-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.summary-number {
  color: var(--brand);
  font-size: 2rem;
  font-weight: 850;
  letter-spacing: -0.06em;
}

.summary-caption {
  color: var(--muted);
  font-size: 0.8rem;
}

.summary-meta {
  margin: 0.55rem 0 0;
  color: #536074;
  font-size: 0.78rem;
  line-height: 1.5;
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.85rem;
}

.count-badge {
  display: inline-grid;
  min-width: 27px;
  height: 27px;
  padding: 0 0.45rem;
  place-items: center;
  border-radius: 999px;
  background: #e8edff;
  color: var(--brand-dark);
  font-size: 0.76rem;
  font-weight: 800;
}

.route-list {
  display: grid;
  gap: 0.55rem;
  max-height: 300px;
  overflow: auto;
}

.route-card {
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.route-card:hover,
.route-card.selected {
  border-color: #a8b8f5;
  background: #f8faff;
  transform: translateY(-1px);
}

.route-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.5rem;
}

.route-card h3 {
  margin: 0;
  font-size: 0.9rem;
}

.route-owner {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.seat-badge {
  flex: 0 0 auto;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  background: #e4f6ef;
  color: var(--available);
  font-size: 0.7rem;
  font-weight: 800;
}

.seat-badge.full {
  background: #eef1f5;
  color: var(--full);
}

.route-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  margin-top: 0.55rem;
  color: #536074;
  font-size: 0.72rem;
}

.empty-state {
  padding: 1rem 0.2rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.detail-grid {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.detail-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 0.6rem;
  font-size: 0.8rem;
}

.detail-label {
  color: var(--muted);
}

.detail-value {
  min-width: 0;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.passenger-list,
.notes-box {
  margin: 0.8rem 0 0;
  padding: 0.75rem;
  border-radius: 9px;
  background: var(--surface-soft);
  font-size: 0.8rem;
  line-height: 1.55;
}

.notes-box {
  white-space: normal;
}

.contact-row {
  align-items: center;
}

.contact-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-width: 0;
}

.contact-email {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.copy-button {
  padding: 0.35rem 0.55rem;
  font-size: 0.72rem;
}

.copy-status {
  color: var(--available);
  font-size: 0.72rem;
}

.publisher-plan-list {
  display: grid;
  gap: 0.45rem;
}

.publisher-plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem;
  border-radius: 8px;
  background: var(--surface-soft);
}

.publisher-plan-copy {
  min-width: 0;
}

.publisher-plan-copy strong,
.publisher-plan-copy small {
  display: block;
}

.publisher-plan-copy strong {
  font-size: 0.78rem;
}

.publisher-plan-copy small {
  margin-top: 0.2rem;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.4;
}

.publisher-plan-row .button-row {
  flex: 0 0 auto;
}

.publisher-plan-row .secondary-button,
.publisher-plan-row .quiet-button {
  padding: 0.35rem 0.5rem;
  font-size: 0.72rem;
}

.draw-box {
  display: grid;
  gap: 0.65rem;
  padding: 0.75rem;
  border: 1px dashed #b8c3dc;
  border-radius: 9px;
  background: #f8faff;
}

.route-editor-priority {
  border-color: #efb4b4;
  background: #fffafa;
}

.draw-origin-button.draw-origin-button-attention {
  background: #dc2626;
  color: #fff;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.3);
  animation: draw-origin-pulse 1.15s ease-in-out 4;
}

.draw-origin-button.draw-origin-button-attention:hover {
  background: #b91c1c;
}

@keyframes draw-origin-pulse {
  0%,
  100% {
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.3);
    transform: scale(1);
  }

  50% {
    box-shadow: 0 0 0 7px rgba(220, 38, 38, 0.08), 0 0 24px rgba(220, 38, 38, 0.55);
    transform: scale(1.035);
  }
}

@media (prefers-reduced-motion: reduce) {
  .draw-origin-button.draw-origin-button-attention {
    animation: none;
  }
}

.draw-box strong {
  font-size: 0.8rem;
}

.field-help {
  margin: 0.2rem 0 0;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.45;
}

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

.weekday-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.4rem;
}

.weekday-grid label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.45rem 0.3rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 0.7rem;
}

.form-error,
.message {
  min-height: 1.2rem;
  color: #b42318;
  font-size: 0.78rem;
  line-height: 1.45;
}

.message.success {
  color: var(--available);
}

.admin-location-list {
  display: grid;
  gap: 0.45rem;
  margin: 0.8rem 0;
}

.admin-location {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem;
  border-radius: 8px;
  background: var(--surface-soft);
  font-size: 0.75rem;
}

.admin-location strong {
  display: block;
  font-size: 0.78rem;
}

.admin-location small {
  color: var(--muted);
}

.admin-location .quiet-button {
  padding: 0.3rem 0.45rem;
  font-size: 0.72rem;
}

.admin-email-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.8rem;
}

.admin-email-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem;
  border-radius: 8px;
  background: var(--surface-soft);
  color: #3b4657;
  font-size: 0.75rem;
}

.admin-email-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.admin-email-row .quiet-button {
  flex: 0 0 auto;
  padding: 0.3rem 0.45rem;
  font-size: 0.72rem;
}

hr {
  height: 1px;
  margin: 1rem 0;
  border: 0;
  background: var(--line);
}

@media (max-width: 1100px) {
  .app-layout {
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  }
}

@media (max-width: 850px) {
  .app-layout {
    display: block;
  }

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

  #editor-panel,
  #admin-panel {
    grid-column: auto;
  }

  .sidebar {
    margin-top: 0.75rem;
  }

  .map-shell {
    min-height: 55vh;
  }

  .route-list {
    max-height: none;
  }
}

@media (max-width: 540px) {
  .topbar {
    align-items: start;
  }

  .topbar-actions {
    align-items: end;
    flex-direction: column;
    gap: 0.2rem;
  }

  .user-chip {
    max-width: 180px;
  }

  .app-layout {
    padding: 0.6rem;
  }

  .publisher-section {
    padding: 0 0.6rem 1rem;
  }

  .publisher-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .publisher-heading .toolbar-button {
    width: 100%;
  }

  .publisher-plan-row {
    align-items: stretch;
    flex-direction: column;
  }

  .publisher-plan-row .button-row {
    justify-content: flex-end;
  }

  .site-footer {
    padding-right: 0.6rem;
    padding-left: 0.6rem;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar-field,
  .toolbar-field.location-field {
    flex-basis: 100%;
  }

  .toolbar-button {
    width: 100%;
  }

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

  .login-access-grid {
    grid-template-columns: 1fr;
  }

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

  .map-shell {
    min-height: 60vh;
    border-radius: 11px;
  }

  .drawing-toolbar {
    flex-wrap: wrap;
  }

  .drawing-toolbar-copy {
    flex: 1 1 100%;
  }

  .drawing-toolbar .button-row {
    margin-left: auto;
  }
}
