/* Lupokits design system: tokens (dark + light), base styles and shared components. */
:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Sora', 'Inter', system-ui, sans-serif;
  --wordmark: 'Space Grotesk', 'Sora', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 22px;
  --r-xl: 30px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --lime: #c7f43a;
  --lime-hi: #d8ff63;
  --green: #6ddc2e;
  --ink: #0b0d07;
}

:root, :root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #090a08;
  --bg-elev: #0e100c;
  --surface: #131611;
  --surface-2: #191d16;
  --surface-3: #22271e;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --text: #f1f4ec;
  --text-2: #c9d0c1;
  --muted: #8b9484;
  --brand: var(--lime);
  --brand-hi: var(--lime-hi);
  --brand-ink: var(--ink);
  --brand-text: #c7f43a;
  --brand-soft: rgba(199, 244, 58, 0.12);
  --brand-line: rgba(199, 244, 58, 0.35);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  --warn: #f5b544;
  --warn-soft: rgba(245, 181, 68, 0.13);
  --ok: #57d98b;
  --ok-soft: rgba(87, 217, 139, 0.13);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.6);
  --glass: rgba(14, 16, 12, 0.72);
  --overlay: rgba(4, 5, 3, 0.62);
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f5f6f2;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f2ec;
  --surface-3: #e6e9e1;
  --line: rgba(12, 14, 10, 0.09);
  --line-strong: rgba(12, 14, 10, 0.17);
  --text: #0e100c;
  --text-2: #2f3429;
  --muted: #636b5d;
  --brand: var(--lime);
  --brand-hi: #bdee22;
  --brand-ink: var(--ink);
  --brand-text: #3f7a00;
  --brand-soft: rgba(110, 170, 0, 0.11);
  --brand-line: rgba(80, 140, 0, 0.35);
  --danger: #d93a3a;
  --danger-soft: rgba(217, 58, 58, 0.09);
  --warn: #b7791f;
  --warn-soft: rgba(183, 121, 31, 0.1);
  --ok: #1e9e57;
  --ok-soft: rgba(30, 158, 87, 0.1);
  --shadow-sm: 0 1px 2px rgba(16, 24, 10, 0.06);
  --shadow: 0 1px 2px rgba(16, 24, 10, 0.05), 0 14px 40px rgba(16, 24, 10, 0.08);
  --shadow-lg: 0 30px 80px rgba(16, 24, 10, 0.16);
  --glass: rgba(255, 255, 255, 0.78);
  --overlay: rgba(14, 17, 10, 0.42);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}
a { color: inherit; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { font-family: var(--display); letter-spacing: -0.03em; line-height: 1.08; margin: 0; }
::selection { background: var(--brand); color: var(--brand-ink); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ic { display: block; flex: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------------ logo */
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font: 700 21px/1 var(--wordmark); letter-spacing: -0.045em; color: var(--text); }
.logo img, .logo svg { width: 32px; height: 32px; border-radius: 9px; }
.logo b { font-weight: inherit; }
.logo span { color: var(--brand-text); }

/* ------------------------------------------------------------------ buttons */
.btn {
  --h: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: 600 14px/1 var(--font); text-decoration: none; white-space: nowrap;
  transition: transform .15s var(--ease), background .2s, border-color .2s, box-shadow .2s, color .2s;
}
.btn:hover { border-color: var(--text-2); }
.btn:active { transform: scale(.98); }
.btn:disabled, .btn.disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); box-shadow: 0 0 0 0 var(--brand-soft); }
.btn.primary:hover { background: var(--brand-hi); border-color: var(--brand-hi); box-shadow: 0 8px 28px -6px rgba(199, 244, 58, .55); }
.btn.dark { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.soft { background: var(--surface-2); border-color: transparent; }
.btn.soft:hover { background: var(--surface-3); }
.btn.sm { --h: 32px; padding: 0 12px; font-size: 13px; }
.btn.lg { --h: 52px; padding: 0 26px; font-size: 16px; }
.btn.block { width: 100%; }
.btn.square { border-radius: 12px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--text-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.on { background: var(--brand-soft); color: var(--brand-text); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.icon-btn.xs { width: 26px; height: 26px; border-radius: 7px; }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; }

/* theme toggle */
.theme-toggle { position: relative; width: 58px; height: 32px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface-2); padding: 0; display: inline-flex; align-items: center; }
.theme-toggle i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; transition: transform .35s var(--ease); }
:root[data-theme='light'] .theme-toggle i { transform: translateX(26px); }
.theme-toggle .ic { width: 14px; height: 14px; }

/* ------------------------------------------------------------------ forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.field .hint, .hint { font-size: 12.5px; color: var(--muted); margin: 0; }
.input, .field input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='color']), .field select, .field textarea, select.input, textarea.input {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--bg-elev); color: var(--text); outline: none; transition: border-color .2s, box-shadow .2s;
}
.field textarea, textarea.input { height: auto; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-line); box-shadow: 0 0 0 4px var(--brand-soft); }
.field.req > label::after { content: 'Required'; font-size: 11px; font-weight: 700; color: var(--brand-text); background: var(--brand-soft); padding: 1px 7px; border-radius: 99px; }
.field.missing input, .field.missing textarea { border-color: var(--warn); }
.check { display: inline-flex; gap: 9px; align-items: center; font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--lime); width: 16px; height: 16px; }
input[type='range'] { accent-color: var(--lime); width: 100%; }
.switch { position: relative; display: inline-block; vertical-align: middle; width: 40px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); transition: background .2s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .25s var(--ease); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(16px); background: var(--ink); }

/* ------------------------------------------------------------------ surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; letter-spacing: .01em; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.brand { background: var(--brand); color: var(--brand-ink); }
.badge.soft { background: var(--brand-soft); color: var(--brand-text); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge .ic { width: 12px; height: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line-strong); background: transparent; font-size: 13.5px; font-weight: 500; color: var(--text-2); transition: all .15s; }
.chip:hover { border-color: var(--text-2); color: var(--text); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: inline-flex; gap: 3px; padding: 4px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.kbd { font: 600 11px var(--mono); padding: 2px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font: 700 13px var(--display); flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.skeleton { background: linear-gradient(110deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%); background-size: 300% 100%; animation: shimmer 1.5s linear infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }
.spin { width: 18px; height: 18px; border: 2.5px solid var(--surface-3); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 30px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); font-size: 13.5px; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.notice.brand { background: var(--brand-soft); color: var(--brand-text); }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--lime)); transition: width .2s; }

/* ------------------------------------------------------------------ modal + toast */
.modal-back { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: var(--overlay); backdrop-filter: blur(6px); animation: fadeIn .2s var(--ease); }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); animation: popIn .25s var(--ease); }
.modal.wide { width: min(1000px, 100%); }
.modal.xwide { width: min(1180px, 100%); }
.modal > header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 22px 24px 8px; }
.modal > header h2 { font-size: 21px; }
.modal-body { padding: 6px 24px 24px; overflow-y: auto; }
.modal > footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px 22px; border-top: 1px solid var(--line); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 120; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 9px; padding: 11px 18px; border-radius: 99px; background: var(--text); color: var(--bg); font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg); animation: popIn .25s var(--ease); transition: opacity .35s, transform .35s; max-width: min(620px, 92vw); }
.toast.error .ic { color: var(--danger); }
.toast.success .ic { color: var(--green); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ------------------------------------------------------------------ upgrade modal */
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.plan { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 22px; border-radius: var(--r-lg); border: 1px solid var(--line-strong); background: var(--bg-elev); }
.plan.hl { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.plan .price { font: 700 34px/1 var(--display); letter-spacing: -0.04em; }
.plan .price small { font: 500 14px var(--font); color: var(--muted); letter-spacing: 0; }
.plan ul { list-style: none; padding: 0; margin: 4px 0 8px; display: grid; gap: 8px; font-size: 13.5px; flex: 1; }
.plan li { display: flex; gap: 8px; align-items: flex-start; }
.plan li .ic { color: var(--brand-text); margin-top: 2px; }
.plan li.no { color: var(--muted); }
.plan li.no .ic { color: var(--muted); }
.plan .tag { position: absolute; top: -11px; left: 20px; }

@media (max-width: 760px) {
  .plans { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------- styled dropdowns (js/studio/dropdown.js) */
.dd-native { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0 !important; pointer-events: none !important; overflow: hidden !important; padding: 0 !important; border: 0 !important; }
.dd-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 44px; padding: 0 10px 0 14px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--bg-elev); color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s, background .15s;
}
.dd-btn:hover:not(:disabled) { border-color: var(--text-2); }
.dd-btn:focus-visible, .dd-btn.open { outline: none; border-color: var(--brand-line); box-shadow: 0 0 0 4px var(--brand-soft); }
.dd-btn:disabled { opacity: .55; cursor: not-allowed; }
.dd-btn .dd-val { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-btn > .ic { flex: none; color: var(--muted); transition: transform .2s var(--ease); }
.dd-btn.open > .ic { transform: rotate(180deg); color: var(--brand-text); }
.dd-pop {
  position: fixed; z-index: 1000; display: flex; flex-direction: column; padding: 6px; border-radius: 16px; background: var(--surface);
  border: 1px solid var(--line-strong); box-shadow: 0 18px 48px -12px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .12); animation: ddIn .16s var(--ease);
}
@keyframes ddIn { from { opacity: 0; transform: translateY(-4px) scale(.985); } }
.dd-search { flex: none; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; margin-bottom: 6px; border-radius: 11px; background: var(--surface-2); color: var(--muted); }
.dd-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); font: inherit; font-size: 13.5px; }
.dd-list { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.dd-group { padding: 10px 10px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-family: var(--font); }
.dd-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 10px; font-size: 14px; color: var(--text); cursor: pointer; line-height: 1.25; }
.dd-opt span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-opt.active { background: var(--surface-2); }
.dd-opt.on { color: var(--brand-text); font-weight: 600; }
.dd-opt.on > .ic { flex: none; }
.dd-opt.off { opacity: .45; cursor: not-allowed; }
.dd-pop.fonts .dd-opt { font-size: 18px; padding: 9px 10px; }
.dd-empty { padding: 16px 10px; text-align: center; font-size: 13px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .dd-pop { animation: none; } }

/* ---------------------------------------------------------------- phones: dialogs come up from the bottom as sheets */
@keyframes sheetUp { from { opacity: 0; transform: translateY(48px); } }
@media (max-width: 640px) {
  .modal-back { place-items: end stretch; padding: 0; }
  .modal, .modal.wide, .modal.xwide { width: 100%; max-height: 92vh; border-radius: 24px 24px 0 0; border-bottom: 0; animation: sheetUp .32s var(--ease); }
  .modal > header { padding: 18px 18px 6px; }
  .modal-body { padding: 6px 18px calc(22px + env(safe-area-inset-bottom)); }
  .modal > footer { padding: 12px 18px calc(16px + env(safe-area-inset-bottom)); }
}
@media (max-width: 860px) { .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); } }
