/* Cuaderno de viajes — estilos */
:root {
  --bg: #f6f1e7;
  --paper: #fffdf8;
  --paper-2: #efe8da;
  --ink: #23201b;
  --ink-2: #5d564b;
  --ink-3: #8b8274;
  --line: #e2d9c7;
  --accent: #1f6f78;
  --accent-ink: #ffffff;
  --accent-soft: #d9ecec;
  --work: #3b5bab;
  --work-soft: #e1e7f6;
  --leisure: #c0612b;
  --leisure-soft: #f8e4d6;
  --wish: #8a5bb0;
  --wish-soft: #eee3f6;
  --ok: #3c8a4f;
  --danger: #b33a3a;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 4px 14px rgba(40, 30, 10, .06);
  --radius: 16px;
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --tabbar-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16191d; --paper: #1f2328; --paper-2: #2a2f35; --ink: #ece7dd; --ink-2: #b8b1a5; --ink-3: #857e73;
    --line: #343a41; --accent: #5cb8bf; --accent-ink: #0f1a1b; --accent-soft: #1d3638;
    --work: #8aa4ec; --work-soft: #232c45; --leisure: #ee9a66; --leisure-soft: #3d2a1e; --wish: #c39be3; --wish-soft: #322640;
    --ok: #74c486; --danger: #ef7d7d; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16191d; --paper: #1f2328; --paper-2: #2a2f35; --ink: #ece7dd; --ink-2: #b8b1a5; --ink-3: #857e73;
  --line: #343a41; --accent: #5cb8bf; --accent-ink: #0f1a1b; --accent-soft: #1d3638;
  --work: #8aa4ec; --work-soft: #232c45; --leisure: #ee9a66; --leisure-soft: #3d2a1e; --wish: #c39be3; --wish-soft: #322640;
  --ok: #74c486; --danger: #ef7d7d; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

#app { max-width: 720px; margin: 0 auto; }
#view { padding: calc(env(safe-area-inset-top) + 8px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 96px); min-height: 100dvh; }

/* Tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: 4px;
  background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); }
.tabbar a { flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 12px; color: var(--ink-3); font-size: 11.5px; font-weight: 600; }
.tabbar a.active { color: var(--accent); }

/* Headers */
.topbar { display: flex; align-items: center; gap: 8px; min-height: 52px; margin-bottom: 6px; }
.topbar h1 { flex: 1; margin: 0; font-family: var(--serif); font-size: 28px; font-weight: 600; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar h1.small { font-size: 20px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; border: 0; background: transparent; color: var(--ink); cursor: pointer; flex: none; }
.icon-btn:active { background: var(--paper-2); }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 22px 2px 8px; }

/* Segmented / chips */
.segmented { display: flex; gap: 4px; padding: 4px; background: var(--paper-2); border-radius: 12px; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button { flex: 1; border: 0; background: transparent; padding: 8px 10px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--ink-2); white-space: nowrap; cursor: pointer; }
.segmented button.active { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip svg { width: 15px; height: 15px; }

.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; letter-spacing: .02em; }
.tag.trabajo { background: var(--work-soft); color: var(--work); }
.tag.ocio { background: var(--leisure-soft); color: var(--leisure); }
.tag.deseado { background: var(--wish-soft); color: var(--wish); }
.tag.en-curso { background: var(--accent); color: var(--accent-ink); }
.tag.neutral { background: var(--paper-2); color: var(--ink-2); }

/* Cards */
.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.list { display: grid; gap: 10px; }
.trip-card { display: flex; gap: 14px; align-items: center; color: var(--ink); }
.trip-cover { width: 58px; height: 58px; border-radius: 14px; display: grid; place-items: center; font-size: 28px; flex: none; background: var(--cover, var(--accent-soft)); overflow: hidden; }
.trip-cover img { width: 100%; height: 100%; object-fit: cover; }
.trip-card .body { flex: 1; min-width: 0; }
.trip-card h3 { margin: 0 0 2px; font-family: var(--serif); font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { font-size: 13.5px; color: var(--ink-2); }
.meta-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }

.hero { position: relative; border-radius: 22px; padding: 18px; color: #fff; background: linear-gradient(135deg, var(--hero-a, #1f6f78), var(--hero-b, #2e4d6b)); box-shadow: var(--shadow); overflow: hidden; }
.hero .label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.9); }
.hero h2 { margin: 4px 0 2px; font-family: var(--serif); font-size: 26px; font-weight: 600; }
.hero .sub { opacity: .9; font-size: 14px; }
.hero .next { margin-top: 14px; background: rgba(255,255,255,.16); border-radius: 14px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; }
.hero .actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.hero .btn { background: rgba(255,255,255,.95); color: #1d2b33; }
.hero .emoji-bg { position: absolute; right: 10px; top: 10px; font-size: 44px; opacity: .9; pointer-events: none; }

/* Trip header */
.trip-head { border-radius: 22px; padding: 16px; background: var(--cover, var(--accent-soft)); color: #1d1d1d; position: relative; overflow: hidden; }
.trip-head.has-photo { color: #fff; }
.trip-head .photo { position: absolute; inset: 0; background-size: cover; background-position: center; }
.trip-head .photo::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.05), rgba(0,0,0,.55)); }
.trip-head > *:not(.photo) { position: relative; }
.trip-head h1 { font-family: var(--serif); font-size: 28px; margin: 6px 0 2px; line-height: 1.15; }
.trip-head .emoji { font-size: 34px; }
.countdown { font-weight: 700; font-size: 14px; }

/* Day groups / timeline */
.day { margin-top: 18px; }
.day h4 { margin: 0 0 8px 2px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.day h4::first-letter, .note .date::first-letter { text-transform: uppercase; }
.booking { display: flex; gap: 12px; align-items: flex-start; color: var(--ink); }
.booking .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.booking .ico.vuelo { background: #dfe8fb; color: #2f57b3; }
.booking .ico.hotel { background: #f6e3d3; color: #a65424; }
.booking .ico.tren { background: #e3f0de; color: #3f7d34; }
.booking .ico.coche { background: #efe3f6; color: #7a4aa6; }
.booking .ico.restaurante { background: #fbe1e1; color: #b13b3b; }
.booking .ico.actividad { background: #fbf0d0; color: #8a6a10; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .booking .ico { filter: saturate(.9) brightness(.85); } }
.booking .body { flex: 1; min-width: 0; }
.booking .t { font-weight: 650; }
.booking .time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink-2); font-size: 13.5px; }
.route { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px; margin: 2px 0; letter-spacing: .02em; }
.route .line { flex: 1; height: 1px; background: var(--line); min-width: 18px; }

/* Forms */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > span, .label { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 11px 12px; font-size: 16px; outline: none; -webkit-appearance: none; appearance: none; }
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 > * { min-width: 0; }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.emoji-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.emoji-pick button { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); font-size: 22px; cursor: pointer; }
.emoji-pick button.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.color-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.color-pick button { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.color-pick button.active { border-color: var(--ink); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 650; font-size: 15px; background: var(--paper-2); color: var(--ink); cursor: pointer; text-align: center; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.ghost { background: transparent; color: var(--accent); padding-left: 8px; padding-right: 8px; }
.btn.block { width: 100%; }
.btn.small { padding: 7px 11px; font-size: 13.5px; border-radius: 10px; }
.btn svg { width: 18px; height: 18px; }
.btn:disabled { opacity: .5; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }

.fab { position: fixed; right: max(16px, calc(50% - 344px)); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); z-index: 15; height: 54px; min-width: 54px; padding: 0 18px; border-radius: 27px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); cursor: pointer; font-size: 15px; }

/* Tabs inside trip */
.tabs { position: sticky; top: 0; z-index: 10; background: var(--bg); margin: 14px -16px 4px; padding: 8px 16px; }

.empty { text-align: center; color: var(--ink-3); padding: 34px 12px; }
.empty .big { font-size: 40px; margin-bottom: 6px; }
.empty p { margin: 4px 0 14px; }

.pre { white-space: pre-wrap; }
.note .date { font-size: 12.5px; color: var(--ink-3); font-weight: 650; margin-bottom: 4px; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.thumbs img, .thumbs .doc { width: 76px; height: 76px; border-radius: 10px; object-fit: cover; cursor: pointer; background: var(--paper-2); }
.thumbs .doc { display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--ink-2); text-align: center; padding: 4px; overflow: hidden; }
.thumb-wrap { position: relative; }
.thumb-wrap .x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); font-size: 13px; line-height: 22px; padding: 0; cursor: pointer; }

.doc-row { display: flex; gap: 12px; align-items: center; color: var(--ink); cursor: pointer; }
.doc-row .preview { width: 52px; height: 52px; border-radius: 10px; background: var(--paper-2); display: grid; place-items: center; overflow: hidden; flex: none; font-size: 11px; font-weight: 800; color: var(--ink-2); }
.doc-row .preview img { width: 100%; height: 100%; object-fit: cover; }

.place { display: grid; gap: 4px; }
.place .head { display: flex; gap: 10px; align-items: flex-start; }
.place .head .body { flex: 1; min-width: 0; }
.place h3 { margin: 0; font-size: 16.5px; font-weight: 650; }
.place .desc { font-size: 14px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.place .desc.open { -webkit-line-clamp: unset; }
.place img.pic { width: 72px; height: 72px; border-radius: 12px; object-fit: cover; flex: none; background: var(--paper-2); }
.stars { color: #d39b16; letter-spacing: 1px; }
.stars button { border: 0; background: none; font-size: 26px; padding: 0 2px; color: var(--line); cursor: pointer; }
.stars button.on { color: #d39b16; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14.5px; }
.kv dt { color: var(--ink-3); font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }
.loc { font-size: 22px; font-weight: 800; letter-spacing: .08em; }

.notice { border-radius: 12px; padding: 11px 13px; background: var(--accent-soft); color: var(--ink); font-size: 14px; }
.notice.warn { background: var(--leisure-soft); }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.spacer { height: 12px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal / sheet */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { background: var(--bg); width: 100%; max-width: 720px; max-height: 92dvh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 10px 16px calc(env(safe-area-inset-bottom) + 18px); animation: up .2s ease; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet h2 { font-family: var(--serif); margin: 4px 0 12px; font-size: 22px; }
.menu { display: grid; gap: 2px; }
.menu button { display: flex; align-items: center; gap: 12px; border: 0; background: var(--paper); padding: 14px; border-radius: 12px; font-size: 16px; font-weight: 600; text-align: left; cursor: pointer; }
.menu button .s { display: block; font-size: 13px; color: var(--ink-3); font-weight: 500; }
.viewer { position: fixed; inset: 0; z-index: 60; background: #fff; display: flex; flex-direction: column; }
.viewer.dark { background: #000; }
.viewer header { display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 6px) 10px 6px; background: rgba(0,0,0,.75); color: #fff; }
.viewer header .t { flex: 1; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer header .icon-btn { color: #fff; }
.viewer .content { flex: 1; overflow: auto; display: grid; place-items: center; }
.viewer .content img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer iframe { width: 100%; height: 100%; border: 0; background: #fff; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }

#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 84px); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; z-index: 70; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (min-width: 760px) {
  #view { padding-left: 24px; padding-right: 24px; }
  .list.grid2 { grid-template-columns: 1fr 1fr; }
}
.empty .actions-row { justify-content: center; }
