/* ══════════════════════════════════════════════════════════
   FootySocial v5 — Shared UI Chrome
   Pattern: bright SocialFC-style workspace, dark mode via data-dark="1"
   Brand tokens: --b1 --b2 --bg-card --dark --font-head
   UI tokens: --ui-bg --ui-surface --ui-border --ui-text --ui-text2
   ══════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Root tokens ─────────────────────────────────────────── */
:root {
  /* Brand (overridden by active theme) */
  --b1: #1A4A2E;
  --b1m: #1E5C38;
  --b1l: #2D7A4F;
  --b2: #9EEA00;
  --b2l: #C6FF3D;
  --bg-card: #F7F8F4;
  --dark: #082316;
  --font-head: 'Barlow Condensed', sans-serif;

  /* UI chrome — light */
  --ui-bg: #F7F8FA;
  --ui-surface: #FFFFFF;
  --ui-surface2: #F8FAFC;
  --ui-border: #E7EBF0;
  --ui-border2: #D8DEE8;
  --ui-text: #071222;
  --ui-text2: #647084;
  --ui-text3: #9AA4B2;
  --ui-topbar: rgba(255,255,255,.94);
  --ui-topbar-border: #E7EBF0;
  --ui-accent: #9EEA00;
  --ui-accent2: #C6FF3D;

  /* Semantic */
  --green: #16A34A;
  --red: #DC2626;
  --amber: #D97706;
  --blue: #2563EB;

  /* Layout */
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
  --shadow-md: 0 8px 22px rgba(15,23,42,.08);
  --shadow-lg: 0 20px 50px rgba(15,23,42,.12);
  --topbar-h: 72px;
  --sidebar-w: 250px;
  --max: 1280px;

  /* Typography */
  --font-body: 'Barlow', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
}

/* ── Dark mode ───────────────────────────────────────────── */
html[data-dark="1"] {
  --ui-bg: #111827;
  --ui-surface: #1F2937;
  --ui-surface2: #374151;
  --ui-border: #374151;
  --ui-border2: #4B5563;
  --ui-text: #F9FAFB;
  --ui-text2: #9CA3AF;
  --ui-text3: #6B7280;
  --ui-topbar: #0A0F1A;
  --ui-topbar-border: rgba(158,234,0,.16);
  --ui-accent: #9EEA00;
  --ui-accent2: #C6FF3D;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,.4);
}

/* ── Base ────────────────────────────────────────────────── */
body {
  font-family: var(--font-body);
  background: var(--ui-bg);
  color: var(--ui-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  transition: background .2s, color .2s;
  -webkit-font-smoothing: antialiased;
}

/* fixed-height layout (editor, admin) */
body.fixed-layout {
  height: 100vh;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
/* html2canvas 1.4.1 measures font baselines with an inline 1×1 image.
   The generic block reset otherwise shifts exported glyphs below their DOM ink. */
img[width="1"][height="1"] { display: inline; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--ui-topbar);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 28px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--ui-topbar-border);
  box-shadow: 0 1px 0 rgba(15,23,42,.02);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.tl-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}

.tl-logo-img { width: 178px; height: auto; display: block; }
.tl-logo-dark { display: none; }
html[data-dark="1"] .tl-logo-light { display: none; }
html[data-dark="1"] .tl-logo-dark { display: block; }

/* nav */
.tnav-wrap {
  display: flex;
  gap: 10px;
  margin-left: 8px;
}

.tnav {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  color: #071222;
  border: none;
  background: transparent;
  transition: color .15s, background .15s;
  white-space: nowrap;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tnav:hover { color: #071222; background: rgba(7,18,34,.045); }
.tnav.active {
  background: linear-gradient(180deg, var(--ui-accent2), var(--ui-accent));
  color: #071222;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.08), 0 8px 18px rgba(158,234,0,.28);
}
html[data-dark="1"] .tnav { color: rgba(255,255,255,.58); }
html[data-dark="1"] .tnav:hover { color: #fff; background: rgba(255,255,255,.08); }
html[data-dark="1"] .tnav.active { color: #071222; }

.tl-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.competition-nav { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; max-width: 260px; }
.competition-nav button { white-space: nowrap; }
.competition-nav [role="status"] { font-size: 10px; color: var(--ui-text2); line-height: 1.2; }
.competition-nav button:disabled { opacity: .55; cursor: default; }
/* UI-only crest viewport: fixed square, complete image, no row reflow.
   Do not apply to graphic layers in Editor / Brand Studio. */
.crest-preview {
  display: block;
  width: var(--crest-size, 80px);
  height: var(--crest-size, 80px);
  min-width: var(--crest-size, 80px);
  min-height: var(--crest-size, 80px);
  max-width: var(--crest-size, 80px);
  max-height: var(--crest-size, 80px);
  aspect-ratio: 1;
  object-fit: contain;
  object-position: center;
  flex-shrink: 0;
}
.competition-meta { color: var(--ui-text2); font-size: 12px; line-height: 1.6; margin: 0 0 12px; }
.competition-meta a { color: var(--b1); text-decoration: underline; }
.league-scroll { overflow-x: auto; margin-bottom: 12px; }
.league-table { min-width: 570px; }
.league-team { display: flex; align-items: center; gap: 8px; }
.league-team .crest-preview { --crest-size: 26px; }
.league-club-crest { --crest-size: 28px; }
.league-row-own { background: var(--ui-bg); font-weight: 700; }
.competition-warnings { color: var(--ui-text2); font-size: 12px; padding-left: 18px; line-height: 1.5; }
@media (max-width: 1250px) {
  .topbar { gap: 12px; padding: 0 14px; }
  .tl-club-name, .tl-theme-badge { display: none; }
  .tnav { padding: 10px 9px; }
  .tnav-wrap { gap: 4px; margin-left: 0; }
}
@media (max-width: 600px) {
  .tl-logo-img { width: 110px; }
  .competition-nav { max-width: 180px; }
  .competition-nav button { font-size: 11px; padding: 6px 8px; }
}

.tl-club-name {
  font-size: 12px;
  color: var(--ui-text2);
  font-weight: 700;
}
.tl-club-name strong { color: var(--ui-text); font-weight: 900; text-transform: uppercase; }

.tl-theme-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .8px;
  color: var(--b2);
  border: 1px solid rgba(158,234,0,.45);
  padding: 3px 8px;
  border-radius: 4px;
  font-family: var(--font-head);
}

.dark-toggle {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(180deg, #F8FAFC, #DDE6F0);
  border: 1px solid rgba(15,23,42,.16);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  box-shadow: inset 0 1px 2px rgba(15,23,42,.1);
  transition: background .2s, border-color .2s;
}
.dark-toggle::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  box-shadow: 0 2px 5px rgba(15,23,42,.22);
  transition: transform .2s;
}
html[data-dark="1"] .dark-toggle {
  border-color: rgba(158,234,0,.45);
  background: linear-gradient(135deg, #102115, #244C2F);
}
html[data-dark="1"] .dark-toggle::after { transform: translateX(16px); }

/* ── App container ───────────────────────────────────────── */
.app {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Page scrollable (index, studio) ────────────────────── */
.page-wrap {
  flex: 1;
  overflow-y: auto;
}

.page-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px 24px 48px;
}

/* ── Sidebar + main split ────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--ui-surface);
  border-right: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Sidebar sections ────────────────────────────────────── */
.sb-section {
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--ui-border);
}
.sb-section:last-child { border-bottom: none; }

.sb-section-title {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.4px;
  color: var(--ui-text3);
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* ── Template picker buttons ─────────────────────────────── */
.tpl-cat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ui-text3);
  padding: 6px 0 4px;
}

.tpl-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--ui-text2);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all .12s;
  text-align: left;
  margin-bottom: 1px;
}
.tpl-btn:hover { background: var(--ui-surface2); color: var(--ui-text); }
.tpl-btn.active {
  background: transparent;
  color: var(--ui-text);
}
html[data-dark="1"] .tpl-btn.active { background: transparent; }

.tpl-btn-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  color: #475569;
  filter: grayscale(1);
}
.tpl-btn.active .tpl-btn-icon {
  color: var(--b2);
  filter: none;
}
.tpl-btn-info { flex: 1; min-width: 0; }
.tpl-btn-label { display: block; font-weight: 800; font-size: 13px; }
.tpl-btn-desc  { display: block; font-size: 10px; color: var(--ui-text3); line-height: 1.2; }
.tpl-btn.active .tpl-btn-desc { color: var(--ui-text3); }

/* ── Form panel ──────────────────────────────────────────── */
.form-panel {
  width: 360px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--ui-surface);
  border-right: 1px solid var(--ui-border);
}

.form-panel-inner { padding: 0 24px 18px; }

.editor-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  padding: 16px 22px 0;
  background: var(--ui-surface);
  border-bottom: 1px solid var(--ui-border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.editor-tabs button {
  height: 42px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ui-text2);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.editor-tabs button.active {
  color: #4E8700;
  border-bottom-color: var(--ui-accent);
}

.form-section { margin-bottom: 18px; }
.form-section:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ui-text2);
  letter-spacing: .4px;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ui-text);
  font-size: 13px;
  line-height: 1.4;
  transition: border .15s, background .15s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--b1);
  background: var(--ui-surface);
}
html[data-dark="1"] .form-input,
html[data-dark="1"] .form-select,
html[data-dark="1"] .form-textarea {
  background: var(--ui-surface2);
  color: var(--ui-text);
}

.form-textarea { resize: vertical; min-height: 72px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

.form-row { display: flex; gap: 8px; }
.form-row > * { flex: 1; }

.form-hint { font-size: 10.5px; color: var(--ui-text3); margin-top: 4px; }

.form-sep { height: 1px; background: var(--ui-border); margin: 14px 0; }

/* ── Preview panel ───────────────────────────────────────── */
.preview-panel {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 50% 20%, rgba(158,234,0,.045), transparent 32%),
    var(--ui-bg);
}

.pv-header {
  padding: 13px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-surface);
  flex-shrink: 0;
}

.pv-header-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ui-text2);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.pv-tools {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.pv-tool-btn {
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: var(--ui-surface2);
  color: var(--ui-text2);
  font-size: 11px;
  font-weight: 700;
}
.pv-tool-btn:hover {
  border-color: var(--b1);
  color: var(--ui-text);
}
.pv-reset-btn {
  min-width: 112px;
  color: #9B1C1C;
}
.pv-reset-btn:hover {
  border-color: #FCA5A5;
  color: #7F1D1D;
}
.pv-zoom {
  width: 120px;
  accent-color: var(--ui-accent);
}
.pv-format {
  height: 28px;
  min-width: 68px;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: var(--ui-surface2);
  color: var(--ui-text);
  font-size: 11px;
  font-weight: 800;
  padding: 0 7px;
}
.pv-zoom-label {
  min-width: 72px;
  font-size: 11px;
  font-weight: 800;
  color: var(--ui-text2);
  text-align: right;
}

.pv-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.pv-canvas-wrap {
  position: relative;
  flex-shrink: 0;
  overflow: visible;
}

/* The card preview keeps fixed document dimensions; zoom is only a viewport transform. */
.pc {
  width: 560px;
  height: 560px;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-lg);
  border-radius: 2px;
  transform-origin: top left;
  transition: transform .16s ease, width .16s ease, height .16s ease;
}

.layers-panel {
  width: 280px;
  flex-shrink: 0;
  background: var(--ui-surface);
  border-left: 1px solid var(--ui-border);
  overflow-y: auto;
}
.layers-panel-head {
  padding: 22px 18px 14px;
  border-bottom: 1px solid var(--ui-border);
}
.layers-title {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--ui-text);
}
.layers-subtitle {
  margin-top: 3px;
  font-size: 11px;
  color: var(--ui-text3);
}
.layers-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}
.layers-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 12px 14px 0;
}
.layers-toolbar button {
  height: 30px;
  border: 1px solid var(--ui-border);
  border-radius: 7px;
  background: #fff;
  color: var(--ui-text2);
  font-size: 10px;
  font-weight: 900;
}
.layers-toolbar button:hover {
  border-color: var(--ui-accent);
  color: var(--ui-text);
}
.layer-group {
  border: 1px solid rgba(226,232,240,.92);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.layer-group.is-mask {
  border-color: rgba(158,234,0,.45);
  box-shadow: inset 2px 0 0 var(--ui-accent);
}
.layer-group-head {
  width: 100%;
  min-height: 40px;
  border-bottom: 1px solid var(--ui-border);
  background: #FBFCFE;
  color: var(--ui-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  text-align: left;
}
.layer-group-head.active {
  background: #F6FFE8;
  box-shadow: inset 3px 0 0 var(--ui-accent);
}
.layer-group-main {
  min-width: 0;
  flex: 1;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0;
}
.layer-group-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-group-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 1px solid var(--ui-border);
  border-radius: 5px;
  background: #fff;
  color: var(--ui-text2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
}
.layer-group-title em {
  flex-shrink: 0;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(158,234,0,.2);
  color: #315B00;
  font-size: 8px;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .35px;
}
.layer-group-main small {
  display: block;
  flex-shrink: 0;
  color: var(--ui-text3);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}
.layer-group-actions {
  display: flex;
  gap: 2px;
}
.layer-group-actions button {
  width: 24px;
  height: 26px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ui-text2);
  font-size: 11px;
  font-weight: 900;
}
.layer-group-actions button:hover {
  background: var(--ui-surface2);
  color: var(--ui-text);
}
.layer-group-items {
  display: grid;
  gap: 1px;
  padding: 4px 5px 5px;
}
.layer-item {
  position: relative;
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ui-text2);
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 5px;
  padding: 5px;
  text-align: left;
}
.layer-item.masked {
  margin-left: 12px;
  width: calc(100% - 12px);
}
.layer-item.masked::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: rgba(148,163,184,.5);
}
.layer-item:hover {
  background: var(--ui-surface2);
  color: var(--ui-text);
}
.layer-item.active {
  background: #F6FFE8;
  border-color: rgba(158,234,0,.65);
  color: var(--ui-text);
}
.layer-item.hidden {
  opacity: .52;
}
.layer-item.locked .layer-name::after {
  content: "  🔒";
  font-size: 10px;
}
.layer-toggle,
.layer-main,
.layer-actions button {
  border: 0;
  background: transparent;
  color: inherit;
}
.layer-toggle {
  width: 22px;
  height: 30px;
  border-radius: 6px;
  font-size: 12px;
}
.layer-toggle:hover,
.layer-actions button:hover {
  background: var(--ui-surface2);
}
.layer-main {
  min-width: 0;
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  gap: 7px;
  text-align: left;
}
.layer-icon {
  width: 26px;
  height: 26px;
  border: 1px solid var(--ui-border);
  border-radius: 5px;
  background: #F8FAFC;
  color: var(--ui-text2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 12px;
}
.layer-name {
  min-width: 0;
  display: block;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-copy {
  min-width: 0;
}
.layer-type {
  display: block;
  color: var(--ui-text3);
  font-size: 9px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: .35px;
}
.layer-mask-hint {
  display: block;
  margin-top: 2px;
  color: #5D7A13;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.15;
}
.layer-actions {
  display: flex;
  gap: 1px;
}
.layer-actions button {
  width: 22px;
  height: 28px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 900;
}

/* ── Simple visual editor controls ──────────────────────── */
.design-panel {
  border-top: 1px solid var(--ui-border);
  padding: 14px;
  background: var(--ui-surface);
}
.design-panel-title {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 900;
  color: var(--ui-text);
}
.design-panel-subtitle {
  margin-top: 2px;
  font-size: 11px;
  color: var(--ui-text3);
  line-height: 1.35;
}
.design-selected-name {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: var(--ui-surface2);
  font-size: 12px;
  font-weight: 800;
  color: var(--ui-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-state-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 8px;
}
.layer-state-row button {
  height: 31px;
  border: 1px solid var(--ui-border);
  border-radius: 7px;
  background: #fff;
  color: var(--ui-text2);
  font-size: 10px;
  font-weight: 900;
}
.layer-state-row button:hover {
  border-color: var(--ui-accent);
  color: var(--ui-text);
}
.design-control-grid {
  display: grid;
  gap: 9px;
  margin-top: 10px;
}
.design-control {
  display: grid;
  gap: 5px;
}
.design-control label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  font-weight: 800;
  color: var(--ui-text2);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.design-control label strong {
  font-size: 10px;
  color: var(--ui-text);
}
.design-control input[type="range"] {
  width: 100%;
  accent-color: var(--b2);
}
.design-panel-actions {
  display: flex;
  gap: 7px;
  margin-top: 10px;
}
.design-panel-actions button {
  flex: 1;
  height: 30px;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: var(--ui-surface2);
  color: var(--ui-text);
  font-size: 11px;
  font-weight: 800;
}
.design-panel-actions button:hover { border-color: var(--b1); }
.design-panel-empty {
  margin-top: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--ui-surface2);
  color: var(--ui-text3);
  font-size: 11px;
  line-height: 1.4;
}
.text-design-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--ui-border);
}
.text-design-title {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .55px;
  text-transform: uppercase;
  color: var(--ui-text);
}
.text-edit-area {
  min-height: 70px;
}
.text-design-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.text-design-grid label {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.text-design-grid label span {
  font-size: 10px;
  font-weight: 900;
  color: var(--ui-text2);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.color-mini-input {
  min-height: 34px;
  padding: 3px;
}
.quick-pick-grid,
.style-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-top: 12px;
}
.quick-pick-grid button,
.style-mini-grid button {
  min-height: 34px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: #fff;
  color: var(--ui-text2);
  font-size: 11px;
  font-weight: 900;
}
.quick-pick-grid button:hover,
.style-mini-grid button:hover {
  border-color: rgba(158,234,0,.65);
  color: var(--ui-text);
}
.module-library {
  display: grid;
  gap: 12px;
  margin: 12px 0;
}
.module-category-title {
  margin-bottom: 7px;
  color: var(--ui-text3);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .9px;
}
.module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.module-tile {
  min-height: 66px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: #fff;
  color: var(--ui-text);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
  padding: 8px;
  text-align: center;
}
.module-tile:hover {
  border-color: var(--ui-accent);
  background: #F6FFE8;
  box-shadow: 0 8px 22px rgba(15,23,42,.08);
}
.module-tile span {
  width: 24px;
  height: 24px;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  background: #F8FAFC;
  color: var(--ui-accent2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 900;
}
.module-tile strong {
  font-size: 10px;
  font-weight: 900;
  line-height: 1.12;
}
.style-mini-grid button.active {
  background: #F6FFE8;
  border-color: var(--ui-accent);
  color: #4E8700;
}
.ed-editable {
  outline: 1px solid transparent;
  outline-offset: 2px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.ed-editable.ed-dragging {
  cursor: grabbing;
}
.ed-hidden-layer {
  display: none !important;
}
.ed-editable.ed-locked-layer {
  cursor: not-allowed;
}
.pc.design-mode .ed-editable:hover,
.pc-inner.design-mode .ed-editable:hover {
  outline-color: transparent;
}
.pc.design-mode .ed-editable.ed-selected,
.pc-inner.design-mode .ed-editable.ed-selected {
  outline-color: transparent;
  box-shadow: none;
}
.pc.design-mode .ed-editable.ed-dragging,
.pc-inner.design-mode .ed-editable.ed-dragging {
  outline-color: var(--ui-accent);
  box-shadow: 0 12px 30px rgba(15,23,42,.16);
}
.ed-editable.ed-text-editing {
  cursor: text;
  user-select: text;
  outline: 2px solid var(--ui-accent) !important;
  background: rgba(255,255,255,.22);
}
.pc-inner.exporting .ed-editable,
.pc-inner.exporting .ed-editable.ed-selected {
  outline: none !important;
  box-shadow: none !important;
}

.transform-box {
  position: absolute;
  display: none;
  border: 1.5px solid var(--ui-accent);
  box-shadow: 0 0 0 1px rgba(255,255,255,.92), 0 10px 24px rgba(15,23,42,.12);
  pointer-events: none;
  z-index: 2000;
  transform: translateZ(0);
}
.transform-box.show {
  display: block;
}
.transform-box.locked {
  border-style: dashed;
  opacity: .72;
}
.tb-body {
  position: absolute;
  inset: -7px;
  border: 0;
  background: transparent;
  cursor: move;
  pointer-events: auto;
}
.tb-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--ui-accent);
  box-shadow: 0 2px 8px rgba(15,23,42,.24);
  pointer-events: auto;
}
.tb-nw { left: -6px; top: -6px; cursor: nwse-resize; }
.tb-ne { right: -6px; top: -6px; cursor: nesw-resize; }
.tb-sw { left: -6px; bottom: -6px; cursor: nesw-resize; }
.tb-se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.tb-rotate {
  position: absolute;
  left: 50%;
  top: -34px;
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--ui-accent);
  box-shadow: 0 3px 12px rgba(15,23,42,.22);
  transform: translateX(-50%);
  cursor: grab;
  pointer-events: auto;
}
.tb-rotate::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 20px;
  width: 1px;
  height: 14px;
  background: var(--ui-accent);
  transform: translateX(-50%);
}
.tb-rotate::after {
  content: "↻";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #102115;
  font-size: 12px;
  font-weight: 900;
}

.editor-context-menu {
  position: fixed;
  display: none;
  z-index: 5000;
  min-width: 190px;
  max-width: 230px;
  padding: 6px;
  border: 1px solid rgba(15,23,42,.12);
  border-radius: 10px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 18px 44px rgba(15,23,42,.18);
  backdrop-filter: blur(18px);
}
.editor-context-menu.show {
  display: block;
}
.editor-context-menu .ctx-head {
  padding: 7px 8px 8px;
  border-bottom: 1px solid var(--ui-border);
  margin-bottom: 4px;
}
.editor-context-menu .ctx-head strong {
  display: block;
  min-width: 0;
  color: var(--ui-text);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.editor-context-menu .ctx-head span {
  display: block;
  margin-top: 2px;
  color: var(--ui-text3);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.editor-context-menu button {
  width: 100%;
  height: 29px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ui-text2);
  display: flex;
  align-items: center;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 800;
  text-align: left;
}
.editor-context-menu button:hover {
  background: #F2F7EA;
  color: var(--ui-text);
}
.editor-context-menu button.danger {
  color: #9B1C1C;
}
.editor-context-menu button.danger:hover {
  background: #FEF2F2;
  color: #7F1D1D;
}
.editor-context-menu .ctx-sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--ui-border);
}
html[data-dark="1"] .editor-context-menu {
  background: rgba(16,24,20,.96);
  border-color: rgba(255,255,255,.12);
}
html[data-dark="1"] .editor-context-menu button:hover {
  background: rgba(158,234,0,.12);
}
.pc-inner.exporting ~ .transform-box,
.transform-box:not(.show) {
  display: none;
}

/* ── Export button ───────────────────────────────────────── */
.btn-export {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: var(--b1);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: background .15s, transform .1s;
  letter-spacing: .3px;
}
.btn-export:hover { background: var(--b1m); }
.btn-export:active { transform: scale(.98); }

/* ── Generic buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all .15s;
}
.btn-primary  { background: var(--b1); color: #fff; }
.btn-primary:hover { background: var(--b1m); }
.btn-accent   { background: var(--b2); color: #000; }
.btn-accent:hover { filter: brightness(1.08); }
.btn-ghost    { background: transparent; color: var(--ui-text2); border: 1px solid var(--ui-border); }
.btn-ghost:hover { background: var(--ui-surface2); color: var(--ui-text); }
.btn-danger   { background: #FEE2E2; color: var(--red); }
.btn-danger:hover { background: #FECACA; }
.btn-sm       { padding: 5px 10px; font-size: 12px; }
.btn-icon     { padding: 7px; width: 32px; height: 32px; justify-content: center; }

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-title {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 700;
  color: var(--ui-text);
  letter-spacing: .3px;
}
.page-subtitle {
  font-size: 13px;
  color: var(--ui-text2);
  margin-top: 3px;
}

/* ── Cards / panels ──────────────────────────────────────── */
.card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}

.card-sm {
  padding: 14px 16px;
  border-radius: var(--radius-md);
}

/* ── Grid systems ────────────────────────────────────────── */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }

/* ── Stat box ────────────────────────────────────────────── */
.stat-box {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-box-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--ui-text3);
}
.stat-box-value {
  font-family: var(--font-head);
  font-size: 32px;
  font-weight: 700;
  color: var(--ui-text);
  line-height: 1;
}
.stat-box-sub {
  font-size: 11px;
  color: var(--ui-text2);
}

/* ── W/D/L badge ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
}
.badge-w { background: #D1FAE5; color: #065F46; }
.badge-d { background: #FEF3C7; color: #92400E; }
.badge-l { background: #FEE2E2; color: #991B1B; }
.badge-blue { background: #DBEAFE; color: #1E40AF; }
.badge-gray { background: var(--ui-surface2); color: var(--ui-text2); }

/* ── Data table ──────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--ui-text3);
  border-bottom: 1px solid var(--ui-border);
}
.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--ui-border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--ui-surface2); }

/* ── Player grid card ────────────────────────────────────── */
.player-card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
}
.player-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.player-card-photo {
  height: 120px;
  background: var(--ui-surface2);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.player-card-photo img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.player-card-num {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--b1);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-head);
}
.player-card-body { padding: 10px 12px 12px; }
.player-card-name { font-weight: 700; font-size: 13px; }
.player-card-pos  { font-size: 11px; color: var(--ui-text2); margin-top: 2px; }
.player-card-stats {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--ui-border);
}
.player-stat { text-align: center; }
.player-stat-val { font-weight: 700; font-size: 15px; font-family: var(--font-head); color: var(--ui-text); }
.player-stat-lbl { font-size: 9px; text-transform: uppercase; letter-spacing: .5px; color: var(--ui-text3); }

/* ── Modals ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--ui-surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  transform: translateY(8px);
  transition: transform .2s;
  overflow: hidden;
}
.modal-backdrop.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--ui-border);
}
.modal-title { font-weight: 700; font-size: 16px; }
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ui-surface2);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: var(--ui-text2);
  flex-shrink: 0;
}
.modal-close:hover { background: var(--ui-border); color: var(--ui-text); }

.modal-body { padding: 20px; overflow-y: auto; max-height: 70vh; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--ui-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Photo upload zone ───────────────────────────────────── */
.photo-zone {
  border: 2px dashed var(--ui-border2);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
}
.photo-zone:hover { border-color: var(--b1); background: var(--ui-surface2); }
.photo-zone input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
}
.photo-zone-preview {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  margin: 0 auto 8px;
}
.photo-zone-preview.crest-preview { object-fit: contain; border-radius: 0; }
#plPhotoPreview .photo-zone-preview { object-fit: contain; object-position: center; border-radius: 0; }
.photo-zone-hint { font-size: 12px; color: var(--ui-text2); }

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ui-text);
  color: var(--ui-surface);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── Search bar ──────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: var(--ui-surface);
  color: var(--ui-text);
  font-size: 13px;
  outline: none;
}
.search-input:focus { border-color: var(--b1); }

.filter-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-tag {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-text2);
  cursor: pointer;
  transition: all .12s;
}
.filter-tag:hover { border-color: var(--b1); color: var(--b1); }
.filter-tag.active { background: var(--b1); color: #fff; border-color: var(--b1); }

/* ── Sponsor slot badge ──────────────────────────────────── */
.slot-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  background: var(--ui-surface2);
  color: var(--ui-text2);
  letter-spacing: .3px;
}

/* ── Timeline / schedule ─────────────────────────────────── */
.schedule-day {
  margin-bottom: 20px;
}
.schedule-day-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--ui-text3);
  margin-bottom: 8px;
}
.schedule-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  transition: box-shadow .15s;
}
.schedule-item:hover { box-shadow: var(--shadow-sm); }
.schedule-item-time { font-size: 11px; font-weight: 600; color: var(--ui-text2); width: 38px; flex-shrink: 0; }
.schedule-item-icon { font-size: 16px; flex-shrink: 0; }
.schedule-item-info { flex: 1; min-width: 0; }
.schedule-item-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.schedule-item-tpl { font-size: 11px; color: var(--ui-text2); }
.schedule-item-actions { display: flex; gap: 4px; }

/* ── Color swatch ────────────────────────────────────────── */
.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .12s, border-color .12s;
  flex-shrink: 0;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { border-color: var(--ui-text); }

/* ── Section heading ─────────────────────────────────────── */
.section-heading {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .3px;
  margin-bottom: 14px;
  color: var(--ui-text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--ui-border);
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--ui-text2);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: .5; }
.empty-state-title { font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.empty-state-desc { font-size: 13px; color: var(--ui-text3); }

/* ── Upcoming match countdown ────────────────────────────── */
.match-countdown {
  background: var(--b1);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.match-countdown-vs {
  flex: 1;
  min-width: 0;
}
.match-countdown-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.6);
  margin-bottom: 4px;
}
.match-countdown-teams {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 700;
}
.match-countdown-meta {
  font-size: 12px;
  color: rgba(255,255,255,.7);
  margin-top: 4px;
}
.match-countdown-time {
  text-align: center;
  flex-shrink: 0;
}
.match-countdown-days {
  font-family: var(--font-head);
  font-size: 40px;
  font-weight: 900;
  line-height: 1;
  color: var(--b2);
}
.match-countdown-days-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: rgba(255,255,255,.6);
}

/* ── Result history bar chart ────────────────────────────── */
.bar-chart { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-row-label { width: 120px; font-size: 12px; color: var(--ui-text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.bar-track { flex: 1; height: 8px; background: var(--ui-surface2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--b1); border-radius: 4px; transition: width .3s ease; }
.bar-val { width: 28px; text-align: right; font-size: 12px; font-weight: 600; color: var(--ui-text); flex-shrink: 0; }

/* ── Footer ──────────────────────────────────────────────── */
.footer {
  padding: 16px 24px;
  font-size: 11px;
  color: var(--ui-text3);
  border-top: 1px solid var(--ui-border);
  text-align: center;
}

/* ── Utilities ───────────────────────────────────────────── */
.text-sm     { font-size: 12px; }
.text-xs     { font-size: 11px; }
.text-muted  { color: var(--ui-text2); }
.text-accent { color: var(--b2); }
.text-brand  { color: var(--b1); }
.text-right  { text-align: right; }
.fw-700      { font-weight: 700; }
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.gap-16      { gap: 16px; }
.mt-8        { margin-top: 8px; }
.mt-12       { margin-top: 12px; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.mb-8        { margin-bottom: 8px; }
.mb-12       { margin-bottom: 12px; }
.mb-16       { margin-bottom: 16px; }
.mb-24       { margin-bottom: 24px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .page-inner { padding: 16px 14px 36px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .topbar .tnav-wrap { display: none; }
  .sidebar { display: none; }
  .form-panel { width: 100%; }
}

/* ── Per-template settings panel (Brand Studio) ──────────── */
.pts-panel {
  padding: 0;
}

.pts-desc {
  font-size: 11.5px;
  color: var(--ui-text2);
  line-height: 1.5;
  margin-bottom: 4px;
}

/* Format button group */
.pts-fmt-group {
  display: flex;
  gap: 5px;
  margin-top: 4px;
}

.pts-fmt-btn {
  flex: 1;
  padding: 6px 0;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: var(--ui-surface2);
  color: var(--ui-text2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all .12s;
  letter-spacing: .5px;
}
.pts-fmt-btn:hover { border-color: var(--b2); color: var(--ui-text); }
.pts-fmt-btn.active {
  background: var(--b2);
  color: var(--dark, #0D2A1A);
  border-color: var(--b2);
}

/* Save/clear actions */
.pts-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  margin-bottom: 4px;
}

/* Saved list */
.pts-saved-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--ui-text3);
  margin: 14px 0 8px;
}

.pts-saved-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pts-saved-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--ui-surface2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  transition: background .12s;
}
.pts-saved-row:hover { background: var(--ui-border); }

.pts-saved-icon { font-size: 14px; flex-shrink: 0; }

.pts-saved-info { flex: 1; min-width: 0; }
.pts-saved-name { display: block; font-weight: 600; color: var(--ui-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pts-saved-meta { display: block; font-size: 10px; color: var(--ui-text3); margin-top: 1px; }

.pts-edit-link {
  font-size: 13px;
  font-weight: 700;
  color: var(--b1);
  text-decoration: none;
  padding: 2px 4px;
  border-radius: 3px;
  transition: background .12s;
  flex-shrink: 0;
}
.pts-edit-link:hover { background: var(--ui-border); }

.pts-clear-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ui-text3);
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .12s, color .12s;
}
.pts-clear-btn:hover { background: #FEE2E2; color: var(--red, #DC2626); }

.pts-empty {
  font-size: 11.5px;
  color: var(--ui-text3);
  padding: 10px 0;
  line-height: 1.5;
}
