:root {
  color-scheme: light;
  --bg: #f7f7f8;
  --panel: #ffffff;
  --text: #171717;
  --muted: #666b75;
  --line: #e4e5e8;
  --brand: #ed1c24;
  --brand-dark: #b5121b;
  --shadow: 0 10px 28px rgba(0,0,0,.08);
  --radius: 20px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111418;
  --panel: #181c22;
  --text: #f4f4f5;
  --muted: #a7adbb;
  --line: #2a3038;
  --brand: #ff2933;
  --brand-dark: #c91b25;
  --shadow: 0 10px 28px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: inherit; }
.container { width: min(1120px, calc(100% - 28px)); margin: 0 auto; }

.header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 78px;
  padding: 10px 0;
}
.logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex: 0 0 auto;
  border-radius: 12px;
}
.brand h1 { margin: 0; font-size: 1.55rem; letter-spacing: -0.02em; }
.brand small { display: block; color: var(--muted); margin-top: 2px; }
.navline { height: 4px; background: linear-gradient(90deg, var(--brand), var(--brand-dark)); }

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 1.15rem;
}
.header-icon-btn:hover, .header-icon-btn[aria-current="page"] {
  background: color-mix(in srgb, var(--brand) 10%, var(--panel));
}

.theme-toggle {
  margin-left: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: .55rem .8rem;
  display: flex;
  gap: .45rem;
  align-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
}

main { padding: 22px 0 36px; }
footer {
  color: var(--muted);
  padding: 28px 0 42px;
  font-size: .95rem;
}

.back {
  display: inline-block;
  text-decoration: none;
  color: var(--muted);
  margin: .3rem 0 1rem;
}
.back:hover { color: var(--text); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card:hover { transform: translateY(-1px); }
.card h3 { margin: 0 0 6px; }
.card p { margin: 0; color: var(--muted); }
.icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  font-size: 1.35rem;
  flex: 0 0 auto;
}

.quick-panel, .nearby-panel, .favorites-panel, .settings-panel, .departure-panel, .emergency-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.quick-head, .nearby-panel__head, .departure-head, .emergency-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.section-kicker, .kicker, .nearby-kicker {
  margin: 0 0 4px;
  color: var(--brand);
  font-weight: 700;
  text-transform: uppercase;
  font-size: .76rem;
  letter-spacing: .06em;
}
.quick-head h2, .nearby-panel h2, .departure-panel h2, .emergency-panel h2 { margin: 0 0 6px; }
.quick-head p, .nearby-panel p, .departure-panel p, .emergency-panel p { color: var(--muted); margin: 0; }
.quick-grid, .nearby-actions, .emergency-actions, .store-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
.quick-action, .nearby-btn, .emergency-call, .store-action {
  border: 0;
  background: var(--brand);
  color: white;
  border-radius: 16px;
  padding: .85rem 1rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}
.quick-action.danger, .emergency-call.danger { background: #c1121f; }
.store-action--secondary, .nearby-btn, .emergency-call:not(.danger) {
  background: color-mix(in srgb, var(--brand) 14%, var(--panel));
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line));
}
.privacy-pill, .badge {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .35rem .65rem;
  color: var(--muted);
  background: var(--bg);
  white-space: nowrap;
}
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 16px 0;
}
.input {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  padding: 0 .9rem;
}
.input input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: .9rem 0;
  font: inherit;
}

.link-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.link-list li a {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  text-decoration: none;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 15px;
}
.host {
  color: var(--muted);
  font-size: .88rem;
}
small.host { display: block; margin-top: 4px; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.region-section, .transport-group { margin: 22px 0; }
.region-section h2, .transport-group h2 { margin: 0 0 10px; }

.position-box, .nearby-status, .emergency-note, .local-results, .favorites-list, .nearby-results {
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  color: var(--muted);
}
.nearby-results { list-style: none; display: grid; gap: 8px; }
.settings-summary {
  cursor: pointer;
  font-weight: 800;
}
.settings-panel > .quick-head { margin-top: 14px; }
.settings-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 14px 0;
}
.local-dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
  color: var(--text);
  width: min(620px, calc(100% - 24px));
}
.local-dialog::backdrop { background: rgba(0,0,0,.42); }
.local-dialog__box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.store-card { align-items: stretch; }
.store-card__content { flex: 1; }

@media (max-width: 650px) {
  .brand { min-height: 68px; }
  .brand h1 { font-size: 1.25rem; }
  .brand small { font-size: .78rem; }
  .logo { width: 44px; height: 44px; }
  .theme-toggle__text { display: none; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .link-list li a { align-items: flex-start; flex-direction: column; }
  .quick-head, .nearby-panel__head, .departure-head, .emergency-head { flex-direction: column; }
}


.settings-page-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.settings-back {
  margin: .3rem 0 1rem;
}
.settings-page-panel h2 { margin: 0 0 6px; }
.settings-page-panel > p { color: var(--muted); }

@media (max-width: 650px) {
  .header-actions { gap: 6px; }
  .header-icon-btn, .theme-toggle {
    width: 42px;
    height: 42px;
    min-width: 42px;
    padding: 0;
    justify-content: center;
  }
}

@media (max-width: 430px) {
  .brand { gap: 9px; }
  .brand > div:not(.header-actions) { min-width: 0; }
  .brand small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
  .header-actions { gap: 4px; }
  .header-icon-btn, .theme-toggle { width: 38px; height: 38px; min-width: 38px; }
}


/* Bookmark/favorite links */
.bookmarkable-link,
.favorite-home-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}
.bookmarkable-link > a,
.favorite-home-item > a {
  min-width: 0;
}
.favorite-toggle {
  width: 46px;
  min-width: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--muted);
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
}
.favorite-toggle.is-active {
  color: #d79b00;
  background: color-mix(in srgb, #d79b00 12%, var(--panel));
  border-color: color-mix(in srgb, #d79b00 35%, var(--line));
}


/* Home address settings */
.address-field-label {
  display: block;
  margin: 14px 0 6px;
  font-weight: 700;
}
.address-field-wrap {
  position: relative;
}
.address-field {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  padding: .9rem 1rem;
  font: inherit;
  outline: none;
}
.address-field:focus {
  border-color: color-mix(in srgb, var(--brand) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent);
}
.address-suggestions {
  list-style: none;
  margin: 6px 0 0;
  padding: 6px;
  position: absolute;
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 260px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.address-suggestions li + li {
  border-top: 1px solid var(--line);
}
.address-suggestions button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: .8rem .7rem;
  text-align: left;
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
}
.address-suggestions button:hover,
.address-suggestions button:focus {
  background: color-mix(in srgb, var(--brand) 10%, var(--panel));
  outline: none;
}


.nearby-results:empty {
  display: none;
}


/* Empty UI containers must never render as blank boxes */
.position-box:empty,
.nearby-status:empty,
.emergency-note:empty,
.local-results:empty,
.favorites-list:empty,
.nearby-results:empty,
.address-suggestions:empty {
  display: none !important;
}
