/* ============================================
   Itinera - Travel Journal Editorial
   ============================================ */

/* --- Tokens --- */
:root {
  /* Light theme: cream paper + ink */
  --bg: #faf6ee;
  --bg-elevated: #ffffff;
  --bg-sunken: #f1ebde;
  --ink: #1a1815;
  --ink-soft: #4a4540;
  --ink-mute: #8a8278;
  --line: #d9d2c2;
  --line-soft: #e8e2d4;
  --accent: #b8763e;        /* ocre/brick */
  --accent-soft: #e6c9a3;
  --accent-deep: #8a5326;
  --stamp: #c84747;          /* postal stamp red */
  --success: #4a7c4a;
  --warn: #c4942b;
  --info: #5a7a9a;

  /* Type */
  --font-display: 'Fraunces', 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  /* Spacing scale */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4rem;

  /* Radius */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 14px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(26, 24, 21, 0.06);
  --shadow-md: 0 2px 8px rgba(26, 24, 21, 0.08);
  --shadow-lg: 0 8px 24px rgba(26, 24, 21, 0.12);

  /* Layout */
  --bottom-nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --bg-elevated: #1a2028;
    --bg-sunken: #0a0e12;
    --ink: #e8e2d4;
    --ink-soft: #b8b0a0;
    --ink-mute: #7a7268;
    --line: #2a323c;
    --line-soft: #1f262e;
    --accent: #c9986a;
    --accent-soft: #6e5236;
    --accent-deep: #e8b888;
    --stamp: #d96a6a;
    --success: #7ab37a;
    --warn: #e0b048;
    --info: #8aaecc;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

[data-theme="dark"] {
  --bg: #0f1419;
  --bg-elevated: #1a2028;
  --bg-sunken: #0a0e12;
  --ink: #e8e2d4;
  --ink-soft: #b8b0a0;
  --ink-mute: #7a7268;
  --line: #2a323c;
  --line-soft: #1f262e;
  --accent: #c9986a;
  --accent-soft: #6e5236;
  --accent-deep: #e8b888;
  --stamp: #d96a6a;
  --success: #7ab37a;
  --warn: #e0b048;
  --info: #8aaecc;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
  --bg: #faf6ee;
  --bg-elevated: #ffffff;
  --bg-sunken: #f1ebde;
  --ink: #1a1815;
  --ink-soft: #4a4540;
  --ink-mute: #8a8278;
  --line: #d9d2c2;
  --line-soft: #e8e2d4;
  --accent: #b8763e;
  --accent-soft: #e6c9a3;
  --accent-deep: #8a5326;
  --stamp: #c84747;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
  min-height: 100vh;
  overflow-x: hidden;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { cursor: pointer; border: none; background: none; padding: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  font-variation-settings: 'opsz' 36, 'SOFT' 50;
  line-height: 1.1;
  margin: 0;
  letter-spacing: -0.01em;
}

h1 { font-size: 2rem; font-variation-settings: 'opsz' 144, 'SOFT' 50, 'wght' 400; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; font-weight: 600; }

.mono { font-family: var(--font-mono); font-size: 0.875em; letter-spacing: -0.02em; }
.muted { color: var(--ink-mute); }
.soft { color: var(--ink-soft); }

/* --- Layout --- */
.app {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--s-4);
  padding-top: max(var(--s-4), env(safe-area-inset-top));
}

@media (min-width: 760px) {
  .app { padding: var(--s-6); }
}

/* --- Top bar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-5);
  gap: var(--s-3);
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.topbar-title .emoji { font-family: -apple-system, BlinkMacSystemFont, sans-serif; }

.topbar-actions { display: flex; gap: var(--s-2); align-items: center; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  transition: background 120ms ease, color 120ms ease;
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; stroke-width: 1.75; }

/* Status indicator (online/offline) */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-sunken);
  color: var(--ink-mute);
}
.status-pill.offline { background: rgba(196, 148, 43, 0.15); color: var(--warn); }
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.status-pill.offline .dot { background: var(--warn); }

/* --- Cover (trip header) --- */
.cover {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-6) var(--s-5);
  margin-bottom: var(--s-5);
  overflow: hidden;
}

.cover::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px dashed var(--line);
  border-radius: calc(var(--r-lg) - 4px);
  pointer-events: none;
}

.cover-emoji { font-size: 2rem; margin-bottom: var(--s-2); }

.cover h1 { margin-bottom: var(--s-2); }

.cover-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin-top: var(--s-3);
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.cover-meta .date {
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}

/* Stamp (postal-style) */
.stamp {
  position: absolute;
  top: var(--s-4);
  right: var(--s-4);
  border: 2px solid var(--stamp);
  color: var(--stamp);
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 4px;
  transform: rotate(-4deg);
  opacity: 0.85;
}

/* --- Cards --- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  margin-bottom: var(--s-4);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-3);
  gap: var(--s-3);
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
}

/* --- Day card --- */
.day-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  margin-bottom: var(--s-4);
  overflow: hidden;
}

.day-header {
  display: flex;
  align-items: flex-start;
  padding: var(--s-4) var(--s-5);
  gap: var(--s-3);
  cursor: pointer;
  transition: background 120ms ease;
  position: relative;
}
.day-header:hover { background: var(--bg-sunken); }

/* Drag handles */
.day-handle, .location-handle {
  display: flex;
  align-items: center;
  color: var(--ink-mute);
  cursor: grab;
  opacity: 0;
  transition: opacity 120ms ease, color 120ms ease;
  flex-shrink: 0;
  padding: 4px 0;
}
.day-handle { padding: 8px 0; margin: -4px 0 0 -8px; }
.location-handle { padding-top: 6px; margin-left: -4px; }
.day-handle svg, .location-handle svg { width: 16px; height: 16px; }
.day-handle:active, .location-handle:active { cursor: grabbing; color: var(--accent); }

/* Reveal handles on hover (desktop) */
.day-card:hover .day-handle,
.location:hover .location-handle {
  opacity: 0.5;
}
.day-handle:hover, .location-handle:hover { opacity: 1 !important; }

/* Touch devices: handles always visible (no hover state) */
@media (hover: none) and (pointer: coarse) {
  .day-handle, .location-handle { opacity: 0.5; }
}

/* Day delete button */
.day-delete {
  position: absolute;
  top: var(--s-3);
  right: 48px;
  background: none;
  border: none;
  color: var(--ink-mute);
  cursor: pointer;
  padding: 4px;
  opacity: 0;
  transition: opacity 120ms, color 120ms;
  border-radius: 4px;
}
.day-card:hover .day-delete { opacity: 0.6; }
.day-delete:hover { opacity: 1 !important; color: var(--stamp); background: var(--bg-sunken); }
.day-delete svg { width: 16px; height: 16px; }
@media (hover: none) and (pointer: coarse) {
  .day-delete { opacity: 0.5; }
}

/* Location delete button: substitui o trash btn */
.loc-delete {
  background: none;
  border: none;
  color: var(--ink-mute);
  margin-left: auto;
  padding: 2px 4px;
  border-radius: 3px;
  cursor: pointer;
  transition: color 120ms, background 120ms;
  opacity: 0.5;
}
.loc-delete:hover { color: var(--stamp); background: var(--bg-sunken); opacity: 1; }
.loc-delete svg { width: 14px; height: 14px; }

/* Add buttons */
.day-add-location {
  margin-top: var(--s-3);
  text-align: center;
}
.btn-add-loc {
  background: none;
  border: 1px dashed var(--line);
  color: var(--ink-mute);
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 120ms;
}
.btn-add-loc:hover { border-color: var(--accent); color: var(--accent); background: var(--bg-sunken); }
.btn-add-loc svg { width: 14px; height: 14px; }

.cover-actions { display: flex; gap: var(--s-2); }

/* SortableJS classes */
.sortable-ghost {
  opacity: 0.4;
  background: var(--accent-soft);
  border: 2px dashed var(--accent);
}
.sortable-chosen { cursor: grabbing; }
.sortable-drag {
  opacity: 0.95;
  box-shadow: var(--shadow-lg);
  cursor: grabbing;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
}

/* Modal form */
.modal-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
}
.modal-form label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  font-weight: 600;
  margin-top: var(--s-2);
}
.modal-form label .req { color: var(--stamp); }
.modal-form input,
.modal-form select,
.modal-form textarea {
  width: 100%;
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
}
.modal-form input:focus,
.modal-form select:focus,
.modal-form textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.modal-form textarea { resize: vertical; }

.day-date-block {
  flex-shrink: 0;
  width: 56px;
  text-align: center;
  border-right: 1px dashed var(--line);
  padding-right: var(--s-4);
}

.day-date-block .day-num {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 500;
  line-height: 1;
  display: block;
  color: var(--ink);
}

.day-date-block .day-month {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  margin-top: 2px;
}

.day-info { flex: 1; min-width: 0; }

.day-info .day-city {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 2px;
}

.day-info .day-theme {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  margin-bottom: var(--s-1);
}

.day-info .day-narrative {
  font-size: 0.875rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

.day-toggle {
  margin-left: auto;
  color: var(--ink-mute);
  flex-shrink: 0;
  transition: transform 200ms ease;
}
.day-card[open] .day-toggle { transform: rotate(90deg); }

.day-body {
  padding: 0 var(--s-5) var(--s-5) calc(var(--s-5) + 56px + var(--s-4));
  border-top: 1px dashed var(--line-soft);
  padding-top: var(--s-4);
}

.day-card[hidden-body] .day-body { display: none; }

@media (max-width: 480px) {
  .day-body { padding-left: var(--s-5); }
}

/* --- Location row --- */
.locations { list-style: none; padding: 0; margin: 0; }

.location {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-3) 0;
  border-bottom: 1px dashed var(--line-soft);
  position: relative;
}
.location:last-child { border-bottom: none; }

.location-time {
  flex-shrink: 0;
  width: 48px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-mute);
  padding-top: 2px;
}

.location-marker {
  position: absolute;
  left: 38px;
  top: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elevated);
}

.location-content { flex: 1; min-width: 0; }

.location-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.location-type-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg-sunken);
  color: var(--ink-mute);
  font-weight: 500;
}
.location-type-badge.food { background: rgba(184, 118, 62, 0.15); color: var(--accent); }
.location-type-badge.attraction { background: rgba(90, 122, 154, 0.15); color: var(--info); }
.location-type-badge.viewpoint { background: rgba(74, 124, 74, 0.15); color: var(--success); }
.location-type-badge.shopping { background: rgba(200, 71, 71, 0.15); color: var(--stamp); }

.location-notes {
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.45;
  margin-top: 2px;
}

.location-why-local {
  font-size: 0.8rem;
  color: var(--accent-deep);
  font-style: italic;
  margin-top: var(--s-1);
  padding-left: var(--s-3);
  border-left: 2px solid var(--accent-soft);
}

.location-actions {
  display: flex;
  gap: var(--s-2);
  margin-top: var(--s-2);
  font-size: 0.75rem;
}
.location-actions a, .location-actions button {
  color: var(--ink-mute);
  font-size: 0.75rem;
}
.location-actions button:hover { color: var(--accent); }

/* --- Today view (large cards) --- */
.today-now {
  background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-sunken) 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-6) var(--s-5);
  margin-bottom: var(--s-4);
  position: relative;
  overflow: hidden;
}

.today-now::before {
  content: 'AGORA';
  position: absolute;
  top: var(--s-3);
  right: var(--s-4);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--accent);
  font-weight: 600;
}

.today-now-time {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--ink-mute);
  margin-bottom: var(--s-2);
}

.today-now-name {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 500;
  margin-bottom: var(--s-2);
}

.today-now-meta { color: var(--ink-soft); font-size: 0.95rem; }

.today-next {
  background: var(--bg-elevated);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  padding: var(--s-4);
  margin-bottom: var(--s-4);
}

.today-next-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  margin-bottom: var(--s-1);
}

/* --- Bottom nav --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--line);
  display: flex;
  height: var(--bottom-nav-h);
  padding-bottom: var(--safe-bottom);
  z-index: 100;
}

.bottom-nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--ink-mute);
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: color 120ms ease;
  position: relative;
}

.bottom-nav button.active { color: var(--accent); }
.bottom-nav button.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
}

.bottom-nav button svg { width: 22px; height: 22px; stroke-width: 1.75; }

/* --- Map --- */
#map-container {
  height: calc(100vh - var(--bottom-nav-h) - 120px);
  min-height: 400px;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--line);
  margin-top: var(--s-3);
}

.map-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 120ms ease;
}
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

[data-theme="dark"] .chip.active { background: var(--accent); border-color: var(--accent); color: var(--bg); }

/* --- Resources lists --- */
.resource-list { list-style: none; padding: 0; margin: 0; }
.resource-item {
  padding: var(--s-3) 0;
  border-bottom: 1px dashed var(--line-soft);
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
}
.resource-item:last-child { border-bottom: none; }

.resource-icon {
  width: 36px; height: 36px;
  background: var(--bg-sunken);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--ink-mute);
}
.resource-icon svg { width: 18px; height: 18px; stroke-width: 1.75; }

.resource-content { flex: 1; min-width: 0; }
.resource-label { font-size: 0.75rem; color: var(--ink-mute); text-transform: uppercase; letter-spacing: 0.08em; }
.resource-value { font-weight: 500; font-size: 0.95rem; word-break: break-word; }

/* Phrasebook */
.phrase-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-3);
  margin-bottom: var(--s-2);
}
.phrase-en { font-size: 0.8rem; color: var(--ink-mute); }
.phrase-local { font-family: var(--font-display); font-size: 1.15rem; margin: 2px 0; }
.phrase-pron { font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent); }

/* Currency */
.currency-converter {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--s-3);
  align-items: end;
  margin-top: var(--s-3);
}

.currency-converter input {
  width: 100%;
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 1.15rem;
}
.currency-converter input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.currency-arrow { color: var(--ink-mute); padding-bottom: var(--s-3); }

.currency-rate-meta {
  font-size: 0.75rem;
  color: var(--ink-mute);
  margin-top: var(--s-2);
  font-family: var(--font-mono);
}

/* Shopping list */
.shopping-card { padding-bottom: var(--s-2); }

.shopping-progress {
  height: 4px;
  background: var(--bg-sunken);
  border-radius: 2px;
  margin: var(--s-2) 0 var(--s-4);
  overflow: hidden;
}
.shopping-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 250ms ease;
}

.shopping-filters {
  background: var(--bg-sunken);
  border-radius: var(--r-md);
  padding: var(--s-3);
  margin-bottom: var(--s-4);
}
.shopping-filter-row {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
}
.shopping-filter-row:last-of-type { margin-bottom: 0; }
.shopping-filter-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  font-weight: 600;
  min-width: 56px;
  padding-top: 6px;
  flex-shrink: 0;
}
.shopping-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
}
.chip.small {
  padding: 3px 9px;
  font-size: 0.72rem;
}
.shopping-filter-clear {
  display: block;
  margin-top: var(--s-3);
  font-size: 0.75rem;
  color: var(--accent);
  background: none;
  border: none;
  padding: 4px 0;
  cursor: pointer;
  font-weight: 500;
}
.shopping-filter-clear:hover { text-decoration: underline; }

.shopping-groups { display: flex; flex-direction: column; gap: var(--s-4); }
.shopping-group {
  border-top: 1px solid var(--line-soft);
  padding-top: var(--s-3);
}
.shopping-group:first-child { border-top: none; padding-top: 0; }
.shopping-group-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  color: var(--accent-deep);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--s-2);
}
.shopping-person-tag {
  font-size: 0.7rem;
  color: var(--ink-mute);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: var(--s-2) 0 4px;
  padding-left: var(--s-2);
}

.shopping-item {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  border-bottom: 1px dashed var(--line-soft);
}
.shopping-item:last-child { border-bottom: none; }
.shopping-item.bought .shopping-name { text-decoration: line-through; color: var(--ink-mute); }

.shopping-content { flex: 1; min-width: 0; }
.shopping-name { font-weight: 500; font-size: 0.9rem; }

.shopping-person-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--accent-soft);
  color: var(--accent-deep);
  padding: 1px 6px;
  border-radius: 3px;
  height: fit-content;
  flex-shrink: 0;
  font-weight: 600;
}

.shopping-check {
  width: 22px; height: 22px;
  border: 2px solid var(--line);
  border-radius: 4px;
  flex-shrink: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 120ms ease;
  margin-top: 1px;
}
.shopping-item.bought .shopping-check { background: var(--accent); border-color: var(--accent); color: white; }
.shopping-check svg { width: 14px; height: 14px; stroke-width: 3; opacity: 0; }
.shopping-item.bought .shopping-check svg { opacity: 1; }

/* --- Editable fields --- */
[data-editable]:not([contenteditable="true"]) {
  cursor: text;
  position: relative;
  border-radius: 3px;
  transition: background 120ms ease;
  padding: 1px 3px;
  margin: -1px -3px;
}
[data-editable]:not([contenteditable="true"]):hover {
  background: rgba(184, 118, 62, 0.08);
  outline: 1px dashed var(--accent-soft);
}

[contenteditable="true"] {
  background: var(--bg);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
  padding: 2px 4px;
  margin: -2px -4px;
}

/* Edit lock — quando um campo está em edição, atenuar os outros */
body.editing-active [data-editable]:not(.editing-target) {
  pointer-events: none;
  opacity: 0.4;
  transition: opacity 150ms ease;
}
body.editing-active .edit-structural-controls {
  pointer-events: none;
  opacity: 0.3;
}
.editing-target {
  position: relative;
  z-index: 150;
}

.edit-toolbar {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + var(--s-3));
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  padding: var(--s-2) var(--s-4);
  display: flex;
  gap: var(--s-3);
  align-items: center;
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: slideUp 180ms ease;
}

.edit-toolbar button { color: var(--bg); padding: 4px 10px; border-radius: 999px; font-weight: 500; }
.edit-toolbar button:hover { background: rgba(255,255,255,0.1); }
.edit-toolbar button.primary { background: var(--accent); color: white; }

@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* --- Modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
  animation: fadeIn 120ms ease;
}

.modal {
  background: var(--bg-elevated);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 180ms ease;
}

.modal h3 { margin-bottom: var(--s-3); }
.modal-body { color: var(--ink-soft); margin-bottom: var(--s-5); }
.modal-actions { display: flex; gap: var(--s-2); justify-content: flex-end; }
.modal-actions button {
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-md);
  font-weight: 500;
  font-size: 0.9rem;
}
.modal-actions .btn-cancel { color: var(--ink-soft); }
.modal-actions .btn-cancel:hover { background: var(--bg-sunken); }
.modal-actions .btn-danger { background: var(--stamp); color: white; }
.modal-actions .btn-danger:hover { background: #b03c3c; }
.modal-actions .btn-primary { background: var(--accent); color: white; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + var(--s-3));
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-md);
  font-size: 0.9rem;
  z-index: 250;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  box-shadow: var(--shadow-lg);
  animation: slideUp 200ms ease;
}

.toast button {
  color: var(--accent-deep);
  font-weight: 600;
  font-size: 0.85rem;
  margin-left: var(--s-2);
}

[data-theme="dark"] .toast button { color: var(--accent); }

/* --- Search --- */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  padding-left: var(--s-4);
  padding-right: var(--s-4);
}

.search-panel {
  background: var(--bg-elevated);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.search-input {
  width: 100%;
  padding: var(--s-4) var(--s-5);
  border: none;
  background: transparent;
  font-size: 1.1rem;
  font-family: var(--font-body);
  border-bottom: 1px solid var(--line);
}
.search-input:focus { outline: none; }

.search-results {
  max-height: 50vh;
  overflow-y: auto;
}

.search-result {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px dashed var(--line-soft);
  transition: background 120ms ease;
}
.search-result:hover { background: var(--bg-sunken); }

.search-result-title { font-weight: 500; }
.search-result-meta {
  font-size: 0.75rem;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  margin-top: 2px;
}

/* --- Trips list (portfolio) --- */
.trips-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-4);
}
@media (min-width: 600px) {
  .trips-grid { grid-template-columns: repeat(2, 1fr); }
}

.trip-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
  position: relative;
  overflow: hidden;
}
.trip-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-soft);
}

.trip-card.active { border-color: var(--accent); border-width: 2px; padding: calc(var(--s-5) - 1px); }

.trip-card-emoji { font-size: 2rem; margin-bottom: var(--s-2); }
.trip-card-name { font-family: var(--font-display); font-size: 1.25rem; font-weight: 500; margin-bottom: var(--s-1); }
.trip-card-dates { font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-mute); }
.trip-card-meta {
  margin-top: var(--s-3);
  display: flex;
  gap: var(--s-3);
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* --- Empty state --- */
.empty {
  text-align: center;
  padding: var(--s-7) var(--s-4);
  color: var(--ink-mute);
}
.empty h3 { font-family: var(--font-display); margin-bottom: var(--s-2); color: var(--ink-soft); }
.empty p { margin-bottom: var(--s-4); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--bg);
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 120ms ease;
  border: 1px solid var(--ink);
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: white; }
.btn.secondary { background: transparent; color: var(--ink); }
.btn.secondary:hover { background: var(--bg-sunken); border-color: var(--line); color: var(--ink); }
.btn.small { padding: 6px 12px; font-size: 0.8rem; }

/* --- Tabs (alternative) --- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--s-5);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: var(--s-3) var(--s-4);
  color: var(--ink-mute);
  font-weight: 500;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 120ms ease;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* --- Settings sheet --- */
.sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border-top-left-radius: var(--r-lg);
  border-top-right-radius: var(--r-lg);
  padding: var(--s-5);
  padding-bottom: calc(var(--s-5) + var(--safe-bottom));
  z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: sheetUp 220ms ease;
  max-height: 80vh;
  overflow-y: auto;
}

.sheet-handle {
  width: 36px; height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: 0 auto var(--s-4);
}

.sheet h3 { margin-bottom: var(--s-4); }

.sheet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) 0;
  border-bottom: 1px dashed var(--line-soft);
  gap: var(--s-3);
}
.sheet-row:last-child { border-bottom: none; }
.sheet-row-label { flex: 1; }
.sheet-row-label .title { font-weight: 500; }
.sheet-row-label .desc { font-size: 0.8rem; color: var(--ink-mute); margin-top: 2px; }

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* Toggle switch */
.toggle {
  width: 44px; height: 26px;
  background: var(--line);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 200ms ease;
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 200ms ease;
  box-shadow: var(--shadow-sm);
}
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(18px); }

/* Journal entries */
.journal-entry {
  border-left: 3px solid var(--accent-soft);
  padding-left: var(--s-4);
  margin-bottom: var(--s-4);
}
.journal-entry-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-mute);
  margin-bottom: var(--s-1);
}
.journal-entry-body {
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

textarea.journal-input {
  width: 100%;
  min-height: 80px;
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
  font-family: var(--font-body);
  resize: vertical;
}

/* Print styles - clean PDF export */
@media print {
  .bottom-nav, .topbar-actions, .icon-btn, .edit-toolbar, .toast, .modal-backdrop, .sheet, #map-container { display: none !important; }
  body { background: white; color: black; padding: 0; }
  .app { padding: 0; max-width: 100%; }
  .day-card, .card, .cover { break-inside: avoid; box-shadow: none; border-color: #ccc; }
  .day-card[hidden-body] .day-body { display: block !important; }
  a { color: black; text-decoration: none; }
  .stamp { display: none; }
  .day-body { display: block !important; }
}

/* Utility */
.hidden { display: none !important; }
.flex-col { display: flex; flex-direction: column; }
.flex { display: flex; }
.gap-2 { gap: var(--s-2); }
.gap-3 { gap: var(--s-3); }
.mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mb-3 { margin-bottom: var(--s-3); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }

/* Map popups (Leaflet override) */
.leaflet-popup-content-wrapper {
  border-radius: var(--r-md) !important;
  background: var(--bg-elevated) !important;
  color: var(--ink) !important;
  font-family: var(--font-body) !important;
}
.leaflet-popup-tip { background: var(--bg-elevated) !important; }
.leaflet-popup-content { margin: 12px 16px !important; font-size: 0.875rem !important; }
.leaflet-popup-content strong { font-family: var(--font-display); font-weight: 500; font-size: 1rem; }
[data-theme="dark"] .leaflet-tile { filter: brightness(0.7) invert(1) hue-rotate(180deg); }
