/* =========================================================
   Atlas & Co. — stylesheet
   Warm editorial CRM. Fraunces display + Geist body.
   ========================================================= */

:root {
  --bg:       #efe8da;
  --paper:    #faf5e9;
  --panel:    #fffdf7;
  --ink:      #1a1612;
  --ink-soft: #4a4238;
  --muted:    #8a7f6f;
  --line:     #d9cdb6;
  --line-soft:#e7dcc5;
  --forest:   #2d4a3e;
  --forest-2: #3d5b4e;
  --rust:     #b85a2e;
  --amber:    #c9962b;
  --berry:    #8b3a4e;

  --fs-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --fs-body: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --fs-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 4px;
  --shadow-brutal: 8px 8px 0 var(--ink);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--fs-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: 0.25; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.1  0 0 0 0 0.08  0 0 0 0 0.06  0 0 0 0.08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

#app { position: relative; z-index: 1; max-width: 1200px; margin: 0 auto; padding: 32px 24px; }

/* ----------- typography helpers ----------- */
.display { font-family: var(--fs-display); font-optical-sizing: auto; letter-spacing: -0.01em; }
.mono { font-family: var(--fs-mono); }
.eyebrow {
  font-family: var(--fs-body);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 10px;
  font-weight: 600;
}

/* ----------- header ----------- */
.header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding-bottom: 24px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.wordmark { font-family: var(--fs-display); font-size: 52px; font-weight: 500; line-height: 1; color: var(--ink); margin: 4px 0 0; }
.wordmark em { font-style: italic; font-weight: 400; color: var(--forest); }

.header-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.nav {
  display: flex; align-items: center; gap: 4px; padding: 4px;
  border-radius: 999px; background: var(--panel); border: 1px solid var(--line);
}
.nav-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 999px; border: 0;
  background: transparent; color: var(--ink-soft); cursor: pointer;
  font-family: var(--fs-body); font-size: 13px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-btn:hover { color: var(--ink); }
.nav-btn.active { background: var(--ink); color: var(--paper); }
.nav-btn svg { width: 14px; height: 14px; stroke-width: 1.8; }

/* ----------- buttons ----------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; border-radius: 999px; cursor: pointer;
  font-family: var(--fs-body); font-weight: 500; font-size: 13px;
  border: 1px solid var(--ink); background: transparent; color: var(--ink);
  transition: background .15s, color .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 14px; height: 14px; }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--forest); border-color: var(--forest); }
.btn.ghost { border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--ink); background: var(--paper); }
.btn.danger { border-color: transparent; color: var(--berry); padding: 6px 10px; }
.btn.danger:hover { background: #f5e3e8; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ----------- inputs ----------- */
.input, .select, textarea.input {
  width: 100%; padding: 10px 12px;
  background: var(--paper); border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--radius); font-size: 14px; font-family: var(--fs-body);
  outline: none; transition: border-color .15s;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--forest); }
.input::placeholder { color: var(--muted); }
textarea.input { min-height: 92px; resize: vertical; line-height: 1.55; }
.select { appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238a7f6f' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

.field { display: block; }
.field .eyebrow { color: var(--muted); display: block; margin-bottom: 6px; }
.field .eyebrow .req { color: var(--rust); }

.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; }

/* ----------- empty state ----------- */
.empty-wrap {
  position: relative; margin: 80px auto 0; max-width: 620px;
  padding: 56px 48px 48px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 8px 8px 0 var(--line);
}
.empty-wrap h2 { font-family: var(--fs-display); font-size: 36px; font-weight: 500; line-height: 1.05; margin: 12px 0 0; color: var(--ink); }
.empty-wrap p { color: var(--ink-soft); font-size: 15px; line-height: 1.55; margin: 16px 0 0; }
.empty-cta { display: flex; gap: 12px; margin-top: 32px; flex-wrap: wrap; }

/* ----------- contacts layout ----------- */
.contacts-grid { display: grid; gap: 24px; grid-template-columns: 340px 1fr; }
@media (max-width: 860px) {
  .contacts-grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}

.sidebar {
  height: calc(100vh - 220px);
  min-height: 560px;
  display: flex; flex-direction: column;
}
@media (max-width: 860px) {
  .sidebar { height: auto; max-height: 420px; }
}
.sidebar-head { padding: 16px; border-bottom: 1px solid var(--line-soft); }
.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--muted); stroke-width: 1.8;
}
.search-wrap .input { padding-left: 36px; }

.sidebar-count { margin-top: 12px; color: var(--muted); }

.contact-list { flex: 1; overflow-y: auto; }
.contact-row {
  display: block; width: 100%; padding: 12px 16px; text-align: left;
  background: transparent; border: 0; border-bottom: 1px solid var(--line-soft);
  border-left: 3px solid transparent; cursor: pointer; transition: background .15s;
}
.contact-row:hover { background: var(--paper); }
.contact-row.active { background: var(--paper); border-left-color: var(--ink); }
.contact-row-inner { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.contact-row-meta { display: flex; align-items: center; gap: 12px; min-width: 0; }
.contact-row-name { font-weight: 500; font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-row-company { font-family: var(--fs-mono); font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-row-count { font-family: var(--fs-mono); font-size: 10px; color: var(--muted); }

/* Avatar */
.avatar {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  color: var(--paper); font-size: 12px; font-weight: 600;
  font-family: var(--fs-body);
}
.avatar.lg { width: 44px; height: 44px; font-size: 14px; }

/* ----------- contact detail ----------- */
.detail { display: flex; flex-direction: column; min-height: 560px; }
.detail-head {
  padding: 24px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  border-bottom: 1px solid var(--line-soft); flex-wrap: wrap;
}
.detail-title { font-family: var(--fs-display); font-size: 32px; font-weight: 500; line-height: 1.05; color: var(--ink); margin: 4px 0 0; }
.detail-id { display: flex; align-items: flex-start; gap: 16px; min-width: 0; }
.tags { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.tag {
  font-family: var(--fs-mono); padding: 3px 8px; border-radius: 3px;
  background: var(--bg); color: var(--ink-soft); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.08em;
}

.detail-rows {
  padding: 20px 24px; display: grid; gap: 16px;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line-soft);
}
@media (max-width: 600px) { .detail-rows { grid-template-columns: 1fr; } }

.detail-row { display: flex; align-items: flex-start; gap: 12px; }
.detail-row svg { width: 15px; height: 15px; stroke-width: 1.6; color: var(--muted); margin-top: 2px; flex-shrink: 0; }
.detail-row-eyebrow { font-family: var(--fs-body); text-transform: uppercase; letter-spacing: 0.18em; font-size: 10px; font-weight: 600; color: var(--muted); }
.detail-row-value { font-size: 14px; color: var(--ink); margin-top: 2px; word-break: break-word; }
.detail-row-value.empty { color: var(--muted); }

.notes-block {
  padding: 20px 24px; background: var(--paper);
  border-bottom: 1px solid var(--line-soft);
}
.notes-block .eyebrow { color: var(--muted); display: block; margin-bottom: 6px; }
.notes-block p { color: var(--ink); font-size: 14px; line-height: 1.65; margin: 0; white-space: pre-wrap; }

.timeline-section { padding: 20px 24px; flex: 1; overflow-y: auto; }
.timeline-section-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.timeline-section-head h3 { font-family: var(--fs-display); font-size: 20px; font-weight: 500; color: var(--ink); margin: 4px 0 0; }
.timeline-section-head .sub { color: var(--muted); font-weight: 400; }

/* ----------- timeline items ----------- */
.tl-list { position: relative; padding-left: 28px; border-left: 1px dashed var(--line); }
.tl-item { position: relative; margin-bottom: 20px; animation: fadeUp .3s ease-out both; }
.tl-item:last-child { margin-bottom: 0; }
.tl-dot {
  position: absolute; left: -41px; top: 0;
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--paper); border: 2px solid var(--panel);
}
.tl-dot svg { width: 12px; height: 12px; stroke-width: 2; }
.tl-card {
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--paper); border: 1px solid var(--line-soft);
}
.tl-card.embedded { background: var(--panel); }
.tl-card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.tl-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted);
}
.tl-kind {
  font-family: var(--fs-mono); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
}
.tl-dot-sep::before { content: "·"; margin: 0 2px; color: var(--muted); }
.tl-italic { font-style: italic; color: var(--muted); font-size: 11px; }
.tl-contact-name { margin-top: 4px; font-size: 12px; color: var(--forest); font-weight: 500; }
.tl-title { margin-top: 4px; font-size: 15px; font-weight: 500; color: var(--ink); }
.tl-notes { margin: 4px 0 0; font-size: 13px; color: var(--ink-soft); line-height: 1.55; white-space: pre-wrap; }
.tl-loc {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 8px; font-size: 11px; color: var(--muted);
}
.tl-loc svg { width: 11px; height: 11px; stroke-width: 1.8; }
.tl-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.tl-item:hover .tl-actions { opacity: 1; }
.icon-btn {
  border: 0; background: transparent; padding: 6px; border-radius: 4px;
  color: var(--muted); cursor: pointer; display: inline-flex;
}
.icon-btn:hover { color: var(--ink); background: var(--bg); }
.icon-btn.danger:hover { color: var(--berry); background: #f5e3e8; }
.icon-btn svg { width: 12px; height: 12px; }

.empty-inline { text-align: center; padding: 36px 20px; color: var(--muted); font-size: 13px; }

/* ----------- timeline view (global) ----------- */
.view-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.view-head h2 { font-family: var(--fs-display); font-size: 32px; font-weight: 500; color: var(--ink); margin: 4px 0 0; }

.filters {
  display: flex; flex-wrap: wrap; gap: 12px; padding: 16px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 24px; align-items: center;
}
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-group .eyebrow { color: var(--muted); }
.filter-group .select { width: auto; min-width: 140px; }
.filters .count { margin-left: auto; color: var(--muted); font-family: var(--fs-mono); font-size: 11px; }

.month-group { margin-bottom: 40px; }
.month-head {
  display: flex; align-items: baseline; gap: 16px; margin-bottom: 18px;
}
.month-head h3 { font-family: var(--fs-display); font-size: 22px; font-weight: 500; color: var(--ink); margin: 0; }
.month-head .rule { flex: 1; height: 0; border-top: 1px solid var(--line); }
.month-head .count { font-family: var(--fs-mono); font-size: 11px; color: var(--muted); }

/* ----------- map view ----------- */
.map-grid { display: grid; gap: 24px; grid-template-columns: 1fr 360px; }
@media (max-width: 900px) { .map-grid { grid-template-columns: 1fr; } }

.map-panel {
  height: 560px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.map-panel > div { width: 100%; height: 100%; }
.map-empty {
  height: 100%; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 8px; text-align: center; padding: 40px; color: var(--muted);
}
.map-empty svg { width: 28px; height: 28px; stroke-width: 1.4; }
.map-empty .primary-line { color: var(--ink-soft); font-size: 14px; }

.itinerary {
  height: 560px; overflow-y: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.itinerary-head { padding: 16px; border-bottom: 1px solid var(--line-soft); background: var(--paper); }
.itinerary-head .title { font-family: var(--fs-display); font-size: 18px; color: var(--ink); font-weight: 500; margin-top: 4px; }

.itinerary-row {
  display: flex; width: 100%; text-align: left; padding: 16px;
  background: transparent; border: 0; border-bottom: 1px solid var(--line-soft);
  border-left: 3px solid transparent; cursor: pointer; transition: background .15s;
  gap: 12px; align-items: flex-start;
}
.itinerary-row:hover { background: var(--paper); }
.itinerary-row.active { background: var(--paper); }
.itinerary-badge {
  margin-top: 2px; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--paper); flex-shrink: 0;
}
.itinerary-badge svg { width: 11px; height: 11px; stroke-width: 2; }
.itinerary-body { min-width: 0; flex: 1; }
.itinerary-name { font-size: 13px; font-weight: 500; color: var(--ink); }
.itinerary-title { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }
.itinerary-loc { margin-top: 4px; display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.itinerary-loc svg { width: 10px; height: 10px; stroke-width: 1.8; }
.itinerary-date { font-family: var(--fs-mono); font-size: 10px; color: var(--muted); margin-top: 2px; }

/* Leaflet tweaks */
.leaflet-container { font-family: var(--fs-body) !important; background: var(--paper) !important; }
.leaflet-popup-content-wrapper {
  border-radius: 6px; border: 1px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
}
.leaflet-popup-content { margin: 10px 14px; font-family: var(--fs-body); font-size: 12px; color: var(--ink); line-height: 1.4; }
.leaflet-popup-tip { background: var(--ink); }
.crm-pin {
  width: 28px; height: 28px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); border: 2px solid var(--ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 2px 2px 0 var(--ink);
}
.crm-pin .initials {
  transform: rotate(45deg); font-size: 11px; font-weight: 700;
  color: var(--paper); font-family: var(--fs-body);
}

/* ----------- modals ----------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(26, 22, 18, 0.4); backdrop-filter: blur(4px);
  padding: 40px 20px; overflow-y: auto;
  display: flex; align-items: flex-start; justify-content: center;
  animation: fadeIn .2s ease-out;
}
.modal {
  width: 100%; max-width: 580px; background: var(--panel);
  border: 1px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow-brutal);
  animation: fadeUp .25s ease-out both;
}
.modal.wide { max-width: 720px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-family: var(--fs-display); font-size: 22px; font-weight: 500; color: var(--ink); margin: 0; }
.modal-body { padding: 24px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 16px 24px; border-top: 1px solid var(--line-soft); background: var(--paper);
}
.modal-close {
  border: 0; background: transparent; padding: 8px; border-radius: 999px;
  color: var(--muted); cursor: pointer; display: inline-flex;
}
.modal-close:hover { color: var(--ink); }
.modal-close svg { width: 18px; height: 18px; }

.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* Kind picker */
.kind-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.kind-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
  font-family: var(--fs-body); font-size: 12px; font-weight: 500;
  transition: all .15s;
}
.kind-btn svg { width: 13px; height: 13px; stroke-width: 1.8; }
.kind-btn.active { color: var(--paper); }

/* Tag chips */
.tag-chip {
  font-family: var(--fs-mono); padding: 4px 8px; border-radius: 3px;
  background: var(--bg); color: var(--ink-soft); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.08em;
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; cursor: pointer;
}
.tag-chip svg { width: 10px; height: 10px; }
.tag-list { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* Location block */
.loc-block {
  margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line-soft);
}
.loc-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.loc-head .sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.mini-map {
  width: 100%; height: 260px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--paper);
}
.loc-coords { margin-top: 8px; font-family: var(--fs-mono); font-size: 11px; color: var(--muted); }
.loc-error { margin-bottom: 8px; color: var(--berry); font-size: 12px; }

/* Toasts / messages */
.msg { padding: 10px 12px; border-radius: var(--radius); font-size: 12px; margin-bottom: 12px; }
.msg.info { background: #eef2ec; color: var(--forest-2); border: 1px solid #d1ddd5; }
.msg.error { background: #f5e3e8; color: var(--berry); border: 1px solid #e7cdd3; }

/* Scrollbar polish */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }

/* Animations */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade { animation: fadeUp .3s ease-out both; }

/* Focus rings */
:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}

/* ----------- modal tabs ----------- */
.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.modal-tabs .tab {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 14px 12px; border: 0;
  background: transparent; cursor: pointer;
  font-family: var(--fs-body); font-size: 13px; font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
}
.modal-tabs .tab:hover { color: var(--ink); background: rgba(0,0,0,0.02); }
.modal-tabs .tab.active {
  color: var(--ink); border-bottom-color: var(--ink);
}
.modal-tabs .tab svg { width: 14px; height: 14px; stroke-width: 1.8; }

.tab-panel[hidden] { display: none; }

/* ----------- sync badge in header ----------- */
.sync-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
  cursor: pointer; font-family: var(--fs-body); font-size: 11px;
  color: var(--ink-soft); font-weight: 500;
  transition: border-color .15s, background .15s;
}
.sync-badge:hover { border-color: var(--ink); background: var(--paper); }
.sync-badge .sync-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}
.sync-badge .sync-label { font-weight: 500; }
.sync-badge .sync-time { color: var(--muted); font-family: var(--fs-mono); font-size: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.sync-badge .sync-dot.spin { animation: spin 1s linear infinite; }

/* ----------- sync panel ----------- */
.sync-status-box {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--paper); border: 1px solid var(--line-soft);
  margin-top: 12px;
}
.sync-status-box .sync-dot {
  margin-top: 6px;
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}
.sync-status-title { font-weight: 500; font-size: 14px; color: var(--ink); }
.sync-status-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.sync-status-err {
  margin-top: 4px; font-size: 12px; color: var(--berry);
  word-break: break-word;
}

.toggle-row {
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 13px; color: var(--ink);
}
.toggle-row input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 36px; height: 20px; border-radius: 999px;
  background: var(--line); border: 1px solid var(--line);
  position: relative; cursor: pointer; transition: background .15s;
}
.toggle-row input[type="checkbox"]::after {
  content: ""; position: absolute; top: 1px; left: 1px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,.15);
  transition: left .15s, background .15s;
}
.toggle-row input[type="checkbox"]:checked {
  background: var(--forest); border-color: var(--forest);
}
.toggle-row input[type="checkbox"]:checked::after { left: 17px; }

.sync-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

.sync-help {
  margin-top: 20px; padding: 12px 14px;
  background: var(--paper); border: 1px dashed var(--line);
  border-radius: var(--radius); font-size: 13px; color: var(--ink-soft);
  line-height: 1.55;
}
.sync-help summary {
  cursor: pointer; font-weight: 500; color: var(--ink);
  list-style: none;
}
.sync-help summary::marker { display: none; }
.sync-help summary::-webkit-details-marker { display: none; }
.sync-help summary::before {
  content: "▸"; display: inline-block; margin-right: 6px;
  transition: transform .15s;
}
.sync-help[open] summary::before { transform: rotate(90deg); }
.sync-help ol { margin: 12px 0 8px; padding-left: 20px; }
.sync-help ol li { margin-bottom: 6px; }
.sync-help code {
  font-family: var(--fs-mono); font-size: 12px;
  background: var(--bg); padding: 1px 5px; border-radius: 3px;
  color: var(--forest);
}
.data-desc code {
  font-family: var(--fs-mono); font-size: 12px;
  background: var(--bg); padding: 1px 5px; border-radius: 3px;
  color: var(--forest);
}


.gate {
  min-height: 85vh;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
}
.gate-card {
  position: relative;
  max-width: 420px; width: 100%;
  padding: 48px 40px 36px;
  background: var(--panel);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-brutal);
  text-align: left;
  animation: fadeUp .35s ease-out both;
}
.gate-eyebrow {
  font-family: var(--fs-body);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 10px;
  font-weight: 600;
  color: var(--rust);
  margin-bottom: 8px;
}
.gate-title {
  font-family: var(--fs-display);
  font-size: 44px;
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
  margin: 0 0 8px;
}
.gate-title em { font-style: italic; font-weight: 400; color: var(--forest); }
.gate-sub {
  font-family: var(--fs-body);
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 24px;
}
.gate-form { display: flex; flex-direction: column; gap: 16px; }
.gate-field { display: block; }
.gate-field .eyebrow {
  display: block; color: var(--muted); margin-bottom: 6px;
}
.gate-msg { margin: 0; }
.gate-msg-placeholder { height: 0; }
.gate-btn { justify-content: center; padding: 11px 16px; font-size: 14px; }
.gate-btn svg { width: 14px; height: 14px; }
.gate-foot {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
  font-family: var(--fs-display);
  font-style: italic;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.gate-version {
  position: absolute;
  top: 12px;
  right: 16px;
  font-family: var(--fs-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
}


.data-grid {
  display: grid; gap: 32px;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 640px) { .data-grid { grid-template-columns: 1fr; } }

.data-col > .eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 3px;
  background: var(--bg);
}
.data-col > .eyebrow svg { width: 11px; height: 11px; stroke-width: 2; }

.data-title {
  font-family: var(--fs-display); font-size: 22px; font-weight: 500;
  color: var(--ink); margin: 10px 0 6px;
}
.data-desc {
  color: var(--ink-soft); font-size: 13px; line-height: 1.55;
  margin: 0 0 16px;
}
.data-desc a {
  color: var(--forest); text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}
.data-desc a:hover { text-decoration-color: var(--forest); }
.data-hint { margin-top: 10px; font-size: 12px; color: var(--muted); font-style: italic; }

/* Drop zone */
.drop-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 28px 16px; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  background: var(--paper); text-align: center;
  transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone:focus-visible { border-color: var(--ink); }
.drop-zone.drag { border-color: var(--forest); background: #eef2ec; }
.drop-icon { color: var(--muted); width: 22px; height: 22px; stroke-width: 1.5; }
.drop-title { font-weight: 500; font-size: 14px; color: var(--ink); }
.drop-hint { font-size: 11px; color: var(--muted); font-family: var(--fs-mono); }

/* Icon-only button variant */
.btn.icon-only { padding: 9px; }
.btn.icon-only svg { margin: 0; }

/* Import preview */
.import-summary {
  margin-top: 16px; padding: 14px 16px;
  background: var(--paper); border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.summary-line {
  margin-top: 4px; font-size: 15px; color: var(--ink);
}
.summary-line strong { font-family: var(--fs-display); font-weight: 600; font-size: 18px; }

.preview-list {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--line);
  display: flex; flex-direction: column; gap: 4px;
}
.preview-row {
  display: flex; gap: 8px; font-size: 12px; align-items: baseline; flex-wrap: wrap;
}
.preview-name { color: var(--ink); font-weight: 500; }
.preview-meta { color: var(--muted); font-family: var(--fs-mono); font-size: 11px; }
.preview-more {
  margin-top: 4px; font-size: 11px; color: var(--muted); font-style: italic;
}

.import-actions {
  margin-top: 14px; display: flex; justify-content: flex-end; gap: 8px;
}

.msg svg { width: 12px; height: 12px; vertical-align: -2px; margin-right: 4px; }

@media (max-width: 640px) {
  #app { padding: 20px 16px; }
  .wordmark { font-size: 38px; }
  .detail-title { font-size: 26px; }
  .view-head h2 { font-family: var(--fs-display); font-size: 26px; }
  .header-right { width: 100%; }
  .nav { flex: 1; justify-content: center; }
  .nav-btn span { display: none; }
}
