/* css/global.css  -  design tokens, base elements, buttons, forms, dialogs, toasts (shared with the public gallery) */
:root {
  --bg: #f5f6fb; --surface: #ffffff; --surface-2: #eef0f7; --text: #141726; --muted: #646b80; --line: #e2e5ef;
  --accent: #4f5bd5; --accent-hover: #4350c4; --accent-ink: #ffffff; --accent-soft: #eaecfd;
  --ok: #0f9d58; --ok-soft: #e1f5ea; --warn: #a96b00; --warn-soft: #fdf1d6; --danger: #d92d20; --danger-soft: #fdeceb;
  --radius: 16px; --radius-sm: 11px; --shadow: 0 1px 2px rgba(20,23,38,.05), 0 8px 24px rgba(20,23,38,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bp-sm: 720px; --tap: 44px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1018; --surface: #171a26; --surface-2: #1f2333; --text: #eceef7; --muted: #959cb4; --line: #2a2f43;
    --accent: #7c88ff; --accent-hover: #939dff; --accent-ink: #0e1018; --accent-soft: #232852;
    --ok: #3ccf8e; --ok-soft: #12302a; --warn: #f0b84a; --warn-soft: #33290f; --danger: #ff6b60; --danger-soft: #3a1b1a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1018; --surface: #171a26; --surface-2: #1f2333; --text: #eceef7; --muted: #959cb4; --line: #2a2f43;
  --accent: #7c88ff; --accent-hover: #939dff; --accent-ink: #0e1018; --accent-soft: #232852;
  --ok: #3ccf8e; --ok-soft: #12302a; --warn: #f0b84a; --warn-soft: #33290f; --danger: #ff6b60; --danger-soft: #3a1b1a;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; padding-bottom: env(safe-area-inset-bottom, 0px); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -.02em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
.ic { flex: none; vertical-align: middle; }
.offscreen { position: fixed; opacity: 0; pointer-events: none; left: -9999px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; justify-content: center; }
.danger-text { color: var(--danger); } .grow { flex: 1; min-width: 0; }
.container { max-width: 1120px; margin: 0 auto; padding: 20px 16px 96px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 16px; border: 1px solid transparent; border-radius: 12px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; -webkit-tap-highlight-color: transparent; }
.btn:active { transform: scale(.98); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); } .btn.primary:hover { background: var(--accent-hover); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line); } .btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--text); } .btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); color: #fff; } .btn.danger:hover { filter: brightness(.93); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: .88rem; border-radius: 10px; }
.btn.lg { min-height: 52px; font-size: 1.02rem; }
.btn.block { width: 100%; }
.btn.icon { width: var(--tap); padding: 0; } .btn.icon.sm { width: 36px; }

/* forms */
.form, .stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-weight: 600; font-size: .88rem; }
.hint { color: var(--muted); font-size: .82rem; }
.input { width: 100%; min-height: var(--tap); padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; }
textarea.input { resize: vertical; min-height: 96px; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.input.invalid { border-color: var(--danger); }
.input:disabled { opacity: .6; }
.input-wrap { position: relative; } .input-wrap .input { padding-right: 52px; }
.input-wrap .eye { position: absolute; right: 2px; top: 0; }
.form-msg { display: none; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: .9rem; }
.form-msg.show { display: block; }
.grid2 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

/* layout bits */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 20px; } .pad-v { padding: 18px 0; }
.row { display: flex; align-items: center; gap: 12px; } .row.between { justify-content: space-between; } .row.wrap { flex-wrap: wrap; }
.gap-s { gap: 8px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px 0; color: var(--muted); }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 40px 16px; }
.empty-ic { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 4px; }
.empty p { max-width: 38ch; }
.empty .row { margin-top: 10px; }

/* dialogs */
dialog.modal { border: 0; padding: 0; background: var(--surface); color: var(--text); border-radius: var(--radius); width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 24px 80px rgba(0,0,0,.35); overflow: hidden; }
dialog.modal[open] { display: flex; flex-direction: column; animation: pop .16s ease-out; }
dialog.modal.small { width: min(440px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(10,12,22,.55); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 10px 6px 20px; }
.modal-head h2 { font-size: 1.1rem; overflow-wrap: anywhere; }
.modal-body { padding: 8px 20px 16px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 20px 18px; border-top: 1px solid var(--line); }
.modal-foot.inline { border: 0; padding: 4px 0 0; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.sheet-list { display: flex; flex-direction: column; gap: 4px; }
.sheet-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 8px 12px; border: 0; background: transparent; color: var(--text); font: inherit; text-align: left; border-radius: 12px; cursor: pointer; }
.sheet-item:hover { background: var(--surface-2); } .sheet-item.danger { color: var(--danger); }
.sheet-item b { display: block; font-weight: 600; } .sheet-item small { color: var(--muted); }
@media (max-width: 720px) {
  dialog.modal.sheet, dialog.modal.small { margin: auto 0 0; width: 100%; max-width: none; border-radius: 22px 22px 0 0; max-height: 88dvh; padding-bottom: env(safe-area-inset-bottom, 0px); }
}

/* toasts */
.toasts { position: fixed; z-index: 2000; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 520px; padding: 12px 16px; border-radius: 14px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-weight: 500; animation: pop .18s ease-out; }
.toast.error { background: var(--danger); color: #fff; } .toast.success { background: var(--ok); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .25s; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
