:root {
  color-scheme: light dark;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1769e0;
  --primary-dark: #1155b4;
  --danger: #c73636;
  --danger-dark: #9f2424;
  --shadow: 0 10px 28px rgba(17, 24, 39, 0.08);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden],
.hidden {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.panel,
.route-card,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: var(--shadow);
}

.auth-card,
.form-panel {
  width: 100%;
  padding: 1rem;
}

.auth-card {
  max-width: 420px;
}

.hero,
.layout {
  width: min(100%, 780px);
  margin: 0 auto;
  padding-inline: 1rem;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 1rem;
  padding-bottom: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 2;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
}

.layout {
  padding-bottom: 2rem;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.9rem, 9vw, 3rem);
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 0.75rem;
  font-size: 1.2rem;
}

h3 {
  margin-bottom: 0.35rem;
}

.eyebrow {
  margin-bottom: 0.35rem;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.intro,
#route-count,
.route-meta,
.route-description,
.empty-state,
.auth-message {
  color: var(--muted);
}

.auth-message {
  min-height: 1.4rem;
  margin-bottom: 0;
  color: var(--danger);
  font-weight: 700;
}

.header-actions,
.form-actions,
.section-heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-actions,
.form-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.section-heading {
  justify-content: space-between;
  margin: 1rem 0 0.75rem;
}

form {
  display: grid;
  gap: 0.8rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem 0.85rem;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

textarea {
  resize: vertical;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 0.95rem;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

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

.secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
}

.secondary:hover {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.danger {
  color: var(--danger);
}

.danger:hover {
  color: #fff;
  background: var(--danger-dark);
}

button:focus-visible,
a:focus-visible,
input:focus,
textarea:focus {
  outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent);
  outline-offset: 2px;
}

.routes-list {
  display: grid;
  gap: 0.75rem;
}

.route-card {
  position: relative;
  overflow: visible;
}

.route-card.menu-open {
  z-index: 100;
}

.route-image {
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--border) 45%, transparent);
}

.route-picture {
  display: block;
  width: 100%;
  height: auto;
}

.route-content {
  padding: 1rem;
}

.route-meta {
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.route-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.route-top h3 {
  flex: 1;
}

.route-title {
  color: var(--text);
  text-decoration: none;
}

.route-title:hover {
  color: var(--primary);
  text-decoration: underline;
}

.route-description {
  margin-bottom: 0;
  white-space: pre-wrap;
}

.route-menu {
  position: relative;
  z-index: 5;
  flex: none;
}

.route-menu[open] {
  z-index: 50;
}

.route-menu summary {
  display: grid;
  width: 2.2rem;
  height: 2.2rem;
  place-items: center;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  list-style: none;
}

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

.route-menu summary:hover,
.route-menu[open] summary {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
}

.menu-items {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 3;
  min-width: 9rem;
  padding: 0.35rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  box-shadow: var(--shadow);
}

.menu-items button {
  display: block;
  width: 100%;
  border-radius: 0.55rem;
  padding: 0.75rem;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.menu-items button:hover {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.menu-items .danger {
  color: var(--danger);
}

.menu-items .danger:hover {
  color: #fff;
  background: var(--danger-dark);
}

.archive-section {
  margin-top: 1rem;
}

.archive-section > summary {
  padding: 0.85rem 0.2rem;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
  list-style-position: inside;
}

.archived-routes-list {
  margin-top: 0.5rem;
}

.archived-routes-list .route-card {
  opacity: 0.82;
}

.archived-routes-list .route-card.menu-open {
  opacity: 1;
}

.empty-state {
  padding: 1.5rem 1rem;
  text-align: center;
}

.empty-state h3 {
  color: var(--text);
}

@media (max-width: 520px) {
  .hero {
    align-items: flex-start;
  }

  .header-actions {
    max-width: 9rem;
  }

  .header-actions button {
    padding-inline: 0.8rem;
  }

}

@media (min-width: 700px) {
  .route-card:has(.route-image:not([hidden])) {
    display: grid;
    grid-template-columns: 180px 1fr;
  }

  .route-image {
    align-self: start;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --panel: #111827;
    --text: #eef2ff;
    --muted: #a6b0c3;
    --border: #273244;
    --primary: #75a7ff;
    --primary-dark: #4f8df0;
    --danger: #ff8585;
    --danger-dark: #d95050;
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  }
}
