:root {
  --ink: #101828;
  --ink-soft: #344054;
  --muted: #667085;
  --line: #d9dee8;
  --paper: #f7f8fb;
  --white: #ffffff;
  --amber: #f5b642;
  --coral: #ef6a5b;
  --teal: #087f73;
  --blue: #3568d4;
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% -10%, rgba(245, 182, 66, .20), transparent 30rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

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

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.4rem clamp(1rem, 3vw, 3.5rem) 1rem;
  color: white;
  background: var(--ink);
  border-bottom: 4px solid var(--amber);
}

.eyebrow {
  margin: 0 0 .25rem;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.topbar .eyebrow { color: #b8c2d8; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.55rem, 3vw, 2.4rem); line-height: 1.08; }
h1 span { color: var(--amber); font-weight: 500; }
h2 { margin-bottom: .25rem; font-size: clamp(1.35rem, 2vw, 1.8rem); }

.trip-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
.language-switch { display: inline-flex; overflow: hidden; border: 1px solid #475467; border-radius: 999px; }
.language-button { padding: .38rem .58rem; border: 0; color: #d0d5dd; background: transparent; font-size: .78rem; font-weight: 800; }
.language-button.active { color: var(--ink); background: white; }
.trip-meta span {
  padding: .4rem .65rem;
  color: #e6e9f0;
  border: 1px solid #344054;
  border-radius: 999px;
  font-size: .82rem;
}
.sync-status {
  padding: .4rem .65rem;
  color: #e6e9f0;
  border: 1px solid #344054;
  border-radius: 999px;
  background: transparent;
  font-size: .82rem;
  font-weight: 750;
}
.sync-status.online { color: #b9f0e6; border-color: #168a7f; }
.sync-status.syncing { color: #ffe19a; border-color: #ad7716; }
.sync-status.error { color: #ffc2bc; border-color: #c85448; }
.sync-status.locked { color: #f4d58c; border-color: #806524; }
.edit-toggle {
  padding: .4rem .7rem;
  color: #172033;
  background: var(--amber);
  border: 1px solid var(--amber);
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 850;
}
.edit-toggle[aria-pressed="true"] { color: white; background: var(--teal); border-color: #37b6a7; }

.tabs {
  display: flex;
  gap: .35rem;
  padding: .65rem clamp(1rem, 3vw, 3.5rem);
  overflow-x: auto;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.tab, .quiet-button {
  border: 0;
  border-radius: .65rem;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 750;
}
.tab { flex: 0 0 auto; padding: .65rem .9rem; }
.tab:hover, .tab:focus-visible { background: #f0f3f8; }
.tab.active { color: var(--ink); background: var(--amber); }

main { padding: 1rem clamp(1rem, 3vw, 3.5rem) 2rem; }
.view { display: none; }
.view.active { display: block; }

.trip-dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .65rem;
  margin-bottom: 1rem;
}
.dashboard-card {
  display: flex;
  align-items: center;
  min-height: 4.6rem;
  gap: .7rem;
  padding: .7rem .8rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: .8rem;
}
.dashboard-card.confirmed { border-left-color: var(--teal); }
.dashboard-card.action { border-left-color: var(--coral); }
.dashboard-card.deadline { border-left-color: var(--amber); }
.dashboard-icon {
  display: grid;
  flex: 0 0 1.8rem;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  color: white;
  background: var(--ink);
  border-radius: 50%;
  font-weight: 900;
}
.dashboard-card strong, .dashboard-card small { display: block; }
.dashboard-card strong { font-size: .88rem; }
.dashboard-card small { margin-top: .12rem; color: var(--muted); font-size: .72rem; line-height: 1.3; }
.progress-card { display: block; }
.progress-copy { display: flex; justify-content: space-between; gap: .4rem; }
.progress-track { height: .52rem; margin-top: .7rem; overflow: hidden; background: #e9edf4; border-radius: 999px; }
#progress-bar { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--teal), #3bb9a8); border-radius: inherit; transition: width .25s ease; }

.agenda-layout {
  display: grid;
  grid-template-columns: minmax(19rem, .85fr) minmax(28rem, 1.6fr);
  gap: 1rem;
  min-height: calc(100vh - 10.5rem);
}
.schedule-panel, .map-panel, .check-card, .food-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
}
.schedule-panel { display: flex; min-height: 0; flex-direction: column; padding: 1rem; }
.schedule-panel, .map-panel, .event-copy { min-width: 0; }
.panel-heading, .map-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.heading-actions { display: flex; gap: .4rem; }
.quiet-button { padding: .5rem .7rem; border: 1px solid var(--line); }
.quiet-button:hover, .quiet-button:focus-visible { border-color: var(--ink); }
.edit-action { display: none; }
body.editing .edit-action { display: inline-flex; align-items: center; justify-content: center; }
.primary-inline { width: fit-content; margin-top: .45rem; padding: .52rem .75rem; color: white; background: var(--teal); border: 0; border-radius: .65rem; font-weight: 800; }

.day-strip { display: flex; gap: .4rem; margin: .7rem 0 .8rem; overflow-x: auto; padding-bottom: .25rem; }
.day-button {
  flex: 0 0 auto;
  min-width: 3.2rem;
  padding: .45rem .4rem;
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: white;
  color: var(--ink-soft);
  text-align: center;
}
.day-button strong, .day-button span { display: block; }
.day-button span { font-size: .72rem; text-transform: uppercase; }
.day-button.active { color: white; background: var(--ink); border-color: var(--ink); }

.event-list { min-height: 0; overflow-y: auto; padding-right: .2rem; }
.event-card {
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  margin-bottom: .55rem;
  border: 1px solid var(--line);
  border-radius: .8rem;
  background: white;
}
.event-card:hover, .event-card:focus-within, .event-card.active { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(53, 104, 212, .12); }
.event-select { width: 100%; display: grid; grid-template-columns: 4.25rem 1fr auto; gap: .75rem; align-items: start; padding: .8rem; text-align: left; border: 0; border-radius: inherit; background: transparent; color: inherit; }
body.editing .event-select { padding-right: 3.25rem; }
.event-time { color: var(--muted); font-weight: 800; font-size: .82rem; }
.event-title { margin: 0; font-weight: 800; }
.event-copy, .event-title, .event-note { display: block; }
.event-note { margin: .35rem 0 0; color: var(--muted); font-size: .82rem; }
.event-arrow { color: var(--blue); font-size: 1.15rem; }
.transport-advice {
  display: grid;
  grid-template-columns: 1.8rem minmax(0, 1fr) auto;
  gap: .55rem;
  align-items: start;
  margin: 0 .7rem .7rem;
  padding: .62rem .7rem;
  color: #234fa8;
  background: #f2f6ff;
  border: 1px solid #d8e3ff;
  border-radius: .65rem;
}
.transport-icon { display: grid; place-items: center; width: 1.65rem; height: 1.65rem; color: white; background: var(--blue); border-radius: 50%; font-weight: 900; }
.transport-advice small, .transport-advice strong, .transport-advice em { display: block; }
.transport-advice small { font-size: .68rem; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.transport-advice strong { color: var(--ink); font-size: .8rem; }
.transport-advice em { margin-top: .16rem; color: var(--muted); font-size: .74rem; font-style: normal; line-height: 1.35; }
.transport-advice a { align-self: center; color: var(--blue); font-size: .72rem; font-weight: 850; text-decoration: none; }
.transport-advice a:hover { text-decoration: underline; }
.status-chip {
  display: inline-block;
  margin: .25rem 0 0;
  padding: .12rem .38rem;
  border-radius: 999px;
  color: #344054;
  background: #eef1f6;
  font-size: .64rem;
  font-weight: 850;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.status-chip.confirmed { color: #05665e; background: #dff5f1; }
.status-chip.todo { color: #b43a2e; background: #fee8e5; }
.status-chip.option { color: #875a00; background: #fff0c8; }
.status-chip.planned { color: #234fa8; background: #e5ecff; }

.map-panel { position: relative; min-height: 35rem; overflow: hidden; }
.map-toolbar { min-height: 4.6rem; padding: .75rem 1rem; }
.map-context { margin: 0; font-weight: 750; }
#map { height: calc(100% - 7.2rem); min-height: 30rem; background: #dfe6ee; }
.map-legend { display: flex; flex-wrap: wrap; gap: 1rem; padding: .65rem 1rem; color: var(--muted); font-size: .78rem; }
.map-legend b { font-weight: 500; }
.dot { display: inline-block; width: .65rem; height: .65rem; margin-right: .25rem; border-radius: 50%; }
.visit { background: var(--blue); }
.food { background: var(--coral); }
.hotel { background: var(--teal); }
.transport { background: var(--amber); }

.section-intro { max-width: 52rem; margin: .5rem 0 1rem; }
.section-intro > p:last-child { color: var(--muted); }
.checklist-grid, .food-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.check-card, .food-card { padding: 1rem; }
.check-card { border-top: 4px solid var(--blue); box-shadow: 0 8px 28px rgba(16,24,40,.07); }
.check-card.urgent { border-top-color: var(--coral); }
.check-card.friend { border-top-color: #9367d5; }
.check-card.booking { border-top-color: var(--amber); }
.check-card.fun { border-top-color: #9367d5; }
.check-card.warning { border-top-color: #cc7b18; }
.check-card.apps { border-top-color: var(--teal); }
.check-card h3, .food-card h3 { margin-bottom: .7rem; }
.check-card h3 { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.owner-badge { padding: .16rem .42rem; border-radius: 999px; color: #05665e; background: #dff5f1; font-size: .65rem; text-transform: uppercase; }
.owner-badge.friend { color: #6842a1; background: #efe7fa; }
.check-row { padding: .65rem 0; border-top: 1px solid #edf0f5; }
.check-row:first-of-type { border-top: 0; }
.check-row label { display: grid; grid-template-columns: 1.2rem 1fr; gap: .6rem; align-items: start; cursor: pointer; }
.check-row input { width: 1.05rem; height: 1.05rem; margin-top: .2rem; accent-color: var(--teal); }
.check-copy strong, .check-copy small { display: block; }
.check-copy strong { font-size: .88rem; }
.check-copy small { margin-top: .14rem; color: var(--muted); font-size: .76rem; line-height: 1.35; }
.check-copy .due { width: fit-content; margin-top: .3rem; padding: .12rem .35rem; color: #875a00; background: #fff0c8; border-radius: 999px; font-weight: 800; }
.check-row > a, .food-footer > a { display: inline-block; margin: .35rem 0 0 1.8rem; color: var(--blue); font-size: .75rem; font-weight: 800; text-decoration: none; }
.check-row > a:hover, .food-footer > a:hover { text-decoration: underline; }
.check-row.done .check-copy { color: var(--muted); text-decoration: line-through; }
.check-row.done .check-copy small { color: #98a2b3; }
.item-edit, .card-edit {
  display: none;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: var(--blue);
  background: #eef3ff;
  border: 1px solid #cddafe;
  border-radius: .55rem;
  font-weight: 900;
}
body.editing .item-edit, body.editing .card-edit { display: grid; }
.event-card > .card-edit { position: absolute; z-index: 2; top: .55rem; right: .55rem; }
.check-row { position: relative; }
body.editing .check-row { padding-right: 2.4rem; }
.check-row > .item-edit { position: absolute; top: .55rem; right: 0; }
.food-card { position: relative; }
body.editing .food-card { padding-right: 3.5rem; }
.food-card > .card-edit { position: absolute; top: .7rem; right: .7rem; }
.food-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.food-card { border-top: 4px solid var(--coral); }
.food-card p { margin-bottom: .55rem; color: var(--ink-soft); }
.food-card .place { color: var(--muted); font-size: .85rem; }
.food-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-top: .8rem; }
.food-footer > a { flex: 0 0 auto; margin: 0; }
.tag { display: inline-block; margin: .15rem .2rem .15rem 0; padding: .2rem .45rem; border-radius: 999px; background: #f0f3f8; font-size: .72rem; font-weight: 750; }

.custom-marker { width: 2rem; height: 2.2rem; padding: 0; border: 0; background: transparent; overflow: visible; }
.custom-marker:focus-visible { outline: 3px solid white; outline-offset: 3px; border-radius: 50%; }
.marker-pin { display: grid; place-items: center; width: 2rem; height: 2rem; color: white; border: 3px solid white; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); box-shadow: 0 4px 12px rgba(16,24,40,.32); }
.marker-pin > span { transform: rotate(45deg); font-size: .68rem; font-weight: 900; }
.marker-pin.visit { background: var(--blue); }
.marker-pin.food { background: var(--coral); }
.marker-pin.hotel { background: var(--teal); }
.marker-pin.transport { background: #c97f00; }

.maplibregl-popup-content { padding: .8rem 1rem; border-radius: .8rem; font-family: inherit; box-shadow: 0 8px 30px rgba(16,24,40,.18); }
.maplibregl-popup-close-button { width: 1.8rem; height: 1.8rem; font-size: 1.1rem; }
.maplibregl-ctrl-group button { width: 30px; height: 30px; }
.maplibregl-ctrl-attrib { font-family: inherit; }
.popup-title { margin-bottom: .15rem; font-weight: 850; }
.popup-date { color: var(--muted); font-size: .8rem; }

footer { padding: 0 clamp(1rem, 3vw, 3.5rem) 1.5rem; color: var(--muted); font-size: .75rem; }
footer p { margin: 0; }

.owner-switch { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .9rem; }
.owner-button {
  padding: .48rem .7rem;
  color: var(--ink-soft);
  background: white;
  border: 1px solid var(--line);
  border-radius: .65rem;
  font-size: .82rem;
  font-weight: 800;
}
.owner-button.active { color: white; background: var(--ink); border-color: var(--ink); }
.owner-note { margin: .55rem 0 0; color: var(--teal) !important; font-size: .78rem; font-weight: 750; }

.clothing-guide {
  display: grid;
  grid-template-columns: minmax(9rem, .65fr) minmax(18rem, 1.8fr) minmax(12rem, 1fr);
  gap: 1.15rem;
  align-items: center;
  margin: 0 0 1rem;
  padding: 1rem;
  border: 1px solid #cfe1ee;
  border-radius: 1rem;
  background: linear-gradient(125deg, #edf8fb 0%, #f7fbff 58%, #fff8e8 100%);
  box-shadow: 0 8px 28px rgba(16,24,40,.06);
}
.clothing-weather { display: grid; gap: .2rem; align-content: center; min-height: 7.5rem; padding: 1rem; color: white; background: var(--ink); border-radius: .8rem; }
.clothing-weather strong { font-size: clamp(1.55rem, 3vw, 2.25rem); line-height: 1; }
.clothing-weather span { color: #dce5f3; font-size: .78rem; line-height: 1.35; }
.clothing-guide h3 { margin: .18rem 0 .55rem; }
.clothing-guide ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .35rem 1rem; margin: 0; padding-left: 1.1rem; color: var(--ink-soft); font-size: .82rem; line-height: 1.4; }
.clothing-avoid { display: grid; gap: .35rem; padding: .85rem; color: #734c00; background: rgba(255,240,200,.75); border-radius: .75rem; font-size: .78rem; line-height: 1.4; }
.clothing-avoid strong { color: #875a00; font-size: .82rem; }

.editor-dialog {
  width: min(94vw, 42rem);
  max-height: min(90vh, 48rem);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 1rem;
  box-shadow: 0 28px 90px rgba(16,24,40,.35);
}
.editor-dialog::backdrop { background: rgba(16,24,40,.72); backdrop-filter: blur(4px); }
.editor-dialog form { padding: 1.25rem; }
.editor-heading { display: flex; justify-content: space-between; align-items: start; gap: 1rem; padding-bottom: .8rem; border-bottom: 1px solid var(--line); }
.editor-heading h2 { margin: 0; }
.icon-button { width: 2.2rem; height: 2.2rem; padding: 0; color: var(--ink-soft); background: #f1f3f7; border: 0; border-radius: 50%; font-size: 1.35rem; }
.editor-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; margin-top: 1rem; }
.editor-field { display: grid; gap: .28rem; }
.editor-field.full { grid-column: 1 / -1; }
.editor-field label { color: var(--ink-soft); font-size: .82rem; font-weight: 800; }
.editor-field input, .editor-field select, .editor-field textarea { width: 100%; padding: .65rem .7rem; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: .6rem; }
.editor-field textarea { min-height: 6rem; resize: vertical; }
.editor-field input:focus, .editor-field select:focus, .editor-field textarea:focus { outline: 3px solid rgba(53,104,212,.15); border-color: var(--blue); }
.editor-footer { display: grid; grid-template-columns: auto 1fr auto auto; gap: .55rem; align-items: center; margin-top: .7rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.editor-save { width: auto; margin: 0; padding-inline: 1rem; }
.danger-button { display: none; padding: .55rem .7rem; color: #a6291d; background: #fff0ee; border: 1px solid #f1b6b0; border-radius: .6rem; font-weight: 800; }
.editor-dialog.is-editing .danger-button { display: inline-flex; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 1.2rem; transform: translate(-50%, 1rem); padding: .65rem .9rem; color: white; background: var(--ink); border-radius: .7rem; box-shadow: var(--shadow); font-size: .82rem; font-weight: 750; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.auth-dialog {
  width: min(92vw, 27rem);
  padding: 0;
  border: 0;
  border-radius: 1rem;
  box-shadow: 0 28px 90px rgba(16,24,40,.35);
}
.auth-dialog::backdrop { background: rgba(16,24,40,.72); backdrop-filter: blur(4px); }
.auth-dialog form { padding: 1.4rem; }
.auth-dialog p { color: var(--muted); }
.auth-dialog .eyebrow { color: var(--teal); }
.field-label, .auth-dialog legend { display: block; margin: .8rem 0 .35rem; color: var(--ink); font-size: .82rem; font-weight: 800; }
.auth-dialog input[type="password"] { width: 100%; padding: .7rem .75rem; border: 1px solid var(--line); border-radius: .6rem; }
.auth-dialog input[type="password"]:focus { outline: 3px solid rgba(53,104,212,.18); border-color: var(--blue); }
.auth-dialog fieldset { display: flex; gap: 1rem; margin: .8rem 0; padding: .75rem; border: 1px solid var(--line); border-radius: .6rem; }
.auth-dialog fieldset label { display: flex; align-items: center; gap: .35rem; }
.primary-button { width: 100%; margin-top: .35rem; padding: .7rem; color: white; background: var(--ink); border: 0; border-radius: .6rem; font-weight: 850; }
.auth-dialog small { display: block; margin-top: .65rem; color: var(--muted); text-align: center; }
.auth-error { min-height: 1.4rem; margin: .4rem 0; color: #b42318 !important; font-size: .8rem; font-weight: 700; }

@media (max-width: 920px) {
  .trip-dashboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agenda-layout { grid-template-columns: 1fr; }
  .schedule-panel { max-height: 34rem; }
  .map-panel { min-height: 30rem; }
  #map { min-height: 24rem; }
  .checklist-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .clothing-guide { grid-template-columns: 10rem 1fr; }
  .clothing-avoid { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .trip-meta { justify-content: flex-start; }
  main { padding-inline: .75rem; }
  .trip-dashboard { grid-template-columns: 1fr; }
  .agenda-layout { min-height: auto; }
  .schedule-panel { max-height: none; }
  .event-list { overflow: visible; }
  .transport-advice { grid-template-columns: 1.8rem minmax(0, 1fr); }
  .transport-advice a { grid-column: 2; }
  .map-panel { min-height: 28rem; }
  .checklist-grid, .food-grid { grid-template-columns: 1fr; }
  .clothing-guide { grid-template-columns: 1fr; }
  .clothing-weather { min-height: auto; }
  .clothing-guide ul { grid-template-columns: 1fr; }
  .clothing-avoid { grid-column: auto; }
  .heading-actions { align-items: stretch; flex-direction: column; }
  .editor-fields { grid-template-columns: 1fr; }
  .editor-field.full { grid-column: auto; }
  .editor-footer { grid-template-columns: 1fr 1fr; }
  .editor-footer > span { display: none; }
  .editor-footer button { justify-content: center; }
}
