/* Kursinama heritage stylesheet */
:root {
  --bg: #f7f1e3;
  --bg-alt: #ede2c8;
  --bg-card: #fff9ec;
  --ink: #1f1410;
  --primary: #7a1f1f;
  --primary-dark: #5a1414;
  --gold: #b58c3d;
  --forest: #2d4a3e;
  --border: #d9c9a3;
  --border-soft: #e2d3ad;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --body: 'Crimson Pro', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 4rem;
}
img { max-width: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topband {
  height: 6px;
  background: linear-gradient(90deg, var(--primary), var(--gold), var(--primary));
}

.site-header {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand-eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
.site-header h1 {
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0.25rem 0 0;
  line-height: 1.1;
}
.user-chip {
  font-size: 0.85rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.user-chip a { color: var(--gold); font-size: 0.8rem; }

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tabs a {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  white-space: nowrap;
  color: rgba(31, 20, 16, 0.6);
  border-bottom: 2px solid transparent;
}
.tabs a:hover { text-decoration: none; color: var(--primary); }
.tabs a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1rem 6rem;
}

.flash-stack { padding: 0.75rem 1rem; max-width: 720px; margin: 0 auto; }
.flash {
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.flash-success { background: #e8f0e8; border-color: var(--forest); color: var(--forest); }
.flash-error { background: #fbe5e5; border-color: var(--primary); color: var(--primary); }
.flash-info { background: var(--bg-card); }

/* Login */
.login-wrap {
  max-width: 380px;
  margin: 2rem auto;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.login-wrap h2 {
  font-family: var(--serif);
  color: var(--primary);
  margin: 0 0 1rem;
  font-size: 1.6rem;
}

/* Forms */
.form-stack label, .form-grid label {
  display: block;
  margin-bottom: 0.75rem;
}
.form-stack label span, .form-grid label span {
  display: block;
  font-size: 0.78rem;
  opacity: 0.7;
  margin-bottom: 0.25rem;
}
input[type=text], input[type=password], input[type=email], input[type=date],
input[type=search], input[type=file], select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font-family: var(--body);
  font-size: 0.95rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(181, 140, 61, 0.2);
}
textarea { resize: vertical; min-height: 90px; }
.full-select { width: 100%; }
.checkbox-line { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; margin: 0.5rem 0; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label.highlight input { background: #fff5d6; border-color: var(--gold); }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.65rem 1.1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--ink);
  font-family: var(--body);
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--bg); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border-color: var(--gold); color: var(--primary); }
.btn-danger-outline { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-dashed { background: transparent; border: 1px dashed var(--gold); color: var(--primary); width: 100%; }
.btn-block { width: 100%; }
.btn-grow { flex: 2; }
.btn-tiny { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

.save-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 0.75rem 0;
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Search */
.search-bar { margin-bottom: 1rem; }
.search-bar input[type=search] { background: var(--bg-card); }

/* Cards */
.card-list { display: flex; flex-direction: column; gap: 0.5rem; }
.person-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.08s;
}
.person-card:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.person-card-body { flex: 1; min-width: 0; }
.person-card-name {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--primary);
}
.person-card-name .alias {
  font-size: 0.75rem;
  font-style: italic;
  font-family: var(--body);
  opacity: 0.6;
  margin-left: 0.25rem;
  font-weight: normal;
}
.person-card-name .dec {
  font-size: 0.7rem;
  opacity: 0.5;
  margin-left: 0.25rem;
}
.person-card-sub {
  font-size: 0.78rem;
  opacity: 0.7;
  margin-top: 0.1rem;
}
.person-card-compact .person-card-name { font-size: 0.95rem; }
.chevron { color: var(--gold); font-size: 1.2rem; opacity: 0.5; }

.avatar {
  border-radius: 50%;
  background: var(--bg-alt);
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar span {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--primary);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
}
.empty-state h2 {
  font-family: var(--serif);
  font-size: 1.6rem;
  color: var(--primary);
  margin: 1rem 0 0.5rem;
}
.empty-state p { opacity: 0.7; font-style: italic; margin-bottom: 1.5rem; }

/* FAB */
.fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 100;
}
.fab:hover { background: var(--primary-dark); text-decoration: none; color: var(--bg); }

/* Profile detail */
.back-link {
  display: inline-block;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--gold);
  opacity: 0.85;
}
.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.profile-head {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.profile-meta { flex: 1; min-width: 0; }
.profile-meta h2 {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0;
  line-height: 1.15;
}
.alias-line { font-style: italic; font-size: 0.9rem; opacity: 0.7; margin: 0.25rem 0; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }
.chip {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  background: var(--bg-alt);
  border-radius: 12px;
  text-transform: lowercase;
}
.chip-dec { background: var(--primary); color: var(--bg); }
.chip-ok { background: var(--forest); color: var(--bg); }
.profile-actions { display: flex; gap: 0.5rem; }

/* Section */
.section { margin: 1.5rem 0; }
.section h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--gold);
  font-weight: 600;
  margin: 0 0 0.5rem 0.25rem;
}
.info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}
.info-grid > div {
  background: var(--bg-card);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
  font-size: 0.9rem;
}
.info-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.5;
  margin-bottom: 0.1rem;
}
.muted-italic { color: rgba(31, 20, 16, 0.5); font-style: italic; padding: 0.25rem; font-size: 0.9rem; }
.muted-small { font-size: 0.8rem; opacity: 0.7; }
.muted-label { font-size: 0.7rem; text-transform: uppercase; opacity: 0.6; }
.muted-tiny { font-size: 0.65rem; opacity: 0.6; }
.muted { opacity: 0.6; }
.center { text-align: center; }
.small { font-size: 0.85rem; }
.leading { line-height: 1.6; }

/* Marriage cards (detail) */
.marriage-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.marriage-heart { color: var(--primary); font-size: 1.1rem; }
.marriage-body { flex: 1; }
.spouse-name, .spouse-link {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--primary);
}
.spouse-family { font-size: 0.8rem; color: var(--gold); font-weight: 600; margin-top: 0.15rem; }
.marriage-details { font-size: 0.8rem; opacity: 0.75; margin-top: 0.4rem; line-height: 1.6; }
.marriage-details .ended { color: var(--primary); }

/* Marriage form rows */
.marriage-form-row {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}
.marriage-form-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.remove-marriage {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
}
.external-spouse .hint {
  font-size: 0.8rem;
  font-style: italic;
  opacity: 0.65;
  margin: 0.5rem 0 0.5rem;
}
.photo-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.small-toggle { font-size: 0.8rem; margin-left: 0.5rem; opacity: 0.6; }

.notes {
  white-space: pre-wrap;
  line-height: 1.6;
  background: var(--bg-card);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
}

/* Tree */
.focal-picker { margin-bottom: 1rem; }
.tree-canvas {
  text-align: center;
  overflow-x: auto;
  padding: 1rem 0;
}
.tree-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin: 0.5rem 0;
}
.tree-line {
  width: 1px;
  height: 1.25rem;
  background: var(--gold);
  margin: 0 auto;
}
.tree-node {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  max-width: 100px;
}
.tree-node:hover { background: var(--bg-card); text-decoration: none; }
.tree-node-focal { background: var(--bg-alt); }
.tree-label {
  font-family: var(--serif);
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}
.tree-node-focal .tree-label { font-weight: 700; color: var(--primary); font-size: 0.9rem; }
.tree-focal-tag {
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 0.1rem;
}
.tree-external {
  background: var(--bg-alt);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-style: italic;
  align-self: center;
}

/* Check / relation */
.info-banner {
  background: var(--bg-alt);
  border: 1px solid var(--gold);
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}
.info-banner strong {
  font-family: var(--serif);
  color: var(--primary);
  font-size: 1.05rem;
  display: block;
  margin-bottom: 0.25rem;
}
.info-banner p { margin: 0; font-size: 0.85rem; opacity: 0.8; }
.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  padding: 0.85rem 1rem;
  border-radius: 8px;
}
.result-ok {
  background: #e8f0e8;
  border: 1px solid var(--forest);
  padding: 0.85rem 1rem;
  border-radius: 8px;
}
.result-ok strong {
  font-family: var(--serif);
  color: var(--forest);
  font-size: 1.05rem;
  display: block;
  margin-bottom: 0.25rem;
}
.result-warn {
  background: #fff5e6;
  border: 1px solid var(--primary);
  padding: 0.85rem 1rem;
  border-radius: 8px;
}
.result-warn strong {
  font-family: var(--serif);
  color: var(--primary);
  font-size: 1.05rem;
  display: block;
  margin-bottom: 0.25rem;
}
.match-list { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.75rem; }
.match-item {
  background: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
}
.match-name { font-family: var(--serif); font-weight: 600; }
.match-sub { font-size: 0.78rem; opacity: 0.7; margin-top: 0.15rem; }
.match-reason { font-size: 0.78rem; color: var(--primary); margin-top: 0.15rem; }

.relation-result {
  background: var(--bg-card);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
  margin-top: 1rem;
}
.rel-avatars {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.rel-heart { color: var(--primary); font-size: 1.3rem; }
.rel-eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.3rem;
}
.rel-label {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
}
.rel-detail { font-style: italic; opacity: 0.7; font-size: 0.9rem; margin: 0.4rem 0 0; }
.rel-names { margin-top: 0.75rem; font-size: 0.85rem; opacity: 0.7; }

/* Users table */
.user-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.user-table th, .user-table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border-soft);
}
.user-table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  background: var(--bg-card);
}

/* Error / footer */
.error-page { text-align: center; padding: 2rem 1rem; }
.error-page h2 { color: var(--primary); font-family: var(--serif); }
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.75rem;
  opacity: 0.5;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}
.page-title { font-family: var(--serif); color: var(--primary); font-size: 1.5rem; font-weight: 600; margin: 0 0 1rem; }

/* Mobile tweaks */
@media (max-width: 480px) {
  .site-header h1 { font-size: 1.5rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label.full { grid-column: 1; }
}
