:root {
  --bg: #f4f6f8; --card: #fff; --ink: #1d2433; --muted: #667085; --line: #e3e7ec;
  --brand: #0b7285; --brand-2: #e8f6f8; --accent: #f08c00; --ok: #2f9e44; --bad: #c92a2a;
  --trip: #d3f0f3; --today: #fff3bf; --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f141b; --card: #171e27; --ink: #e6ebf1; --muted: #98a2b3; --line: #273140;
    --brand: #3bc9db; --brand-2: #10343b; --trip: #12343a; --today: #3d3511; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: .2em 0 .5em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.wrap { max-width: 980px; margin: 0 auto; padding: 16px 16px 80px; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .center { text-align: center; } .pad { padding: 40px 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.top-nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.top-nav a, .top-nav button { padding: 6px 10px; border-radius: 8px; font-size: .9rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

button, .btn { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 9px 14px; border-radius: 10px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
button:hover, .btn:hover { border-color: var(--brand); text-decoration: none; }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
button.ghost { background: transparent; border-color: transparent; }
button.danger { color: var(--bad); }
button:disabled { opacity: .55; cursor: default; }
button.sm, .btn.sm { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }

input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; width: 100%; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
label { display: block; font-size: .875rem; color: var(--muted); margin-bottom: 4px; }
.field + .field { margin-top: 10px; }
.fields { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: .95rem; }
.check input { width: auto; }
.err { color: var(--bad); font-size: .9rem; min-height: 1.2em; }

/* Ingreso */
.login { max-width: 420px; margin: 8vh auto 0; }
.login .logo { font-size: 2.6rem; text-align: center; }
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* Inicio */
.trip-card { display: block; color: var(--ink); overflow: hidden; padding: 0; }
.trip-card:hover { text-decoration: none; border-color: var(--brand); }
.trip-cover { height: 92px; display: flex; align-items: flex-end; justify-content: space-between; padding: 12px 16px;
  background: linear-gradient(135deg, #0b7285, #1098ad 55%, #f08c00); color: #fff; }
.trip-cover .emoji { font-size: 2.4rem; line-height: 1; }
.trip-cover .when { font-size: .85rem; background: rgba(0,0,0,.25); padding: 3px 8px; border-radius: 99px; }
.trip-body { padding: 12px 16px 16px; }
.trip-body h3 { margin: 0 0 4px; }
.avatars { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.av { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; padding: 0 8px;
  border-radius: 99px; background: var(--brand-2); color: var(--brand); font-size: .78rem; font-weight: 600; }
.pill { display: inline-block; white-space: nowrap; align-self: flex-start; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--brand-2); color: var(--brand); font-weight: 600; }
.pill.warn { background: #fff3bf; color: #8a5a00; }
.pill.ok { background: #d3f9d8; color: #2b8a3e; }
.pill.gray { background: var(--line); color: var(--muted); }

/* Viaje */
.trip-head { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.trip-head .emoji { font-size: 2.6rem; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 0 -16px 16px; padding: 0 16px; scrollbar-width: none; }
.tabs a { padding: 10px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs a.on { color: var(--brand); border-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 99px; background: var(--accent); color: #fff; font-size: .72rem; text-align: center; }

/* Almanaque */
.month { margin-bottom: 18px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { font-size: .72rem; color: var(--muted); text-align: center; text-transform: uppercase; padding: 2px 0; }
.cal .d { min-height: 86px; border-radius: 10px; padding: 6px; background: var(--card); border: 1px solid var(--line);
  font-size: .78rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal .d.trip { background: var(--trip); color: var(--ink); cursor: pointer; border-color: transparent; }
.cal .d.trip:hover { outline: 2px solid var(--brand); text-decoration: none; }
.cal .d.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal .d.empty { background: transparent; border: none; }
.cal .num { font-weight: 700; font-size: .9rem; color: inherit; }
.cal .city { font-weight: 600; color: var(--brand); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .first { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .icons { margin-top: auto; }
@media (max-width: 560px) {
  .cal { gap: 2px; } .cal .d { min-height: 62px; padding: 4px; font-size: .68rem; } .cal .first { display: none; }
}
.list-days a { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.list-days a:hover { text-decoration: none; background: var(--brand-2); }

/* Día */
.day-nav { display: flex; align-items: center; gap: 8px; }
.day-nav h1 { margin: 0; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: none; }
.timeline .t { width: 58px; flex: none; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.timeline .ic { font-size: 1.3rem; width: 28px; flex: none; text-align: center; }
.timeline .notes { white-space: pre-wrap; color: var(--muted); font-size: .9rem; margin-top: 2px; }

/* Votaciones */
.poll .opt { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 12px; margin-top: 6px; border-radius: 10px; overflow: hidden; }
.poll .opt .bar { position: absolute; inset: 0 auto 0 0; background: var(--brand-2); z-index: 0; transition: width .3s; }
.poll .opt > *:not(.bar) { position: relative; z-index: 1; }
.poll .opt.mine { border-color: var(--brand); font-weight: 600; }
.poll .opt.win { border-color: var(--ok); }
.poll .voters { font-size: .78rem; color: var(--muted); }

/* Comentarios */
.comment { display: flex; gap: 10px; padding: 8px 0; }
.comment .av { flex: none; }
.comment .body { white-space: pre-wrap; }

/* Archivos */
.file { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.file:last-child { border-bottom: none; }
.file .ic { font-size: 1.4rem; }

/* Tita Turismo */
.tita { display: grid; grid-template-columns: 240px 1fr; gap: 12px; }
@media (max-width: 760px) { .tita { grid-template-columns: 1fr; } .tita .chats { order: 2; } }
.tita .chats a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink); font-size: .9rem; }
.tita .chats a.on, .tita .chats a:hover { background: var(--brand-2); text-decoration: none; }
.msgs { display: flex; flex-direction: column; gap: 12px; }
.msg { padding: 12px 14px; border-radius: 14px; max-width: 100%; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; max-width: 85%; white-space: pre-wrap; }
.msg.assistant { background: var(--card); border: 1px solid var(--line); }
.msg.assistant table { border-collapse: collapse; width: 100%; font-size: .88rem; margin: 8px 0; display: block; overflow-x: auto; }
.msg.assistant th, .msg.assistant td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
.msg.assistant p { margin: .4em 0; } .msg.assistant ul, .msg.assistant ol { padding-left: 1.3em; margin: .4em 0; }
.msg .sources { margin-top: 8px; font-size: .8rem; }
.msg .sources a { display: inline-block; margin: 2px 6px 2px 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { font-size: .85rem; padding: 6px 10px; border-radius: 99px; }
.typing { color: var(--muted); font-style: italic; }
.tita-hero { display: flex; gap: 12px; align-items: center; }
.tita-hero .face { font-size: 2.4rem; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: calc(100% - 32px); box-shadow: var(--shadow); }
dialog { border: none; border-radius: var(--radius); padding: 0; width: min(560px, calc(100% - 32px)); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog .card { border: none; box-shadow: none; }
details > summary { cursor: pointer; color: var(--brand); font-weight: 500; }
.empty-state { text-align: center; color: var(--muted); padding: 24px 8px; }
