:root {
  --ink: #131f1e;
  --panel: #1b2a28;
  --panel-2: #21332f;
  --line: #2e423d;
  --paper: #ece9df;
  --muted: #8ea39c;
  --accent: #f2b33d;
  --danger: #e4726b;
  --d1: #f2b33d; --d2: #5cc8c2; --d3: #e4726b; --d4: #9d8ce8;
  --d5: #7fbf7b; --d6: #e89ad0; --d7: #c9b458;
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Instrument Sans", system-ui, sans-serif;
  background: var(--ink);
  color: var(--paper);
}
h1, h2, h3 { font-family: "Bricolage Grotesque", "Instrument Sans", sans-serif; }

#layout {
  display: grid;
  grid-template-columns: 330px auto 1fr;
  height: 100vh;
}

/* ---------------------------------------------------------- sidebar */
#sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.brand { padding: 22px 20px 10px; }
.brand h1 {
  margin: 0;
  font-family: "Noto Sans Tamil", "Bricolage Grotesque", sans-serif;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.brand h1::after { content: "·"; color: var(--accent); margin-left: 4px; }
.tagline { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }
.tagline b { color: var(--paper); font-weight: 600; }

.panel { padding: 16px 20px; border-top: 1px solid var(--line); }
.panel h2 { margin: 0 0 10px; font-size: 1.05rem; }

.field { display: block; margin-bottom: 12px; }
.field > span, .interests > span {
  display: block; font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); margin-bottom: 5px;
}
.row { display: flex; gap: 10px; }
.row .field { flex: 1; }

input[type="text"], input[type="number"], select {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--paper);
  padding: 9px 10px;
  font: inherit;
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.geo-wrap { position: relative; }
.geo-results {
  position: absolute; z-index: 1200; left: 0; right: 0; top: 100%;
  margin: 4px 0 0; padding: 4px; list-style: none;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; max-height: 220px; overflow-y: auto;
}
.geo-results li {
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  font-size: 0.88rem; line-height: 1.3;
}
.geo-results li:hover { background: var(--line); }

.country-block {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 12px; background: var(--panel-2);
}
.country-block .country-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.country-block .country-head b { font-size: 0.92rem; }
.country-block .country-head .del {
  border: 0; background: none; color: var(--muted); font-size: 1rem; padding: 2px 6px;
}
.country-block .country-head .del:hover { color: var(--danger); }
.country-block .geo-wrap input { font-size: 0.88rem; padding: 7px 9px; }

.city-list { list-style: none; margin: 8px 0 0; padding: 0; }
.city-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 0; font-size: 0.88rem;
}
.city-chip .name { flex: 1; }
.city-chip .days-stepper {
  display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 0.8rem;
}
.city-chip .days-stepper button {
  border: 0; background: var(--panel); color: var(--muted);
  width: 20px; height: 20px; border-radius: 6px; font-size: 0.8rem; line-height: 1;
}
.city-chip .days-stepper button:hover { color: var(--paper); }
.city-chip .days-stepper span { min-width: 2.4em; text-align: center; }
.city-chip .del {
  border: 0; background: none; color: var(--muted); font-size: 1rem; padding: 2px 6px;
}
.city-chip .del:hover { color: var(--danger); }
.no-cities { color: var(--muted); font-size: 0.82rem; margin: 4px 0 0; }

.interests { border: 0; padding: 0; margin: 0 0 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chips label { cursor: pointer; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips i {
  display: inline-block; font-style: normal; font-size: 0.85rem;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.chips input:checked + i {
  background: var(--accent); border-color: var(--accent); color: var(--ink);
  font-weight: 600;
}
.chips input:focus-visible + i { outline: 2px solid var(--accent); }

button {
  font: inherit; cursor: pointer; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--paper);
}
button.primary {
  width: 100%; padding: 11px;
  background: var(--accent); border-color: var(--accent);
  color: var(--ink); font-weight: 600; font-size: 1rem;
}
button.primary:disabled { opacity: 0.55; cursor: wait; }
button.ghost { padding: 8px 14px; }
button.ghost:hover { border-color: var(--accent); }

.status { margin: 10px 0 0; font-size: 0.85rem; color: var(--muted); }
.status.error { color: var(--danger); }

.trips ul { list-style: none; margin: 0; padding: 0; }
.trips li {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 10px; border-radius: 8px; font-size: 0.9rem;
}
.trips li:hover { background: var(--panel-2); }
.trips li a { color: var(--paper); text-decoration: none; cursor: pointer; flex: 1; }
.trips li a:hover { color: var(--accent); }
.trips li .del {
  border: 0; background: none; color: var(--muted); font-size: 1rem; padding: 2px 6px;
}
.trips li .del:hover { color: var(--danger); }
.trips .empty { color: var(--muted); font-size: 0.85rem; cursor: default; }
.trips .empty:hover { background: none; }

/* ---------------------------------------------------------- hotels */
.hotels h2 { display: flex; align-items: center; justify-content: space-between; }
button.ghost.small { padding: 3px 10px; font-size: 0.78rem; }
.hotels ul { list-style: none; margin: 0; padding: 0; }
.hotels .hotel-item {
  padding: 8px 10px; border-radius: 8px; font-size: 0.88rem;
  position: relative;
}
.hotels .hotel-item:hover { background: var(--panel-2); }
.hotel-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hotel-sub { font-size: 0.78rem; margin-top: 2px; }
.hotels .hotel-item .tools {
  position: static; display: none; gap: 6px; margin-top: 6px;
}
.hotels .hotel-item:hover .tools { display: flex; }
.hotels .hotel-item .tools button {
  border: 0; background: var(--panel); color: var(--muted);
  padding: 3px 9px; border-radius: 6px; font-size: 0.76rem;
}
.hotels .hotel-item .tools .edit:hover { color: var(--accent); }
.hotels .hotel-item .tools .del:hover { color: var(--danger); }
.hotels .empty { color: var(--muted); font-size: 0.85rem; }

/* lodging banner in the day ribbon */
.lodging {
  position: relative; padding: 10px 12px 10px 34px; margin-bottom: 16px;
  border: 1px dashed var(--accent); border-radius: 10px; background: var(--panel-2);
}
.lodging .dot {
  position: absolute; left: 8px; top: 10px; font-size: 1rem; line-height: 1;
}
.lodging .meta { font-size: 0.82rem; color: var(--muted); line-height: 1.5; }
.lodging .meta b { color: var(--paper); font-weight: 600; }
.lodging .meta a { color: var(--accent); text-decoration: none; }
.lodging .meta a:hover { text-decoration: underline; }

/* ---------------------------------------------------------- transfers */
.transfers h2 { display: flex; align-items: center; justify-content: space-between; }
.transfers .empty { color: var(--muted); font-size: 0.85rem; }

/* transfer banner in the day ribbon */
.transfer-banner {
  position: relative; padding: 10px 12px 10px 34px; margin-bottom: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2);
}
.transfer-banner .dot {
  position: absolute; left: 8px; top: 10px; font-size: 1rem; line-height: 1;
}
.transfer-banner .meta { font-size: 0.82rem; color: var(--muted); line-height: 1.5; }
.transfer-banner .meta b { color: var(--paper); font-weight: 600; }

/* ---------------------------------------------------------- hotel modal */
.modal[hidden] { display: none; }
.modal {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(13, 21, 20, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-card {
  width: 100%; max-width: 440px; max-height: 90vh;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 1.1rem; }
.icon-btn {
  border: 0; background: none; color: var(--muted); font-size: 1rem; padding: 2px 6px;
}
.icon-btn:hover { color: var(--danger); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-body textarea, .modal-body input[type="text"], .modal-body input[type="url"],
.modal-body input[type="date"] {
  width: 100%; background: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; color: var(--paper); padding: 9px 10px; font: inherit; resize: vertical;
}
.modal-body hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.hotel-extract-row { align-items: center; margin-top: 8px; }
.hotel-extract-row input[type="file"] {
  flex: 1; min-width: 0; font-size: 0.8rem; color: var(--muted);
}
.modal-actions { padding: 14px 18px; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------- itinerary */
#itinerary {
  width: 372px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.itin-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 18px 18px 10px; gap: 10px;
}
.itin-head h2 { margin: 0; font-size: 1.25rem; line-height: 1.2; }
.muted { color: var(--muted); font-size: 0.82rem; margin: 3px 0 0; }

.itin-head-actions { display: flex; align-items: center; gap: 8px; }
#trip-date {
  width: auto; padding: 7px 8px; font-size: 0.8rem; color: var(--muted);
}

#day-tabs {
  display: flex; gap: 6px; padding: 0 18px 12px; flex-wrap: wrap;
}
#day-tabs button {
  padding: 6px 13px; border-radius: 999px; font-size: 0.85rem;
  border: 1px solid var(--line); background: none; color: var(--muted);
}
#day-tabs button.active {
  color: var(--ink); font-weight: 600;
  background: var(--day-color); border-color: var(--day-color);
}

#ribbon { overflow-y: auto; padding: 4px 18px 24px; flex: 1; }

/* the route ribbon: vertical line in day colour, stops hang off it */
.stop, .lunch, .hotel-anchor {
  position: relative;
  padding: 0 0 18px 34px;
}
.stop::before, .lunch::before, .hotel-anchor::before {
  content: ""; position: absolute; left: 11px; top: 6px; bottom: -6px;
  width: 2px; background: var(--day-color);
}
.stop:last-child::before, .lunch:last-child::before, .hotel-anchor:last-child::before { display: none; }
.stop .dot {
  position: absolute; left: 0; top: 0;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--day-color); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem;
}
.lunch .dot {
  position: absolute; left: 4px; top: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px dashed var(--day-color); background: var(--panel);
}
.hotel-anchor .dot {
  position: absolute; left: 1px; top: -1px; font-size: 1rem; line-height: 1;
}
.hotel-anchor .meta { font-size: 0.82rem; color: var(--muted); }
.hotel-anchor .meta b { color: var(--paper); font-weight: 600; }
.travel-chip {
  display: inline-block; margin-bottom: 6px;
  font-size: 0.72rem; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 999px; padding: 2px 9px;
}
.stop h3 { margin: 0 0 2px; font-size: 0.98rem; font-weight: 600; }
.stop .meta, .lunch .meta {
  font-size: 0.8rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.stop .meta b { color: var(--paper); font-weight: 500; }
.stop .links { margin-top: 3px; font-size: 0.78rem; }
.stop .links a { color: var(--accent); text-decoration: none; margin-right: 10px; }
.stop .links a:hover { text-decoration: underline; }
.stop .tools {
  position: absolute; right: 0; top: 0; display: none; gap: 2px; align-items: center;
}
.stop:hover .tools { display: flex; }
.tools button {
  border: 0; background: var(--panel-2); color: var(--muted);
  width: 24px; height: 24px; border-radius: 6px; font-size: 0.8rem; line-height: 1;
}
.tools button:hover { color: var(--paper); }
.tools .rm:hover { color: var(--danger); }
.tools select.move-day {
  height: 24px; width: auto; max-width: 84px; padding: 0 4px;
  border: 0; background: var(--panel-2); color: var(--muted);
  border-radius: 6px; font-size: 0.7rem;
}

.time-edit {
  width: auto; padding: 0 2px; border: 1px solid transparent; border-radius: 4px;
  background: none; color: var(--paper); font: inherit; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.time-edit:hover, .time-edit:focus { border-color: var(--line); background: var(--panel-2); }
.time-edit.pinned { color: var(--accent); border-color: var(--accent); }
.auto-time {
  border: 0; background: none; color: var(--accent); font-size: 0.72rem;
  padding: 0 4px; text-decoration: underline;
}

.add-place { margin: 0 0 16px; }
.add-place input { font-size: 0.88rem; padding: 8px 10px; }

/* ---------------------------------------------------------- map */
#map { height: 100%; background: #0d1514; }

/* ---------------------------------------------------------- print / PDF */
#print-view { display: none; }

@media print {
  body * { visibility: hidden; }
  #print-view, #print-view * { visibility: visible; }
  #print-view {
    display: block; position: absolute; left: 0; top: 0; width: 100%;
    background: #fff; color: #131f1e; font-family: "Instrument Sans", system-ui, sans-serif;
    padding: 0;
  }
  #print-view h1 { font-size: 1.5rem; margin: 0 0 4px; }
  #print-view .print-sub { color: #556; font-size: 0.85rem; margin: 0 0 18px; }
  #print-view h2 {
    font-size: 1.05rem; margin: 20px 0 8px; padding-top: 8px;
    border-top: 1px solid #ccc; break-after: avoid;
  }
  #print-view .print-map {
    display: block; width: 100%; max-width: 600px; height: auto;
    margin: 4px 0 12px; border: 1px solid #ccc; border-radius: 4px;
    break-inside: avoid;
  }
  #print-view .print-day { break-inside: avoid; }
  #print-view .print-row {
    display: flex; gap: 12px; padding: 4px 0; font-size: 0.85rem;
    border-bottom: 1px dotted #ddd; break-inside: avoid;
  }
  #print-view .print-time {
    flex: 0 0 90px; color: #667; font-variant-numeric: tabular-nums;
  }
  #print-view .print-lunch span:last-child { font-style: italic; color: #667; }
  #print-view .print-nav {
    font-size: 0.75rem; color: #889; font-style: italic;
    padding: 2px 0 2px 14px; break-inside: avoid;
  }
  #print-view .print-hotel { background: #f7f3e8; }
  #print-view .print-transfer {
    font-size: 0.85rem; margin: 4px 0 12px; padding: 8px 10px;
    border: 1px solid #ccc; border-radius: 4px; break-inside: avoid;
  }
  #print-view .print-muted { color: #889; font-size: 0.85rem; }
  #print-view .print-hotel-card {
    font-size: 0.85rem; line-height: 1.6; padding: 10px 0;
    border-bottom: 1px solid #ccc; break-inside: avoid;
  }
}

@media (max-width: 1000px) {
  #layout { grid-template-columns: 1fr; grid-template-rows: auto auto 60vh; height: auto; }
  #sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  #itinerary { width: auto; max-height: 55vh; border-right: 0; border-bottom: 1px solid var(--line); }
  #map { height: 60vh; }
}
@media (prefers-reduced-motion: no-preference) {
  .stop, .lunch, .hotel-anchor { animation: rise 0.25s ease both; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } }
}
