@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/InterVariable.woff2") format("woff2-variations"),
       url("fonts/InterVariable.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #eef0f4;
  --text: #0b1220;
  --muted: #5b6473;
  --line: rgba(11, 18, 32, 0.08);
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.10);
  --warning: #b45309;
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px rgba(11, 18, 32, 0.04);
  --shadow: 0 12px 32px rgba(11, 18, 32, 0.08);
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0c10;
  --surface: #11141a;
  --surface-soft: #181c24;
  --text: #e6e8ee;
  --muted: #8b94a3;
  --line: rgba(230, 232, 238, 0.09);
  --accent: #818cf8;
  --accent-soft: rgba(129, 140, 248, 0.14);
  --warning: #f59e0b;
  --danger: #f87171;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.40);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  overflow-x: hidden;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at top right, var(--accent-soft), transparent 32rem),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  font-feature-settings: "ss01", "cv11";
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color 260ms ease, color 260ms ease;
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

*:focus {
  outline: none;
}

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.app-shell {
  min-height: 100svh;
  overflow-x: hidden;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 8px;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  display: inline-grid;
  place-items: center;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms ease;
}

.icon-button:hover {
  background: var(--surface-soft);
}

.icon-button:active {
  transform: scale(0.96);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-button {
  position: relative;
}

.theme-icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(0.8) rotate(-14deg);
  transition: opacity 240ms ease, transform 240ms ease;
}

:root:not([data-theme="dark"]) .theme-sun,
[data-theme="dark"] .theme-moon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.main {
  min-height: 100svh;
  position: relative;
}

.view {
  display: none;
  width: 100%;
  min-height: 100svh;
  padding: calc(env(safe-area-inset-top) + 80px) 20px calc(env(safe-area-inset-bottom) + 28px);
  opacity: 0;
  transform: translateY(16px);
}

.view.is-active {
  display: block;
  animation: viewIn 380ms cubic-bezier(.2, .8, .2, 1) forwards;
}

@keyframes viewIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-home,
.view-signin {
  display: none;
  align-items: center;
  justify-content: center;
}

.view-home.is-active,
.view-signin.is-active {
  display: flex;
}

.signin-status {
  margin-top: 14px;
  font-size: 0.92rem;
  color: var(--muted);
}

.signin-status.is-error {
  color: var(--danger);
}

body.is-signed-out .topbar #menuButton {
  visibility: hidden;
}

.home-card {
  width: min(100%, 460px);
  max-width: calc(100vw - 40px);
  position: relative;
  padding: 18svh 0 8svh;
}

.home-card h1,
.flow-panel h1,
.itinerary-hero h1 {
  margin: 0;
  font-size: clamp(1.75rem, 7.6vw, 2.25rem);
  line-height: 1.06;
  letter-spacing: -0.012em;
  font-weight: 700;
}

.home-card h1 {
  max-width: 12ch;
}

.name-form {
  margin-top: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
}

.name-form input,
.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 14px;
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  outline: none;
  transition: border-color 160ms ease, background-color 220ms ease;
}

.field textarea {
  min-height: 88px;
  padding-top: 12px;
  resize: vertical;
  line-height: 1.5;
}

.name-form input:focus,
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
}

.name-form input:focus-visible,
.field input:focus-visible,
.field textarea:focus-visible,
.field select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.enter-button,
.primary-button,
.secondary-button,
.text-button {
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms ease;
}

.enter-button,
.primary-button {
  height: 44px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.95rem;
}

.enter-button {
  display: grid;
  place-items: center;
  padding: 0;
}

.primary-button {
  padding: 0 18px;
}

.enter-button:hover,
.primary-button:hover {
  background: color-mix(in srgb, var(--text) 88%, var(--accent));
}

.enter-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-button:active,
.secondary-button:active,
.text-button:active,
.enter-button:active {
  transform: scale(0.98);
}

.secondary-button {
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  font-size: 0.92rem;
}

.secondary-button:hover {
  background: var(--surface-soft);
}

.text-button {
  height: 32px;
  padding: 0 12px;
  background: transparent;
  color: var(--accent);
  font-weight: 500;
  font-size: 0.88rem;
}

.text-button:hover {
  background: var(--accent-soft);
}

.full-width {
  width: 100%;
}

.progress-track {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 64px);
  left: 20px;
  right: 20px;
  height: 3px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  z-index: 10;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 360ms ease;
}

.flow-panel {
  width: min(100%, 560px);
  margin: 0 auto;
  padding-top: clamp(16px, 6svh, 64px);
}

.step-kicker {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.step-copy {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.95rem;
}

#stepBody {
  margin-top: 24px;
}

.step-grid {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.field input,
.field textarea,
.field select {
  color: var(--text);
  font-weight: 500;
  font-size: 0.98rem;
  min-width: 0;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 20px;
}

.button-row.single {
  grid-template-columns: 1fr;
}

.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.choice-button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms ease;
}

.choice-button:hover {
  background: var(--surface-soft);
}

.choice-button:active {
  transform: scale(0.98);
}

.choice-button.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.inline-note {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.88rem;
}

.warning-note {
  color: var(--warning);
}

.entry-stack,
.review-stack,
.itinerary-body {
  display: grid;
  gap: 12px;
}

.entry-card,
.review-card,
.trip-card,
.detail-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.entry-card,
.review-card,
.detail-card {
  padding: 16px;
}

.entry-head,
.review-head,
.detail-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.entry-head h3,
.review-head h3,
.detail-head h2,
.drawer-section h3 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.meta-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.meta-line {
  display: grid;
  gap: 2px;
}

.meta-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.meta-value {
  color: var(--text);
  line-height: 1.4;
  font-size: 0.94rem;
  overflow-wrap: anywhere;
}

.meta-value a {
  color: var(--accent);
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.2em;
}

.meta-value a:hover {
  text-decoration-thickness: 0.1em;
}

.mini-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mini-button {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.mini-button:hover {
  background: var(--surface-soft);
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(11, 18, 32, 0.36);
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
}

[data-theme="dark"] .drawer {
  background: rgba(0, 0, 0, 0.5);
}

.drawer.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  width: min(86vw, 360px);
  min-height: 100%;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px);
  background: var(--surface);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(-104%);
  transition: transform 300ms cubic-bezier(.2, .8, .2, 1);
}

.drawer.is-open .drawer-panel {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawer-head h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.012em;
}

.drawer-actions {
  margin: 16px 0;
}

.drawer-section {
  margin-top: 24px;
}

.drawer-section h3 {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.trip-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.trip-card {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 14px;
  text-align: left;
  color: var(--text);
}

.trip-open {
  width: 100%;
  border: 0;
  padding: 0;
  text-align: left;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.trip-open strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.trip-open span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.84rem;
}

.trip-actions,
.itinerary-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.trip-actions.single {
  grid-template-columns: 1fr;
}

.itinerary-actions {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.trip-action {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.trip-action:hover {
  background: var(--surface-soft);
}

.danger-action {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 32%, transparent);
}

.danger-action:hover {
  background: color-mix(in srgb, var(--danger) 8%, transparent);
}

.empty-state {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.saved-hint {
  margin: 0 0 20px;
  color: var(--accent);
  font-weight: 500;
  font-size: 0.92rem;
}

.menu-cue {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 60px);
  left: 18px;
  color: var(--accent);
  animation: cuePulse 1600ms ease-in-out infinite;
}

.menu-cue svg {
  width: 42px;
  height: 42px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes cuePulse {
  0%, 100% {
    opacity: 0.35;
    transform: translateX(0);
  }
  50% {
    opacity: 0.7;
    transform: translateX(-4px);
  }
}

.itinerary-hero {
  width: min(100%, 640px);
  margin: 0 auto 20px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.itinerary-body {
  width: min(100%, 640px);
  margin: 0 auto;
  padding-bottom: 20px;
}

.detail-card h2 {
  font-size: 1.02rem;
}

.offline-pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.74rem;
  letter-spacing: 0.02em;
}

@media (max-width: 359px) {
  .view {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .home-card {
    max-width: calc(100vw - 28px);
  }

  .name-form {
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 8px;
  }

  .enter-button {
    height: 42px;
  }

  .button-row,
  .choice-row {
    grid-template-columns: 1fr;
  }
}

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