:root {
  --paper:  #F5F4EE;
  --ink:    #1F1D1B;
  --clay:   #CC785C;
  --clay-d: #A1543D;
  --sand:   #EBE5D7;
  --border: rgba(20,20,19,0.10);
  --radius: 8px;
  font-family: Inter, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body { min-height: 100vh; background: var(--paper); }

/* ── Nav ──────────────────────────────────────────────────────────────── */
nav {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  background: var(--ink); color: var(--paper);
}
nav a { color: var(--paper); text-decoration: none; font-size: 14px; }
nav a:hover { color: var(--clay); }
nav .brand { font-size: 17px; font-weight: 600; color: var(--clay); }

/* ── Layout ───────────────────────────────────────────────────────────── */
.page { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 6px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: none; transition: background 0.15s;
}
.btn-primary { background: var(--clay); color: #fff; }
.btn-primary:hover { background: var(--clay-d); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--ink); }
.btn-ghost:hover { background: var(--sand); }

/* ── Search ───────────────────────────────────────────────────────────── */
.search-box {
  display: flex; gap: 8px; align-items: center;
}
.search-box input {
  flex: 1; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; background: #fff; outline: none;
}
.search-box input:focus { border-color: var(--clay); }

/* ── Person cards list ────────────────────────────────────────────────── */
.person-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.person-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: border-color 0.15s;
  text-decoration: none; color: var(--ink);
}
.person-item:hover { border-color: var(--clay); }
.person-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--sand); display: flex; align-items: center;
  justify-content: center; font-size: 18px; flex-shrink: 0;
}
.person-info { flex: 1; }
.person-name { font-weight: 600; font-size: 15px; }
.person-dates { font-size: 12px; color: #777; margin-top: 2px; }

/* ── Person profile ───────────────────────────────────────────────────── */
.profile-header {
  display: flex; gap: 24px; align-items: flex-start;
  margin-bottom: 24px;
}
.profile-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--sand); display: flex; align-items: center;
  justify-content: center; font-size: 36px; flex-shrink: 0;
}
.profile-name { font-size: 24px; font-weight: 700; }
.profile-dates { color: #777; margin-top: 4px; }

.relations-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px; margin-top: 24px;
}
.relation-section h3 {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: #777; margin-bottom: 8px;
}

/* ── Tree canvas ──────────────────────────────────────────────────────── */
#tree-container {
  width: 100%; height: calc(100vh - 120px);
  background: var(--sand); border-radius: var(--radius);
  overflow: hidden; position: relative;
}
#tree-svg { width: 100%; height: 100%; }

.tree-node rect {
  fill: #fff; stroke: var(--border); stroke-width: 1.5;
  rx: 6; ry: 6;
}
.tree-node.male rect   { stroke: #6A8CAA; }
.tree-node.female rect { stroke: var(--clay); }
.tree-node text { font-family: Inter, sans-serif; font-size: 11px; fill: var(--ink); }
.tree-node .node-name { font-weight: 600; font-size: 12px; }
.tree-link { fill: none; stroke: var(--clay); stroke-width: 1.5; opacity: 0.5; }

.tree-controls {
  position: absolute; top: 12px; right: 12px;
  display: flex; flex-direction: column; gap: 6px;
}

/* ── Import area ──────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--clay); border-radius: var(--radius);
  padding: 48px 24px; text-align: center;
  color: #777; cursor: pointer; transition: background 0.15s;
}
.drop-zone:hover { background: var(--sand); }
.drop-zone.dragover { background: var(--sand); border-color: var(--clay-d); }

/* ── Stats bar ────────────────────────────────────────────────────────── */
.stats-bar {
  display: flex; gap: 32px; padding: 16px 20px;
  background: var(--sand); border-radius: var(--radius);
  margin-bottom: 24px;
}
.stat-item { text-align: center; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--clay); }
.stat-label { font-size: 12px; color: #777; }

/* ── Upload feedback ──────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 20px; border-radius: 8px;
  font-size: 14px; font-weight: 500;
  background: var(--ink); color: #fff;
  animation: fadeIn 0.2s ease;
  z-index: 999;
}
.toast.success { background: #2d6a4f; }
.toast.error   { background: #9d2020; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }
