/* The Crow's Forge - Studio frontend. Same crimson/dark brand + layout system as the Vault app (see
   vault_template/app/static/style.css) - two customer-facing apps, one consistent look. Redesign this file
   freely without touching main.py/editor.js; see studio_template/README.md. */

@font-face { font-family: "Rajdhani"; src: url("/static/fonts/rajdhani/Rajdhani-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Rajdhani"; src: url("/static/fonts/rajdhani/Rajdhani-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/static/fonts/inter/Inter-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/static/fonts/inter/Inter-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/static/fonts/inter/Inter-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/static/fonts/inter/Inter-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #0a0908;
  --panel: #161211;
  --panel-hi: #1e1917;
  --text: #ece7e0;
  --muted: #96897d;
  --line: #2c2523;
  --crimson: #c8192c;
  --crimson-hi: #e42438;
  --crimson-dim: #5c1319;
  --ink: #150c0d;
  --ok: #4c9a6a;
  --warn: #d9a441;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
/* ---------------------------------------------------------------- themed scrollbars (Firefox + Chromium) */
* { scrollbar-width: thin; scrollbar-color: var(--crimson-dim) var(--panel); }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--panel); }
*::-webkit-scrollbar-thumb { background: var(--crimson-dim); border-radius: 6px; border: 2px solid var(--panel); }
*::-webkit-scrollbar-thumb:hover { background: var(--crimson); }
body {
  background: var(--bg); color: var(--text); margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", Arial, sans-serif;
  position: relative;
}
h1, h2, h3, .display {
  font-family: "Rajdhani", "Inter", sans-serif; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
a { color: var(--crimson-hi); text-decoration: none; }
a:hover { color: var(--crimson); }
.muted { color: var(--muted); }
.icon { width: 16px; height: 16px; flex: none; }

/* ---------------------------------------------------------------- background effects (the "old CRT" look) */
.bg-effects { position: fixed; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; }
.noise-layer { position: absolute; inset: -50px; opacity: 0.25; mix-blend-mode: screen; background: url('/static/noise.svg') repeat; }
.light-sweep {
  position: absolute; top: -20%; left: -20%; width: 70%; height: 70%; border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 25, 44, 0.35) 0%, rgba(200, 25, 44, 0) 70%); filter: blur(40px);
}
.scanlines {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.3) 50%);
  background-size: 100% 3px; animation: scanline-scroll 1s linear infinite;
}
@keyframes scanline-scroll { 0% { background-position: 0 0; } 100% { background-position: 0 6px; } }
@keyframes noise-jitter {
  0% { transform: translate(0, 0); } 10% { transform: translate(-5px, -10px); } 20% { transform: translate(-15px, 5px); }
  30% { transform: translate(7px, -25px); } 40% { transform: translate(-5px, 25px); } 50% { transform: translate(-15px, 10px); }
  60% { transform: translate(15px, 0); } 70% { transform: translate(0, 15px); } 80% { transform: translate(-15px, -5px); }
  90% { transform: translate(10px, 5px); } 100% { transform: translate(0, 0); }
}
@keyframes light-sweep {
  0% { transform: translate(-20%, -20%) scale(1); opacity: 0.15; }
  33% { transform: translate(10%, -10%) scale(1.1); opacity: 0.25; }
  66% { transform: translate(-5%, 15%) scale(0.9); opacity: 0.2; }
  100% { transform: translate(-20%, -20%) scale(1); opacity: 0.15; }
}
.animate-noise { animation: noise-jitter 0.20s steps(1) infinite; }
.animate-light-sweep { animation: light-sweep 15s ease-in-out infinite; }

/* ---------------------------------------------------------------- language switcher (shared) */
.lang-switch { display: flex; gap: 14px; margin-top: 28px; }
.lang-code {
  font-family: "Rajdhani", sans-serif; font-weight: 700; font-size: 13px; letter-spacing: 0.06em;
  color: var(--muted); text-decoration: none; padding: 2px 4px; border-bottom: 2px solid transparent;
}
.lang-code:hover { color: var(--text); }
.lang-code.is-active { color: var(--crimson-hi); border-color: var(--crimson-hi); }
.footer-lang { font-size: 11px; font-weight: 700; color: var(--muted); text-decoration: none; letter-spacing: 0.04em; }
.footer-lang.is-active { color: var(--crimson-hi); }
.footer-lang:hover { color: var(--text); }

/* ================================================================== LOGIN / SIGNUP / FORGOT / RESET */
.login-page { position: relative; min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 480px) 1fr; }
.login-panel { background: var(--bg); z-index: 3; display: flex; flex-direction: column; justify-content: center; padding: 48px; position: relative; }
.login-panel-inner { max-width: 340px; margin: 0 auto; width: 100%; }
.login-logo { width: 56px; height: 56px; object-fit: contain; margin-bottom: 20px; border-radius: 50%; }
.login-title { font-size: 30px; margin: 0 0 8px; color: var(--text); }
.login-subtitle { color: var(--muted); font-size: 13px; letter-spacing: 0.08em; margin: 0 0 28px; }
.banner-error {
  background: rgba(200, 25, 44, 0.12); border: 1px solid var(--crimson-dim); color: #ff9aa4;
  border-radius: 8px; padding: 10px 14px; font-size: 12px; letter-spacing: 0.03em; margin-bottom: 18px;
}
.banner-message {
  background: rgba(76, 154, 106, 0.12); border: 1px solid var(--ok); color: #a9e0bd;
  border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 18px;
}

.login-form { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.login-form input[type=text], .login-form input[type=email], .login-form input[type=password] {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 13px 14px;
  color: var(--text); font-size: 15px; font-family: "Inter", sans-serif; width: 100%;
}
.login-form input:focus { outline: none; border-color: var(--crimson); box-shadow: 0 0 0 3px rgba(200, 25, 44, 0.2); }
.login-form input.has-error { border-color: var(--crimson); }
.btn-validate {
  margin-top: 10px; background: var(--crimson); border: 0; border-radius: 8px; padding: 13px 18px;
  font-family: "Rajdhani", sans-serif; font-weight: 700; letter-spacing: 0.06em; font-size: 15px;
  color: #fff; cursor: pointer; text-transform: uppercase; width: 100%;
}
.btn-validate:hover { background: var(--crimson-hi); }
.login-footnote { margin-top: 20px; font-size: 13px; color: var(--muted); }
.login-wordmark {
  position: absolute; bottom: 20px; right: 28px; font-family: "Rajdhani", sans-serif; font-weight: 700;
  font-size: 12px; letter-spacing: 0.1em; color: var(--muted);
}
.login-hero { position: relative; background: #050505 center/cover no-repeat; }
.login-hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to right, var(--bg) 0%, rgba(10, 9, 8, 0) 18%), linear-gradient(to top, rgba(10,9,8,0.4), rgba(10,9,8,0));
}
@media (max-width: 860px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { min-height: 260px; order: -1; }
  .login-wordmark { position: static; text-align: center; margin-top: 24px; }
}

/* ================================================================== POST-LOGIN CHROME: topbar + sidebar + main */
.app-shell { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.app-shell.is-bare { height: auto; min-height: 100vh; overflow: visible; }
.topbar {
  position: relative; z-index: 1; flex: none; display: flex; align-items: center; gap: 16px; padding: 12px 24px;
  border-bottom: 1px solid var(--line); background: rgba(20, 17, 16, 0.7); flex-wrap: wrap;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; }
.topbar .brand-logo { width: 26px; height: 26px; object-fit: contain; border-radius: 50%; }
.topbar .brand-wordmark { font-family: "Rajdhani", sans-serif; font-weight: 700; letter-spacing: 0.06em; font-size: 13px; }
.topbar-heading {
  font-family: "Rajdhani", sans-serif; font-weight: 700; letter-spacing: 0.03em; font-size: 15px;
  color: var(--text); padding-left: 16px; border-left: 1px solid var(--line); text-transform: uppercase;
}
.topbar-actions { margin-left: auto; }
.topbar-btn { padding: 8px 14px; font-size: 0.78rem; }
.topbar-btn .icon { width: 14px; height: 14px; }

.app-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 260px 1fr; }
.app-body.is-bare { display: block; }
.app-main.is-bare { padding: 0; z-index: auto;}
.app-sidebar {
  position: relative; z-index: 1; border-right: 1px solid var(--line); padding: 18px 10px;
  overflow-y: auto; background: rgba(15, 12, 11, 0.4); display: flex; flex-direction: column;
}
.app-sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-link {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase;
}
.sidebar-link:hover { background: var(--panel-hi); color: var(--text); }
.sidebar-link.is-active { background: rgba(200, 25, 44, 0.16); color: var(--crimson-hi); }
.sidebar-link-external-icon { width: 13px; height: 13px; opacity: 0.6; }
.sidebar-divider { border: 0; border-top: 1px solid var(--line); margin: 10px 6px; }

.sidebar-footer { margin-top: auto; padding-top: 14px; }
.sidebar-user {
  display: flex; align-items: center; gap: 10px; padding: 12px 6px; border-top: 1px solid var(--line); border-bottom: 1px dashed var(--line); margin-bottom: 8px;
}
.sidebar-user-icon { width: 30px; height: 30px; padding: 6px; border-radius: 50%; background: var(--panel-hi); color: var(--crimson-hi); flex: none; }
.sidebar-user-label { font-size: 10px; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.sidebar-user-value { font-size: 12px; color: var(--text); word-break: break-all; }
.sidebar-footer-langs { display: flex; gap: 12px; flex-wrap: wrap; padding: 4px 6px 0; margin-bottom: -1px;}

.app-main { position: relative; z-index: 1; min-width: 0; overflow-y: auto; padding: 22px 26px 32px; }
.app-main.is-wide { padding: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.mobile-footer { display: none; }   /* shown only once the sidebar itself collapses behind the hamburger - see the mobile section near the end of this file */

/* ---------------------------------------------------------------- mobile hamburger menu + off-canvas sidebar */
.hamburger-btn {
  display: none; flex-direction: column; justify-content: center; gap: 4px; width: 34px; height: 34px;
  padding: 0; background: transparent; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; flex: none;
}
.hamburger-btn span { display: block; width: 16px; height: 2px; background: var(--text); margin: 0 auto; }
.sidebar-backdrop { display: none; }
.btn-label { display: inline; }

@media (max-width: 760px) {
  .hamburger-btn { display: flex; }
  .app-body { grid-template-columns: 1fr; }
  .app-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 84vw; z-index: 41;
    border-right: 1px solid var(--line); border-bottom: 0; background: var(--bg);
    transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  }
  .app-sidebar.is-open { transform: translateX(0); }
  .app-sidebar nav { flex-direction: column; flex-wrap: nowrap; }
  .sidebar-footer { margin-top: auto; }
  .sidebar-backdrop.is-open {
    display: block; position: fixed; inset: 0; z-index: 40; background: rgba(5, 4, 4, 0.6);
  }
  .topbar-btn .btn-label { display: none; }
  .topbar-btn { padding: 8px 10px; }
  .topbar-heading { display: none; }
  .renders-list { grid-template-columns: 1fr; }
}

.account-card { max-width: 420px; }

.render-card { max-width: 520px; }
.cd-columns { display: grid; grid-template-columns: 1.6fr 1.2fr 1.2fr; gap: 16px; align-items: start; }
.cd-column { margin-bottom: 0; }
.cd-column h2 { font-size: 0.95rem; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cd-change-size { font-size: 0.7rem; padding: 4px 10px; text-transform: none; letter-spacing: normal; }
@media (max-width: 1000px) {
  .cd-columns { grid-template-columns: 1fr; }
}
.cd-records-list { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto;
  margin-bottom: 12px; }
.cd-record-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; font-size: 0.9rem;
  text-transform: none; letter-spacing: normal; font-weight: 400; cursor: pointer; border-radius: 6px; }
.cd-record-row:hover { background: var(--panel-hi); }
.switch-visual { position: relative; display: inline-block; width: 34px; height: 20px; flex: none; }
.switch-visual .slider {
  position: absolute; inset: 0; background: var(--panel-hi); border: 1px solid var(--line);
  border-radius: 20px; transition: background 0.15s ease, border-color 0.15s ease;
}
.switch-visual .slider::before {
  content: ""; position: absolute; height: 14px; width: 14px; left: 2px; top: 2px; border-radius: 50%;
  background: var(--muted); transition: transform 0.15s ease, background 0.15s ease;
}
.switch-visual.is-on .slider { background: var(--crimson-dim); border-color: var(--crimson); }
.switch-visual.is-on .slider::before { transform: translateX(14px); background: var(--crimson-hi); }

/* one card per render, as many per row as fit (a minimum of ~290px each) */
.renders-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.renders-row {
  display: flex; flex-direction: column; align-items: stretch; justify-content: space-between; gap: 14px;
  margin-bottom: 0; min-width: 0;
}
.renders-row-title { display: block; overflow-wrap: anywhere; }
.renders-row-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.8rem; }
.renders-format-badge {
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.05em; color: var(--text);
}
.renders-row-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.renders-row-time { margin: 4px 0 0; font-size: 0.78rem; }
.renders-row-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.renders-status-text { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); }
.renders-row-error { margin: 0; font-size: 0.78rem; flex-basis: 100%; overflow-wrap: anywhere; }
.renders-row-cleanup { margin: 4px 0 0; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.renders-cleanup-good { color: var(--ok); }
.renders-cleanup-warn { color: var(--warn); }
.renders-cleanup-bad { color: var(--crimson-hi); }
.renders-spinner {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line);
  border-top-color: var(--crimson-hi); animation: spin 0.7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- Contact page: the support ticket system */
.contact-email-line { margin: -6px 0 18px; }
.contact-new-ticket { max-width: 560px; }
.contact-tickets-heading { font-size: 1rem; margin: 20px 0 10px; }
.contact-tickets-list { display: flex; flex-direction: column; gap: 10px; }
.contact-ticket-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 0;
  color: var(--text); transition: border-color 0.15s ease, background 0.15s ease;
}
.contact-ticket-row:hover { border-color: var(--crimson-dim); background: var(--panel-hi); }
.contact-ticket-status {
  flex: none; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 4px 10px; border-radius: 20px; background: var(--panel-hi); color: var(--muted);
}
.contact-ticket-status-open { color: var(--ok); }
.contact-thread { max-width: 640px; }
.contact-thread-subject { margin: 12px 0 2px; }
.contact-messages { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.contact-message { padding: 10px 14px; border-radius: 8px; background: var(--panel-hi); border: 1px solid var(--line); }
.contact-message-admin { border-color: var(--crimson-dim); }
.contact-message-meta { display: flex; justify-content: space-between; gap: 10px; margin: 0 0 6px; font-size: 0.75rem; }
.contact-message-sender { font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text); }
.contact-message-body { margin: 0; white-space: pre-wrap; }
.contact-reply-form { margin-top: 4px; }

/* ---------------------------------------------------------------- page-loading transition (catalog/dashboard ->
   editor) - see static/page-transition.js and editor.html/editor.js. Two separate copies of this same markup:
   one shown by the OLD page for the one frame before it unloads, one baked into editor.html itself from first
   paint, removed once the new page's own preview setup finishes - together they cover the whole navigation gap. */
.page-loading-overlay {
  position: fixed; inset: 0; z-index: 999; background: var(--bg);
  display: flex; flex-direction: column; gap: 26px; align-items: center; justify-content: center;
  transition: opacity 0.2s ease;
}
/* appears by itself after 8s (a keyframe, so it works even if this page's own scripts never ran) - the loading
   screen can hang on a slow/failed navigation, and a person needs a way out */
.page-loading-stuck { opacity: 0; visibility: hidden; animation: page-loading-stuck-in 0.3s ease 8s forwards; }
@keyframes page-loading-stuck-in { to { opacity: 1; visibility: visible; } }

.page-loading-overlay.is-fading { opacity: 0; pointer-events: none; }
.page-loading-spinner {
  width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--line);
  border-top-color: var(--crimson-hi); animation: spin 0.7s linear infinite;
}

.renders-delete-form { display: inline-flex; }
.render-format-toggle { display: flex; align-items: center; gap: 12px; }
.render-format-side { font-weight: 400; text-transform: none; letter-spacing: normal; font-size: 0.95rem;
  color: var(--muted); transition: color 0.15s ease; }
.render-format-side.is-active { color: var(--text); font-weight: 600; }
.render-cutmarks-label { display: flex; align-items: center; gap: 10px; }
.render-cutmarks-label label[for] { font-weight: 400; text-transform: none; letter-spacing: normal;
  font-size: 0.95rem; color: var(--text); cursor: pointer; }
.render-options-row, .render-custom-size-row { display: flex; gap: 14px; }
.render-options-row .field, .render-custom-size-row .field { flex: 1; }
input[type=color] { width: 100%; height: 40px; padding: 3px; cursor: pointer; }
#render-download { margin: 14px 0; }

.page-head { margin-bottom: 22px; display: flex; justify-content: space-between; flex-direction: column;}
.page-head p { margin: 6px 0 0; }

.card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; }
.card .error { color: var(--crimson-hi); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], select, textarea {
  width: 100%; padding: 10px 12px; background: var(--panel-hi); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; font-size: 0.95rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--crimson); box-shadow: 0 0 0 3px rgba(200, 25, 44, 0.15); }
textarea { min-height: 80px; resize: vertical; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px;
  border-radius: 8px; border: 1px solid var(--crimson); background: var(--crimson); color: #fff;
  font-weight: 700; font-family: "Rajdhani", sans-serif; letter-spacing: 0.04em; text-transform: uppercase;
  cursor: pointer; font-size: 0.85rem;
}
button:hover, .btn:hover { background: var(--crimson-hi); border-color: var(--crimson-hi); color: #fff; }
button.ghost, .btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.ghost:hover, .btn.ghost:hover { border-color: var(--muted); color: var(--text); }
button.ghost.is-active, .btn.ghost.is-active { border-color: var(--crimson); color: var(--crimson-hi); }
button.danger, .btn.danger { background: var(--crimson); border-color: var(--crimson); color: #fff; }
button.danger:hover, .btn.danger:hover { background: var(--ok); border-color: var(--ok); color: #fff; }
.error { color: var(--crimson-hi); margin: 10px 0; font-size: 0.9rem; }
.message { color: var(--ok); margin: 10px 0; font-size: 0.9rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; transition: border-color 0.15s ease, background 0.15s ease; display: flex; height: 100%; flex-direction: column; }
.tile:hover { border-color: var(--crimson-dim); background: var(--panel-hi); }
.tile h3 { margin: 0 0 6px; font-size: 0.95rem; letter-spacing: 0.02em; }
.tile .actions { display: flex; gap: 8px; margin-top: 14px; }
.tile { position: relative; }
.tooltip-hint { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

/* ---------------------------------------------------------------- select-all/bulk-action bottom bar (My Cards,
   My Gallery multi-select) - reuses .save-bar's own "stuck to the bottom" mechanics (see EDITOR section below),
   just under a second class for these two pages' own spacing. */
.bulk-select-all { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; cursor: pointer; }
.bulk-select-all input { width: 16px; height: 16px; cursor: pointer; }
.bulk-count { font-size: 0.82rem; }
.tile-bottom-bar button:disabled { opacity: 0.4; cursor: not-allowed; }
.empty-state { text-align: center; margin-top: 60px; color: var(--muted); padding: 0 24px; }

.category-heading {
  font-size: 12px; font-weight: 700; color: var(--crimson-hi); text-transform: uppercase;
  letter-spacing: 0.06em; margin: 18px 0 10px;
}

/* ---------------------------------------------------------------- catalog & custom-download: per-category
   aspect-ratio "shelf" layout - every card in an Edition->Category sits on a shared slot sized to the BIGGEST
   card in that category (so a tarot-size card's slot doesn't look arbitrarily different from a poker-size one's),
   bottom-left-anchored at its own true physical size relative to that shelf. See main.py's _attach_category_max_size. */
.catalog-section { margin-bottom: 32px; border-radius: 14px; transition: box-shadow 0.3s ease; }
.catalog-section.is-highlighted { box-shadow: 0 0 0 2px var(--crimson), 0 0 24px rgba(200, 25, 44, 0.35); padding: 24px; }
.catalog-section.is-highlighted:hover { background-color: var(--panel-hi); }
.catalog-breadcrumb { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 14px; }
.catalog-edition { color: #fff; font-size: 1.2em; }
.catalog-sep { color: var(--muted); margin: 0 10px; }
.catalog-category { color: var(--crimson-hi); }
.catalog-slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px; }
.catalog-slot {
  position: relative; width: 100%; border: 1px dashed var(--line); border-radius: 10px; background: var(--panel);
}
.catalog-card-box {
  position: absolute; bottom: 0; left: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; text-align: center; padding: 14px 10px; box-sizing: border-box;
  background: var(--panel-hi); border: 1px solid var(--line); border-radius: 8px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.catalog-card-box:hover { border-color: var(--crimson-dim); }
.catalog-card-box h3 { margin: 0; font-size: 0.9rem; letter-spacing: 0.02em; }
.catalog-card-box p { margin: 0; font-size: 0.75rem; }

/* ---------------------------------------------------------------- catalog redesign: hero, "choose a format",
   category quick-nav, preview editions, quickselect - see docs/studio.md. Deliberately reuses .catalog-section/
   .catalog-breadcrumb/.catalog-edition/.catalog-sep/.catalog-category from the "shelf" layout above - same
   markup, same meaning, just a different grid below it - and never touches .catalog-slot-grid/.catalog-slot/
   .catalog-card-box, which custom_download.html's own "pick a card" step still relies on unchanged. */
.catalog-hero {
  position: relative; margin: -22px -26px 32px; min-height: 360px; display: flex; align-items: flex-end;
  overflow: hidden; background: var(--panel);
}
.catalog-hero-media {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background-size: cover;
  background-position: center;
}
.catalog-hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(0deg, rgba(10, 9, 8, 0.96) 0%, rgba(10, 9, 8, 0.55) 55%, rgba(10, 9, 8, 0.15) 100%);
}
.catalog-hero-content { position: relative; z-index: 1; padding: 48px 40px; max-width: 640px; }
.catalog-hero-label {
  display: inline-block; background: var(--crimson); color: #fff; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; padding: 5px 12px; border-radius: 4px; margin-bottom: 14px;
}
.catalog-hero-content h1 { font-size: 2.4rem; margin: 0 0 10px; line-height: 1.1; }
.catalog-hero-content p { margin: 0 0 24px; color: var(--muted); font-size: 1rem; max-width: 480px; }
.catalog-hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.catalog-hero-actions .btn.ghost { background: rgba(255, 255, 255, 0.04); backdrop-filter: blur(2px); }
/* the plain banner every OTHER page gets (see base.html): the same hero, shorter, with just the page name on it.
   On the full-height "wide" pages (My Cards / My Gallery) <main> has no padding to cancel and is a flex column whose
   own content scrolls, so the banner just sits on top at a fixed height. */
.page-hero { min-height: 190px; margin-bottom: 24px; }
.page-hero .catalog-hero-content { padding: 26px 34px; max-width: none; }
.page-hero .catalog-hero-label { margin-bottom: 0; }
.app-main.is-wide > .page-hero { margin: 0; flex: none; min-height: 150px; }

.catalog-section-title { font-size: 0.95rem; margin: 0 0 16px; }

.catalog-nav-section { margin-bottom: 36px; }
.catalog-nav-wrap { position: relative; }
.catalog-nav-strip {
  display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 6px;
  scroll-behavior: smooth;
}
.catalog-nav-tile {
  flex: 0 0 auto; width: 110px; scroll-snap-align: start; background: none; border: none; padding: 4px; padding-top: 6px;
  cursor: pointer; display: flex; flex-direction: column; gap: 8px; align-items: center; color: inherit;
}
.catalog-nav-img {
  width: 104px; height: 104px; border-radius: 10px; background: var(--panel-hi) center/cover no-repeat;
  border: 1px solid var(--line); transition: border-color 0.15s ease, transform 0.15s ease;
}
.catalog-nav-tile:hover .catalog-nav-img { border-color: var(--crimson); transform: translateY(-2px); }
.catalog-nav-name { font-size: 0.78rem; text-align: center; letter-spacing: 0.02em; }
.catalog-nav-tile.is-preview { opacity: 0.45; }
.catalog-nav-tile.is-preview .catalog-nav-img { filter: grayscale(1); }
.catalog-nav-more {
  position: absolute; right: -4px; top: 35px; width: 36px; height: 36px; border-radius: 50%;
  background: var(--panel-hi); border: 1px solid var(--line); color: var(--text); font-size: 1.3rem;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.catalog-nav-more:hover { border-color: var(--crimson); color: var(--crimson-hi); }

.catalog-format-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; }
.catalog-format-tile, .catalog-unlocked-tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  display: flex; min-height: 160px; transition: border-color 0.15s ease;
}
.catalog-format-tile:hover { border-color: var(--crimson-dim); }
.catalog-format-img {
  width: 176px; background: var(--panel-hi) center/cover no-repeat; position: relative;
}
.catalog-format-img::after {
  content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(22, 18, 17, 0) 55%, var(--panel) 100%);
}
.catalog-format-info {
  flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 16px;
}
.catalog-format-info h3 { margin: 0; font-size: 1rem; }
.catalog-format-info p { margin: 0 0 4px; font-size: 0.8rem; }
.catalog-format-info .btn { align-self: flex-start; margin-top: 10px; }
/* Custom Download's tiles carry their own Edition -> Category line (same .catalog-breadcrumb markup, just sized
   for a tile) above the name, since its tiles from different categories share one grid */
.catalog-format-info .catalog-breadcrumb { font-size: 0.68rem; margin: 0 0 2px; line-height: 1.3; }
.catalog-format-info .catalog-edition { font-size: 1em; color: var(--muted); }
.catalog-format-info .catalog-sep { margin: 0 6px; }
/* the compact grid: four tiles per row (Custom Download) */
.catalog-format-grid.is-compact { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.catalog-format-grid.is-compact .catalog-format-tile { min-height: 132px; }
.catalog-format-grid.is-compact .catalog-format-img { width: 108px; flex: none; }
.catalog-format-grid.is-compact .catalog-format-info { padding: 12px; min-width: 0; }
.catalog-format-grid.is-compact .catalog-format-info h3 { font-size: 0.95rem; overflow-wrap: anywhere; }


.catalog-unlocked-tile { background: linear-gradient(135deg, var(--crimson-dim), var(--panel)); }
.catalog-unlocked-img { flex: 0 0 42%; background: var(--panel-hi) center/cover no-repeat; }
.catalog-unlocked-info { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 16px; }
.catalog-unlocked-edition { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.catalog-unlocked-category { font-size: 1.1rem; font-weight: 700; font-family: "Rajdhani", sans-serif; }
.catalog-unlocked-badge {
  display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-size: 0.78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px;
}
.catalog-unlocked-tile.is-locked { background: linear-gradient(135deg, var(--panel-hi), var(--panel)); }
.catalog-unlocked-tile.is-locked .catalog-unlocked-badge { color: var(--muted); }
.icon-sm { width: 13px; height: 13px; }

/* ---- the store: price on the locked tile, the Purchase button, and the notices after a payment */
.catalog-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin-top: 6px; }
.catalog-price-now { font-family: "Rajdhani", sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1; }
.catalog-price-old { color: var(--muted); text-decoration: line-through; font-size: 0.95rem; }
.catalog-price-badge {
  background: rgba(200, 25, 44, 0.18); border: 1px solid var(--crimson-dim); color: #ff9aa4; border-radius: 20px;
  padding: 1px 9px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
}
.catalog-price-tax { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.03em; }
/* the Purchase button sits INSIDE the category tile, on its right (one purchase unlocks the whole category); such a tile takes two grid columns */
.catalog-unlocked-tile.has-buy { grid-column: span 2; }
.catalog-unlocked-tile.has-buy .catalog-unlocked-img { flex-basis: 36%; }
.catalog-buy { flex: none; display: flex; flex-direction: column; justify-content: center; align-items: flex-end; padding: 16px 22px 16px 8px; }
.catalog-buy .btn { padding: 12px 26px; font-size: 1rem; cursor: pointer; font-family: inherit; white-space: nowrap; }
.js-buy-form { margin: 0; }
.js-buy-form button { cursor: pointer; font-family: inherit; }
.js-buy-form button:disabled { opacity: 0.55; cursor: progress; }
.buy-dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); }
.buy-dialog::backdrop { background: rgba(8, 6, 6, 0.72); backdrop-filter: blur(3px); }
.buy-dialog form { padding: 26px 28px 22px; display: flex; flex-direction: column; gap: 10px; }
.buy-dialog-title { margin: 0; font-family: "Rajdhani", sans-serif; font-size: 1.6rem; line-height: 1.15; }
.buy-dialog-text { margin: 4px 0 0; white-space: pre-line; line-height: 1.55; color: var(--text); }
.buy-dialog-sub { margin: 12px 0 0; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.buy-dialog-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.buy-dialog-list li { display: flex; align-items: center; gap: 9px; font-size: 0.92rem; }
.buy-dialog-list .icon-sm { color: var(--ok); flex: none; }
.buy-dialog-price { margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.buy-dialog-price .catalog-price { margin-top: 0; }
.buy-dialog-note { margin: 4px 0 0; font-size: 0.78rem; }
.buy-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.buy-dialog-actions .btn { padding: 10px 22px; cursor: pointer; font-family: inherit; }
.store-notices { max-width: 1200px; margin: 18px auto 0; padding: 0 24px; display: flex; flex-direction: column; gap: 10px; }
.store-banner { border-radius: 8px; padding: 11px 16px; font-size: 0.86rem; border: 1px solid var(--line); background: var(--panel); }
.store-banner.is-ok { background: rgba(76, 154, 106, 0.12); border-color: var(--ok); color: #a9e0bd; }
.store-banner.is-error { background: rgba(200, 25, 44, 0.12); border-color: var(--crimson-dim); color: #ff9aa4; }
.store-banner.is-test { background: rgba(217, 164, 65, 0.12); border-color: var(--warn); color: #f0cf8a; font-weight: 600; letter-spacing: 0.02em; }

.catalog-section.is-preview .catalog-format-tile { opacity: 0.55; filter: grayscale(0.6); }
.btn.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
/* admin accounts only: where a category stands, next to its heading */
.catalog-status { display: inline-block; margin-left: 12px; padding: 2px 10px; border-radius: 999px; font-size: 0.68rem; letter-spacing: 0.06em; vertical-align: middle; border: 1px solid var(--line); color: var(--muted); }
.catalog-status.is-purchase { border-color: var(--ok); color: #a9e0bd; }
.catalog-status.is-preview { border-color: var(--warn); color: #f0cf8a; }
.catalog-unready { font-size: 0.75rem; margin: 6px 0 0; }

.catalog-body { display: flex; align-items: flex-start; gap: 28px; }
.catalog-main { flex: 1; min-width: 0; }
.catalog-sidebar { flex: 0 0 260px; position: sticky; top: 20px; }
.catalog-quickselect { display: flex; flex-direction: column; gap: 10px; }
.catalog-quickselect-item {
  display: flex; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px; text-decoration: none; color: inherit;
}
.catalog-quickselect-item:hover { border-color: var(--crimson-dim); }
.catalog-quickselect-thumb {
  width: 44px; height: 44px; border-radius: 6px; background: var(--panel-hi) center/cover no-repeat; flex: none;
}
.catalog-quickselect-text { min-width: 0; }
.catalog-quickselect-text .name { font-size: 0.85rem; font-weight: 600; display: block; }
.catalog-quickselect-text .path { font-size: 0.72rem; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catalog-quickselect-empty { font-size: 0.82rem; }
.catalog-quickselect-reset {
  display: flex; align-items: center; justify-content: center; gap: 6px; margin: 14px auto 0; background: none;
  border: none; padding: 4px 8px; color: var(--muted); font-size: 0.75rem; cursor: pointer;
  text-transform: none; letter-spacing: normal; font-weight: 400;
}
.catalog-quickselect-reset:hover { color: var(--text); }
.catalog-quickselect-reset[hidden] { display: none; }
/* below 1350px there isn't room for the quickselect column next to the formats - it goes away, and the
   formats take the whole width (they're an auto-fit grid, so they simply re-flow into it) */
@media (max-width: 1350px) {
  .catalog-sidebar { display: none; }
  .catalog-body { gap: 0; }
  .catalog-format-grid.is-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .catalog-format-grid.is-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


/* ---------------------------------------------------------------- toggle switches (boolean fields) */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider {
  position: absolute; inset: 0; background: var(--panel-hi); border: 1px solid var(--line);
  border-radius: 24px; cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease;
}
.switch .slider::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; border-radius: 50%;
  background: var(--muted); transition: transform 0.15s ease, background 0.15s ease;
}
.switch input:checked + .slider { background: var(--crimson-dim); border-color: var(--crimson); }
.switch input:checked + .slider::before { transform: translateX(18px); background: var(--crimson-hi); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(200, 25, 44, 0.25); }

.signup-toggle { display: flex; align-items: center; gap: 12px; margin: 14px 0 18px; cursor: pointer; font-size: 0.88rem; color: var(--muted); }
.signup-toggle:hover { color: var(--text); }
#order-fields[hidden] { display: none; }

/* ================================================================== EDITOR: front | back | live preview */
#save-form { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.fetch-data-bar {
  flex: none; position: relative; background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 12px 24px;
}
.fetch-data-bar label { display: block; font-size: 0.78rem; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 6px; }
/* mobile-only accordion toggle - hidden entirely on desktop, where the body below is just always shown (see the
   shared mobile section near the end of this file for the collapsed state itself). */
.fetch-data-toggle { display: none; }
.fetch-data-exit { display: none; }
.fetch-data-body { max-height: none; overflow: visible; }
.fetch-search-row { display: flex; align-items: center; gap: 8px; }
.fetch-search-row input { flex: 1; }
.fetch-search-divider { width: 1px; align-self: stretch; background: var(--line); margin: 2px 2px; }

/* ---------------------------------------------------------------- language picker (real SVG flags - see main.py's
   _flag_svg() docstring for why this can't just be a native <select>) */
.lang-picker { position: relative; flex: none; }
.lang-picker-toggle {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--panel-hi);
  border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-family: "Inter", sans-serif;
  text-transform: none; letter-spacing: normal; font-weight: 500; font-size: 0.85rem;
}
.lang-picker-toggle:hover { border-color: var(--muted); }
.lang-picker-flag { display: inline-flex; width: 20px; height: 14px; flex: none; }
.lang-picker-flag svg { width: 100%; height: 100%; border-radius: 2px; display: block; }
.lang-picker-name { white-space: nowrap; }
.lang-picker-caret { width: 12px; height: 12px; flex: none; color: var(--muted); }
.lang-picker-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; min-width: 180px;
  background: var(--panel-hi); border: 1px solid var(--line); border-radius: 8px; padding: 4px;
  box-shadow: 0 10px 24px rgba(5, 4, 4, 0.45); max-height: 260px; overflow-y: auto;
}
.lang-picker-option {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; background: none; border: 0;
  border-radius: 6px; color: var(--text); font-family: "Inter", sans-serif; text-transform: none;
  letter-spacing: normal; font-weight: 500; font-size: 0.85rem; text-align: left;
}
.lang-picker-option:hover { background: var(--panel); }
.lang-picker-option.is-active { background: rgba(200, 25, 44, 0.12); color: var(--crimson-hi); }
.fetch-search-results {
  position: absolute; left: 24px; right: 24px; top: 100%; z-index: 20; margin-top: 4px;
  background: var(--panel-hi); border: 1px solid var(--line); border-radius: 8px; max-height: 260px;
  overflow-y: auto; box-shadow: 0 10px 24px rgba(5, 4, 4, 0.45);
}
.fetch-search-result {
  display: block; width: 100%; text-align: left; padding: 9px 14px; background: none; border: 0;
  border-bottom: 1px solid var(--line); color: var(--text); font: inherit; cursor: pointer;
}
.fetch-search-result:last-child { border-bottom: 0; }
.fetch-search-result:hover, .fetch-search-result:focus-visible { background: rgba(200, 25, 44, 0.1); }
.fetch-search-empty { margin: 0; padding: 10px 14px; color: var(--muted); font-size: 0.85rem; }

.editor-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 24px; }
.editor-grid {
  display: grid; gap: 16px; align-items: start;
  grid-template-columns: 1fr; grid-template-areas: "preview" "front" "back";
}
@media (min-width: 900px) {
  .editor-grid { grid-template-columns: 1fr 1fr; grid-template-areas: "front back" "preview preview"; }
}
@media (min-width: 1300px) {
  .editor-grid { grid-template-columns: 1fr 1fr minmax(300px, 380px); grid-template-areas: "front back preview"; }
  .preview-pane { position: sticky; top: 0; }
}
.editor-col.front-col { grid-area: front; }
.editor-col.back-col { grid-area: back; }
.editor-col.preview-pane { grid-area: preview; }
.editor-col h2 { font-size: 0.82rem; letter-spacing: 0.04em; color: var(--crimson-hi); margin-bottom: 8px; }
.editor-field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.editor-field-row .field { flex: 1; min-width: 140px; margin-bottom: 0; }

.richtext-inline { display: flex; flex-direction: column; }
.richtext-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px; background: var(--panel-hi);
  border: 1px solid var(--line); border-bottom: none; border-radius: 6px 6px 0 0; padding: 6px;
}
.richtext-toolbar button {
  background: transparent; border: 1px solid transparent; color: var(--text); font-family: "Inter", sans-serif;
  text-transform: none; letter-spacing: normal; font-weight: 600; padding: 6px 10px; min-width: 34px;
  border-radius: 6px;
}
.richtext-toolbar button:hover { background: var(--panel); border-color: var(--line); color: #fff; }
.richtext-toolbar .richtext-html-btn { font-family: monospace; }
.richtext-size-box { display: inline-flex; align-items: stretch; }
.richtext-toolbar input.richtext-font-size {
  width: 56px; margin: 0; padding: 6px 8px; background: var(--panel); border: 1px solid var(--line); border-right: none;
  border-radius: 6px 0 0 6px; color: var(--text); font-family: "Inter", sans-serif; font-size: 0.85rem;
  -moz-appearance: textfield; appearance: textfield;
}
.richtext-toolbar input.richtext-font-size::-webkit-outer-spin-button,
.richtext-toolbar input.richtext-font-size::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.richtext-toolbar input.richtext-font-size:focus { outline: none; border-color: var(--crimson); }
/* our own up/down arrows (the browser's default ones are grey and ignore the theme) */
.richtext-spin { display: flex; flex-direction: column; width: 18px; }
.richtext-toolbar .richtext-spin button {
  flex: 1; min-width: 0; padding: 0; font-size: 7px; line-height: 1; background: var(--panel); color: var(--muted);
  border: 1px solid var(--line); border-radius: 0; cursor: pointer;
}
.richtext-toolbar .richtext-spin button:first-child { border-radius: 0 6px 0 0; border-bottom-width: 0; }
.richtext-toolbar .richtext-spin button:last-child { border-radius: 0 0 6px 0; }
.richtext-toolbar .richtext-spin button:hover { background: var(--panel-hi); color: var(--crimson-hi); border-color: var(--line); }
.richtext-toolbar button.richtext-size-preset { min-width: 28px; padding: 6px 7px; font-size: 0.8rem; }
.richtext-toolbar button.richtext-size-preset.is-active { background: var(--crimson-dim); border-color: var(--crimson); color: #fff; }
.richtext-swatches { display: inline-flex; gap: 3px; align-items: center; }
.richtext-toolbar button.richtext-swatch {
  width: 18px; height: 18px; min-width: 0; padding: 0; border-radius: 50%; background: var(--c); border: 1px solid rgba(255, 255, 255, 0.18);
}
.richtext-toolbar button.richtext-swatch:hover { background: var(--c); border-color: #fff; transform: scale(1.12); }
.richtext-toolbar button.richtext-swatch.is-active { border-color: #fff; box-shadow: 0 0 0 2px var(--crimson); }
/* "no color" dot: an empty ring with a slash - the text keeps the card's own color */
.richtext-toolbar button.richtext-swatch-clear {
  --c: transparent; border-color: rgba(255, 255, 255, 0.55);
  background: linear-gradient(135deg, transparent 44%, #e4243a 44%, #e4243a 56%, transparent 56%);
}
.richtext-toolbar button.richtext-swatch-clear:hover { background: linear-gradient(135deg, transparent 44%, #e4243a 44%, #e4243a 56%, transparent 56%); }
.richtext-toolbar input.richtext-color {
  width: 36px; height: 32px; margin: 0; padding: 2px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; cursor: pointer;
}
.richtext-toolbar input.richtext-color.is-active { border-color: #fff; box-shadow: 0 0 0 2px var(--crimson); }
.richtext-divider { width: 1px; align-self: stretch; background: var(--line); margin: 2px 4px; }
/* The editing box. Its text is laid out in CARD pixels (26px base, 1.2 line height - the same numbers richtext.js writes into
   the stored HTML) and then shrunk by the preview's own scale, so what you see here is what the preview shows. */
.richtext-frame {
  min-height: 90px; max-height: 80vh; overflow-y: auto; resize: vertical; background: var(--panel-hi);
  border: 1px solid var(--line); border-radius: 0 0 6px 6px; cursor: text; display: flex; flex-direction: column;
}
.richtext-frame:focus-within { border-color: var(--crimson); box-shadow: 0 0 0 3px rgba(200, 25, 44, 0.15); }
.richtext-area {
  zoom: var(--preview-scale, 0.5); font-size: 26px; line-height: 1.2; outline: none; overflow-wrap: anywhere;
  min-height: calc(60px / var(--preview-scale, 0.5));
  /* the area IS the whole inside of the frame (the padding is its own), so a drag that starts beside or below the text still selects */
  flex: 1 0 auto; padding: calc(10px / var(--preview-scale, 0.5)) calc(12px / var(--preview-scale, 0.5));
}
.richtext-area ul, .richtext-area ol { margin: 0.4em 0; padding-left: 1.4em; }
/* the selection stays visible while the size box or the color picker has the focus */
::highlight(rt-selection) { background-color: rgba(228, 36, 56, 0.55); color: #fff; }

.preview-toggle-row { display: flex; gap: 8px; margin-bottom: 10px; }
.preview-viewport { width: 100%; display: flex; justify-content: center; }
.preview-frame-wrap {
  background: repeating-conic-gradient(#221c1c 0% 25%, #1a1615 0% 50%) 50% / 20px 20px;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; position: relative;
}
/* Two stacked iframes (front/back), only one visible at a time - switching sides is a pure CSS toggle, never a
   network round trip, since both are already kept up to date independently in the background (see editor.js). */
.preview-frame { position: absolute; top: 0; left: 0; border: 0; background: transparent; display: none; transform-origin: top left; }
.preview-frame.is-active { display: block; }

.save-bar {
  flex: none; background: var(--panel); border-top: 1px solid var(--line);
  padding: 12px 24px; display: flex; gap: 12px; align-items: center;
}
.save-bar .field { margin-bottom: 0; flex: none; width: 260px; }
.save-bar .field label { display: none; }
.save-bar-spacer { flex: 1; }
#reset-card-btn .icon { display: none; }   /* icon-only is a mobile-only treatment - see the mobile section below */

/* ---------------------------------------------------------------- image upload (file-type fields) */
.upload-field { display: flex; flex-direction: column; gap: 6px; }
.dropzone {
  position: relative; border: 1px dashed var(--line); border-radius: 8px; background: var(--panel-hi);
  min-height: 110px; display: flex; align-items: center; justify-content: center; cursor: pointer;
  overflow: hidden; transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--crimson); background: rgba(200, 25, 44, 0.06); }
.dropzone-thumb { display: none; max-width: 100%; max-height: 160px; object-fit: contain; }
.dropzone.has-image .dropzone-thumb { display: block; }
.dropzone.has-image .dropzone-empty { display: none; }
.dropzone-empty { text-align: center; padding: 14px; color: var(--muted); font-size: 0.8rem; }
.dropzone-remove {
  display: none; position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; padding: 0;
  border-radius: 50%; background: var(--ink); border: 1px solid var(--line); color: var(--text);
  align-items: center; justify-content: center; font-size: 16px; line-height: 1;
}
.dropzone.has-image .dropzone-remove { display: flex; }
.dropzone-filename { font-size: 0.78rem; color: var(--muted); word-break: break-all; }
.upload-actions { display: flex; gap: 8px; }
.upload-error { color: var(--crimson-hi); font-size: 0.78rem; margin: 0; }

.gallery-modal-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(5, 4, 4, 0.72);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.gallery-modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px;
  width: 100%; max-width: 1360px; max-height: 80vh; display: flex; flex-direction: column; gap: 14px;
}
.gallery-modal-overlay[hidden] { display: none; }
.render-modal { max-width: 520px; overflow-y: auto; }
.render-modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.render-modal-actions .btn, .render-modal-actions button { flex: 0 1 auto; }
.gallery-modal h2 { font-size: 1rem; margin: 0; }
.gallery-modal-search { display: flex; gap: 8px; }
.gallery-modal-search input { flex: 1; }
.gallery-modal-folders { display: flex; flex-wrap: wrap; gap: 6px; }
.gallery-folder {
  font-size: 0.8rem; padding: 4px 10px; border-radius: 999px; opacity: 1;
}
.gallery-folder.is-inactive { opacity: 0.45; }
.gallery-folder.is-active { border-color: var(--crimson); color: var(--text); }
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px;
  overflow-y: auto; padding-right: 4px; min-height: 100px;
}
.gallery-item {
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel-hi); cursor: pointer;
  padding: 6px; display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.gallery-item:hover { border-color: var(--crimson); }
.gallery-item img { width: 100%; height: 90px; object-fit: cover; border-radius: 4px; }
.gallery-item span { font-size: 0.75rem; color: var(--text); word-break: break-word; text-align: center; }
.gallery-empty { color: var(--muted); text-align: center; padding: 20px; grid-column: 1 / -1; }
.gallery-modal-pagination { display: flex; align-items: center; justify-content: center; gap: 14px; }

/* ---------------------------------------------------------------- raw HTML source popup (`text` fields) */
.richtext-modal { max-width: 620px; }
.richtext-html-source {
  width: 100%; min-height: 260px; resize: vertical; background: var(--panel-hi); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px 14px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.85rem;
  color: var(--text);
}
.richtext-html-source:focus { outline: none; border-color: var(--crimson); box-shadow: 0 0 0 3px rgba(200, 25, 44, 0.15); }
.richtext-modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------------------------------------------------------------- My Gallery's OWN internal record search (still
   used by custom_download.html's data-picker column) - NOT the My Gallery PAGE's own top bar any more, which now
   uses .tile-search-row below, shared with My Cards. */
.gallery-search-row { display: flex; gap: 10px; margin-bottom: 18px; width: 100%; }
.gallery-search-row input { flex: 1; }
.gallery-storage { margin: 0 24px 8px; flex: none; }
.pagination-row { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 12px 24px; flex: none; }

/* ================================================================== My Cards / My Gallery: shared tile grid
   (see static/tile-grid.js) - one design, applied identically to both pages via the exact same markup shape. */
.tile-grid-page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tile-layout { flex: 1; min-height: 0; display: flex; }
.tile-main {
  flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column;
}
/* min-height: 0 matters even though .tile-layout is a ROW on desktop (where .tile-main's height is stretched to
   its sibling's, not this rule) - on mobile .tile-layout switches to a COLUMN (see the mobile section), and
   without it .tile-main can't shrink below its own content's natural height in that axis. Without this, its
   content (#bulk-form > .tile-scroll) silently overflows every ancestor's flex constraint instead of being
   clipped/scrolled internally, which was the actual cause of a real reported bug: the bottom action bar (and the
   page's own mobile-only footer right after it) ending up rendered on top of each other instead of stacked. */
#bulk-form { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tile-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 24px; }
.tile-bottom-bar { flex: none; }

/* ------------------------------------------------------------ left sidebar: folder browser - collapses to an
   accordion under the tile-toolbar's own mobile breakpoint (see the shared mobile section near the end of this
   file), .tile-folder-toggle only ever shown there. */
.tile-folder-sidebar {
  flex: none; width: 210px; display: flex; flex-direction: column;
  padding: 16px 12px; border-right: 1px solid var(--line);
}
.tile-folder-toggle {
  display: none; width: 100%; background: transparent; border: 0; align-items: center; justify-content: flex-start;
  gap: 8px; padding: 4px 2px; color: var(--text); font-family: "Rajdhani", sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.82rem; cursor: pointer;
}
.tile-folder-toggle:hover { background: transparent; border-color: transparent; color: var(--crimson-hi); }
.tile-folder-toggle .icon { flex: none; }
.tile-folder-toggle-label { flex: 1; text-align: left; }
.tile-folder-toggle-caret { flex: none; transition: transform 0.15s ease; }
.tile-folder-sidebar.is-open .tile-folder-toggle-caret { transform: rotate(180deg); }
.tile-folder-body { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.tile-folder-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.tile-folder-item { display: flex; align-items: center; gap: 4px; }
.tile-folder-btn {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: transparent; border: 1px solid transparent; border-radius: 8px; color: var(--muted);
  cursor: pointer; text-align: left; font-family: "Inter", sans-serif; font-weight: 500; text-transform: none;
  letter-spacing: normal; font-size: 0.85rem; justify-content: left;
}
.tile-folder-btn .icon { width: 16px; height: 16px; flex: none; }
.tile-folder-btn:hover { background: var(--panel-hi); color: var(--text); }
.tile-folder-btn.is-active { background: var(--panel-hi); border-color: var(--crimson); color: var(--text); }
.tile-folder-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-folder-delete-btn {
  width: 26px; height: 26px; flex: none; opacity: 0; transition: opacity 0.15s ease;
}
.tile-folder-delete-btn .icon { width: 13px; height: 13px; }
.tile-folder-item:hover .tile-folder-delete-btn, .tile-folder-delete-btn:focus-visible { opacity: 1; }
.tile-add-folder-form { flex: none; display: flex; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.tile-add-folder-form input { flex: 1; min-width: 0; }
.tile-add-folder-form button { padding: 10px 12px; }

/* ------------------------------------------------------------ top bar: search + view toggle */
.tile-toolbar {
  flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 16px 24px 0;
}
.tile-search-row { position: relative; display: flex; align-items: center; gap: 8px; flex: 1; min-width: 220px; }
.tile-search-icon { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.tile-search-row input { flex: 1; padding-left: 32px; height: 40px; box-sizing: border-box; }
.tile-search-row .icon-btn { width: 40px; height: 40px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; flex: none;
  background: var(--panel-hi); border: 1px solid var(--line); border-radius: 8px; color: var(--muted);
  cursor: pointer; transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { border-color: var(--muted); color: var(--text); }
.icon-btn.is-active { border-color: var(--crimson); color: var(--crimson-hi); background: rgba(200, 25, 44, 0.1); }
.icon-btn .icon { width: 17px; height: 17px; }

/* ------------------------------------------------------------ tile grid itself */
.tile-grid-page .grid .tile {
  background: none; border: 0; padding: 0; border-radius: 0; cursor: pointer;
}
.tile-grid-page .grid .tile:hover { background: none; }
.tile-grid-page .grid .tile.is-hidden-by-search { display: none; }

.save-thumb-wrap {
  position: relative; width: 100%; border-radius: 10px; background: var(--panel-hi);
  overflow: hidden; border: 1px solid var(--line); transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.tile-grid-page .grid .tile:hover .save-thumb-wrap { border-color: var(--crimson-dim); }
.tile-grid-page .grid .tile.is-selected .save-thumb-wrap {
  border-color: var(--crimson); box-shadow: 0 0 0 2px rgba(200, 25, 44, 0.35);
}
.save-thumb {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
}
.save-thumb-back {
  opacity: 0; transition: opacity 0.2s ease; background: var(--panel-hi);
}
.save-thumb-wrap:hover .save-thumb-back { opacity: 1; }
.save-thumb-pending {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
}
.save-thumb-spinner {
  width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line);
  border-top-color: var(--crimson-hi); animation: spin 0.7s linear infinite; flex: none;
}
.save-thumb-pending-label { font-size: 0.75rem; color: var(--muted); text-align: center; padding: 0 8px; }

/* image-only default: the info row (title/subtitle/icons) is hidden entirely */
.tile-info { display: none; }

/* full view: restore the bordered container look the tile used to always have, plus the redesigned info row */
.tile-grid-page .grid.is-full-view .tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
}
.tile-grid-page .grid.is-full-view .tile:hover { background: var(--panel-hi); }
.tile-grid-page .grid.is-full-view .tile.is-selected { border-color: var(--crimson); background: var(--panel-hi); }
.tile-grid-page .grid.is-full-view .save-thumb-wrap { margin-bottom: 10px; }
.tile-grid-page .grid.is-full-view .tile-info { display: block; margin-top: auto; }
.tile-title {
  margin: 0; width: 100%; font-size: 0.85rem; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); padding: 6px 0px;
}
.tile-info-row2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile-subtitle { margin: 0; font-size: 0.72rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-subtitle .tile-lang { vertical-align: -3px; margin-right: 6px; }
.tile-icon-row { display: flex; gap: 6px; flex: none; }
.tile-icon-row .icon-btn { width: 28px; height: 28px; }
.tile-icon-row .icon-btn .icon { width: 14px; height: 14px; }
.tile-delete-form { display: inline-flex; }

/* move-to-folder popover - re-parented (see tile-grid.js) into whichever .tile is being moved and covers it
   completely, so it's always anchored to the right card/image on any screen size with no coordinate math at all -
   a min-width lets it stay usable even over a narrow gallery tile, at the cost of spilling slightly over that
   tile's own edge in that case (an acceptable trade next to "the menu isn't even on screen"). */
.tile-move-menu {
  display: none; position: absolute; inset: 0; z-index: 30; min-width: 180px; min-height: 220px;
  background: rgba(10, 9, 8, 0.96); border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  box-shadow: 0 10px 24px rgba(5, 4, 4, 0.5);
}
.tile-move-menu.is-open { display: flex; flex-direction: column; }
.tile-move-menu-heading {
  flex: none; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); margin-bottom: 6px;
}
.tile-move-menu-options { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.tile-move-option {
  display: block; width: 100%; text-align: left; padding: 8px 10px; background: none; border: 0; flex: none;
  border-radius: 6px; color: var(--text); font-family: "Inter", sans-serif; text-transform: none;
  letter-spacing: normal; font-weight: 500; font-size: 0.85rem;
}
.tile-move-option:hover { background: var(--panel-hi); }
.tile-move-cancel { flex: none; margin-top: 8px; }

/* ------------------------------------------------------------ My Gallery only: borderless justified image grid
   (see static/tile-grid.js's layoutJustifiedGallery) - the grid itself switches from CSS Grid to a plain flex-wrap
   row; each tile/image gets an explicit inline width/height set by JS once real aspect ratios are known. */
.gallery-justified { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; max-width: 100%; }
.gallery-justified .tile { flex: none; max-width: 100%; }
.gallery-thumb {
  display: block; max-width: 100%; height: auto; border-radius: 6px; object-fit: cover; transition: box-shadow 0.15s ease;
}
.gallery-justified .tile.is-selected .gallery-thumb { box-shadow: 0 0 0 3px var(--crimson); }
.gallery-justified .tile:hover .gallery-thumb { box-shadow: 0 0 0 2px var(--crimson-dim); }
.gallery-justified .tile.is-selected:hover .gallery-thumb { box-shadow: 0 0 0 3px var(--crimson); }
.gallery-justified .tile-info { margin-top: 6px; }
/* the icon row is shrunk down from the default 28px so a full title+3-icon row still fits above even a fairly
   narrow (tall/portrait) image's own column - layoutJustifiedGallery() also enforces a minimum per-image width
   for exactly this reason (see MIN_TILE_WIDTH in tile-grid.js), so this only ever has to cover the small gap
   between that floor and a comfortable fit, never an arbitrarily narrow tile. */
.gallery-justified .tile-info-row2 { flex-wrap: wrap; row-gap: 4px; }
.gallery-justified .tile-icon-row { gap: 4px; }
.gallery-justified .tile-icon-row .icon-btn { width: 22px; height: 22px; }
.gallery-justified .tile-icon-row .icon-btn .icon { width: 11px; height: 11px; }

/* ------------------------------------------------------------ storage-used meter, in My Gallery's bottom bar */
.storage-meter { display: flex; align-items: center; gap: 10px; flex: none; }
.storage-meter-label { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.storage-meter-track {
  width: 120px; height: 6px; border-radius: 3px; background: var(--panel-hi); overflow: hidden; flex: none;
}
.storage-meter-fill { display: block; height: 100%; background: var(--crimson); border-radius: 3px; }

.fetch-data-toggle-row {display: none;}

@media (max-width: 760px) {

  .tile-layout { flex-direction: column; }
  .tile-folder-sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 16px; }
  .tile-folder-toggle { display: flex; }
  .tile-folder-body { display: none; margin-top: 8px; max-height: 45vh; }
  .tile-folder-sidebar.is-open .tile-folder-body { display: flex; }
  .tile-folder-list { flex: none; max-height: 220px; }

  .tile-search-row { min-width: 0; }

  .topbar .brand-wordmark {
    font-size: 0;
  }

  .topbar .brand-wordmark::after {
    content: "TCF - Studio";
    font-size: 1rem;
    letter-spacing: normal;
  }

  .save-bar { flex-wrap: wrap; padding: 10px 14px; }
  .save-bar .field { width: 100%; order: -1; margin-bottom: 4px; }
  .save-bar-spacer { display: none; }
  .save-bar > a.btn, .save-bar > button { flex: 1 1 auto; }
  .storage-meter { width: 100%; order: 1; justify-content: center; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .grid.is-full-view { grid-template-columns: repeat(2, 1fr); }
  .catalog-slot-grid { gap: 14px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }

  .catalog-hero { margin: -16px -16px 24px; min-height: 260px; }
  .catalog-hero-content { padding: 28px 20px; }
  .catalog-hero-content h1 { font-size: 1.7rem; }
  .catalog-hero-actions { flex-direction: column; align-items: stretch; }
  .page-hero { min-height: 140px; margin-bottom: 18px; }
  .page-hero .catalog-hero-content { padding: 18px 20px; }
  .catalog-body { flex-direction: column; }
  .catalog-sidebar { position: static; width: 100%; }
  .catalog-format-tile, .catalog-unlocked-tile { flex-direction: column; min-height: 0; }
  .catalog-unlocked-tile.has-buy { grid-column: auto; }
  .catalog-buy { align-items: stretch; padding: 0 16px 16px; }
  .catalog-format-img, .catalog-unlocked-img { flex: none; height: 140px; width: 100%; }
  .catalog-format-img::after { background: linear-gradient(0deg, var(--panel) 0%, rgba(22, 18, 17, 0) 30%); }
  .catalog-format-grid.is-compact { grid-template-columns: 1fr; }
  .catalog-format-grid.is-compact .catalog-format-img { width: 100%; flex: none; }
  .gallery-modal-overlay { padding: 10px; }
  .gallery-modal { padding: 14px; }

  .catalog-sidebar { display: none; }

  .render-options-row, .render-custom-size-row { flex-direction: column; gap: 0; }
  .fetch-search-row { flex-wrap: wrap; margin-top: 8px; }
  .fetch-search-divider { display: none; }
  .lang-picker { width: 100%; }
  .lang-picker-toggle { width: 100%; justify-content: space-between; }

  .app-shell.editor-page .topbar { display: none; }

  .fetch-data-toggle-row { display: flex !important; align-items: center; gap: 6px; }
  .fetch-data-exit { display: flex; flex: none; }
  .fetch-data-toggle {
    display: flex; flex: 1; min-width: 0; align-items: center; justify-content: center; position: relative;
    background: transparent; border: 0; padding: 8px 30px; color: var(--text); font-family: "Rajdhani", sans-serif;
    font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.8rem; cursor: pointer;
  }
  .fetch-data-toggle:hover { background: transparent; border-color: transparent; color: var(--crimson-hi); }
  .fetch-data-toggle-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .fetch-data-toggle-caret { position: absolute; right: 6px; flex: none; transition: transform 0.15s ease; }
  .fetch-data-bar.is-open .fetch-data-toggle-caret { transform: rotate(180deg); }
  .fetch-data-body { max-height: 0; overflow: hidden; transition: max-height 0.25s ease; }
  .fetch-data-bar.is-open .fetch-data-body { max-height: 420px; }
  .fetch-data-body > label { margin-top: 10px; }

  .preview-pane { position: sticky; top: 0; z-index: 5; background: var(--bg); padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
  .preview-header-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); margin-bottom: 8px;}
  .preview-header-row h2 { margin: 0; }
  .preview-toggle-row { margin-top: 8px; }
  .preview-viewport { max-height: 35vh; overflow: hidden; }
  .tooltip-hint { text-align: center; margin: 0px; display: none;}

  .save-bar .field { width: auto; flex: 1 1 140px; margin-bottom: 0; }
  .editor-cancel-link { display: none; }
  #reset-card-btn { flex: none; width: 40px; padding: 10px; }
  #reset-card-btn .icon { display: inline-flex; }
  #reset-card-btn .editor-reset-label { display: none; }

  .cd-column h2 { font-size: 0.88rem; }
  .contact-ticket-row { flex-wrap: wrap; }
  .contact-message-meta { flex-wrap: wrap; }

  .mobile-footer { display: block; flex: none; text-align: center; padding: 14px 20px; border-top: 1px solid var(--line); }
  .mobile-footer p { margin: 0; font-size: 0.72rem; color: var(--muted); }

  .editor-scroll { padding-top: 0px; }
}

@media (max-width: 420px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
  .tile-scroll { padding: 12px 14px; }
  .tile-toolbar { padding: 12px 14px 0; }
}


/* My orders (combine orders) */
.my-orders-card { margin-bottom: 18px; overflow-x: auto; }
.my-orders-table { width: 100%; border-collapse: collapse; }
.my-orders-table th { text-align: left; font-size: 0.75rem; letter-spacing: 0.06em; color: var(--muted); padding: 8px 12px; }
.my-orders-table td { padding: 10px 12px; border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08)); overflow-wrap: anywhere; }
.my-orders-note { margin: 14px 12px 4px; font-size: 0.82rem; }
@media (max-width: 640px) {
  .my-orders-table thead { display: none; }
  .my-orders-table, .my-orders-table tbody, .my-orders-table tr, .my-orders-table td { display: block; width: 100%; }
  .my-orders-table td { border-top: 0; padding: 4px 12px; }
  .my-orders-table td::before { content: attr(data-label); display: block; font-size: 0.7rem; letter-spacing: 0.06em; color: var(--muted); }
  .my-orders-table tr { border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08)); padding: 8px 0; }
}


/* "Included in ..." on a category that has no product of its own, and the grayed-out "Purchase <that product>" on its sizes */
.catalog-included-in { display: block; margin-top: 6px; font-size: 0.78rem; line-height: 1.35; color: var(--text); text-decoration: none; border-bottom: 1px dotted var(--muted); width: fit-content; max-width: 100%; }
.catalog-included-in:hover { border-bottom-color: var(--crimson); }
.btn.btn-included { white-space: normal; line-height: 1.25; text-align: center; font-size: 0.7rem; }

/* an account that has not confirmed its email yet: the bar on top of every page, and the popups that ask for it */
.verify-bar { flex: none; display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; padding: 9px 24px;
  background: rgba(217, 164, 65, 0.14); border-bottom: 1px solid var(--warn); color: #f0cf8a; font-size: 0.86rem; text-align: center; }
.verify-bar form { margin: 0; }
.verify-bar-btn { background: transparent; border: 1px solid var(--warn); color: #f0cf8a; border-radius: 6px; padding: 4px 12px; font: inherit; font-size: 0.78rem; cursor: pointer; }
.verify-bar-btn:hover { background: rgba(217, 164, 65, 0.2); }
.verify-card .btn, .verify-card button { margin-top: 4px; }
#verify-needed[open], .delete-dialog[open] { padding: 26px 28px 22px; display: flex; flex-direction: column; gap: 10px; }
#verify-needed .buy-dialog-actions form { padding: 0; }
.delete-step { display: flex; flex-direction: column; gap: 10px; }
.delete-step[hidden] { display: none; }
.delete-dialog form.delete-step { padding: 0; }
.delete-actions { flex-wrap: wrap; }
.delete-actions .btn { text-decoration: none; display: inline-flex; align-items: center; }
.delete-check { display: flex; align-items: flex-start; gap: 10px; line-height: 1.4; cursor: pointer; }
.delete-check input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--crimson); }
.delete-dialog .btn.danger:hover:not(:disabled) { background: var(--crimson-hi); border-color: var(--crimson-hi); }
.delete-dialog .btn.danger:disabled { opacity: 0.4; cursor: not-allowed; }
.account-delete-card { border-color: var(--crimson-dim); }
.account-delete-card .btn.danger:hover { background: var(--crimson-hi); border-color: var(--crimson-hi); }


/* ---- structured ("JSON") fields on the editor form - drawn by static/json-field.js from the structure the admin designed */
.json-field { display: flex; flex-direction: column; gap: 10px; }
.json-root { min-width: 0; }
.jf-group { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px 10px; margin: 0; min-width: 0; }
.jf-group .jf-group { background: rgba(255, 255, 255, 0.02); }
.jf-legend { font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 0 6px; font-weight: 700; }
.jf-list-title { padding: 0; margin-bottom: 6px; }
.jf-hint { font-size: 0.74rem; color: var(--muted); margin: 0 0 6px; line-height: 1.35; }
.jf-children { display: flex; gap: 8px; }
.jf-children.is-row > .jf-field { flex: 1 1 0; min-width: 0; }
.jf-children.is-row.is-many { flex-wrap: wrap; }
.jf-children.is-row.is-many > .jf-field { flex: 1 1 90px; }
.jf-children.is-stack { flex-direction: column; }
.jf-children.is-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.jf-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.jf-label { font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.jf-field input, .jf-field textarea { width: 100%; min-width: 0; box-sizing: border-box; padding-left: 8px; padding-right: 8px; }
.jf-field textarea { min-height: 70px; resize: vertical; }
.jf-items { display: flex; flex-direction: column; gap: 8px; }
.jf-item { display: flex; align-items: flex-start; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: rgba(255, 255, 255, 0.02); }
.jf-item-num { flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--crimson-dim); color: #fff; font-size: 0.7rem; display: flex; align-items: center; justify-content: center; margin-top: 2px; }
.jf-item-body { flex: 1; min-width: 0; }
.jf-item-body > .jf-group { border: 0; padding: 0; background: none; }
.jf-item-tools { display: flex; flex-direction: column; gap: 4px; flex: none; }
.jf-tool { width: 26px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; line-height: 1; font-size: 0.9rem; }
.jf-tool:hover:not(:disabled) { border-color: var(--muted); }
.jf-tool.jf-del:hover { border-color: var(--crimson); color: var(--crimson-hi); }
.jf-tool:disabled { opacity: 0.3; cursor: default; }
.jf-empty { font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.jf-add { margin-top: 8px; padding: 7px 14px; font-size: 0.78rem; }
.jf-field-rich .richtext-inline { width: 100%; }


/* ---- the Shop page: the catalog's category tiles in a webshop grid, with the product's own square picture */
.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(470px, 1fr)); gap: 18px; align-items: stretch; }
.store-item { position: relative; display: flex; min-width: 0; }
.store-item > .catalog-unlocked-tile { flex: 1; min-width: 0; min-height: 170px; }
.store-item .catalog-buy { min-width: 0; padding-right: 16px; }
.store-item .catalog-buy .btn { padding: 10px 20px; font-size: 0.92rem; }
.store-item .catalog-unready { max-width: 150px; text-align: right; }
.store-item .catalog-unlocked-info { min-width: 0; }
.store-item .catalog-unlocked-img, .store-item .catalog-unlocked-tile.has-buy .catalog-unlocked-img { flex: none; width: auto; aspect-ratio: 1 / 1; }
.store-item.is-preview .catalog-unlocked-img { opacity: 0.55; }
.store-item > .catalog-status { position: absolute; top: 10px; right: 10px; margin: 0; background: var(--panel); }
.store-notices-inline { max-width: none; margin: 0 0 18px; padding: 0; }

/* the purchase popup with the product's square picture on the left */
.buy-dialog-grid { display: block; }
.buy-dialog.has-art { width: min(820px, calc(100vw - 32px)); }
.buy-dialog.has-art .buy-dialog-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); align-items: start; }
.buy-dialog-art { width: 280px; aspect-ratio: 1 / 1; margin: 26px 0 26px 26px; border-radius: 10px; background: var(--panel-hi) center/cover no-repeat; border: 1px solid var(--line); }
@media (max-width: 720px) {
  .store-grid { grid-template-columns: 1fr; }
  .buy-dialog.has-art .buy-dialog-grid { display: block; }
  .buy-dialog-art { width: min(260px, calc(100% - 56px)); margin: 24px auto 0; }
}

/* an admin account's "Create card" text link under a size's grayed-out button (a design that is not live can still be tried) */
.catalog-admin-create { align-self: flex-start; margin-top: 8px; font-size: 0.74rem; color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--muted); }
.catalog-admin-create:hover { color: var(--text); border-bottom-color: var(--crimson); }

/* the languages a category is offered in: small round flags, display only (catalog sizes, Shop tiles, purchase popup) */
.lang-dots { display: inline-flex; flex-wrap: wrap; gap: 5px; align-items: center; margin: 2px 0 0; }
.lang-dot { display: inline-flex; width: 15px; height: 15px; border-radius: 50%; overflow: hidden; flex: none; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14); opacity: 0.9; }
.lang-dot svg { display: block; flex: none; width: 22.5px; height: 15px; margin-left: -3.75px; }
.catalog-format-info .lang-dots { margin: 2px 0 2px; }
.catalog-buy .lang-dots { margin: 0 0 10px; justify-content: flex-end; }
.buy-dialog .lang-dots { margin: 6px 0 4px; }
