/* ── Reset & Variables ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #22263a;
  --accent:    #4f7cff;
  --accent2:   #7b5ea7;
  --green:     #34c759;
  --yellow:    #ffd60a;
  --red:       #ff453a;
  --text:      #e8eaf0;
  --text-dim:  #7a7f9a;
  --radius:    14px;
  --radius-sm: 8px;
  --max-w:     430px;
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Mobile shell ──────────────────────────────────────────────────────────── */
#app {
  width: 100%;
  max-width: var(--max-w);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

/* ── Status bar ────────────────────────────────────────────────────────────── */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px 4px;
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.status-bar .time { font-weight: 600; color: var(--text); }

/* ── Top bar ───────────────────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 10px;
  flex-shrink: 0;
}
.logo { font-size: 20px; font-weight: 700; letter-spacing: -.5px; }
.logo span { color: var(--accent); }
.page-title { font-size: 17px; font-weight: 600; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.back-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.back-btn svg { width: 18px; height: 18px; }

/* ── Scrollable content ────────────────────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 0 14px 110px;
  -webkit-overflow-scrolling: touch;
}

/* ── Section header ────────────────────────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 0 8px;
}
.section-header h2 { font-size: 16px; font-weight: 600; }
.section-header a   { font-size: 13px; color: var(--accent); text-decoration: none; cursor: pointer; }

/* ── Color helpers ─────────────────────────────────────────────────────────── */
.safe { color: var(--green); }
.warn { color: var(--yellow); }
.crit { color: var(--red); }

/* ── Empty / hint ──────────────────────────────────────────────────────────── */
.empty-hint {
  text-align: center; color: var(--text-dim);
  font-size: 13px; padding: 24px 0; line-height: 1.6;
}
.page-hint {
  font-size: 13px; color: var(--text-dim); line-height: 1.5;
  padding: 4px 0 12px;
}

/* ── Hero card ─────────────────────────────────────────────────────────────── */
.hero-card {
  background: linear-gradient(135deg, #1e2a5e 0%, #2a1b4a 100%);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 8px;
  position: relative;
  overflow: hidden;
}
.hero-card::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at top right, rgba(79,124,255,.2) 0%, transparent 60%);
}
.location-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-dim); margin-bottom: 12px;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 6px var(--green);
  animation: pulse 2s infinite;
}
.country-name { font-size: 26px; font-weight: 700; margin-bottom: 2px; }
.since        { font-size: 12px; color: var(--text-dim); margin-bottom: 16px; }
.counters {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
}
.counter-block { text-align: center; }
.counter-block .val { font-size: 26px; font-weight: 700; line-height: 1; }
.counter-block .lbl { font-size: 10px; color: var(--text-dim); margin-top: 3px; }

/* ── Schengen / limit card ─────────────────────────────────────────────────── */
.schengen-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
}
.schengen-card .row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.schengen-card .title { font-size: 13px; font-weight: 600; }
.badge {
  font-size: 11px; font-weight: 600; padding: 3px 8px;
  border-radius: 20px; background: rgba(52,199,89,.15); color: var(--green);
  white-space: nowrap;
}
.badge.warn { background: rgba(255,214,10,.15); color: var(--yellow); }
.progress-track {
  height: 6px; border-radius: 3px; background: var(--surface2); overflow: hidden; margin-bottom: 6px;
}
.progress-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--green), #7ed321);
  transition: width .5s ease;
}
.progress-fill.warn { background: linear-gradient(90deg, var(--yellow), var(--red)); }
.hint { font-size: 11px; color: var(--text-dim); }

/* ── Notification banner ───────────────────────────────────────────────────── */
.notif-banner {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,214,10,.12);
  border: 1px solid rgba(255,214,10,.3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 10px;
  cursor: pointer;
}
.notif-banner.notif-orange {
  background: rgba(255,149,0,.12);
  border-color: rgba(255,149,0,.3);
}
.notif-banner.notif-red {
  background: rgba(255,69,58,.12);
  border-color: rgba(255,69,58,.3);
}
.notif-red .notif-text strong { color: var(--red); }
.notif-icon { font-size: 20px; }
.notif-text { flex: 1; }
.notif-text strong { display: block; font-size: 13px; color: var(--yellow); margin-bottom: 2px; }
.notif-orange .notif-text strong { color: #ff9500; }
.notif-text span   { font-size: 11px; color: var(--text-dim); }
.notif-arr { color: var(--text-dim); font-size: 18px; }
.notif-arr-up { font-size: 14px; }

/* ── Notification group (collapsible multi-notification) ───────────────────── */
.notif-group { display: flex; flex-direction: column; }
.notif-group .notif-banner { margin-bottom: 4px; }
.notif-group .notif-banner:last-child { margin-bottom: 10px; }
.notif-group-toggle {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,214,10,.12);
  border: 1px solid rgba(255,214,10,.3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 4px;
  cursor: pointer;
}
.notif-group-toggle.notif-red {
  background: rgba(255,69,58,.12);
  border-color: rgba(255,69,58,.3);
}
.notif-group-toggle.notif-red .notif-text strong { color: var(--red); }

/* ── Countries mini (home) ─────────────────────────────────────────────────── */
.countries-mini { display: flex; flex-direction: column; gap: 4px; }
.country-mini-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 9px 12px; cursor: pointer;
}
.country-mini-row .cf { font-size: 20px; }
.country-mini-row .cn { flex: 1; font-size: 14px; }
.country-mini-row .cd { font-size: 18px; font-weight: 700; }

/* ── CALENDAR ──────────────────────────────────────────────────────────────── */
.cal-controls {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0 10px;
}
.cal-month-label { font-size: 16px; font-weight: 600; }
.cal-nav-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface); border: none; cursor: pointer;
  color: var(--accent); font-size: 20px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  margin-bottom: 8px;
}
.cal-hdr {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 0 6px;
  font-weight: 500;
}
.cal-cell { min-height: 46px; padding: 1px 0; position: relative; }
.cal-inner {
  display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start;
  padding: 4px 2px 3px;
  height: 100%;
  border-radius: 0;
}
/* Period background */
.cal-cell.has-e .cal-inner {
  background: var(--cbg, rgba(100,100,100,0.2));
}
.cal-cell.p-l .cal-inner { border-top-left-radius: 16px; border-bottom-left-radius: 16px; }
.cal-cell.p-r .cal-inner { border-top-right-radius: 16px; border-bottom-right-radius: 16px; }
/* Today circle */
.cal-cell.cal-today .cal-num {
  background: var(--accent); color: white;
  border-radius: 50%;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
}
/* Future days */
.cal-cell.cal-future .cal-num { color: var(--text-dim); }
.cal-num {
  font-size: 13px; font-weight: 500; line-height: 1;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
}
.cal-flags {
  display: flex; gap: 0px; margin-top: 2px; flex-wrap: wrap; justify-content: center;
}
.cal-flag  { font-size: 11px; line-height: 1; }
.t-flag    { opacity: 0.35; }
.pend-flag { opacity: 0.65; }
.cal-more  { font-size: 9px; color: var(--text-dim); }
/* Legend */
.cal-legend {
  display: flex; flex-wrap: wrap; gap: 8px 12px;
  padding: 8px 0;
  border-top: 1px solid var(--surface2);
  margin-top: 8px;
}
.leg-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-dim); }
.leg-dot  { width: 10px; height: 10px; border-radius: 3px; }

/* ── COUNTRIES LIST ────────────────────────────────────────────────────────── */
.period-header {
  font-size: 13px; color: var(--text-dim);
  padding: 10px 0 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.period-header strong { color: var(--accent); }
.period-range { font-size: 12px; }

.countries-list { display: flex; flex-direction: column; gap: 6px; }
.country-row {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
}
.country-row.schengen-row { border-left: 3px solid var(--accent); }
.cr-flag { font-size: 26px; flex-shrink: 0; }
.cr-info { flex: 1; min-width: 0; }
.cr-name { display: block; font-size: 15px; font-weight: 500; }
.cr-rule { display: block; font-size: 11px; color: var(--text-dim); margin: 1px 0 4px; }
.cr-bar-wrap { height: 4px; background: var(--surface2); border-radius: 2px; overflow: hidden; }
.cr-bar  { height: 100%; border-radius: 2px; transition: width .4s; }
.cr-right { text-align: right; flex-shrink: 0; }
.cr-days  { font-size: 22px; font-weight: 700; line-height: 1; }
.cr-avail { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.cr-avail.cr-avail-warn { color: var(--red); }
.cr-avail.cr-avail-overstay { color: var(--red); font-weight: 600; font-size: 10px; }
.cr-notes { font-size: 10px; color: var(--text-dim); margin: 2px 0 3px; line-height: 1.3; }

/* ── Visa tags (countries page) ────────────────────────────────────────────── */
.visa-tag {
  display: inline-block;
  font-size: 9px; font-weight: 600; text-transform: uppercase;
  border-radius: 3px; padding: 1px 4px; vertical-align: middle;
}
.visa-free  { background: rgba(48,209,88,.2);  color: var(--green); }
.visa-voa   { background: rgba(255,214,10,.2); color: var(--yellow); }
.visa-eta   { background: rgba(255,214,10,.2); color: var(--yellow); }
.visa-evisa { background: rgba(255,149,0,.2);  color: #ff9500; }
.visa-req   { background: rgba(255,69,58,.15); color: var(--red); }

/* ── Passport indicator (countries page header) ────────────────────────────── */
.passport-indicator {
  font-size: 12px; color: var(--text-dim);
  padding: 0 0 10px;
  cursor: pointer;
}
.fallback-rules-notice {
  font-size: 12px;
  background: rgba(255,204,0,.12);
  border: 1px solid rgba(255,204,0,.35);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  color: var(--yellow);
  line-height: 1.4;
}
.cr-fallback-mark {
  font-size: 10px; color: var(--text-dim);
  opacity: .7; cursor: help;
}

/* ── Document rows (settings) ──────────────────────────────────────────────── */
.doc-row {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 6px;
  border-left: 3px solid var(--surface2);
}
.doc-row-active { border-left-color: var(--green); }
.doc-row-main { display: flex; align-items: center; gap: 10px; }
.doc-row-flag { font-size: 22px; flex-shrink: 0; }
.doc-row-info { flex: 1; min-width: 0; }
.doc-row-type { display: block; font-size: 13px; font-weight: 600; }
.doc-row-num  { display: block; font-size: 11px; color: var(--text-dim); margin-top: 1px; }
.doc-active-badge {
  font-size: 10px; color: var(--green);
  background: rgba(48,209,88,.15); border-radius: 4px;
  padding: 1px 6px; flex-shrink: 0;
}
.doc-row-actions { display: flex; gap: 6px; margin-top: 8px; justify-content: flex-end; }

/* ── TIMELINE ──────────────────────────────────────────────────────────────── */
.tl-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0 8px;
  font-size: 14px; font-weight: 600;
}
.tl-total { font-size: 13px; color: var(--accent); font-weight: 700; }
.tl-list { display: flex; flex-direction: column; gap: 6px; }
.tl-period {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  border-left: 3px solid var(--surface2);
}
.tl-period-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
}
.tl-dates { font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.tl-meta  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-days-badge {
  background: var(--surface2); color: var(--accent);
  font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 10px;
}
.tl-cities { font-size: 12px; color: var(--text-dim); }
.tl-src    { font-size: 14px; }
.tl-delete-btn, .tl-edit-btn {
  background: none; border: none; cursor: pointer;
  font-size: 16px; opacity: .5; padding: 2px 4px; flex-shrink: 0;
  border-radius: 6px; transition: opacity .15s, background .15s;
}
.tl-delete-btn:hover { opacity: 1; background: rgba(255,69,58,.15); }
.tl-edit-btn:hover   { opacity: 1; background: rgba(79,124,255,.15); }

/* Documents in timeline period */
.tl-docs {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px;
}

/* Future date calculator */
.future-calc {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 16px;
}
.future-calc h4 { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.future-row { display: flex; gap: 8px; align-items: center; }
.future-row input {
  flex: 1; background: var(--surface2); border: none; border-radius: var(--radius-sm);
  color: var(--text); padding: 8px 10px; font-size: 14px;
}
.future-btn {
  background: var(--accent); color: white; border: none;
  border-radius: var(--radius-sm); padding: 8px 14px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.future-result { margin-top: 10px; }
.future-res-row {
  display: flex; justify-content: space-between;
  font-size: 13px; padding: 4px 0;
  border-bottom: 1px solid var(--surface2);
}
.future-res-row:last-child { border-bottom: none; }

/* Deleted note in day modal */
.modal-deleted-note {
  font-size: 11px; color: var(--text-dim);
  padding: 8px 0 0; margin-top: 6px;
  border-top: 1px solid var(--surface2);
}

/* Documents section in day modal */
.modal-docs-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--surface2);
}
.modal-docs-title {
  font-size: 12px; color: var(--text-dim); font-weight: 500; margin-bottom: 6px;
}

/* ── TRIPS PAGE ────────────────────────────────────────────────────────────── */
.trips-header { padding: 8px 0 4px; }
.trips-filter-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.trips-share-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.trip-sets-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.trip-sets-mini { display: flex; flex-direction: column; gap: 6px; }

/* Trip set card */
.ts-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  border-left: 3px solid var(--surface2);
}
.ts-card.ts-has-conflict {
  border-left-color: var(--red);
  background: rgba(255,69,58,.06);
}
.ts-conflict-badge {
  display: inline-block;
  font-size: 10px;
  color: var(--red);
  background: rgba(255,69,58,.15);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  vertical-align: middle;
}
.ts-card.ts-has-limit-warn {
  border-left-color: var(--red);
  background: rgba(255,69,58,.04);
}
.ts-limit-badge {
  display: inline-block;
  font-size: 10px;
  color: var(--red);
  background: rgba(255,69,58,.15);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  vertical-align: middle;
}
.ts-card-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  margin-bottom: 10px;
}
.ts-name {
  font-size: 15px; font-weight: 600; display: block; margin-bottom: 4px;
}
.ts-status {
  font-size: 11px; font-weight: 500;
}
.ts-status.st-confirmed { color: var(--green); }
.ts-status.st-pending   { color: var(--yellow); }
.ts-status.st-cancelled { color: var(--text-dim); }

.ts-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.ts-btn {
  border: none; border-radius: var(--radius-sm);
  padding: 5px 10px; font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.ts-confirm {
  background: rgba(52,199,89,.15); color: var(--green);
}
.ts-del {
  background: rgba(255,69,58,.12); color: var(--red);
  padding: 5px 8px;
}

.ts-legs { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.ts-leg {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px solid var(--surface2);
}
.ts-leg:last-child { border-bottom: none; }
.ts-leg.ts-transit { opacity: .6; }
.ts-leg-flag  { font-size: 18px; flex-shrink: 0; }
.ts-leg-info  { flex: 1; color: var(--text); }
.ts-leg-dates { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.transit-tag  {
  font-size: 10px; background: rgba(255,255,255,.08);
  border-radius: 4px; padding: 1px 5px; color: var(--text-dim);
}

/* Documents inside trip card */
.doc-count {
  font-size: 11px; color: var(--text-dim); margin-top: 4px; display: block;
}
.ts-docs {
  margin-top: 8px; display: flex; flex-direction: column; gap: 4px;
}
.ts-doc-item {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
  background: var(--surface2); border-radius: 6px; padding: 6px 10px;
}
.doc-type-icon { font-size: 14px; flex-shrink: 0; }
.doc-fname     { flex: 1; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-type      { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.doc-del-btn {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--text-dim); padding: 2px 4px;
  border-radius: 4px; flex-shrink: 0;
}
.doc-del-btn:hover { color: var(--red); }

/* ── Source & status badges ────────────────────────────────────────────────── */
.src-badge {
  display: inline-block;
  font-size: 10px; font-weight: 500;
  padding: 2px 6px; border-radius: 6px;
  background: var(--surface2); color: var(--text-dim);
  white-space: nowrap;
}
.src-gps    { background: rgba(52,199,89,.12);  color: var(--green); }
.src-manual { background: rgba(79,124,255,.12); color: var(--accent); }
.src-doc    { background: rgba(123,94,167,.15); color: #b08cff; }
.src-auto   { background: rgba(255,214,10,.10); color: var(--yellow); }

.status-badge {
  display: inline-block;
  font-size: 10px; font-weight: 500;
  padding: 2px 6px; border-radius: 6px;
  background: var(--surface2); color: var(--text-dim);
  white-space: nowrap;
}
.st-confirmed { background: rgba(52,199,89,.12);  color: var(--green); }
.st-pending   { background: rgba(255,214,10,.12); color: var(--yellow); }
.st-deleted   { background: rgba(255,69,58,.10);  color: var(--red); }

/* ── HISTORY PAGE ──────────────────────────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.history-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.history-flag { font-size: 22px; flex-shrink: 0; }
.history-info { flex: 1; font-size: 13px; line-height: 1.5; }
.restore-btn {
  background: rgba(79,124,255,.15); color: var(--accent);
  border: none; border-radius: var(--radius-sm);
  padding: 5px 10px; font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
}

/* ── SETTINGS ──────────────────────────────────────────────────────────────── */
.settings-list { padding-top: 6px; }
.settings-section {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  color: var(--text-dim); letter-spacing: .5px;
  padding: 10px 0 6px;
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 6px;
  gap: 10px;
}
.settings-row.disabled { opacity: .5; }
.settings-label { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.settings-label > span:first-child { font-size: 14px; }
.settings-hint { font-size: 12px; color: var(--text-dim); }
.settings-select {
  background: var(--surface2); color: var(--text);
  border: none; border-radius: var(--radius-sm);
  padding: 6px 8px; font-size: 13px; cursor: pointer;
}
.badge-soon {
  background: rgba(79,124,255,.15); color: var(--accent);
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 10px;
  white-space: nowrap;
}

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: rgba(120,120,128,.38); border-radius: 13px; cursor: pointer;
  transition: background .2s;
  border: 1.5px solid rgba(255,255,255,.12);
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle-track::after {
  content: ""; position: absolute;
  left: 3px; top: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: white;
  transition: transform .2s;
}
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }
.toggle.small { width: 38px; height: 22px; }
.toggle.small .toggle-track::after { width: 16px; height: 16px; }
.toggle.small input:checked + .toggle-track::after { transform: translateX(16px); }

/* ── MODAL ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.65);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }
.modal-box {
  width: 100%; max-width: var(--max-w);
  background: #1e2130;
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 36px;
  max-height: 80dvh;
  overflow-y: auto;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
  font-size: 15px; font-weight: 600;
}
.modal-close {
  background: var(--surface2); border: none; cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%;
  color: var(--text-dim); font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.modal-hint { font-size: 12px; color: var(--text-dim); margin-bottom: 14px; }
.modal-entries { display: flex; flex-direction: column; gap: 8px; }
.modal-entry {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.modal-flag { font-size: 22px; flex-shrink: 0; }
.modal-entry-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.modal-entry-info strong { display: block; font-size: 14px; }
.modal-entry-info span  { font-size: 12px; color: var(--text-dim); }
.transit-lbl { font-size: 11px; color: var(--text-dim); white-space: nowrap; }

/* ── Day modal entries — Style C ─────────────────────────────────────────── */
.entry-wrap { display: flex; flex-direction: column; }
.modal-entry-c {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2);
  border-left: 3px solid var(--surface2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 12px;
  cursor: pointer; user-select: none;
}
.modal-entry-c.entry-confirmed { border-left-color: var(--green); }
.modal-entry-c.entry-pending   { border-left-color: #8e8ea0; }
.modal-entry-c.entry-conflict  { border-left-color: var(--red); background: rgba(255,69,58,.07); }
.modal-entry-c.entry-gps       { border-left-color: var(--accent); }
.modal-entry-c.entry-gapfill   { border-left-color: var(--text-dim); opacity: .75; }
.entry-cname  { font-size: 14px; font-weight: 600; }
.entry-city   { font-size: 12px; color: var(--text-dim); }
.entry-times  { font-size: 11px; color: var(--accent); font-weight: 500; }
.status-online  { font-size: 13px; font-weight: 500; color: var(--green); }
.status-offline { font-size: 13px; font-weight: 500; color: var(--red); }
.entry-src-badges { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.entry-status-pill {
  font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 8px;
  flex-shrink: 0; white-space: nowrap;
}
.entry-status-pill.entry-confirmed { background: rgba(52,199,89,.12);   color: var(--green); }
.entry-status-pill.entry-pending   { background: rgba(255,255,255,.08); color: #8e8ea0; }
.entry-status-pill.entry-conflict  { background: rgba(255,69,58,.12);   color: var(--red); }
.entry-status-pill.entry-gps       { background: rgba(79,124,255,.12);  color: var(--accent); }
.entry-status-pill.entry-gapfill   { background: rgba(255,255,255,.06); color: var(--text-dim); }
.entry-ctx {
  background: rgba(255,255,255,.03);
  border-left: 3px solid rgba(255,255,255,.06);
  border-radius: 0 0 var(--radius-sm) 0;
  padding: 8px 12px 8px 10px;
}
.entry-ctx-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.entry-ctx-transit { display: flex; align-items: center; gap: 6px; flex: 1; }
.entry-ctx-docs {
  display: flex; flex-direction: column; gap: 4px;
  width: 100%; order: 3;
}
.entry-ctx-del {
  background: rgba(255,69,58,.12); color: var(--red);
  border: none; border-radius: 6px; cursor: pointer;
  padding: 4px 10px; font-size: 12px; flex-shrink: 0;
  order: 2;
}
.modal-save {
  width: 100%; margin-top: 16px;
  background: var(--accent); color: white;
  border: none; border-radius: var(--radius-sm);
  padding: 13px; font-size: 15px; font-weight: 600; cursor: pointer;
}
/* Modal action buttons (delete/restore per entry) */
.modal-action-btn {
  border: none; cursor: pointer; border-radius: 6px;
  padding: 4px 8px; font-size: 13px; flex-shrink: 0;
}
.modal-action-btn.delete {
  background: rgba(255,69,58,.12); color: var(--red); opacity: .7;
}
.modal-action-btn.delete:hover { opacity: 1; }
.modal-action-btn.restore {
  background: rgba(79,124,255,.15); color: var(--accent);
  font-size: 12px;
}

/* Document links in day modal */
.modal-docs {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px;
}
.doc-open-btn {
  background: rgba(123,94,167,.15); color: #b08cff;
  border: none; border-radius: 6px; cursor: pointer;
  padding: 3px 8px; font-size: 11px; white-space: nowrap;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis;
}
.doc-open-btn:hover { background: rgba(123,94,167,.3); }

/* Edit button in trip card */
.ts-edit {
  background: rgba(79,124,255,.12); color: var(--accent);
}

/* Conflict list */
.conflict-list {
  list-style: none; margin: 4px 0 4px 0;
  display: flex; flex-direction: column; gap: 4px;
}
.conflict-list li {
  background: var(--surface2); border-radius: 6px;
  padding: 6px 10px; font-size: 12px; color: var(--text-dim);
}

/* ── ADD TRIP FORM (full-screen overlay) ───────────────────────────────────── */
#trip-form-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; flex-direction: column;
  max-width: var(--max-w);
  margin: 0 auto;
}
#trip-form-overlay.hidden { display: none; }

.form-overlay-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--surface2);
  flex-shrink: 0;
}
.form-overlay-title { font-size: 17px; font-weight: 600; flex: 1; }
.form-close-btn {
  background: var(--surface2); border: none; cursor: pointer;
  width: 30px; height: 30px; border-radius: 50%;
  color: var(--text-dim); font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}

.form-overlay-scroll {
  flex: 1; overflow-y: auto; padding: 14px 16px 100px;
  -webkit-overflow-scrolling: touch;
}

/* Form type row */
.form-type-row {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.form-type-btn {
  flex: 1; padding: 9px 8px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--surface2); background: var(--surface);
  color: var(--text-dim); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .15s;
}
.form-type-btn.active {
  border-color: var(--accent); background: rgba(79,124,255,.1); color: var(--accent);
}

/* Leg form block */
.leg-form-block {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--surface2);
}
.leg-transit-block { opacity: .8; border-style: dashed; }
.leg-form-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 600; color: var(--accent);
  margin-bottom: 10px;
}
.leg-role-label { font-size: 12px; font-weight: 600; color: var(--accent); }
.leg-move-btn {
  background: var(--surface2); border: none; cursor: pointer;
  color: var(--text-dim); font-size: 14px;
  width: 26px; height: 26px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, background .15s;
}
.leg-move-btn:hover { color: var(--text); background: var(--surface); }
.leg-remove-btn {
  background: rgba(255,69,58,.12); border: none; cursor: pointer;
  color: var(--red); font-size: 13px;
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.leg-date-err {
  font-size: 11px; color: var(--red);
  margin: -4px 0 6px; line-height: 1.4;
}

.form-row { margin-bottom: 10px; }
.form-row.two-col {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.form-label {
  display: block; font-size: 11px; font-weight: 500;
  color: var(--text-dim); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: .3px;
}
.form-input,
.form-select {
  width: 100%; background: var(--surface2);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  color: var(--text); padding: 9px 10px; font-size: 14px;
  transition: border-color .15s;
}
.form-input:focus,
.form-select:focus { outline: none; border-color: var(--accent); }
.form-input::placeholder { color: var(--text-dim); }
.form-check-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-dim);
  padding: 6px 0 2px; cursor: pointer;
}
.form-check-row input[type=checkbox] {
  width: 18px; height: 18px; border-radius: 4px;
  accent-color: var(--accent); cursor: pointer; flex-shrink: 0;
}

/* Docs section inside form */
.form-section {
  font-size: 13px; font-weight: 600; color: var(--text-dim);
  margin: 14px 0 8px;
  display: flex; justify-content: space-between; align-items: center;
}
.form-section-btn {
  background: rgba(79,124,255,.12); color: var(--accent);
  border: none; border-radius: var(--radius-sm);
  padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.doc-row {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  background: var(--surface); border-radius: 8px;
  padding: 8px 12px; margin-bottom: 6px;
}
.doc-row .doc-fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.doc-type-sel {
  background: var(--surface2); color: var(--text);
  border: none; border-radius: 6px;
  padding: 4px 6px; font-size: 11px; cursor: pointer;
}

/* Form bottom bar (sticky) */
.form-footer {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(15,17,23,.95);
  backdrop-filter: blur(12px);
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--surface2);
  display: flex; gap: 8px;
}
.form-footer-btn {
  flex: 1; padding: 13px 0; border-radius: var(--radius-sm);
  border: none; font-size: 14px; font-weight: 600; cursor: pointer;
}
#form-save-btn {
  background: var(--accent); color: white;
}
#form-add-leg {
  background: var(--surface2); color: var(--accent);
  flex: 0 0 auto; padding: 13px 16px;
}

/* ── FAB ───────────────────────────────────────────────────────────────────── */
#fab-add {
  position: fixed;
  bottom: max(76px, calc(60px + env(safe-area-inset-bottom)));
  right: calc(50% - var(--max-w)/2 + 16px);
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent);
  border: none; cursor: pointer;
  font-size: 26px; color: white; font-weight: 300;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(79,124,255,.4);
  z-index: 50;
  transition: transform .15s, box-shadow .15s;
}
#fab-add:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(79,124,255,.5); }

/* ── Bottom nav ────────────────────────────────────────────────────────────── */
.bottom-nav {
  position: sticky; bottom: 0;
  background: rgba(26,29,39,.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  font-size: 10px; color: var(--text-dim);
  cursor: pointer; border: none; background: none; padding: 3px 0;
  transition: color .15s;
}
.nav-item.active { color: var(--accent); }
.nav-item svg { width: 22px; height: 22px; }

/* ── Animations ────────────────────────────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity:1; } 50% { opacity:.4; }
}

/* ── Desktop frame ─────────────────────────────────────────────────────────── */
@media (min-width: 500px) {
  body { background: #080a10; padding: 24px 0; }
  #app {
    border-radius: 40px;
    box-shadow: 0 24px 80px rgba(0,0,0,.7);
    min-height: min(900px, 95dvh);
    max-height: 900px;
    overflow: hidden;
  }
  .modal-box { border-radius: 20px; margin: 0 auto; margin-bottom: 24px; }
  #fab-add {
    right: calc(50% - var(--max-w)/2 + 16px);
    bottom: 84px;
  }
  #trip-form-overlay {
    border-radius: 40px;
    overflow: hidden;
    max-height: min(900px, 95dvh);
  }
}

/* ── Flag images ──────────────────────────────────────────────────────────── */
.flag-img {
  display: inline-block;
  width: 16px;
  height: auto;
  border-radius: 2px;
  vertical-align: middle;
  object-fit: cover;
}

/* ── v3: Gap-fill calendar flags ──────────────────────────────────────────── */
.cal-flag.gap-flag {
  opacity: 0.42;
  filter: grayscale(30%);
}

/* ── v3: Gap-fill modal entry ─────────────────────────────────────────────── */
.modal-entry-gapfill {
  opacity: 0.7;
}
.modal-entry-gapfill .modal-flag {
  filter: grayscale(25%);
}
.src-badge.src-gap-origin {
  opacity: 0.6;
  font-style: italic;
}
.src-badge.src-gap {
  background: rgba(255,255,255,.07);
  color: var(--text-dim);
  font-size: 10px;
}

/* ── v3: Trigger settings block ───────────────────────────────────────────── */
.trigger-settings-block {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 8px 4px 4px;
  margin: 4px 0 8px;
}
.trigger-group-label {
  font-size: 11px;
  color: var(--text-dim);
  padding: 2px 8px 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.trigger-group-header {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  padding: 10px 8px 4px;
}
.trigger-group-box {
  margin: 0 0 4px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  overflow: hidden;
}
.trigger-group-box .trigger-row {
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.trigger-group-box .trigger-row:last-child {
  border-bottom: none;
}
.trigger-row {
  padding: 6px 8px;
}
.trigger-row .settings-label span:first-child {
  font-size: 13px;
}

/* ── v3: Per-leg docs section ─────────────────────────────────────────────── */
.leg-docs-section {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 4px;
}
.leg-docs-section .form-section {
  padding: 0;
  margin-bottom: 4px;
}

/* ── Per-leg docs in trip card ────────────────────────────────────────────── */
.ts-leg-docs {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ts-leg-docs .ts-doc-item {
  padding: 2px 0;
}

/* ── Per-leg doc panel (modal + trips card) ───────────────────────────────── */
.modal-leg-doc-panel {
  margin-top: 6px;
  background: var(--surface-raised, #252525);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.leg-doc-panel-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.leg-doc-panel-row:last-child { border-bottom: none; }

.leg-doc-panel-item {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  padding: 8px 10px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}
.leg-doc-panel-item:active { background: rgba(255,255,255,.08); }

/* items in modal (no del button) are wrapped directly, no .leg-doc-panel-row */
.modal-leg-doc-panel > .leg-doc-panel-item {
  border-bottom: 1px solid rgba(255,255,255,.05);
  width: 100%;
}
.modal-leg-doc-panel > .leg-doc-panel-item:last-child { border-bottom: none; }

.ldp-type  { color: var(--text-dim); white-space: nowrap; flex-shrink: 0; }
.ldp-sep   { color: var(--text-dim); }
.ldp-name  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-modified { font-size: 10px; color: var(--text-dim); white-space: nowrap; flex-shrink: 0; margin-left: 4px; }

.leg-doc-del-btn {
  flex-shrink: 0;
  padding: 0 10px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
}
.leg-doc-del-btn:active { color: var(--red); }

/* Icon badge in trips card / modal badges row */
.leg-doc-icon {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: rgba(var(--accent-rgb, 10,132,255),.12);
  user-select: none;
}
.leg-doc-icon:active { opacity: .7; }

/* ── Photo import button + modal ─────────────────────────────────────────── */
.photo-import-btn {
  flex-shrink: 0;
  padding: 6px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.photo-import-btn:active { opacity: .75; }

.pi-list {
  max-height: 52vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 -4px;
}
.pi-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.pi-row:last-child { border-bottom: none; }
.pi-row:not(.pi-exists):hover { background: rgba(255,255,255,.04); }
.pi-exists { opacity: .45; }
.pi-flag  { flex-shrink: 0; }
.pi-name  { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-date  { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.pi-count { color: var(--text-dim); font-size: 11px; white-space: nowrap; flex-shrink: 0; }

/* ── Leg time input (form) ──────────────────────────────────────────────────── */
.leg-time-inp {
  margin-top: 4px;
  font-size: 13px;
  padding: 5px 8px;
  color: var(--text-dim);
}

/* ── Day timeline (modal) ───────────────────────────────────────────────────── */
.day-timeline-scroll {
  overflow-y: auto;
  max-height: 56vh;
  margin: 8px -4px 0;
}
.day-timeline {
  position: relative;
  width: 100%;
}
.tl-grid-line {
  position: absolute;
  left: 0; right: 0; height: 1px;
  background: rgba(255,255,255,.1);
  z-index: 0;
}
.tl-axis-divider {
  position: absolute;
  top: 0; bottom: 0; left: 44px; width: 1px;
  background: rgba(255,255,255,.15);
  z-index: 1;
}
.tl-axis-label {
  position: absolute;
  left: 0; width: 40px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: right;
  transform: translateY(-50%);
  padding-right: 5px;
  z-index: 2;
  pointer-events: none;
}
.tl-leg-block {
  position: absolute;
  left: 48px; right: 4px;
  border-left: 3px solid transparent;
  border-radius: 0 6px 6px 0;
  z-index: 1;
  overflow: visible;
}
.tl-leg-label {
  position: sticky;
  top: 4px;
  display: block;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-time-top, .tl-time-bottom {
  position: absolute;
  left: 8px; right: 6px;
  font-size: 10px; font-weight: 600;
  color: rgba(255,255,255,.8);
  white-space: nowrap; pointer-events: none; line-height: 1;
}
.tl-time-top    { top: 3px; }
.tl-time-bottom { bottom: 3px; text-align: right; }
.tl-time-top + .tl-leg-label { padding-top: 16px; }
.tl-gps-event {
  position: absolute;
  left: 52px;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,.2);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 3;
  white-space: nowrap;
  transform: translateY(-50%);
  max-width: calc(100% - 60px);
}

/* Timeline open button (compact) */
.tl-open-btn {
  background: var(--surface2);
  border: none; border-radius: 8px;
  color: var(--text-dim);
  font-size: 12px; font-weight: 500;
  padding: 5px 10px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.tl-open-btn:hover { background: var(--surface); color: var(--text); }

/* ── Trip card compact/expanded ─────────────────────────────────────────────── */
.ts-compact-header {
  display: flex; flex-direction: column; gap: 5px;
  cursor: pointer; padding: 2px 0; user-select: none;
}
.ts-compact-route {
  font-size: 13px; font-weight: 600; line-height: 1.5;
}
.ts-compact-route img { vertical-align: middle; }
.ts-compact-footer {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.ts-compact-dates {
  font-size: 11px; color: var(--text-dim); white-space: nowrap; flex-shrink: 0;
}
.ts-compact-meta {
  display: flex; align-items: center; gap: 3px; flex-wrap: wrap; flex: 1;
}
.ts-chevron {
  font-size: 10px; color: var(--text-dim); flex-shrink: 0; line-height: 1; margin-left: auto;
}
.ts-expanded-body {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--surface2);
}

/* ── Timeline notes ──────────────────────────────────────────────────────────── */
.tl-add-note-btn {
  background: rgba(79,124,255,.15); color: var(--accent);
  border: none; border-radius: 8px;
  font-size: 12px; font-weight: 600;
  padding: 5px 10px; cursor: pointer; white-space: nowrap;
}
.tl-add-note-btn:hover { background: rgba(79,124,255,.25); }
.tl-note-block {
  position: absolute;
  height: 26px;
  background: rgba(255,214,10,.18);
  border: 1px solid rgba(255,214,10,.55);
  border-radius: 5px;
  cursor: pointer;
  z-index: 4;
  display: flex; align-items: center;
  padding: 0 6px;
  transform: translateY(-50%);
  overflow: hidden;
}
.tl-note-block:hover { background: rgba(255,214,10,.3); }
.tl-note-title {
  font-size: 11px; font-weight: 500; color: #ffd60a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Note edit modal ─────────────────────────────────────────────────────────── */
.note-modal-header {
  display: flex; align-items: center; gap: 8px;
}
.note-del-btn {
  background: rgba(255,69,58,.12); color: var(--red);
  border: none; border-radius: 7px;
  padding: 5px 9px; cursor: pointer; font-size: 14px;
  line-height: 1;
}
.note-del-btn:hover { background: rgba(255,69,58,.25); }
.note-form-body {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 10px;
}
.note-form-top-row {
  display: flex; gap: 8px;
}
.note-time-input {
  width: 90px !important; flex-shrink: 0;
}
.note-title-input {
  flex: 1; min-width: 0;
}
.note-text-area {
  min-height: 320px;
  resize: vertical;
  font-size: 14px;
  line-height: 1.5;
}
.note-view-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  min-height: 300px;
  overflow-y: auto;
}

/* ── Import collision UI ─────────────────────────────────────────────────────── */
.pi-section-label {
  font-size: 11px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px;
}
.pi-trip-card {
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 8px 10px;
  border-left: 3px solid rgba(255,255,255,.1);
}
.pi-trip-card.pi-marked-delete { opacity: .4; }
.pi-trip-route {
  font-size: 13px; font-weight: 600; line-height: 1.4; margin-bottom: 3px;
}
.pi-trip-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pi-trip-del {
  margin-left: auto; flex-shrink: 0;
  background: rgba(255,69,58,.12); color: var(--red);
  border: none; border-radius: 5px; cursor: pointer;
  padding: 3px 8px; font-size: 11px;
}

/* ── Friends row (Home page) ─────────────────────────────────────────────── */
.friends-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.friends-row::-webkit-scrollbar { display: none; }

.friend-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 6px 8px;
  border-radius: 12px;
  border: 2px solid transparent;
  transition: border-color .15s, background .15s;
}
.friend-avatar:hover { background: var(--surface2); }
.friend-avatar.active {
  border-color: var(--accent);
  background: rgba(10,132,255,.1);
}
.friend-icon { font-size: 28px; line-height: 1; }
.friend-name {
  font-size: 11px;
  color: var(--text-dim);
  max-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}
.friend-no-data {
  font-size: 9px;
  color: var(--red);
  text-align: center;
}
.friend-add-btn, .friend-mgmt-btn {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2px dashed var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
}
.friend-add-btn:hover { border-color: var(--accent); color: var(--accent); }
.friend-mgmt-btn { font-size: 16px; border-style: solid; }
.friend-mgmt-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Friend-view banner ─────────────────────────────────────────────────── */
.friend-view-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(10,132,255,.12);
  border: 1px solid rgba(10,132,255,.25);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 8px;
}
.friend-view-banner.home { margin-top: 4px; }
.friend-view-exit {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 12px; padding: 2px 6px;
  border-radius: 6px; transition: background .15s;
}
.friend-view-exit:hover { background: var(--surface2); color: var(--text); }

/* ── Friend management modal rows ────────────────────────────────────────── */
.friend-mgmt-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.friend-mgmt-row:last-child { border-bottom: none; }
.friend-mgmt-icon { font-size: 22px; flex-shrink: 0; }
.friend-mgmt-info { flex: 1; min-width: 0; }
.friend-mgmt-name { font-size: 14px; font-weight: 600; display: block; }
.friend-mgmt-meta { font-size: 11px; color: var(--text-dim); }
.friend-mgmt-btns { display: flex; gap: 6px; flex-shrink: 0; }
