:root {
  color-scheme: light;
  --paper: #f7f3ec;
  --card: #fffdf8;
  --ink: #241c14;
  --muted: #6e6256;
  --line: #e4d7c6;
  --green: #1e6b45;
  --green-soft: #e7f3ec;
  --pending: #c56a32;
  --pending-bg: #f8ecdc;
  --pending-ink: #6a3d18;
  --danger: #9f3d3d;
  --danger-bg: #fbeeee;
  --shadow: 0 12px 30px rgba(70, 48, 20, 0.08);
}

* { box-sizing: border-box; }

html { font-size: 17px; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1000px 420px at 0% -10%, #efe4cf 0%, transparent 55%),
    radial-gradient(800px 380px at 100% 0%, #e5f2ea 0%, transparent 50%),
    var(--paper);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  line-height: 1.4;
}

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

button:disabled { opacity: 0.55; cursor: default; }

button:focus-visible,
.card:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #b7d8c6;
  outline-offset: 2px;
}

h1, h2, h3, .brand-name {
  font-family: Palatino, "Palatino Linotype", "Iowan Old Style", Georgia, serif;
  font-weight: 600;
  line-height: 1.15;
}

h1, h2, h3, p { margin: 0; }

.hidden { display: none !important; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.logo { width: 36px; height: 36px; flex: none; }

.brand { display: flex; align-items: center; gap: 10px; }

.brand-name { font-size: 1.45rem; }

.brand-sub { color: var(--muted); font-size: 0.86rem; }

.shell {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  padding: 14px 18px;
  background: rgba(255, 253, 248, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.search { flex: 1 1 180px; max-width: 280px; }

.search input,
.field input,
.field select,
.field textarea,
.inline input,
.inline select {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  padding: 10px 12px;
}

.field textarea { min-height: 90px; resize: vertical; }

.legend, .toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.legend { gap: 14px; }

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  display: inline-block;
}

.swatch.ok { background: var(--green); }

.swatch.wait { background: var(--pending); }

.toolbar, .row-actions, .zoombar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

button.primary,
button.ghost,
button.warn,
button.danger,
button.tiny {
  border-radius: 12px;
  padding: 10px 14px;
}

button.primary { background: var(--green); color: white; border: 0; }

button.ghost { background: transparent; border: 1px solid var(--line); }

button.warn { background: var(--pending); color: white; border: 0; }

button.danger { background: transparent; color: var(--danger); border: 1px solid #e7c1c1; }

button.tiny { padding: 6px 10px; font-size: 0.86rem; }

button.wide { width: 100%; }

.badge {
  display: inline-flex;
  min-width: 1.4em;
  justify-content: center;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: white;
  color: var(--pending);
  font-size: 0.8rem;
  font-weight: 700;
}

.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
}

.board-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.board {
  flex: 1;
  overflow: auto;
  cursor: grab;
}

.board.is-panning { cursor: grabbing; user-select: none; }

.board-scale {
  box-sizing: content-box;
  padding: max(72px, 10vh) max(80px, 8vw);
}

.board-inner { position: relative; transform-origin: 0 0; }

.board-inner svg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: visible;
}

.zoombar {
  position: absolute;
  z-index: 3;
  right: 16px;
  bottom: 16px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.zoombar button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: white;
}

.zoombar .ghost { width: auto; border-radius: 999px; }

.card {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 6px solid var(--green);
  border-radius: 16px;
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
}

.card .name {
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .years, .card-foot { color: var(--muted); font-size: 0.82rem; }

.card-foot {
  min-height: 1.2em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-main { display: flex; gap: 10px; align-items: center; }

.avatar {
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-weight: 700;
  object-fit: cover;
}

.board-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 10px 16px 0;
}

.view-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #f6f1e8;
  border-radius: 14px;
}

.view-switch button {
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 8px 14px;
}

.view-switch button.active {
  background: white;
  color: var(--green);
  font-weight: 700;
}

.photos { display: flex; flex-direction: column; gap: 10px; }

.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.photo-item { width: 96px; }

.photo-thumb {
  width: 96px;
  height: 96px;
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f6f1e8;
}

.photo-thumb img, .photo-open img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-open {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.photo-open img {
  height: 220px;
  border-radius: 16px;
  object-fit: cover;
  background: #f6f1e8;
}

.card.selected { outline: 3px solid var(--green); outline-offset: 3px; }

.card.is-pending {
  background: var(--pending-bg);
  border: 1.5px dashed var(--pending);
  border-left: 6px solid var(--pending);
  color: var(--pending-ink);
}

.card.is-pending .avatar { background: #e7c4a4; color: var(--pending-ink); }

.card.is-pending .years,
.card.is-pending .card-foot { color: var(--pending-ink); font-weight: 700; }

.card.is-pending.selected { outline-color: var(--pending); }

.card.has-edit { box-shadow: inset 0 0 0 2px #e7c09a, var(--shadow); }

.card.has-edit .card-foot { color: var(--pending-ink); font-weight: 700; }

.card.has-delete {
  background: var(--danger-bg);
  border-left-color: var(--danger);
}

.card.has-delete .card-foot { color: var(--danger); font-weight: 700; }

.card.has-delete .avatar { background: var(--danger); }

.card.dimmed { opacity: 0.28; }

.card.matched { outline: 3px solid var(--green); outline-offset: 3px; }

.panel {
  width: 400px;
  flex: none;
  overflow: auto;
  background: var(--card);
  border-left: 1px solid var(--line);
}

.panel-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border-bottom: 1px solid #f0e6d8;
}

.panel-body, .stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-body { padding: 16px; }

.panel-body.is-fiche { padding: 0 0 28px; gap: 0; }

.fiche {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px 0;
}

.fiche h3 { font-size: 1.05rem; }

.fiche-actions .primary { width: 100%; }

.hero-photo {
  display: block;
  width: 100%;
  height: 230px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #f3ece3;
  overflow: hidden;
}

.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 28%;
}

.hero-photo.is-empty {
  height: 148px;
  color: var(--muted);
}

.photo-tools { padding: 10px 18px 0; display: flex; flex-direction: column; gap: 8px; }

.photo-strip { display: flex; gap: 8px; overflow-x: auto; }

.photo-thumb {
  width: 54px;
  height: 54px;
  padding: 0;
  flex: none;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  background: #f6f1e8;
}

.photo-thumb.is-shown { border-color: var(--green); }

.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.kin-list { display: flex; flex-direction: column; }

.kin {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 11px 2px;
  border: 0;
  border-bottom: 1px solid #f0e6d8;
  background: transparent;
  border-radius: 0;
}

.kin-role { color: var(--muted); font-size: 0.86rem; }

.kin-name { font-weight: 700; }

.kin-note { color: var(--pending); font-size: 0.78rem; }

.add-grid { display: flex; flex-wrap: wrap; gap: 8px; }

.fold {
  border-top: 1px solid #f0e6d8;
  padding-top: 8px;
}

.fold summary {
  cursor: pointer;
  color: var(--muted);
  padding: 6px 0;
}

.fold .stack { margin-top: 10px; }

.text-danger {
  align-self: flex-start;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--danger);
}

.is-ghost { z-index: 3; }

.board-inner svg { transition: none; }

.life, .hint, .muted { color: var(--muted); }

.hint { font-size: 0.92rem; }

.notes { white-space: pre-wrap; }

.proposal-box, .link-row, .review-item, .user-row, .code-banner {
  border: 1px solid #f0e6d8;
  border-radius: 14px;
  padding: 12px;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.proposal-box {
  background: var(--pending-bg);
  border: 1px dashed var(--pending);
}

.proposal-box.is-delete {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.diff-label { font-size: 0.82rem; color: var(--muted); }

.before { color: var(--muted); text-decoration: line-through; }

.after {
  background: #f3d7b5;
  color: var(--pending-ink);
  border-radius: 8px;
  padding: 4px 8px;
}

.person-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--green);
  text-align: left;
  font-weight: 700;
}

.field, .check { display: flex; gap: 6px; }

.field { flex-direction: column; font-size: 0.92rem; color: #4e453c; }

.check { align-items: center; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

fieldset.also {
  margin: 0;
  border: 1px solid #f0e6d8;
  border-radius: 12px;
  padding: 10px 12px;
}

.code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 1.5rem;
  letter-spacing: 0.14em;
  background: var(--pending-bg);
  color: var(--pending-ink);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.form-error {
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: 10px;
  padding: 8px 10px;
}

.empty {
  margin: auto;
  max-width: 460px;
  padding: 48px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.empty .logo { width: 64px; height: 64px; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card {
  width: min(480px, 100%);
  background: var(--card);
  border-radius: 24px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #f6f1e8;
  border-radius: 14px;
}

.tab {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 12px 8px;
  font-size: 1.05rem;
}

.code-entry {
  font-size: 1.7rem;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
  padding: 16px 12px;
  font-weight: 700;
}

.code-entry.small {
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  padding: 12px;
}

button.big {
  padding: 16px 18px;
  font-size: 1.15rem;
}

.or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  margin: 2px 0;
}

.or::before,
.or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.account-block {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tab.active { background: white; color: var(--green); font-weight: 700; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 20;
  max-width: min(520px, calc(100% - 24px));
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}

body.busy { cursor: progress; }

@media (max-width: 860px) {
  .workspace { flex-direction: column; height: auto; }
  .board { height: 68vh; }
  .shell.panel-open .board { height: 42vh; }
  .panel { width: 100%; border-left: 0; border-top: 1px solid var(--line); }
  .split { grid-template-columns: 1fr; }
}
