:root {
  --color-primary: #1D5185;
  --color-accent: #0D99FF;
  --color-neutral: #A5A5A5;
  --color-blue: #4472C4;
  --color-gold: #FFC000;
  --color-orange: #ED7D31;

  --bg: #faf7f0;
  --bg-alt: #f1ece0;
  --text: #24303a;
  --text-muted: #6b6459;
  --border: #e4dcc9;
  --card-bg: #ffffff;
  --today-bg: #fff3d9;

  --ridge-1: #1D5185;
  --ridge-2: #2c6ca3;
  --ridge-3: #4472C4;

  color-scheme: light;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

:root[data-theme="dark"] {
  --bg: #14171a;
  --bg-alt: #1c1f1a;
  --text: #eef0f2;
  --text-muted: #a3a08f;
  --border: #2e2c22;
  --card-bg: #1e2119;
  --today-bg: #2c2410;

  --ridge-1: #0b1d2e;
  --ridge-2: #12314d;
  --ridge-3: #1D5185;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3, .heading-font {
  font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}

body {
  padding-bottom: 3rem;
  /* subtle topographic contour texture, evokes a trail map */
  background-image:
    radial-gradient(circle at 15% 8%, rgba(165,165,165,0.14) 0, transparent 42%),
    radial-gradient(circle at 85% 18%, rgba(165,165,165,0.10) 0, transparent 38%),
    radial-gradient(circle at 40% 55%, rgba(165,165,165,0.09) 0, transparent 40%),
    radial-gradient(circle at 75% 80%, rgba(165,165,165,0.12) 0, transparent 40%);
  background-attachment: fixed;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--ridge-1) 0%, var(--ridge-2) 55%, var(--ridge-3) 100%);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1rem 2.25rem;
  overflow: hidden;
}

/* mountain range silhouette, reserved in the header's own bottom padding
   so it never overlaps the group toggle sitting above it */
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 28px;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 60' preserveAspectRatio='none'><path d='M0 60 L45 18 L80 40 L120 8 L160 38 L205 14 L250 42 L290 20 L330 44 L365 12 L400 34 L400 60 Z' fill='%23faf7f0'/></svg>");
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

:root[data-theme="dark"] .topbar::after {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 60' preserveAspectRatio='none'><path d='M0 60 L45 18 L80 40 L120 8 L160 38 L205 14 L250 42 L290 20 L330 44 L365 12 L400 34 L400 60 Z' fill='%2314171a'/></svg>");
}

.topbar-inner {
  max-width: 640px;
  margin: 0 auto 0.75rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  position: relative;
  z-index: 2;
}

.theme-toggle {
  flex: 0 0 auto;
  display: flex;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 999px;
  padding: 0.2rem;
  gap: 0.2rem;
}

.theme-btn {
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.75);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.theme-btn svg {
  width: 17px;
  height: 17px;
}

.theme-btn.is-active {
  background: var(--color-gold);
  color: #2a2205;
}

.app-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.01em;
}

.app-title::before {
  content: "\26F0\FE0E  ";
  color: var(--color-gold);
}

.app-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.875rem;
  color: rgba(255,255,255,0.8);
}

.trip-select-wrap {
  position: relative;
  z-index: 5;
}

.trip-select-trigger {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.trip-select-caret {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--color-gold);
  transition: transform 0.15s;
}

.trip-select-wrap.is-open .trip-select-caret {
  transform: rotate(180deg);
}

.trip-select-menu {
  display: none;
  flex-direction: column;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.5rem;
  min-width: 190px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  z-index: 20;
}

.trip-select-wrap.is-open .trip-select-menu {
  display: flex;
}

.trip-select-option {
  border: none;
  background: none;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}

.trip-select-option + .trip-select-option {
  border-top: 1px solid var(--border);
}

.trip-select-option.is-active {
  color: var(--color-primary);
  background: var(--today-bg);
}

.date-tabs {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.6rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: relative;
  z-index: 1;
}
.date-tabs::-webkit-scrollbar { display: none; }

.date-tab {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.date-tab:active { transform: scale(0.96); }

.date-tab.is-active {
  background: var(--color-orange);
  border-color: var(--color-orange);
  color: #fff;
}

.date-tab.is-today:not(.is-active) {
  border-color: var(--color-gold);
  color: var(--color-gold);
  font-weight: 700;
}

.date-tab .today-dot {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-gold);
}
.date-tab.is-active .today-dot { background: #fff; }

.group-toggle {
  display: flex;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.2rem;
  gap: 0.2rem;
  position: relative;
  z-index: 1;
}

.day-group-toggle {
  margin-bottom: 0.75rem;
}

.group-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.group-btn.is-active {
  background: var(--color-primary);
  color: #fff;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
}

.day {
  margin-bottom: 2rem;
  scroll-margin-top: 12rem;
}

.day-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}

.day-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.day.is-today .day-title {
  color: var(--color-primary);
}

.day-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.day-label {
  margin: 0.1rem 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.today-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--color-orange);
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.5rem;
}

.split-note {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-orange);
  border: 1px solid var(--color-orange);
  background: rgba(237, 125, 49, 0.08);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.75rem;
}

.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 1rem 0 0.5rem;
}

.stop-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--card-bg);
}

.stop-list + .stop-list {
  margin-top: 0.75rem;
}

.stop {
  display: flex;
  align-items: stretch;
  gap: 0.7rem;
  border-left: 3px solid var(--color-neutral);
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.stop:last-child {
  border-bottom: none;
}

.stop:active { transform: scale(0.995); }

.stop.is-done {
  background: var(--bg-alt);
  border-left-color: var(--color-gold);
}

.stop-track {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* stretch the track past the row's own padding so the line reaches
     the row's border edges and touches the divider directly */
  margin: -0.7rem 0;
}

.track-line {
  width: 2px;
  flex: 1 1 auto;
  min-height: 6px;
  background: var(--border);
  transition: background 0.15s;
}

.stop:first-child .track-line-top { visibility: hidden; }
.stop:last-child .track-line-bottom { visibility: hidden; }

.stop.is-done .track-line-bottom {
  background: var(--color-gold);
}

.stop.is-done + .stop .track-line-top {
  background: var(--color-gold);
}

.stop-check {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  transform: rotate(45deg);
  border: 2px solid var(--color-neutral);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 0.7rem;
  background: var(--card-bg);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.stop-check::before {
  content: "";
  display: block;
  transform: rotate(-45deg);
}

.stop.is-done .stop-check {
  background: var(--color-gold);
  border-color: var(--color-gold);
  color: #2a2205;
}

.stop.is-done .stop-check::before {
  content: "\2713";
}

.stop-body { flex: 1; min-width: 0; }

.stop-name {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}

.stop-activity-icon {
  display: inline-block;
  margin-right: 0.3rem;
  font-size: 0.85em;
}

.stop.is-done .stop-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.stop-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.stop-time {
  display: inline-flex;
  align-items: center;
}

.stop-location a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

.stop-location a:hover { text-decoration: underline; }

.stop-location.is-placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.day-complete-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border);
}

.day-complete-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.day-complete-btn {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-primary);
  background: none;
  border: 1px solid var(--color-primary);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
}

.day-complete-btn.is-done {
  background: var(--color-primary);
  color: #fff;
}

.day-stay {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 0.85rem;
  padding: 0.5rem 0.7rem;
  background: var(--bg-alt);
  border-radius: 8px;
}

.day-stay-icon {
  flex: 0 0 auto;
}

.day-stay a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
}
.day-stay a:hover { text-decoration: underline; }

.day-wake-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stop-alltrails a {
  color: var(--color-orange);
  text-decoration: none;
  font-weight: 600;
}
.stop-alltrails a:hover { text-decoration: underline; }

.app-footer {
  max-width: 640px;
  margin: 1.5rem auto 0;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.reset-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  cursor: pointer;
  flex: 0 0 auto;
}

/* Desktop: mouse-hover affordances on every clickable control */
@media (hover: hover) and (pointer: fine) {
  .stop:not(.is-done):hover { background: var(--bg-alt); border-left-color: var(--color-orange); }
  .date-tab:not(.is-active):hover { border-color: var(--color-gold); color: var(--color-gold); }
  .group-btn:not(.is-active):hover { background: var(--border); }
  .theme-btn:not(.is-active):hover { background: rgba(255,255,255,0.28); }
  .day-complete-btn:not(.is-done):hover { background: var(--today-bg); }
  .reset-btn:hover { border-color: var(--text-muted); color: var(--text); }
  .trip-select-option:not(.is-active):hover { background: var(--bg-alt); }
}

/* Desktop: a wider, more comfortable reading column once there's room for it */
@media (min-width: 860px) {
  .topbar-inner,
  .date-tabs,
  main,
  .app-footer {
    max-width: 760px;
  }

  .stop {
    padding: 0.85rem 1rem;
  }

  .stop-track {
    margin: -0.85rem 0;
  }
}

/* ---- Ratings ------------------------------------------------------ */

.star-row {
  position: relative;
  display: flex;
  flex: 0 0 auto;
}

.star-row svg {
  width: 20%;
  height: 100%;
  flex: 0 0 auto;
}

.star-bg-icon {
  fill: none;
  stroke: var(--color-neutral);
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.star-fg-icon {
  fill: var(--color-gold);
  stroke: var(--color-gold);
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.rating-gauge {
  flex: 0 0 auto;
  align-self: center;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  border: none;
  background: none;
  padding: 0.25rem;
  margin: -0.25rem 0;
  cursor: pointer;
}

.rating-gauge-value {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.rating-modal-stars {
  display: flex;
  justify-content: center;
  margin: 0.75rem 0;
}

.star-hit {
  position: absolute;
  top: 0;
  height: 100%;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.rating-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 20, 0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.rating-modal-overlay.is-open {
  display: flex;
}

.rating-modal {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 1.25rem;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.rating-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.rating-modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text);
}

.rating-modal-close {
  border: none;
  background: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.25rem;
}

.rating-modal-value {
  text-align: center;
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.rating-modal-comment {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
}

.rating-modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.rating-modal-clear {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font-size: 0.82rem;
  cursor: pointer;
}

.rating-modal-save {
  background: var(--color-gold);
  border: none;
  color: #2a2205;
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
