/* Fyndercode design system: tokens, reset and shared components. */
:root {
  --bg: #f6f2e9;
  --bg-2: #efe9db;
  --surface: #ffffff;
  --surface-2: #faf7f1;
  --ink: #1e1519;
  --ink-2: #5e5358;
  --ink-3: #8f848b;
  --line: #e8e0d2;
  --line-2: #f0eadf;
  --wine: #7a2142;
  --wine-2: #5c1530;
  --wine-3: #3d0e1f;
  --blush: #f8e8ed;
  --blush-2: #f0cdd9;
  --ok: #1b8f50;
  --ok-bg: #e5f6ec;
  --warn: #b9700f;
  --warn-bg: #fdf1dc;
  --danger: #cc2f46;
  --danger-bg: #fdebee;
  --info: #2f6fe0;
  --info-bg: #e8f0fd;
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 24px;
  --r-xl: 32px;
  --shadow-sm: 0 1px 2px rgb(60 20 35 / 6%), 0 1px 1px rgb(60 20 35 / 4%);
  --shadow: 0 8px 24px rgb(60 20 35 / 8%), 0 2px 6px rgb(60 20 35 / 5%);
  --shadow-lg: 0 30px 70px rgb(60 20 35 / 18%), 0 8px 20px rgb(60 20 35 / 8%);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
img { display: block; max-width: 100%; }
svg { max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--wine); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--blush-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.display { font-family: var(--display); font-weight: 400; letter-spacing: -0.01em; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.mono { font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--wine); }
.ico { display: inline-block; vertical-align: middle; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: 999px;
  font-weight: 600; font-size: 14.5px; line-height: 1; white-space: nowrap;
  border: 1px solid transparent; transition: transform 0.15s var(--ease), background 0.2s, box-shadow 0.2s, border-color 0.2s, opacity 0.2s;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--wine); color: #fff; box-shadow: 0 6px 18px rgb(122 33 66 / 28%); }
.btn-primary:hover:not(:disabled) { background: var(--wine-2); box-shadow: 0 8px 22px rgb(122 33 66 / 36%); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover:not(:disabled) { background: #000; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn-secondary:hover:not(:disabled) { border-color: var(--blush-2); background: var(--surface-2); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: rgb(30 21 25 / 6%); color: var(--ink); }
.btn-soft { background: var(--blush); color: var(--wine); }
.btn-soft:hover:not(:disabled) { background: var(--blush-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { color: var(--danger); border-color: #f2c5cc; background: var(--surface); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-bg); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 13.5px; }
.btn-lg { min-height: 54px; padding: 0 28px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; min-height: 40px; padding: 0; border-radius: 50%; }
.btn .spinner { width: 16px; height: 16px; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Forms */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12.5px; color: var(--ink-3); }
.input, .textarea, .select {
  width: 100%; min-height: 48px; padding: 0 16px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px;
  transition: border-color 0.2s, box-shadow 0.2s; outline: none;
}
.textarea { padding: 12px 16px; min-height: 96px; resize: vertical; line-height: 1.5; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 40px; }
.input:hover, .textarea:hover, .select:hover { border-color: var(--blush-2); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--wine); box-shadow: 0 0 0 4px rgb(122 33 66 / 12%); }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input-wrap { position: relative; }
.input-wrap .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.input-wrap .input { padding-left: 44px; }
.input-wrap .suffix { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-error { color: var(--danger); font-size: 13.5px; font-weight: 500; min-height: 20px; }
.form-error:empty { display: none; }
.counter { font-size: 12px; color: var(--ink-3); text-align: right; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--ink-2); }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--wine); }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 24px; }
.card-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.divider { height: 1px; background: var(--line); border: 0; margin: 20px 0; }
.stack { display: grid; gap: 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Chips, badges */
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 16px;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface);
  font-weight: 600; font-size: 13.5px; color: var(--ink-2); transition: all 0.2s;
}
.chip:hover { border-color: var(--blush-2); color: var(--ink); }
.chip[aria-pressed="true"], .chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.chips::-webkit-scrollbar { display: none; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  background: var(--blush); color: var(--wine); font-size: 12px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap;
}
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.danger { background: var(--danger-bg); color: var(--danger); }
.tag.info { background: var(--info-bg); color: var(--info); }
.tag.neutral { background: var(--bg-2); color: var(--ink-2); }
.code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 600; letter-spacing: 0.04em;
}
.verified { color: var(--info); display: inline-flex; vertical-align: -3px; }
.count-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--wine); color: #fff;
  font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; line-height: 1;
}
.count-badge:empty { display: none; }

/* Avatar */
.avatar {
  --s: 44px; width: var(--s); height: var(--s); border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--blush-2), var(--blush)); color: var(--wine);
  display: grid; place-items: center; font-weight: 700; font-size: calc(var(--s) * 0.36);
  object-fit: cover; overflow: hidden; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
}
.avatar.lg { --s: 64px; }
.avatar.xl { --s: 112px; }
.avatar.sm { --s: 34px; }
.avatar.locked { background: var(--bg-2); color: var(--ink-3); }

/* Skeleton */
.skeleton { position: relative; overflow: hidden; background: var(--bg-2); border-radius: 12px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 60%), transparent);
  transform: translateX(-100%); animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* Empty / error states */
.state { text-align: center; padding: 56px 24px; display: grid; gap: 10px; justify-items: center; }
.state .state-ico { width: 64px; height: 64px; border-radius: 50%; background: var(--blush); color: var(--wine); display: grid; place-items: center; margin-bottom: 6px; }
.state h3 { font-size: 18px; font-weight: 700; }
.state p { color: var(--ink-2); max-width: 380px; }

/* Notices */
.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px;
  background: var(--info-bg); color: #1e4aa3; font-size: 13.5px; line-height: 1.45;
}
.notice.warn { background: var(--warn-bg); color: #8a5208; }
.notice.danger { background: var(--danger-bg); color: #9d2236; }
.notice.ok { background: var(--ok-bg); color: #146c3c; }
.notice.brand { background: var(--blush); color: var(--wine-2); }
.notice .ico { margin-top: 1px; }

/* Toast */
#toasts { position: fixed; z-index: 1000; left: 0; right: 0; bottom: calc(24px + var(--safe-b)); display: grid; gap: 10px; justify-items: center; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 460px;
  background: var(--ink); color: #fff; padding: 13px 18px; border-radius: 16px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: toast-in 0.35s var(--ease);
}
.toast.error { background: #7b1626; }
.toast.ok .ico { color: #6be39a; }
.toast.out { opacity: 0; transform: translateY(8px); transition: all 0.3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } }

/* Modal / sheet */
.overlay {
  position: fixed; inset: 0; z-index: 500; background: rgb(30 12 20 / 55%); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 20px; animation: fade 0.2s;
  overflow-y: auto;
}
.overlay.sheet-mode { align-items: end; padding: 0; }
.dialog {
  position: relative; width: min(100%, 460px); background: var(--surface); border-radius: 28px;
  padding: 30px; box-shadow: var(--shadow-lg); animation: pop 0.3s var(--ease); margin: auto;
}
.dialog.wide { width: min(100%, 620px); }
.dialog .dialog-close { position: absolute; top: 14px; right: 14px; }
.dialog h2 { font-size: 26px; letter-spacing: -0.02em; line-height: 1.15; }
.dialog .sub { color: var(--ink-2); margin-top: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.97); } }
@media (max-width: 640px) {
  .overlay { align-items: end; padding: 0; }
  .dialog { width: 100%; border-radius: 28px 28px 0 0; padding: 26px 20px calc(26px + var(--safe-b)); animation: sheet 0.32s var(--ease); max-height: 94vh; overflow-y: auto; }
  @keyframes sheet { from { transform: translateY(100%); } }
}

/* Tabs */
.seg { display: inline-flex; padding: 4px; background: var(--bg-2); border-radius: 999px; gap: 2px; }
.seg button { padding: 8px 18px; border-radius: 999px; font-weight: 600; font-size: 13.5px; color: var(--ink-2); transition: all 0.2s; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* Misc */
.progress { height: 6px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--wine); border-radius: 99px; transition: width 0.4s var(--ease); }
.kbd { font: 600 12px ui-monospace, monospace; padding: 2px 6px; background: var(--bg-2); border-radius: 6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
