:root {
  --bg:          #f6f7f9;
  --surface:     #ffffff;
  --surface-alt: #f9fafb;
  --text:        #111827;
  --muted:       #6b7280;
  --border:      #e5e7eb;
  --accent:      #4f46e5;
  --accent-dark: #4338ca;
  --accent-soft: #eef2ff;
  --danger:      #dc2626;
  --danger-soft: #fef2f2;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-md:   0 4px 12px rgba(16,24,40,.08), 0 2px 4px rgba(16,24,40,.04);
  --shadow-lg:   0 12px 32px rgba(16,24,40,.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #0b0f19;
    --surface:     #131824;
    --surface-alt: #1a2030;
    --text:        #e5e7eb;
    --muted:       #9aa3b2;
    --border:      #262d3d;
    --accent:      #818cf8;
    --accent-dark: #a5b4fc;
    --accent-soft: #1e2438;
    --danger:      #f87171;
    --danger-soft: #2a1a1d;
    --shadow:      0 1px 2px rgba(0,0,0,.3);
    --shadow-md:   0 4px 12px rgba(0,0,0,.35);
    --shadow-lg:   0 12px 32px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Roboto, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { max-width: 860px; margin: 0 auto; padding: 0 1.25rem 4rem; }

/* ── Top bar ───────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.75rem;
}
.topbar-inner {
  max-width: 860px; margin: 0 auto; padding: .8rem 1.25rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand {
  font-weight: 700; font-size: 1.15rem; letter-spacing: -.02em;
  color: var(--text); display: inline-flex; align-items: center; gap: .45rem;
}
.brand:hover { text-decoration: none; }
.brand .dot { color: var(--accent); }

.nav { display: flex; align-items: center; gap: .25rem; margin-left: auto; flex-wrap: wrap; }
.nav a {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .4rem .7rem; border-radius: var(--radius-sm);
  color: var(--muted); font-size: .9rem; font-weight: 500;
}
.nav a:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent-dark); }
.nav .sep { width: 1px; height: 20px; background: var(--border); margin: 0 .35rem; }

/* ── Group chips ───────────────────────────────────────────── */
.groups { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.groups .label {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; margin-right: .25rem;
}
.chip {
  padding: .3rem .75rem; border-radius: 999px; font-size: .85rem; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  transition: border-color .12s, color .12s, background .12s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on:hover { color: #fff; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.5rem; margin-bottom: 1.25rem;
}
.card h2 { margin: 0 0 1.15rem; font-size: 1.05rem; letter-spacing: -.01em; }

/* ── Profile header ────────────────────────────────────────── */
.profile { text-align: center; padding: 2.25rem 1.5rem; }
.profile h1 {
  margin: 0 0 .35rem; font-size: 1.9rem; letter-spacing: -.03em;
  display: inline-flex; align-items: center; gap: .5rem;
}
.profile h1 .edit { color: var(--muted); display: inline-flex; }
.profile h1 .edit:hover { color: var(--accent); }
.profile .contact {
  display: flex; justify-content: center; gap: 1.25rem; flex-wrap: wrap;
  color: var(--muted); font-size: .92rem; margin-bottom: .9rem;
}
.profile .contact span { display: inline-flex; align-items: center; gap: .3rem; }
.profile .bio { margin: 0 auto; max-width: 52ch; color: var(--muted); }

/* ── Sortable CV items ─────────────────────────────────────── */
.items { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; align-items: flex-start; gap: .9rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem; margin-bottom: .75rem;
  transition: box-shadow .12s, border-color .12s;
}
.item:hover { box-shadow: var(--shadow-md); }
.item .handle {
  cursor: grab; color: var(--border); flex: 0 0 auto; margin-top: .1rem;
  transition: color .12s;
}
.item:hover .handle { color: var(--muted); }
.item .handle:active { cursor: grabbing; }
.item .body { flex: 1 1 auto; min-width: 0; }
.item .title { font-weight: 600; margin-bottom: .2rem; }
.item .info { color: var(--muted); font-size: .93rem; overflow-wrap: anywhere; }
.item .tools { display: flex; gap: .15rem; flex: 0 0 auto; align-items: center; }
.item .tools a, .iconbtn {
  display: inline-flex; padding: .35rem; border-radius: var(--radius-sm);
  color: var(--muted); background: none; border: 0; cursor: pointer;
  font: inherit; line-height: 1;
}
.item .tools a:hover, .iconbtn:hover { background: var(--surface-alt); color: var(--accent); }
.iconbtn.del:hover { background: var(--danger-soft); color: var(--danger); }

/* Drag feedback */
.item.ui-sortable-helper { box-shadow: var(--shadow-lg); border-color: var(--accent); }
.ui-sortable-placeholder {
  visibility: visible !important;
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: transparent; margin-bottom: .75rem;
}

/* ── Forms ─────────────────────────────────────────────────── */
.field { margin-bottom: 1.1rem; }
.field label {
  display: block; font-size: .82rem; font-weight: 600;
  color: var(--text); margin-bottom: .35rem;
}
.input, .textarea, .select {
  font: inherit; width: 100%; padding: .6rem .75rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.select { appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.25rem;
}

/* ── Buttons ───────────────────────────────────────────────── */
.actions { display: flex; gap: .6rem; align-items: center; margin-top: 1.4rem; }
.btn {
  font: inherit; font-size: .92rem; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  height: 40px; padding: 0 1.1rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-alt); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

/* ── Misc ──────────────────────────────────────────────────── */
.empty {
  text-align: center; color: var(--muted); padding: 3rem 1.5rem;
  border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty p { margin: 0 0 1rem; }
.grouplist { list-style: none; margin: 0; padding: 0; }
.grouplist li {
  padding: .7rem 0; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .5rem;
}
.grouplist li:last-child { border-bottom: 0; }
.material-symbols-outlined, .material-symbols-rounded {
  font-size: 20px; line-height: 1; vertical-align: middle;
}

/* ── Auth pages ────────────────────────────────────────────── */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1.5rem;
}
.auth { width: 100%; max-width: 380px; }
.auth-brand {
  text-align: center; font-weight: 700; font-size: 1.4rem;
  letter-spacing: -.02em; margin-bottom: 1.1rem;
}
.auth-brand .dot { color: var(--accent); }
.auth .card { margin-bottom: 0; }
.auth-alt {
  margin: 1.2rem 0 0; text-align: center;
  color: var(--muted); font-size: .88rem;
}
.btn.block { width: 100%; }
.alert {
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  padding: .65rem .8rem; border-radius: var(--radius-sm);
  font-size: .88rem; margin-bottom: 1.1rem;
}
.or {
  display: flex; align-items: center; gap: .7rem;
  margin: 1.15rem 0; color: var(--muted); font-size: .8rem;
}
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Passkeys ──────────────────────────────────────────────── */
.hint { color: var(--muted); font-size: .85rem; margin: 0 0 1rem; }
.pk-msg {
  color: var(--muted); font-size: .85rem;
  margin-top: .6rem; min-height: 1.15em;
}
.pk-msg--err { color: var(--danger); }
.pk-msg--ok  { color: #059669; }
.pk-del { height: 32px; padding: 0 .75rem; font-size: .85rem; }
.pk-del:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

/* ── Shared / print CV ─────────────────────────────────────── */
.sheet {
  max-width: 760px; margin: 2.5rem auto; padding: 3rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
}
.sheet .entry { padding: 1.25rem 0; border-bottom: 1px solid var(--border); }
.sheet .entry:last-child { border-bottom: 0; }
.sheet .entry .title { font-weight: 600; margin-bottom: .25rem; }
.sheet .entry .info { color: var(--muted); }

@media print {
  body { background: #fff; }
  .topbar, .groups, .tools, .btn { display: none !important; }
  .sheet { margin: 0; padding: 0; border: 0; box-shadow: none; max-width: none; }
  .card, .item { box-shadow: none; border-color: #ddd; break-inside: avoid; }
}

@media (max-width: 640px) {
  .shell { padding: 0 1rem 3rem; }
  .card, .profile { padding: 1.25rem; }
  .sheet { padding: 1.5rem; margin: 1rem; }
  .nav { width: 100%; margin-left: 0; }
  .actions { flex-wrap: wrap; }
}
