/* ---------- Logo ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none !important; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand .wordmark { font-family: var(--font-display); font-size: 22px; font-weight: 500; letter-spacing: -0.01em; font-variation-settings: "opsz" 72, "SOFT" 50; }

/* ---------- Buttons ---------- */
.btn {
  --h: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 16px; border-radius: var(--r-md);
  font-weight: 560; font-size: 14px; letter-spacing: -0.005em; white-space: nowrap;
  border: 1px solid transparent; user-select: none; text-decoration: none !important;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-primary { background: linear-gradient(180deg, var(--gold-400), var(--gold)); color: var(--accent-contrast); box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 1px 2px rgba(0,0,0,.2); }
.btn-primary:hover { background: linear-gradient(180deg, var(--gold-300), var(--gold-400)); box-shadow: var(--glow-gold); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { filter: brightness(1.08); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.btn-sm { --h: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { --h: 50px; padding: 0 24px; font-size: 16px; border-radius: 14px; }
.btn-icon { width: var(--h); padding: 0; }
.btn-block { width: 100%; }

/* ---------- Form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 550; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; height: 44px; padding: 0 14px;
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--text) 26%, transparent); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
.input.invalid { border-color: var(--bad); }
.textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%238892a6' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.select-sm, .input-sm { height: 34px; font-size: 13px; border-radius: var(--r-sm); padding-left: 10px; }
.select-sm { padding-right: 30px; background-position: right 9px center; }
.input-group { display: flex; gap: 0; }
.input-group > :first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > :last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.code-input { display: flex; gap: 8px; justify-content: center; }
.code-input input { width: 48px; height: 58px; text-align: center; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; padding: 0; border-radius: 12px; }

.switch { position: relative; display: inline-flex; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); transition: background var(--dur) var(--ease); }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); transition: transform var(--dur) var(--ease-out); }
.switch input:checked + span { background: var(--blue); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: var(--focus); }

/* ---------- Segmented / tabs ---------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; }
.seg button { height: 30px; padding: 0 12px; border-radius: 8px; font-size: 13px; font-weight: 550; color: var(--text-2); white-space: nowrap; transition: all var(--dur) var(--ease); display: inline-flex; align-items: center; gap: 6px; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"], .seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
:root[data-theme="light"] .seg button[aria-pressed="true"] { background: #fff; }
.seg svg { width: 14px; height: 14px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-hd { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.card-hd h3 { font-size: 15px; font-weight: 620; display: flex; align-items: center; gap: 8px; }
.card-hd h3 svg { width: 16px; height: 16px; color: var(--text-3); }
.card-bd { padding: 14px 20px 20px; }
.card-lift { transition: transform .25s var(--ease-out), box-shadow .25s var(--ease-out), border-color .25s; }
.card-lift:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }

/* ---------- Chips & badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--r-full); font-size: 13px; font-weight: 520; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; transition: all var(--dur) var(--ease); }
button.chip:hover, a.chip:hover { color: var(--text); border-color: var(--border-strong); text-decoration: none; }
.chip[aria-pressed="true"], .chip.on { background: var(--blue-soft); color: var(--text); border-color: color-mix(in srgb, var(--blue) 50%, transparent); }
.chip svg { width: 14px; height: 14px; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip-person { padding-left: 3px; height: 30px; }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 11.5px; font-weight: 600; letter-spacing: .01em; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge-gold { background: var(--accent-soft); color: var(--accent-ink); }
.badge-blue { background: var(--blue-soft); color: var(--link); }
.badge-good { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.badge-bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.band { display: inline-flex; gap: 2px; align-items: flex-end; height: 10px; }
.band i { width: 3px; border-radius: 1px; background: var(--border-strong); }
.band i:nth-child(1) { height: 4px; } .band i:nth-child(2) { height: 7px; } .band i:nth-child(3) { height: 10px; }
.band[data-band="weak"] i:nth-child(1), .band[data-band="medium"] i:nth-child(-n+2), .band[data-band="strong"] i { background: var(--accent); }

/* ---------- Avatar ---------- */
.avatar { --s: 36px; width: var(--s); height: var(--s); border-radius: 50%; flex: none; position: relative; display: grid; place-items: center; overflow: hidden;
  font-size: calc(var(--s) * .38); font-weight: 600; letter-spacing: .01em; color: #fff; user-select: none;
  background: var(--av, #2E7DD7); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.xs { --s: 24px; } .avatar.sm { --s: 30px; } .avatar.lg { --s: 56px; } .avatar.xl { --s: 92px; }
.avatar.ring { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.avatar-stack { display: flex; } .avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); margin-left: -8px; } .avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- Rating (stars / fire / ice) ---------- */
.stars { display: inline-flex; align-items: center; gap: 1px; position: relative; }
.stars button { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; color: var(--border-strong); position: relative; transition: transform .12s var(--ease), color .12s; }
.stars button svg { width: 16px; height: 16px; }
.stars button .emo { font-size: 15px; line-height: 1; filter: saturate(1.1); }
.stars button.on { color: var(--accent); }
.stars button.hov { color: var(--gold-300); }
.stars button:hover { transform: scale(1.18); }
.stars.lg button { width: 32px; height: 32px; } .stars.lg button svg { width: 24px; height: 24px; } .stars.lg button .emo { font-size: 22px; }
.stars.readonly button { pointer-events: none; }
.stars .lvl { margin-left: 8px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.stars.compact .lvl { display: none; }
.rating-tip { position: fixed; z-index: 1000; pointer-events: none; padding: 6px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 550; background: var(--text); color: var(--bg); box-shadow: var(--shadow-md); transform: translate(-50%, calc(-100% - 8px)); white-space: nowrap; opacity: 0; transition: opacity .12s; }
.rating-tip.show { opacity: 1; }

/* ---------- Tooltip (CSS) ---------- */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  padding: 5px 9px; border-radius: 7px; background: var(--text); color: var(--bg); font-size: 12px; font-weight: 550; white-space: nowrap; z-index: 50; pointer-events: none; box-shadow: var(--shadow-md);
}
[data-tip-pos="right"]:hover::after { left: calc(100% + 10px); bottom: auto; top: 50%; transform: translateY(-50%); }

/* ---------- Kbd ---------- */
kbd, .kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; font-family: var(--font-ui); font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; }

/* ---------- Code block with copy ---------- */
.codeblock { position: relative; display: flex; align-items: stretch; background: #051024; border: 1px solid rgba(246,243,236,.1); border-radius: 12px; overflow: hidden; color: #E9E5DA; }
:root[data-theme="light"] .codeblock { background: #0B1E3A; }
.codeblock pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-family: var(--font-mono); font-size: 13.5px; line-height: 1.6; flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-all; }
.codeblock pre .p { color: #C9A227; user-select: none; }
.codeblock pre .t { color: #8FC1FF; }
.codeblock .copy { flex: none; align-self: flex-start; margin: 8px; height: 32px; padding: 0 10px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: #E9E5DA; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); transition: all var(--dur); }
.codeblock .copy:hover { background: rgba(255,255,255,.14); }
.codeblock .copy.done { color: #7CE0B5; }
.codeblock .copy svg { width: 14px; height: 14px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 900; background: rgba(3, 10, 22, .62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; animation: fadeIn .18s var(--ease); }
:root[data-theme="light"] .modal-backdrop { background: rgba(11, 30, 58, .32); }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 20px; box-shadow: var(--shadow-lg); animation: popIn .26s var(--ease-out); }
.modal-hd { display: flex; align-items: flex-start; gap: 12px; padding: 22px 22px 6px; }
.modal-hd h2 { font-size: 19px; font-weight: 620; }
.modal-hd p { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.modal-bd { padding: 14px 22px; }
.modal-ft { display: flex; justify-content: flex-end; gap: 10px; padding: 8px 22px 22px; }
.modal .x { margin-left: auto; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Toast ---------- */
.toasts { position: fixed; z-index: 1100; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 12px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 14px; font-weight: 520; box-shadow: var(--shadow-lg); animation: slideUp .24s var(--ease-out); max-width: calc(100vw - 32px); }
.toast svg { width: 18px; height: 18px; flex: none; }
.toast.good svg { color: #1B8A5E; } .toast.bad svg { color: #E66767; }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .2s var(--ease); }
@media (max-width: 860px) { .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); } }

/* ---------- Command palette ---------- */
.cmdk-backdrop { place-items: start center; padding-top: min(14vh, 120px); }
.cmdk { width: min(640px, 100%); background: var(--surface-glass); backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4); border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; animation: popIn .2s var(--ease-out); }
.cmdk-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.cmdk-input svg { width: 18px; height: 18px; color: var(--text-3); flex: none; }
.cmdk-input input { flex: 1; height: 58px; background: transparent; border: 0; outline: none; font-size: 17px; }
.cmdk-list { max-height: min(56vh, 460px); overflow: auto; padding: 6px; }
.cmdk-group { padding: 10px 12px 6px; font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.cmdk-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px; border-radius: 10px; text-align: left; color: var(--text); min-height: 44px; }
.cmdk-item .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.cmdk-item .ic svg { width: 16px; height: 16px; }
.cmdk-item .sub { color: var(--text-3); font-size: 13px; }
.cmdk-item[aria-selected="true"] { background: var(--blue-soft); }
.cmdk-item[aria-selected="true"] .ic { color: var(--text); }
.cmdk-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }
.cmdk-foot span { display: inline-flex; gap: 6px; align-items: center; }
.cmdk-empty { padding: 28px; text-align: center; color: var(--text-3); }

/* ---------- Skeleton / empty ---------- */
.skel { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: 8px; }
.empty { display: grid; place-items: center; text-align: center; gap: 10px; padding: 40px 20px; color: var(--text-2); }
.empty .ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); }
.empty .ic svg { width: 24px; height: 24px; }
.empty h4 { font-size: 15px; color: var(--text); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.demo-pill { position: fixed; z-index: 800; top: 10px; left: 50%; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; font-size: 12px; font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); border-radius: 999px; backdrop-filter: blur(8px); }
.demo-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
