:root {
  --bg: #f6f9f8;
  --bg-elevated: #fbfdfc;
  --surface: #ffffff;
  --surface-soft: #f1f7f7;
  --surface-tint: #e7f2f4;
  --text: #172126;
  --text-muted: #5b6c75;
  --text-subtle: #71818a;
  --border: #d9e4e8;
  --border-strong: #b9d2da;
  --brand: #1f9ac7;
  --brand-strong: #0d6380;
  --accent: #df6d2d;
  --accent-strong: #b9501f;
  --success: #2d8a63;
  --warning: #b7791f;
  --danger: #b42318;
  --radius: 8px;
  --shadow-soft: 0 8px 24px rgba(23, 33, 38, 0.06);
  --shadow-raised: 0 14px 34px rgba(23, 33, 38, 0.11);
  --shadow-sticky: 0 18px 44px rgba(23, 33, 38, 0.2);
  --focus-ring: 0 0 0 3px rgba(31, 154, 199, 0.18);
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --space-6: 32px;
  --ink: var(--text);
  --muted: var(--text-muted);
  --line: var(--border);
  --panel: var(--surface);
  --soft: var(--surface-soft);
  --sky: var(--brand);
  --leaf: var(--success);
  --orange: var(--accent);
  --orange-dark: var(--accent-strong);
  --shadow: var(--shadow-raised);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  cursor: progress;
  opacity: 0.72;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 48px);
  background: rgba(246, 249, 248, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
}

.nav {
  position: sticky;
  top: 72px;
  z-index: 19;
  display: flex;
  justify-content: center;
  gap: 6px;
  min-height: 58px;
  padding: 8px 18px;
  background: rgba(246, 249, 248, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.nav__item,
.link-button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.nav__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 78px;
  min-height: 42px;
  border-radius: 8px;
  font-weight: 700;
}

.nav__item svg {
  width: 18px;
  height: 18px;
}

.nav__item.is-active {
  background: var(--surface-tint);
  color: var(--brand-strong);
  box-shadow: inset 0 0 0 1px rgba(31, 154, 199, 0.16);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  gap: 0;
  min-height: calc(100vh - 116px);
  max-height: 760px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elevated);
}

.hero__media {
  min-height: 440px;
}

.hero__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero__content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  padding: clamp(28px, 6vw, 72px);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--sky);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 5.5rem;
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1.1;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.lead {
  max-width: 620px;
  color: #43545d;
  font-size: 1.12rem;
  line-height: 1.7;
}

.prompt-rail,
.chat-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.prompt-rail button,
.chat-prompts button {
  min-height: 38px;
  border: 1px solid #cfe0e5;
  border-radius: 999px;
  padding: 0 14px;
  background: var(--surface-soft);
  color: var(--brand-strong);
  font-weight: 800;
}

.prompt-rail button:hover,
.chat-prompts button:hover {
  border-color: var(--sky);
  background: #e4f3f6;
}

.planner,
.trip-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: 0;
}

input,
select {
  height: 46px;
  padding: 0 14px;
}

textarea {
  min-height: 92px;
  padding: 14px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--sky);
  box-shadow: var(--focus-ring);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(31, 154, 199, 0.34);
  outline-offset: 3px;
}

.primary,
.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  border-radius: var(--radius);
  padding: 0 18px;
  font-weight: 800;
}

.primary {
  border: 1px solid var(--orange);
  background: var(--orange);
  color: #fff;
  box-shadow: 0 8px 18px rgba(223, 109, 45, 0.18);
}

.primary:hover {
  background: var(--orange-dark);
  border-color: var(--orange-dark);
}

.secondary {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.secondary:hover,
.icon-button:hover,
.tool-card:hover,
.city-card:hover,
.trip-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-raised);
}

.section {
  padding: clamp(28px, 5vw, 56px) clamp(18px, 4vw, 48px);
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 28px;
}

.section__head {
  margin-bottom: 24px;
}

.section__head.row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.view-status {
  min-height: 24px;
  margin: -10px 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.view-status[data-tone="error"] {
  color: var(--danger);
}

.view-status[data-tone="success"] {
  color: var(--success);
}

.search {
  max-width: 360px;
}

.city-strip,
.city-grid,
.tool-grid,
.trip-list {
  display: grid;
  gap: 16px;
}

.city-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.city-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.city-card,
.tool-card,
.readiness,
.tool-detail,
.trip-card,
.chat-shell {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.empty-state,
.skeleton-card {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
}

.empty-state {
  display: grid;
  gap: 10px;
  min-height: 168px;
  align-content: center;
}

.empty-state h3,
.empty-state p {
  margin-bottom: 0;
}

.empty-state .secondary {
  width: max-content;
}

.skeleton-card {
  display: grid;
  gap: 12px;
}

.skeleton-card span {
  display: block;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #eef5f6, #dfecef, #eef5f6);
  background-size: 220% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.skeleton-card span:first-child {
  height: 120px;
  border-radius: var(--radius);
}

.skeleton-card span:last-child {
  width: 62%;
}

.city-card {
  overflow: hidden;
}

.city-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #dce8eb;
}

.city-card__body,
.tool-card,
.trip-card,
.tool-detail,
.readiness {
  padding: 18px;
}

.city-card__body,
.tool-card,
.trip-card {
  display: grid;
  align-content: start;
  gap: 10px;
}

.city-card__body h3,
.tool-card h3,
.trip-card h3 {
  margin-bottom: 0;
}

.city-card__facts,
.trip-card__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.city-card__facts span,
.trip-card__facts span {
  min-height: 26px;
  border: 1px solid #d9e8ec;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
  margin-bottom: 0;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag {
  border: 1px solid #c9dde4;
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef7f8;
  color: #185b70;
  font-size: 0.78rem;
  font-weight: 700;
}

.readiness ul {
  display: grid;
  gap: 14px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.readiness li {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: center;
  color: #43545d;
}

.readiness span {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: var(--leaf);
}

.chat-shell {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  min-height: 560px;
  overflow: hidden;
}

.chat-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(170px, 0.9fr) minmax(130px, 0.6fr);
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.chat-prompts {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.preset-group {
  display: grid;
  align-content: start;
  gap: 8px;
}

.preset-group h3 {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.chat-status {
  display: grid;
  align-items: center;
  min-height: 40px;
  margin: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elevated);
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 400px;
  max-height: 58vh;
  overflow: auto;
  padding: 20px;
  background: var(--soft);
}

.message {
  max-width: min(760px, 92%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--surface);
}

.message.is-user {
  align-self: flex-end;
  border-color: #f0c2a7;
  background: #fff5ef;
}

.message span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.message p {
  margin: 0;
  line-height: 1.65;
  white-space: pre-wrap;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.tool-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.tool-card {
  text-align: left;
}

.tool-card button {
  margin-top: 12px;
  justify-self: start;
}

.tool-detail {
  margin-top: 18px;
}

.tool-detail ul {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
  padding-left: 20px;
  color: #43545d;
  line-height: 1.55;
}

.trip-form {
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) 150px 150px auto;
  margin-bottom: 18px;
}

.trip-list {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

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

.auth-dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  width: min(520px, calc(100vw - 32px));
  padding: 0;
}

.auth-dialog::backdrop {
  background: rgba(23, 33, 38, 0.36);
}

.dialog-close {
  display: flex;
  justify-content: flex-end;
  padding: 12px;
}

.sheet-handle {
  display: none;
}

.auth-layout {
  display: grid;
  gap: 18px;
  padding: 0 24px 24px;
}

.auth-form,
.profile-form {
  display: grid;
  gap: 12px;
}

.link-button {
  min-height: 40px;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  max-width: min(360px, calc(100vw - 36px));
  min-height: 46px;
  display: grid;
  align-items: center;
  border: 1px solid #bdd7de;
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast[data-tone="error"] {
  border-color: #f3b7b0;
  color: #8f1f17;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 920px) {
  .topbar {
    grid-template-columns: auto auto;
  }

  .nav {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .hero,
  .dashboard {
    grid-template-columns: 1fr;
    max-height: none;
  }

  .hero__media {
    min-height: 320px;
  }

  .planner,
  .trip-form,
  .chat-form {
    grid-template-columns: 1fr;
  }

  .city-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  body {
    padding-bottom: calc(82px + env(safe-area-inset-bottom));
  }

  main {
    overflow-x: hidden;
  }

  .topbar {
    min-height: 58px;
    padding: 9px 14px;
  }

  .brand span {
    display: inline;
    font-size: 0.98rem;
  }

  .brand img {
    width: 36px;
    height: 36px;
  }

  .nav {
    position: fixed;
    top: auto;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 12px;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    min-height: 66px;
    padding: 6px;
    overflow: visible;
    border: 1px solid rgba(185, 213, 221, 0.92);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow-sticky);
    backdrop-filter: blur(18px);
  }

  .nav__item {
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    min-height: 54px;
    border-radius: var(--radius);
    font-size: 0.72rem;
  }

  .nav__item svg {
    width: 19px;
    height: 19px;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .hero {
    display: flex;
    flex-direction: column;
    min-height: auto;
  }

  .hero__media {
    min-height: 0;
    height: 122px;
  }

  .hero__content {
    gap: 12px;
    padding: 16px 16px 18px;
  }

  h1 {
    font-size: 2.32rem;
  }

  h2 {
    font-size: 1.55rem;
  }

  .lead {
    font-size: 1rem;
    line-height: 1.45;
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .prompt-rail,
  .chat-prompts {
    display: flex;
    flex-wrap: nowrap;
    margin-right: -16px;
    margin-left: -16px;
    padding-right: 16px;
    padding-left: 16px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .prompt-rail::-webkit-scrollbar,
  .chat-prompts::-webkit-scrollbar {
    display: none;
  }

  .prompt-rail button,
  .chat-prompts button {
    flex: 0 0 auto;
    min-height: 38px;
    white-space: nowrap;
  }

  .chat-toolbar {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .preset-group {
    flex: 0 0 78%;
  }

  .preset-group button {
    width: 100%;
    justify-content: flex-start;
    white-space: normal;
    text-align: left;
  }

  .planner {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
  }

  .planner label:first-child {
    grid-column: 1 / -1;
  }

  .planner .primary {
    min-width: 112px;
  }

  input,
  select {
    height: 44px;
  }

  .section {
    padding: 28px 16px;
  }

  .section__head.row {
    display: grid;
    align-items: start;
  }

  .search {
    max-width: none;
  }

  .city-strip {
    display: flex;
    margin-right: -16px;
    overflow-x: auto;
    padding: 0 16px 8px 0;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .city-strip::-webkit-scrollbar {
    display: none;
  }

  .city-strip .city-card {
    flex: 0 0 82%;
    scroll-snap-align: start;
  }

  .city-grid,
  .tool-grid,
  .trip-list {
    grid-template-columns: 1fr;
  }

  .city-card img {
    aspect-ratio: 16 / 10;
  }

  .city-card__body,
  .tool-card,
  .trip-card,
  .tool-detail,
  .readiness {
    padding: 15px;
  }

  .tags {
    gap: 6px;
  }

  .tag {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chat-shell {
    min-height: calc(100dvh - 176px);
  }

  .chat-log {
    min-height: 320px;
    max-height: none;
    padding: 14px;
  }

  .message {
    max-width: 94%;
    padding: 12px 13px;
  }

  .chat-form {
    position: sticky;
    bottom: calc(82px + env(safe-area-inset-bottom));
    grid-template-columns: 1fr;
    padding: 12px;
    box-shadow: 0 -10px 26px rgba(23, 33, 38, 0.08);
  }

  .chat-form textarea {
    min-height: 76px;
  }

  body[data-view="chat"] {
    overflow: auto;
  }

  body[data-view="chat"] main {
    height: auto;
    overflow: visible;
  }

  body[data-view="chat"] .workspace[data-view-panel="chat"] {
    display: block !important;
    height: auto;
    min-height: calc(100dvh - 58px);
    padding: 24px 16px 104px;
    overflow: visible;
  }

  body[data-view="chat"] .workspace[data-view-panel="chat"] .section__head {
    margin-bottom: 16px;
  }

  body[data-view="chat"] .chat-shell {
    min-height: auto;
    height: auto;
    overflow: visible;
  }

  body[data-view="chat"] .chat-log {
    min-height: 240px;
    height: auto;
  }

  body[data-view="chat"] .chat-form {
    position: static;
  }

  .trip-form {
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
  }

  .auth-dialog {
    position: fixed;
    inset: auto 8px calc(10px + env(safe-area-inset-bottom)) 8px;
    width: auto;
    max-width: none;
    max-height: calc(100dvh - 34px);
    margin: 0;
    border-radius: var(--radius);
    overflow: auto;
  }

  .sheet-handle {
    display: block;
    width: 44px;
    height: 5px;
    margin: 10px auto 0;
    border-radius: 999px;
    background: #c9d9de;
  }

  .dialog-close {
    padding: 6px 10px 0;
  }

  .auth-layout {
    padding: 0 16px 18px;
  }

  .toast {
    right: 14px;
    bottom: calc(92px + env(safe-area-inset-bottom));
    left: 14px;
    max-width: none;
  }
}

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

@keyframes shimmer {
  0% {
    background-position: 120% 0;
  }

  100% {
    background-position: -120% 0;
  }
}
