:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #182026;
  --muted: #6b7680;
  --line: #dce3e8;
  --accent: #007a78;
  --accent-strong: #005f5d;
  --accent-soft: #e4f4f2;
  --danger: #b23a48;
  --danger-soft: #fae8eb;
  --shadow: 0 16px 40px rgba(28, 43, 54, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 28px;
}

.brand-row,
.planner-header,
.planner-actions,
.day-heading,
.day-heading-actions,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-row {
  justify-content: center;
  text-align: center;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 31px;
}

h2 {
  margin-bottom: 8px;
  font-size: 32px;
  line-height: 1.16;
}

h3 {
  margin-bottom: 0;
  font-size: 22px;
}

.subtle {
  margin-bottom: 0;
  color: var(--muted);
}

.trip-form,
.item-form {
  display: grid;
  gap: 14px;
  margin-top: 28px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.modal .item-form,
.modal .trip-form {
  margin-top: 0;
}

.trip-modal-dialog {
  width: min(520px, 100%);
}

label {
  display: grid;
  gap: 7px;
  color: #31404a;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.date-grid,
.time-title-grid,
.place-grid,
.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.time-title-grid {
  grid-template-columns: 120px 140px 1fr;
}

.check-label {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 0 12px;
}

.check-label input {
  width: 18px;
  height: 18px;
  box-shadow: none;
}

.primary-button,
.ghost-button,
.danger-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 15px;
  font-weight: 800;
}

.primary-button {
  border: 0;
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
}

.danger-button {
  border: 1px solid var(--danger-soft);
  background: var(--danger-soft);
  color: var(--danger);
}

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

.trip-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 14px;
  text-align: left;
}

.trip-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.trip-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}

.trip-card span {
  color: var(--muted);
  font-size: 13px;
}

.planner {
  padding: 32px;
}

.empty-state,
.planner-content {
  max-width: 960px;
  margin: 0 auto;
}

.empty-state {
  display: grid;
  align-content: center;
  min-height: calc(100vh - 64px);
}

.planner-header {
  padding-bottom: 24px;
}

.planner-actions {
  flex-wrap: wrap;
}

.share-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  padding: 16px;
}

.share-panel h3 {
  margin-bottom: 5px;
}

.share-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.day-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 14px;
}

.day-tab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 11px 14px;
  color: var(--text);
  font-weight: 800;
}

.day-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.day-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 24px;
}

.day-heading {
  margin-bottom: 18px;
}

.day-heading-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.timeline {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.day-map {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
}

.map-picker {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
}

.day-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.map-picker h4,
.day-map-header h4 {
  margin: 0;
  font-size: 16px;
}

.map-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.map-picker-preview {
  display: grid;
  gap: 10px;
}

.map-picker-preview p {
  margin: 0;
  color: var(--muted);
}

.map-results {
  display: grid;
  gap: 8px;
}

.map-result-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px 12px;
  text-align: left;
}

.map-result-button strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.map-result-button span {
  color: var(--muted);
  font-size: 13px;
}

.map-result-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.day-map-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.day-map-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 13px;
}

.timeline-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

.item-card {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 14px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
}

.item-time {
  color: var(--accent-strong);
  font-weight: 900;
}

.item-card h4 {
  margin: 0 0 6px;
  font-size: 17px;
}

.item-card p {
  margin-bottom: 0;
  color: var(--muted);
  white-space: pre-wrap;
}

.item-main {
  display: grid;
  gap: 12px;
}

.item-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

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

.type-badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

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

.detail-chip {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 13px;
}

.detail-chip strong {
  color: var(--text);
}

.note-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.note-list li {
  border-radius: 8px;
  background: white;
  padding: 8px 10px;
  color: #3f4b53;
  font-size: 13px;
}

.map-frame {
  width: 100%;
  height: 460px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8edf0;
}

.leaflet-day-map {
  width: 100%;
  height: 460px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8edf0;
}

.map-picker .map-frame {
  height: 380px;
}

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

.map-link.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.map-link {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--accent-strong);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.small-button {
  min-width: 44px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  font-weight: 800;
}

.small-button.danger {
  border-color: var(--danger-soft);
  color: var(--danger);
}

.small-button:disabled {
  cursor: default;
  opacity: 0.38;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: rgba(16, 28, 35, 0.45);
  padding: 20px;
}

.modal-dialog {
  position: relative;
  z-index: 2001;
  width: min(760px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border-radius: 8px;
  background: white;
  box-shadow: 0 24px 70px rgba(14, 30, 38, 0.28);
  padding: 18px;
}

.leaflet-container {
  z-index: 0;
}

.route-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 180px;
  gap: 10px;
}

.route-controls select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 10px 12px;
}

.sequence-toggle {
  display: inline-flex;
  width: fit-content;
  min-height: 40px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 0 12px;
}

.sequence-toggle input {
  width: 18px;
  height: 18px;
}

.sequence-arrow {
  color: var(--accent);
  font-size: 23px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(16, 28, 35, 0.18);
}

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

.modal-header h4 {
  margin: 0;
  font-size: 20px;
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 20px;
  }

  .planner {
    padding: 20px;
  }

  .planner-header,
  .planner-actions,
  .day-heading,
  .day-heading-actions,
  .modal-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .date-grid,
  .time-title-grid,
  .place-grid,
  .check-grid,
  .place-details {
    grid-template-columns: 1fr;
  }

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

  .item-card {
    grid-template-columns: 1fr;
  }

  .item-topline {
    flex-direction: column;
  }

  .map-search {
    grid-template-columns: 1fr;
  }

  .route-controls {
    grid-template-columns: 1fr;
  }

  .map-frame {
    height: 360px;
  }

  .leaflet-day-map {
    height: 360px;
  }

  .map-picker .map-frame {
    height: 300px;
  }

  h2 {
    font-size: 25px;
  }
}
