/* ==========================================================================
   UniPass theme layer — design tokens + overrides for Tailwind utilities.
   Loaded after styles.css. `html` prefixes beat the Tailwind CDN on ties.
   ========================================================================== */

:root {
  --brand-50: 239 246 255; --brand-100: 219 234 254; --brand-200: 191 219 254; --brand-300: 147 197 253; --brand-400: 96 165 250;
  --brand-500: 59 130 246; --brand-600: 37 99 235; --brand-700: 29 78 216; --brand-800: 30 64 175; --brand-900: 30 58 138;

  --bg: 244 246 250;
  --surface: 255 255 255;
  --surface-2: 247 248 251;
  --surface-3: 238 241 246;
  --line: 228 232 239;
  --line-soft: 238 241 246;
  --line-strong: 206 213 224;
  --ink: 15 23 42;
  --ink-2: 44 56 76;
  --ink-3: 71 85 105;
  --muted: 100 116 139;
  --faint: 148 163 184;
  --faint-2: 203 213 225;

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px;
  --shadow-card: 0 1px 2px rgb(15 23 42 / .04), 0 6px 20px -8px rgb(15 23 42 / .08);
  --shadow-hover: 0 2px 4px rgb(15 23 42 / .04), 0 18px 40px -14px rgb(var(--brand-800) / .28);
  --shadow-pop: 0 30px 80px -20px rgb(15 23 42 / .35);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: light;
}

html.dark {
  --bg: 9 12 19;
  --surface: 17 22 33;
  --surface-2: 22 28 42;
  --surface-3: 29 36 52;
  --line: 37 45 63;
  --line-soft: 29 36 52;
  --line-strong: 52 62 84;
  --ink: 236 240 247;
  --ink-2: 205 212 225;
  --ink-3: 170 180 197;
  --muted: 140 152 172;
  --faint: 104 116 138;
  --faint-2: 72 82 102;
  --shadow-card: 0 0 0 1px rgb(255 255 255 / .02), 0 10px 30px -12px rgb(0 0 0 / .6);
  --shadow-hover: 0 0 0 1px rgb(var(--brand-400) / .18), 0 22px 50px -18px rgb(0 0 0 / .8);
  --shadow-pop: 0 30px 90px -20px rgb(0 0 0 / .8);
  color-scheme: dark;
}

/* ---------- Personalization: font size, radius, motion ---------- */
html[data-font="sm"] { font-size: 14.5px; }
html[data-font="md"] { font-size: 16px; }
html[data-font="lg"] { font-size: 17.5px; }

html[data-radius="sharp"] { --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 10px; }
html[data-radius="round"] { --r-sm: 12px; --r-md: 16px; --r-lg: 22px; --r-xl: 30px; }
html .rounded-lg { border-radius: var(--r-sm); }
html .rounded-xl { border-radius: var(--r-md); }
html .rounded-2xl { border-radius: var(--r-lg); }
html .rounded-3xl { border-radius: var(--r-xl); }
html .rounded-t-3xl { border-top-left-radius: var(--r-xl); border-top-right-radius: var(--r-xl); }

html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after {
  animation: none !important; transition: none !important; scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  html *, html *::before, html *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Base ---------- */
html, html body { font-family: 'Be Vietnam Pro', 'Inter', system-ui, sans-serif; }
html body {
  background:
    radial-gradient(1100px 520px at 0% -10%, rgb(var(--brand-400) / .12), transparent 60%),
    radial-gradient(900px 480px at 100% -5%, rgb(var(--brand-600) / .08), transparent 55%),
    rgb(var(--bg)) !important;
  background-attachment: fixed !important;
  color: rgb(var(--ink-2)) !important;
  transition: background-color .35s var(--ease), color .35s var(--ease);
}
html.dark body {
  background:
    radial-gradient(1100px 520px at 0% -10%, rgb(var(--brand-600) / .16), transparent 60%),
    radial-gradient(900px 480px at 100% -5%, rgb(var(--brand-800) / .14), transparent 55%),
    rgb(var(--bg)) !important;
  background-attachment: fixed !important;
}
html *, html ::before, html ::after { border-color: rgb(var(--line)); }
::selection { background: rgb(var(--brand-500) / .3); color: inherit; }
html h1, html h2, html h3 { letter-spacing: -.02em; text-wrap: balance; }

/* Smooth color crossfade when switching theme */
html .bg-white, html .bg-slate-50, html .bg-slate-100, html article, html header, html footer, html input, html select, html textarea {
  transition-property: background-color, border-color, color, box-shadow, transform;
  transition-duration: .3s;
  transition-timing-function: var(--ease);
}

/* ---------- Neutral utilities → tokens ---------- */
html .bg-white { background-color: rgb(var(--surface)); }
html .bg-slate-50, html .bg-slate-50\/50, html .bg-slate-50\/20 { background-color: rgb(var(--surface-2)); }
html .bg-slate-100 { background-color: rgb(var(--surface-3)); }
html .bg-slate-200 { background-color: rgb(var(--line)); }
html .hover\:bg-slate-50:hover, html .hover\:bg-slate-100:hover { background-color: rgb(var(--surface-3)); }
html .border-slate-100 { border-color: rgb(var(--line-soft)); }
html .border-slate-200 { border-color: rgb(var(--line)); }
html .border-slate-300 { border-color: rgb(var(--line-strong)); }
html .divide-slate-100 > :not([hidden]) ~ :not([hidden]) { border-color: rgb(var(--line-soft)); }
html .text-slate-900, html .text-slate-800 { color: rgb(var(--ink)); }
html .text-slate-700 { color: rgb(var(--ink-2)); }
html .text-slate-600, html .hover\:text-slate-600:hover { color: rgb(var(--ink-3)); }
html .text-slate-500 { color: rgb(var(--muted)); }
html .text-slate-400 { color: rgb(var(--faint)); }
html .text-slate-300 { color: rgb(var(--faint-2)); }
html .placeholder\:text-slate-400::placeholder, html input::placeholder, html textarea::placeholder { color: rgb(var(--faint)); }
/* Dark chrome (admin header, toasts) keeps its readable greys */
html .bg-slate-900 .text-slate-400, html .bg-slate-800 .text-slate-400, html .bg-slate-900 .text-slate-300 { color: #94a3b8; }
html .bg-slate-900 .text-slate-100 { color: #f1f5f9; }
html.dark .bg-slate-900 { background-color: #070a10; }
html.dark .bg-slate-800 { background-color: #0d121c; }

html input:not([type="file"]):not([type="checkbox"]):not([type="radio"]),
html select, html textarea { color: rgb(var(--ink)); }
html.dark input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([class*="bg-"]),
html.dark select:not([class*="bg-"]), html.dark textarea:not([class*="bg-"]) { background-color: rgb(var(--surface-2)); }
html input:disabled { opacity: .75; }

/* ---------- Tinted chips in dark mode ---------- */
html.dark .bg-brand-50, html.dark .bg-blue-50, html.dark .bg-sky-50, html.dark .bg-blue-50\/70 { background-color: rgb(var(--brand-500) / .14); }
html.dark .bg-brand-100, html.dark .bg-blue-100 { background-color: rgb(var(--brand-500) / .22); }
html.dark .hover\:bg-brand-50:hover, html.dark .hover\:bg-brand-100:hover, html.dark .hover\:bg-blue-50:hover, html.dark .hover\:bg-blue-50\/40:hover { background-color: rgb(var(--brand-500) / .2); }
html.dark .text-brand-700, html.dark .text-brand-800, html.dark .text-brand-900, html.dark .text-blue-700, html.dark .text-blue-800, html.dark .text-sky-700, html.dark .hover\:text-brand-700:hover, html.dark .hover\:text-blue-700:hover { color: rgb(var(--brand-300)); }
html.dark .text-brand-600, html.dark .text-brand-500 { color: rgb(var(--brand-400)); }
html.dark .border-sky-200, html.dark .border-blue-200, html.dark .border-blue-300, html.dark .hover\:border-brand-200:hover, html.dark .hover\:border-blue-300:hover { border-color: rgb(var(--brand-400) / .35); }
html.dark .bg-emerald-50, html.dark .bg-emerald-100 { background-color: rgb(16 185 129 / .16); }
html.dark .text-emerald-700, html.dark .text-emerald-600 { color: #6ee7b7; }
html.dark .bg-rose-50 { background-color: rgb(244 63 94 / .14); }
html.dark .text-rose-700, html.dark .text-rose-600 { color: #fda4af; }
html.dark .bg-red-50, html.dark .hover\:bg-red-50:hover { background-color: rgb(239 68 68 / .14); }
html.dark .text-red-500, html.dark .text-red-600, html.dark .text-red-700 { color: #fca5a5; }
html.dark .bg-amber-50 { background-color: rgb(245 158 11 / .14); }
html.dark .text-amber-700, html.dark .text-amber-800 { color: #fcd34d; }

/* ---------- Buttons: smooth, tactile ---------- */
html button, html .rail-link, html [role="button"] {
  -webkit-tap-highlight-color: transparent;
  transition: transform .25s var(--ease), background-color .2s var(--ease), color .2s var(--ease), box-shadow .25s var(--ease), border-color .2s var(--ease), opacity .2s;
}
html button:hover:not(:disabled) { transform: translateY(-1px); }
html button:active:not(:disabled), html [role="button"]:active { transform: translateY(0) scale(.965); transition-duration: .08s; }
html button:disabled { opacity: .55; cursor: not-allowed; }
html button:focus-visible, html a:focus-visible, html [role="button"]:focus-visible, html input:focus-visible, html select:focus-visible, html textarea:focus-visible {
  outline: 2px solid rgb(var(--brand-500)); outline-offset: 2px;
}
html .focus\:ring-brand-500:focus, html .forum-center #forum-post-input:focus,
html #market-filter-keyword:focus, html #market-filter-cat:focus, html #market-filter-price:focus, html #market-filter-status:focus, html #market-filter-faculty:focus,
html #tab-feedback form input:focus, html #tab-feedback form textarea:focus, html #tab-feedback form select:focus {
  outline: none; border-color: rgb(var(--brand-400)) !important;
  box-shadow: 0 0 0 4px rgb(var(--brand-500) / .16) !important;
  background-color: rgb(var(--surface)) !important;
}
html .bg-brand-800, html .bg-brand-700, html .bg-blue-700, html .bg-blue-600, html .bg-brand-600 {
  background-image: linear-gradient(180deg, rgb(255 255 255 / .1), transparent);
  box-shadow: 0 1px 0 rgb(255 255 255 / .18) inset, 0 8px 20px -10px rgb(var(--brand-700) / .75);
}
html button.bg-brand-800:hover:not(:disabled), html button.bg-blue-700:hover:not(:disabled) {
  box-shadow: 0 1px 0 rgb(255 255 255 / .18) inset, 0 14px 28px -12px rgb(var(--brand-600) / .85);
}

/* Ripple (injected by theme.js) */
.rp-host { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; pointer-events: none; z-index: 0; }
.rp { position: absolute; border-radius: 50%; background: currentColor; opacity: .16; transform: scale(0); animation: rp-grow .6s var(--ease) forwards; }
@keyframes rp-grow { to { transform: scale(1); opacity: 0; } }

/* ---------- Header & navigation ---------- */
/* Blur lives on ::before: backdrop-filter on the header itself would trap the fixed mobile nav inside it. */
html header.glass-card, html .glass-card {
  background: rgb(var(--surface) / .78) !important;
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
  border-color: rgb(var(--line) / .7) !important;
  box-shadow: 0 1px 0 rgb(var(--line) / .5), 0 10px 30px -20px rgb(15 23 42 / .25);
  isolation: isolate;
}
html header.glass-card::before, html .glass-card::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; border-radius: inherit;
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
}
html .glass-card:not(header) { position: relative; }
html .header-search { background: rgb(var(--surface-3)); border: 1px solid transparent; }
html .header-search:focus-within { background: rgb(var(--surface)); border-color: rgb(var(--brand-400)); box-shadow: 0 0 0 4px rgb(var(--brand-500) / .14); }
html .header-search input { color: rgb(var(--ink)); }
html .site-nav button { position: relative; }
html .site-nav button.bg-brand-50 { background-color: rgb(var(--brand-500) / .12); color: rgb(var(--brand-700)); }
html.dark .site-nav button.bg-brand-50 { color: rgb(var(--brand-300)); }
html #notification-button, html .theme-btn { background: rgb(var(--surface-3)); color: rgb(var(--ink-2)); }
html #notification-button:hover, html .theme-btn:hover { background: rgb(var(--brand-500) / .14); color: rgb(var(--brand-700)); }
html.dark #notification-button:hover, html.dark .theme-btn:hover { color: rgb(var(--brand-300)); }
.theme-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: var(--r-md); flex-shrink: 0; }
.theme-btn svg { width: 19px; height: 19px; }
.theme-btn .ic-sun, html.dark .theme-btn .ic-moon { display: none; }
html.dark .theme-btn .ic-sun { display: block; }

@media (max-width:767px),(pointer:coarse) and (max-height:540px) {
  html .site-nav {
    background: rgb(var(--surface) / .96) !important;
    border-top: 1px solid rgb(var(--line)) !important;
    box-shadow: 0 -10px 30px -18px rgb(15 23 42 / .35) !important;
  }
  html .site-nav button.bg-brand-50 i, html .site-nav button.bg-brand-50 svg { transform: translateY(-1px) scale(1.08); }
  html #tab-chat > div:first-child, html #chat-threads-list > button { border-color: rgb(var(--line)) !important; }
  .theme-btn { width: 38px; height: 38px; }
}

/* ---------- Community feed ---------- */
html .rail-link { color: rgb(var(--ink-3)); }
html .rail-link:hover { background: rgb(var(--brand-500) / .1); color: rgb(var(--brand-700)); transform: translateX(2px); }
html.dark .rail-link:hover { color: rgb(var(--brand-300)); }
html .rail-link svg { color: rgb(var(--brand-600)); }
html.dark .rail-link svg { color: rgb(var(--brand-400)); }
html .forum-center #forum-post-input { background: rgb(var(--surface-3)); color: rgb(var(--ink)); }
html .forum-center > div.bg-white, html .forum-left-rail > div.bg-white, html .forum-right-rail > .bg-white, html .forum-right-rail > button {
  border-color: rgb(var(--line) / .8); box-shadow: var(--shadow-card); border-radius: var(--r-lg);
}
html .forum-center #forum-posts-container > article {
  background: rgb(var(--surface)); border: 1px solid rgb(var(--line) / .6); border-radius: var(--r-lg); box-shadow: var(--shadow-card);
  animation: rise-in .45s var(--ease) both;
}
html .forum-center #forum-posts-container article footer button:hover { background: rgb(var(--surface-3)); }
html .forum-right-rail > div:nth-child(2) {
  background:
    radial-gradient(circle at 100% 0%, rgb(var(--brand-300) / .45), transparent 50%),
    linear-gradient(145deg, rgb(var(--brand-800)), rgb(var(--brand-600))) !important;
  border-radius: var(--r-lg);
}
html .forum-right-rail > div:first-child > div > div { background: rgb(var(--surface-2)); }
html .forum-right-rail > div:first-child > div > div:hover { background: rgb(var(--brand-500) / .1); }
html .post-gallery { border-radius: var(--r-md); }
html .post-gallery img, html .post-gallery video { background: rgb(var(--surface-3)); }
html .sp-label { color: rgb(var(--brand-600)); }
html .book-thumb { background: rgb(var(--surface) / .92); border-color: rgb(var(--surface)); }

/* ---------- Market ---------- */
html #tab-market > div:first-child {
  position: relative; overflow: hidden; border-radius: var(--r-xl);
  background:
    radial-gradient(circle at 92% 10%, rgb(var(--brand-300) / .55), transparent 40%),
    radial-gradient(circle at 0% 100%, rgb(var(--brand-900) / .9), transparent 60%),
    linear-gradient(120deg, rgb(var(--brand-900)), rgb(var(--brand-700)) 65%, rgb(var(--brand-500))) !important;
  box-shadow: 0 24px 50px -28px rgb(var(--brand-800) / .9);
}
html #tab-market > div:first-child > button { color: rgb(var(--brand-800)) !important; background: #fff !important; }
html #tab-market > div:nth-child(2) { box-shadow: var(--shadow-card); border-radius: var(--r-lg); }
html #market-books-grid > article {
  background: rgb(var(--surface)); border: 1px solid rgb(var(--line) / .7); border-radius: var(--r-lg);
  box-shadow: var(--shadow-card); animation: rise-in .45s var(--ease) both;
  transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .3s;
}
html #market-books-grid > article:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: rgb(var(--brand-400) / .45); }
html #market-books-grid > article img, html #market-books-grid > article video { transition: transform .6s var(--ease); }
html #market-books-grid > article:hover img, html #market-books-grid > article:hover video { transform: scale(1.05); }
html #market-books-grid > article:nth-child(2) { animation-delay: .04s; }
html #market-books-grid > article:nth-child(3) { animation-delay: .08s; }
html #market-books-grid > article:nth-child(4) { animation-delay: .12s; }
html #market-books-grid > article:nth-child(n+5) { animation-delay: .16s; }

/* ---------- Chat ---------- */
html #tab-chat { box-shadow: var(--shadow-card); border-color: rgb(var(--line) / .8); }
html #chat-messages-box { scrollbar-color: rgb(var(--line-strong)) transparent; background: rgb(var(--surface-2) / .5); }
html #chat-threads-list > button { transition: background-color .2s var(--ease); }
html #chat-threads-list > button:hover { background: rgb(var(--brand-500) / .08); }
html #tab-chat form { background: rgb(var(--surface)); }

/* ---------- Profile, notifications, feedback ---------- */
html #tab-profile > .bg-white, html #tab-feedback > .bg-white, html #tab-feedback > form, html #notifications-list > * { box-shadow: var(--shadow-card); }
html #notifications-list button:hover { box-shadow: var(--shadow-hover); }
html #tab-feedback > div:first-child, html .register-banner {
  background:
    radial-gradient(circle at 92% 12%, rgb(var(--brand-300) / .5), transparent 38%),
    linear-gradient(135deg, rgb(var(--brand-900)), rgb(var(--brand-700)) 62%, rgb(var(--brand-500))) !important;
}

/* ---------- Modals, admin, toast ---------- */
html [id$="Modal"]:not(.hidden), html #book-detail-modal:not(.hidden) { animation: fade-in .22s var(--ease) both; }
html [id$="Modal"]:not(.hidden) > div, html #book-detail-modal:not(.hidden) > div { animation: dialog-in .34s var(--ease-spring) both; box-shadow: var(--shadow-pop); }
html [id$="Modal"] > div.bg-white { border-color: rgb(var(--line)); }
html #adminPortalModal table th { background: rgb(var(--surface-3)); }
html #adminPortalModal .flex-1.bg-slate-50 { background: rgb(var(--bg)); }
html #gmailNotificationPopup { border-radius: var(--r-lg); box-shadow: var(--shadow-pop); }
html #gmailNotificationPopup:not(.hidden) { animation: toast-in .4s var(--ease-spring) both; }
html footer#site-footer { background: rgb(var(--surface) / .7); border-color: rgb(var(--line)); }

/* ---------- Scrollbars ---------- */
html ::-webkit-scrollbar { width: 10px; height: 10px; }
html ::-webkit-scrollbar-thumb { background: rgb(var(--line-strong)); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
html ::-webkit-scrollbar-thumb:hover { background: rgb(var(--faint)); background-clip: padding-box; border: 3px solid transparent; }
html ::-webkit-scrollbar-track { background: transparent; }

/* ---------- Motion ---------- */
html main .tab-content:not(.hidden) { animation: tab-in .4s var(--ease) both; }
@keyframes tab-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Personalization panel
   ========================================================================== */
html.tp-lock, html.tp-lock body { overflow: hidden; }
.tp-root { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.tp-root.is-open { pointer-events: auto; }
.tp-overlay { position: absolute; inset: 0; background: rgb(2 6 15 / .45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); opacity: 0; transition: opacity .3s var(--ease); }
.tp-root.is-open .tp-overlay { opacity: 1; }
.tp-sheet {
  position: absolute; top: 12px; right: 12px; bottom: 12px; width: min(400px, calc(100vw - 24px));
  display: flex; flex-direction: column; background: rgb(var(--surface)); color: rgb(var(--ink-2));
  border: 1px solid rgb(var(--line)); border-radius: var(--r-xl); box-shadow: var(--shadow-pop);
  transform: translateX(calc(100% + 24px)); transition: transform .45s var(--ease); overflow: hidden;
}
.tp-root.is-open .tp-sheet { transform: none; }
.tp-head { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; border-bottom: 1px solid rgb(var(--line-soft)); }
.tp-head-icon { width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, rgb(var(--brand-500)), rgb(var(--brand-800))); box-shadow: 0 8px 18px -8px rgb(var(--brand-600)); flex-shrink: 0; }
.tp-head-icon svg { width: 20px; height: 20px; }
.tp-head-text { flex: 1; min-width: 0; }
.tp-head-text h2 { margin: 0; font-size: 1rem; font-weight: 800; color: rgb(var(--ink)); }
.tp-head-text p { margin: 2px 0 0; font-size: .75rem; color: rgb(var(--muted)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-close { width: 36px; height: 36px; border-radius: var(--r-sm); display: grid; place-items: center; color: rgb(var(--muted)); }
.tp-close:hover { background: rgb(var(--surface-3)); color: rgb(var(--ink)); }
.tp-close svg { width: 18px; height: 18px; }
.tp-body { flex: 1; overflow-y: auto; padding: 16px 18px 8px; display: flex; flex-direction: column; gap: 20px; }
.tp-section h3 { margin: 0 0 10px; font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: rgb(var(--muted)); }

.tp-preview { display: flex; gap: 12px; padding: 12px; border-radius: var(--r-lg); background: rgb(var(--surface-2)); border: 1px solid rgb(var(--line-soft)); }
.tp-preview-cover { width: 64px; flex-shrink: 0; aspect-ratio: 3 / 4; border-radius: var(--r-sm); display: flex; align-items: flex-end; padding: 6px; color: #fff; font-size: 9px; font-weight: 800; letter-spacing: .04em; background: radial-gradient(circle at 80% 15%, rgb(var(--brand-300) / .8), transparent 45%), linear-gradient(150deg, rgb(var(--brand-600)), rgb(var(--brand-900))); box-shadow: 0 10px 20px -12px rgb(var(--brand-800)); }
.tp-preview-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tp-preview-info strong { font-size: .82rem; color: rgb(var(--ink)); line-height: 1.3; }
.tp-preview-info small { font-size: .7rem; color: rgb(var(--muted)); }
.tp-preview-row { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tp-preview-row b { font-size: .85rem; color: rgb(var(--brand-700)); }
html.dark .tp-preview-row b { color: rgb(var(--brand-300)); }
.tp-preview-btn { font-size: .7rem; font-weight: 700; color: #fff; padding: 6px 12px; border-radius: var(--r-sm); background: rgb(var(--brand-700)); }

.tp-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: var(--r-md); background: rgb(var(--surface-3)); }
.tp-seg-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 58px; padding: 8px 6px; border-radius: calc(var(--r-md) - 3px); font-size: .74rem; font-weight: 700; color: rgb(var(--muted)); }
html .tp-seg-btn:hover:not(:disabled) { transform: none; color: rgb(var(--ink)); }
.tp-seg-btn.is-active { background: rgb(var(--surface)); color: rgb(var(--brand-700)); box-shadow: 0 1px 2px rgb(15 23 42 / .08), 0 4px 12px -4px rgb(15 23 42 / .15); }
html.dark .tp-seg-btn.is-active { background: rgb(var(--line)); color: rgb(var(--brand-300)); }
.tp-seg-btn svg { width: 18px; height: 18px; }
.tp-aa { font-weight: 800; line-height: 1; height: 19px; display: flex; align-items: flex-end; }
.tp-shape { width: 22px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-bottom-color: transparent; }

.tp-swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tp-swatch { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: var(--r-md); border: 1px solid rgb(var(--line)); background: rgb(var(--surface)); text-align: left; }
html .tp-swatch:hover:not(:disabled) { border-color: rgb(var(--line-strong)); }
.tp-swatch.is-active { border-color: rgb(var(--brand-500)); box-shadow: 0 0 0 3px rgb(var(--brand-500) / .18); }
.tp-swatch-dot { width: 26px; height: 26px; border-radius: 999px; flex-shrink: 0; display: grid; place-items: center; color: #fff; box-shadow: inset 0 0 0 2px rgb(255 255 255 / .25); }
.tp-swatch-dot svg { width: 14px; height: 14px; stroke-width: 3; opacity: 0; transform: scale(.4); transition: opacity .2s, transform .3s var(--ease-spring); }
.tp-swatch.is-active .tp-swatch-dot svg { opacity: 1; transform: none; }
.tp-swatch-name { font-size: .7rem; font-weight: 700; color: rgb(var(--ink-2)); line-height: 1.2; min-width: 0; }

.tp-toggle { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-md); background: rgb(var(--surface-2)); border: 1px solid rgb(var(--line-soft)); cursor: pointer; }
.tp-toggle > span:first-child { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.tp-toggle strong { font-size: .82rem; color: rgb(var(--ink)); }
.tp-toggle small { font-size: .7rem; color: rgb(var(--muted)); }
.tp-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tp-switch { position: relative; width: 44px; height: 26px; border-radius: 999px; background: rgb(var(--line-strong)); flex-shrink: 0; transition: background-color .25s var(--ease); }
.tp-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 999px; background: #fff; box-shadow: 0 2px 6px rgb(0 0 0 / .25); transition: transform .3s var(--ease-spring); }
.tp-toggle input:checked + .tp-switch { background: rgb(var(--brand-600)); }
.tp-toggle input:checked + .tp-switch::after { transform: translateX(18px); }
.tp-toggle input:focus-visible + .tp-switch { outline: 2px solid rgb(var(--brand-500)); outline-offset: 2px; }

.tp-foot { display: flex; gap: 8px; padding: 14px 18px 18px; border-top: 1px solid rgb(var(--line-soft)); }
.tp-reset { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 12px; border-radius: var(--r-md); font-size: .78rem; font-weight: 700; color: rgb(var(--ink-3)); background: rgb(var(--surface-3)); }
.tp-reset svg { width: 15px; height: 15px; }
.tp-done { flex: 1; padding: 11px 12px; border-radius: var(--r-md); font-size: .8rem; font-weight: 800; color: #fff; background: linear-gradient(180deg, rgb(var(--brand-600)), rgb(var(--brand-800))); box-shadow: 0 10px 22px -12px rgb(var(--brand-700)); }

@media (max-width:767px),(pointer:coarse) and (max-height:540px) {
  .tp-sheet { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 88dvh; border-radius: var(--r-xl) var(--r-xl) 0 0; border-bottom: 0; transform: translateY(100%); padding-bottom: env(safe-area-inset-bottom); }
  .tp-swatches { grid-template-columns: repeat(2, 1fr); }
}
