:root {
  --card-size: 176px;
  --switcher-bg: linear-gradient(180deg, rgba(19, 24, 34, .96), rgba(12, 17, 26, .96));
  --switcher-border: rgba(116, 132, 161, .22);
  --switcher-shadow: 0 20px 55px rgba(0, 0, 0, .28);
  --switcher-text: #eef2f8;
  --switcher-muted: #9ba7ba;
  --switcher-accent: #76a2ff;
  --switcher-accent-strong: #8eb1ff;
  --switcher-menu-bg: rgba(10, 15, 24, .96);
  --switcher-option-ring: rgba(118, 162, 255, .18);
}

html, body { min-height: 100%; }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid #5ba4ff; outline-offset: 3px; }

.design-switcher {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  width: min(320px, calc(100vw - 24px));
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.design-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--switcher-border);
  border-radius: 18px;
  color: var(--switcher-text);
  background: var(--switcher-bg);
  box-shadow: var(--switcher-shadow), 0 0 0 1px color-mix(in srgb, var(--switcher-accent) 10%, transparent), 0 0 36px color-mix(in srgb, var(--switcher-accent) 14%, transparent);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.design-toggle:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--switcher-accent) 46%, transparent);
}
.design-toggle:disabled { opacity: .6; cursor: progress; }
.design-toggle::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: 18px 0 0 18px;
  background: linear-gradient(180deg, var(--switcher-accent-strong), var(--switcher-accent));
  box-shadow: 0 0 20px color-mix(in srgb, var(--switcher-accent) 65%, transparent);
}
.design-toggle { position: relative; overflow: hidden; }
.design-toggle::after {
  content: "";
  position: absolute;
  top: -70%;
  right: -14%;
  width: 120px;
  height: 190px;
  transform: rotate(24deg);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--switcher-accent) 12%, white 8%), transparent);
  pointer-events: none;
  opacity: .75;
}
.design-toggle-copy { display: block; min-width: 0; text-align: left; }
.design-toggle-kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--switcher-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.design-toggle-name {
  display: block;
  font-size: 15px;
  font-weight: 760;
  line-height: 1.2;
  letter-spacing: -.02em;
}
.design-toggle-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--switcher-accent) 22%, transparent), rgba(255,255,255,.055));
  color: var(--switcher-accent-strong);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--switcher-accent) 18%, transparent), 0 8px 22px color-mix(in srgb, var(--switcher-accent) 13%, transparent);
  font-size: 16px;
  transition: transform .16s ease, background .16s ease;
}
.design-switcher.is-open .design-toggle-icon { transform: rotate(180deg); background: color-mix(in srgb, var(--switcher-accent) 24%, rgba(255,255,255,.05)); }
.design-switcher.is-open .design-toggle {
  border-color: color-mix(in srgb, var(--switcher-accent) 58%, transparent);
  box-shadow: var(--switcher-shadow), 0 0 0 1px color-mix(in srgb, var(--switcher-accent) 20%, transparent), 0 0 52px color-mix(in srgb, var(--switcher-accent) 22%, transparent);
}
.design-menu[hidden] { display: none !important; }
.design-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 100%;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--switcher-border);
  border-radius: 22px;
  background: var(--switcher-menu-bg);
  box-shadow: var(--switcher-shadow), 0 0 40px color-mix(in srgb, var(--switcher-accent) 12%, transparent);
  backdrop-filter: blur(22px) saturate(145%);
  -webkit-backdrop-filter: blur(20px) saturate(130%);
}
.design-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border: 1px solid transparent;
  border-radius: 16px;
  text-align: left;
  cursor: pointer;
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease, background .14s ease;
}
.design-option:hover:not(:disabled) { transform: translateY(-1px); }
.design-option[aria-selected="true"] {
  border-color: var(--switcher-accent);
  box-shadow: 0 0 0 4px var(--switcher-option-ring), 0 0 30px color-mix(in srgb, var(--switcher-accent) 16%, transparent);
}
.design-option:disabled { opacity: .55; cursor: progress; }
.design-option-index {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}
.design-option-copy { min-width: 0; display: block; }
.design-option-copy strong { display: block; font-size: 14px; line-height: 1.2; }
.design-option-copy small { display: block; margin-top: 3px; font-size: 11px; line-height: 1.3; opacity: .84; }

.design-option--classic {
  background: linear-gradient(135deg, rgba(17,24,39,.98), rgba(11,17,28,.98));
  color: #eef2f8;
  border-color: rgba(124,156,255,.14);
}
.design-option--classic .design-option-index { background: linear-gradient(145deg, #4f6ed8, #293a67); color: #eff4ff; }
.design-option--classic .design-option-copy small { color: #9ba7ba; }

.design-option--macos {
  background: linear-gradient(135deg, rgba(36,37,44,.98), rgba(24,25,31,.98));
  color: #f5f5f8;
  border-color: rgba(255,255,255,.08);
}
.design-option--macos .design-option-index { background: linear-gradient(145deg, #0a84ff, #005fd4); color: #fff; }
.design-option--macos .design-option-copy small { color: #a0a2ad; }

.design-option--minimal {
  background: linear-gradient(135deg, #ffffff, #f4f6f9);
  color: #2b3139;
  border-color: rgba(34,38,46,.09);
}
.design-option--minimal .design-option-index { background: #232730; color: #fff; }
.design-option--minimal .design-option-copy small { color: #6d7583; }

.design-option--tropical {
  background: linear-gradient(135deg, rgba(4,27,40,.98), rgba(4,21,34,.98));
  color: #ecfffa;
  border-color: rgba(87,255,211,.15);
  position: relative;
  overflow: hidden;
}
.design-option--tropical::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 85% 25%, rgba(255,244,188,.18), transparent 18%), radial-gradient(circle at 15% 0%, rgba(54,255,204,.11), transparent 30%);
  pointer-events: none;
}
.design-option--tropical .design-option-index { position: relative; z-index: 1; background: linear-gradient(145deg, rgba(85,255,211,.28), rgba(116,90,255,.22)); color: #ebfffa; }
.design-option--tropical .design-option-copy { position: relative; z-index: 1; }
.design-option--tropical .design-option-copy small { color: #8fcac2; }

.pages-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--card-size)), 1fr)) !important; }
.pages-grid:empty { display: none; }
.page-card { cursor: grab; }
.page-card:active { cursor: grabbing; }
.page-thumb img { object-fit: contain; }
.group-remove-page:focus-visible { opacity: 1; }
.page-source, .group-page-label, .group-stat { font-size: 12px; }
.group-page img { object-fit: contain; }
html[data-design='macos'] .workspace-layout { min-height: calc(100dvh - 104px); grid-template-columns: 220px minmax(0,1fr) 304px; }
html[data-design='macos'] .app-window { min-height: calc(100dvh - 52px); }
html[data-design='macos'] .canvas-toolbar, html[data-design='macos'] .selection-toolbar { flex-wrap: wrap; }
html[data-design='macos'] .empty-state { min-height: 420px; }
html[data-design='macos'] .export-sidebar { max-height: none; }
html[data-design='classic'] .toolbar label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
html[data-design='classic'] .toolbar input { width: 100px; }

html[data-design='classic'] {
  --switcher-bg: linear-gradient(180deg, rgba(16, 24, 40, .96), rgba(9, 15, 25, .96));
  --switcher-border: rgba(124, 156, 255, .24);
  --switcher-shadow: 0 24px 60px rgba(0, 0, 0, .34);
  --switcher-text: #eff4ff;
  --switcher-muted: #9fb2d4;
  --switcher-accent: #7c9cff;
  --switcher-accent-strong: #c4d4ff;
  --switcher-menu-bg: rgba(10, 16, 27, .97);
  --switcher-option-ring: rgba(124, 156, 255, .16);
}
html[data-design='macos'] {
  --switcher-bg: linear-gradient(180deg, rgba(35, 36, 43, .94), rgba(22, 23, 28, .96));
  --switcher-border: rgba(255, 255, 255, .09);
  --switcher-shadow: 0 24px 58px rgba(0, 0, 0, .4);
  --switcher-text: #f4f4f7;
  --switcher-muted: #9497a1;
  --switcher-accent: #0a84ff;
  --switcher-accent-strong: #8dc8ff;
  --switcher-menu-bg: rgba(27, 28, 34, .96);
  --switcher-option-ring: rgba(10, 132, 255, .14);
}
html[data-design='minimal'] {
  --switcher-bg: linear-gradient(180deg, rgba(255, 255, 255, .97), rgba(246, 248, 251, .97));
  --switcher-border: rgba(34, 38, 46, .1);
  --switcher-shadow: 0 18px 45px rgba(30, 46, 70, .14);
  --switcher-text: #22262e;
  --switcher-muted: #6e7785;
  --switcher-accent: #22262e;
  --switcher-accent-strong: #3b4350;
  --switcher-menu-bg: rgba(255,255,255,.98);
  --switcher-option-ring: rgba(34, 38, 46, .09);
}
html[data-design='tropical'] {
  --switcher-bg: linear-gradient(180deg, rgba(3, 20, 35, .92), rgba(6, 28, 42, .95));
  --switcher-border: rgba(97, 255, 216, .18);
  --switcher-shadow: 0 28px 70px rgba(0, 4, 13, .38);
  --switcher-text: #e8fff8;
  --switcher-muted: #7bc3bb;
  --switcher-accent: #57ffd3;
  --switcher-accent-strong: #cffff2;
  --switcher-menu-bg: rgba(3, 20, 33, .96);
  --switcher-option-ring: rgba(87, 255, 211, .14);
}

html[data-design='tropical'] .design-toggle {
  background:
    radial-gradient(circle at 84% 14%, rgba(255,245,188,.18), transparent 24%),
    radial-gradient(circle at 13% 0%, rgba(56,255,210,.16), transparent 30%),
    linear-gradient(180deg, rgba(3, 24, 40, .95), rgba(3, 18, 31, .97));
}
html[data-design='tropical'] .design-toggle-name {
  text-shadow: 0 0 20px rgba(87,255,211,.18);
}
html[data-design='minimal'] .design-toggle {
  box-shadow: 0 18px 45px rgba(30,46,70,.16), 0 0 0 1px rgba(34,38,46,.03);
}
html[data-design='macos'] .design-toggle {
  background: linear-gradient(180deg, rgba(42,43,51,.96), rgba(26,27,33,.98));
}
html[data-design='classic'] .design-toggle {
  background:
    radial-gradient(circle at 87% 10%, rgba(124,156,255,.15), transparent 30%),
    linear-gradient(180deg, rgba(15,24,41,.97), rgba(8,14,25,.98));
}

@media (max-width: 1050px) {
  html[data-design='macos'] .workspace-layout { grid-template-columns: 200px minmax(0,1fr); }
  html[data-design='macos'] .export-sidebar { grid-column: 1 / -1; }
}
@media (max-width: 680px) {
  .design-switcher { top: 12px; right: 12px; width: min(290px, calc(100vw - 24px)); }
  .design-toggle { padding: 12px 12px; border-radius: 16px; }
  .design-toggle-name { font-size: 14px; }
  html[data-design='macos'] .workspace-layout { display: block; }
  html[data-design='macos'] .tools-sidebar .sidebar-actions { display: flex; flex-wrap: wrap; gap: 6px; }
  html[data-design='macos'] .sidebar-actions .nav-action { width: auto; }
  html[data-design='macos'] .sidebar-actions .section-label { display: none; }
}
@media (max-width: 560px) {
  .design-switcher { width: calc(100vw - 20px); right: 10px; top: 10px; }
  .design-menu { padding: 8px; gap: 7px; }
  .design-option { padding: 10px; border-radius: 14px; }
  .design-option-index { width: 30px; height: 30px; border-radius: 10px; }
  .design-option-copy strong { font-size: 13px; }
  .design-option-copy small { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* A dedicated fixed rail keeps the appearance control clear of document tools. */
body { padding-top: 76px; }
.appearance-bar { position: fixed; inset: 0 0 auto; height: 76px; z-index: 2000; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; gap: 16px; background: var(--switcher-menu-bg); border-bottom: 1px solid var(--switcher-border); color: var(--switcher-text); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.appearance-brand { font-size: 14px; font-weight: 650; letter-spacing: -.02em; white-space: nowrap; }
.appearance-brand span { color: var(--switcher-muted); font-weight: 400; margin-left: 8px; }
.appearance-bar .design-switcher { position: relative; top: auto; right: auto; width: 280px; flex-shrink: 0; }
.appearance-bar .design-toggle { min-height: 52px; padding: 8px 12px; border-radius: 10px; box-shadow: none; background: var(--switcher-bg); }
.appearance-bar .design-toggle::before, .appearance-bar .design-toggle::after { display: none; }
.appearance-bar .design-toggle:hover { transform: none; }
.appearance-bar .design-toggle-kicker { font-size: 9px; margin-bottom: 3px; letter-spacing: .1em; }
.appearance-bar .design-toggle-name { font-size: 13px; line-height: 1.3; }
.appearance-bar .design-toggle-icon { width: 28px; height: 28px; border-radius: 7px; box-shadow: none; }
.appearance-bar .design-menu { box-sizing: border-box; width: min(340px, calc(100vw - 24px)); border-radius: 14px; max-height: calc(100dvh - 94px); overflow-y: auto; overscroll-behavior: contain; box-shadow: var(--switcher-shadow); }
.appearance-bar .design-option { border-radius: 9px; padding: 11px; }
.appearance-bar .design-option[aria-selected="true"] { box-shadow: inset 3px 0 var(--switcher-accent); }
html[data-design='classic'] .appearance-bar { border-bottom-color: #293950; }
html[data-design='macos'] .appearance-bar { background: rgba(26,27,32,.95); }
html[data-design='macos'] .appearance-bar .design-toggle { background: #303137; border-color: #494a52; }
html[data-design='minimal'] .appearance-bar { background: rgba(255,255,255,.96); }
html[data-design='minimal'] .appearance-bar .design-toggle { background: #f8f9fa; border-radius: 6px; }
html[data-design='tropical'] .appearance-bar { background: rgba(3,23,34,.94); border-bottom-color: #26594f; }
html[data-design='tropical'] .appearance-bar .design-toggle { border-radius: 18px; background: linear-gradient(120deg,#10382f,#0b2635); }
html[data-design='winter'] { --switcher-bg: #eef1f3; --switcher-border: #cbd2d7; --switcher-text: #35424b; --switcher-muted: #65727c; --switcher-accent: #627b8b; --switcher-accent-strong: #425d70; --switcher-menu-bg: rgba(244,246,247,.97); --switcher-shadow: 0 14px 38px #283b4824; --switcher-option-ring: #627b8b22; }
.design-option--winter { background: linear-gradient(135deg,#f4f6f7,#dce3e8); color: #35424b; border-color: #cbd2d7; }
.design-option--winter .design-option-index { background: #cad5dd; color: #425d70; font-size: 22px; }
html[data-design='winter'] .appearance-bar .design-toggle { border-radius: 14px; box-shadow: inset 0 1px #fff; }
@media(max-width: 720px) { .appearance-brand span { display: none; } .appearance-bar { padding-inline: 12px; gap: 10px; } }
@media(max-width: 440px) { .appearance-brand { display: none; } .appearance-bar .design-switcher { width: 100%; } .appearance-bar .design-menu { width: 100%; } }
