:root {
  color-scheme: light;
  --bg: #f6f2eb;
  --ink: #121917;
  --muted: #5d6a65;
  --accent: #0f5d5a;
  --accent-2: #f2a65a;
  --panel: #ffffff;
  --shadow: rgba(15, 25, 23, 0.12);
  --radius: 18px;
  --font: "Fraunces", "EB Garamond", "Georgia", serif;
  --sans: "IBM Plex Sans", "Avenir", "Helvetica", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  background: radial-gradient(circle at top left, #fdf9f2, #f1ebe2 60%, #e6e0d6);
  color: var(--ink);
  overflow-x: hidden;
  width: 100%;
}

html {
  width: 100%;
  overflow-x: hidden;
  max-width: 100%;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 16px 18px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(246, 242, 235, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #e2d9cd;
  gap: 10px;
  width: 100%;
  max-width: 100vw;
}

.header-title {
  font-family: var(--font);
  font-size: 18px;
  letter-spacing: 0.05em;
  font-weight: 700;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-flat {
  border: none;
  background: transparent;
  color: var(--ink);
  width: 36px;
  height: 36px;
  font-size: 20px;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: none;
  flex: 0 0 auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.title {
  min-width: 0;
  overflow: hidden;
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font);
  font-size: 18px;
  letter-spacing: 1px;
  flex: 0 0 auto;
}

.title .app-name {
  font-family: var(--font);
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trip-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
  width: auto;
  justify-content: flex-end;
  flex-shrink: 0;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-family: var(--sans);
  font-size: 13px;
  background: var(--accent-2);
  color: #1e1710;
  cursor: pointer;
  box-shadow: 0 6px 14px var(--shadow);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  border: 1px solid #d9cec1;
  box-shadow: none;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.file-btn input {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 18px 32px rgba(11, 16, 15, 0.08);
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.trip-select-toggle {
  flex: 1 1 220px;
  width: auto;
  border: 1px solid #e2d6c8;
  background: #faf6ef;
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  box-shadow: none;
  min-height: 44px;
}

.trip-select-toggle span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip-select-collapsed {
  display: none;
  width: 100%;
}

.trip-select-collapsed.open {
  display: block;
}

.trip-meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.panel-actions {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 12px;
  width: 100%;
}

.add-menu-wrap {
  position: relative;
  flex: 0 0 auto;
}

.add-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: auto;
  display: grid;
  gap: 6px;
  min-width: 190px;
  max-width: min(92vw, 260px);
  padding: 8px;
  border-radius: 12px;
  border: 1px solid #e2d6c8;
  background: #fff;
  box-shadow: 0 14px 28px rgba(11, 16, 15, 0.16);
  z-index: 5;
}

.hidden {
  display: none !important;
}

.day-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 10px;
  margin-bottom: 4px;
  scrollbar-width: thin;
  width: 100%;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}

.day-chip {
  border: 1px solid #e5d8c8;
  border-radius: 999px;
  background: #f8f3eb;
  color: #4a5752;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  padding: 10px 12px;
  min-width: 46px;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  flex: 0 0 auto;
}

.day-chip.month {
  background: #ecdfcc;
  color: #3d2f1b;
  border-color: #e6d5bd;
  font-weight: 600;
  position: sticky;
  left: 0;
  z-index: 2;
  box-shadow: 10px 0 10px rgba(246, 242, 235, 0.92);
}

.day-chip.sunday,
.day-chip.wednesday {
  border-style: dashed;
}

.day-chip.today {
  border-color: var(--accent);
  color: var(--accent);
}

.day-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #efe6d8;
  font-size: 12px;
  width: fit-content;
}

.agenda {
  position: relative;
  height: 60vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 2px;
  scroll-snap-type: y proximity;
  overscroll-behavior: contain;
  scroll-padding-top: 10vh;
  scroll-padding-bottom: 10vh;
  width: 100%;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.agenda-item {
  margin: 10px auto;
  padding: 14px 16px;
  border-radius: 16px;
  background: #f9f6f0;
  border: 1px solid #eadfce;
  scroll-snap-align: center;
  transition: transform 0.25s ease, opacity 0.25s ease, filter 0.25s ease;
  display: grid;
  gap: 6px;
  width: calc(100% - 2px);
  max-width: 100%;
  overflow: hidden;
  position: relative;
}

.agenda-spacer {
  height: 6vh;
}

.route-estimate-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 6px 0 10px;
  flex-wrap: wrap;
}

.route-estimate-btn {
  border: 1px dashed #d8cbb8;
  background: #faf6ef;
  color: #5d6a65;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  cursor: pointer;
}

.route-estimate-btn.ghost {
  background: transparent;
  border-style: solid;
}

.route-estimate-row.is-loading .route-estimate-btn {
  opacity: 0.75;
  cursor: wait;
}

.agenda-item.active {
  border-color: var(--accent);
  box-shadow: 0 12px 24px rgba(15, 93, 90, 0.2);
}

.agenda-item .meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.agenda-item .meta span {
  min-width: 0;
}

.agenda-item {
  transform-origin: center;
  will-change: transform, opacity;
}

.source-icon {
  font-size: 14px;
}

.agenda-item .title {
  font-size: 15px;
  font-weight: 600;
}

.agenda-add {
  position: absolute;
  right: 12px;
  bottom: 10px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid #e3d6c6;
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 16px;
  cursor: pointer;
}

.day-separator {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.day-separator .line {
  height: 1px;
  background: #e6ddd1;
  flex: 1;
}

.day-separator .flag {
  background: #efe6d8;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  background: #efe6d8;
  color: #3d2f1b;
}

.details-dialog {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: visible;
  margin: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: calc(100vh - 16px);
  max-height: calc(100vh - 16px);
}

.details-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.highlights {
  display: grid;
  gap: 8px;
  background: #f3ede3;
  border-radius: 14px;
  padding: 12px;
}

.highlight-title {
  font-family: var(--font);
  font-size: 16px;
}

.highlight-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.details-section .source-pre {
  background: #f7f3ec;
  border-radius: 12px;
  padding: 10px;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
  font-size: 12px;
}

.details-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.details-header > div {
  min-width: 0;
  flex: 1 1 auto;
}

.details-title {
  font-family: var(--font);
  font-size: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.details-meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.details-grid {
  display: grid;
  gap: 8px;
  max-width: 100%;
  overflow-x: hidden;
}

.details-grid .row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  background: #f7f3ec;
  border-radius: 12px;
  font-size: 13px;
  width: 100%;
}

.details-grid .row strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.details-grid .row span {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  max-width: 100%;
}

.details-grid .row span a {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#eventDialogDetails {
  width: min(560px, calc(100vw - 12px));
  max-width: calc(100vw - 12px);
  max-height: calc(100vh - 12px);
  padding: 0;
  overflow-x: hidden;
  overflow-y: hidden;
}

#eventDetails {
  min-width: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

#eventDialogDetails menu {
  position: static;
  flex: 0 0 auto;
  background: #fff;
  padding-top: 6px;
}

.eta-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #efe6d8;
  color: #67543d;
}

.dialog-form .row {
  align-items: center;
}

.dialog-form .row input {
  flex: 1;
}

.details-section h4 {
  margin: 0 0 6px 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.details-card .grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.details-card label {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.details-card input,
.details-card textarea,
.details-card select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #d9cec1;
  font-family: var(--sans);
  font-size: 13px;
}

.details-card textarea {
  width: 100%;
}

.details-card .details-actions {
  display: none;
}

.details-card.editing .details-actions {
  display: flex;
}

.details-card.editing .edit-field {
  display: grid;
}

.details-card .edit-field {
  display: none;
}

.details-card .edit-notes {
  grid-column: 1 / -1;
}

@media (max-width: 480px) {
  .details-card .grid {
    grid-template-columns: 1fr;
  }
}

details.details-section {
  background: #faf6ef;
  border-radius: 12px;
  padding: 10px;
}

details.details-section summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.details-notes {
  white-space: pre-wrap;
  line-height: 1.4;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: #efe6d8;
  font-size: 12px;
  cursor: pointer;
}

.details-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.details-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.details-edit-btn {
  width: 34px;
  height: 34px;
  font-size: 18px;
}

.dialog-form {
  display: grid;
  gap: 12px;
  min-width: 280px;
}

.dialog-form h3 {
  margin: 0;
  font-family: var(--font);
}

.dialog-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.dialog-form input,
.dialog-form textarea,
.dialog-form select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #d9cec1;
  font-family: var(--sans);
  font-size: 13px;
  max-width: 100%;
}

select {
  max-width: 100%;
}

.dialog-form menu {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin: 0;
  padding: 0;
}

.dialog-actions-vertical {
  display: grid !important;
  gap: 8px !important;
}

.provider-block {
  border: 1px solid #e2d6c8;
  border-radius: 14px;
  padding: 12px;
  background: #faf6ef;
  display: grid;
  gap: 10px;
}

.provider-title {
  font-family: var(--font);
  font-size: 15px;
}

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

.small {
  font-size: 12px;
}

@media (min-width: 900px) {
  .agenda {
    height: 70vh;
  }
}

@media (max-width: 480px) {
  body {
    max-width: 430px;
    margin: 0 auto;
  }

  .topbar,
  .layout {
    max-width: 430px;
    margin: 0 auto;
  }

  .topbar {
    padding: 12px;
    gap: 8px;
  }

  .panel {
    padding: 12px 10px;
  }

  .btn {
    padding: 8px 12px;
    font-size: 12px;
  }

  .top-actions .btn {
    padding-inline: 10px;
  }

  #btnNewTrip {
    padding: 7px 10px;
    font-size: 11px;
  }

  .logo {
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }

  .title .app-name {
    font-size: 15px;
  }

  .header-title {
    font-size: 16px;
  }

  #eventDialogDetails {
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
  }

  .details-dialog {
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
    padding: 10px;
    height: calc(100vh - 12px);
    max-height: calc(100vh - 12px);
  }

  .trip-label {
    font-size: 11px;
  }

  .trip-select-toggle {
    font-size: 16px;
    padding: 9px 10px;
  }

  .day-chip {
    padding: 8px 9px;
  }

  .agenda {
    height: 66vh;
    scroll-padding-top: 9vh;
    scroll-padding-bottom: 9vh;
  }

  .agenda-spacer {
    height: 5vh;
  }
}
