:root {
  --text: #111;
  --muted: #5b6471;
  --line: #222;
  --paper-shadow: rgba(0, 0, 0, 0.12);
  --app-header-height: 3.4rem;
  --page-padding: 0.35rem;
  --sheet-page-width: 8.5in;
  --sheet-page-height: 11in;
  --app-bg: #d7e1ea;
  --panel-bg: rgba(248, 250, 252, 0.84);
  --panel-border: rgba(148, 163, 184, 0.38);
  --toolbar-bg: rgba(248, 250, 252, 0.88);
  --toolbar-border: rgba(148, 163, 184, 0.46);
  --preview-bg-top: #ccd7e2;
  --preview-bg-bottom: #d8e0e8;
  --preview-glow: rgba(255, 255, 255, 0.7);
  --button-bg: #f8fafc;
  --button-hover: #edf2f7;
  --input-bg: #fff;
  --input-border: #b8c0cc;
  --section-toggle-bg: #fff;
  --section-toggle-border: #b8c0cc;
  --section-toggle-text: #29313b;
  --header-bg: rgba(248, 250, 252, 0.72);
  --header-border: rgba(148, 163, 184, 0.42);
  --header-accent: #0f172a;
  --header-shadow: rgba(15, 23, 42, 0.08);
  --header-fun-accent: #e11d48;
  --bingo-red: #e11d48;
  --bingo-blue: #2563eb;
  --bingo-gold: #f59e0b;
  --bingo-green: #059669;
  --bingo-purple: #7c3aed;
  --control-ring: rgba(225, 29, 72, 0.2);
}

body.dark-mode {
  --text: #e5e7eb;
  --muted: #aab4c3;
  --line: #cbd5e1;
  --app-bg: #0f172a;
  --panel-bg: rgba(15, 23, 42, 0.9);
  --panel-border: rgba(71, 85, 105, 0.72);
  --toolbar-bg: rgba(15, 23, 42, 0.94);
  --toolbar-border: rgba(71, 85, 105, 0.78);
  --preview-bg-top: #162235;
  --preview-bg-bottom: #111c2c;
  --preview-glow: rgba(96, 165, 250, 0.08);
  --button-bg: #f8fafc;
  --button-hover: #e2e8f0;
  --input-bg: #111827;
  --input-border: #475569;
  --section-toggle-bg: #0f172a;
  --section-toggle-border: #475569;
  --section-toggle-text: #e5e7eb;
  --header-bg: rgba(15, 23, 42, 0.72);
  --header-border: rgba(71, 85, 105, 0.8);
  --header-accent: #e5e7eb;
  --header-shadow: rgba(0, 0, 0, 0.28);
  --header-fun-accent: #fb7185;
  --bingo-red: #fb7185;
  --bingo-blue: #60a5fa;
  --bingo-gold: #fbbf24;
  --bingo-green: #34d399;
  --bingo-purple: #a78bfa;
  --control-ring: rgba(251, 113, 133, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Trebuchet MS", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.78), transparent 26rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.26) 25%, transparent 25%) 0 0 / 18px 18px,
    linear-gradient(135deg, transparent 75%, rgba(15, 23, 42, 0.035) 75%) 0 0 / 18px 18px,
    var(--app-bg);
  min-height: 100vh;
}

body.dark-mode {
  background:
    radial-gradient(circle at top left, rgba(96, 165, 250, 0.16), transparent 24rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%) 0 0 / 18px 18px,
    linear-gradient(135deg, transparent 75%, rgba(255, 255, 255, 0.025) 75%) 0 0 / 18px 18px,
    var(--app-bg);
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: var(--page-padding);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

body.auth-pending .app-shell,
body.auth-required .app-shell {
  display: none;
}

body.auth-ready .auth-gate {
  display: none;
}

.platform-dashboard {
  display: none;
}

html.platform-home-route body.auth-ready .app-shell {
  display: none;
}

html.platform-home-route body.auth-ready .platform-dashboard {
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: clamp(1rem, 3vw, 2.5rem);
  background:
    radial-gradient(circle at 18% 18%, rgba(251, 191, 36, 0.2), transparent 18rem),
    radial-gradient(circle at 84% 18%, rgba(225, 29, 72, 0.2), transparent 20rem),
    radial-gradient(circle at 56% 84%, rgba(37, 99, 235, 0.18), transparent 22rem),
    #020617;
}

.platform-dashboard-inner {
  width: min(980px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 1rem;
}

.platform-dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1rem, 2.5vw, 1.45rem);
  border: 1px solid rgba(96, 165, 250, 0.28);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.94), rgba(30, 41, 59, 0.86));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.platform-brand-mark {
  display: flex;
  gap: 0.28rem;
  margin-bottom: 0.65rem;
}

.platform-brand-mark span {
  width: 2.05rem;
  height: 2.05rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  font-weight: 950;
  box-shadow: 0 0.18rem 0 rgba(0, 0, 0, 0.18);
}

.platform-brand-mark span:nth-child(1) { background: #e11d48; }
.platform-brand-mark span:nth-child(2) { background: #f59e0b; }
.platform-brand-mark span:nth-child(3) { background: #059669; }
.platform-brand-mark span:nth-child(4) { background: #2563eb; }
.platform-brand-mark span:nth-child(5) { background: #7c3aed; }

.platform-dashboard h1,
.platform-dashboard h2,
.platform-dashboard p {
  margin: 0;
}

.platform-dashboard h1 {
  color: #f8fafc;
  font-family: "Lilita One", "Arial Black", sans-serif;
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.platform-dashboard-header p,
.platform-game-card p {
  color: #cbd5e1;
  font-weight: 750;
  line-height: 1.35;
}

.platform-account-card {
  min-width: min(18rem, 100%);
  display: grid;
  gap: 0.55rem;
  justify-items: end;
  color: #dbeafe;
  font-weight: 850;
}

.platform-account-card button {
  min-height: 2.3rem;
  padding-inline: 1rem;
}

.platform-game-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.platform-game-card {
  min-height: 16rem;
  display: grid;
  align-content: space-between;
  gap: 1.25rem;
  padding: clamp(1rem, 2.5vw, 1.35rem);
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.96));
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}

.platform-game-card.is-coming-soon {
  opacity: 0.72;
}

.platform-game-kicker {
  color: #fbbf24 !important;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.platform-game-card h2 {
  color: #f8fafc;
  font-family: "Lilita One", "Arial Black", sans-serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 0.95;
}

.platform-game-copy {
  display: grid;
  gap: 0.45rem;
}

.platform-game-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.platform-game-actions button {
  min-height: 3rem;
  font-weight: 950;
}

@media (max-width: 720px) {
  .platform-dashboard-header {
    display: grid;
  }

  .platform-game-grid,
  .platform-game-actions {
    grid-template-columns: 1fr;
  }

  .platform-account-card {
    justify-items: start;
  }
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background:
    radial-gradient(circle at 20% 18%, rgba(251, 191, 36, 0.22), transparent 18rem),
    radial-gradient(circle at 82% 14%, rgba(225, 29, 72, 0.2), transparent 20rem),
    radial-gradient(circle at 58% 82%, rgba(37, 99, 235, 0.18), transparent 22rem);
}

.auth-gate-card {
  width: min(470px, 100%);
  display: grid;
  gap: 0.9rem;
  padding: 1.35rem;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(248, 250, 252, 0.82));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.72) inset,
    0 24px 70px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(12px);
}

.auth-gate-balls {
  justify-content: center;
}

.auth-gate-balls span {
  width: 2rem;
  height: 2rem;
  font-size: 1.05rem;
}

.auth-gate-title {
  display: grid;
  gap: 0.32rem;
  text-align: center;
}

.auth-gate-title h1 {
  margin: 0;
  color: var(--header-accent);
  font-family: "Franklin Gothic Heavy", Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 1.55rem;
  line-height: 0.95;
  text-transform: uppercase;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.62),
    0.045em 0.045em 0 rgba(225, 29, 72, 0.14);
}

.auth-gate-title p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.auth-gate-form {
  display: grid;
  gap: 0.7rem;
}

.auth-gate-form label {
  display: grid;
  grid-template-columns: 4.7rem minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  font-weight: 750;
}

.auth-gate-form input[type="email"],
.auth-gate-form input[type="password"] {
  width: 100%;
  min-height: 2.15rem;
  border-radius: 7px;
}

.auth-gate-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.auth-gate-actions button {
  min-height: 2.35rem;
  font-weight: 850;
}

.link-button {
  width: fit-content;
  justify-self: center;
  min-height: 1.5rem;
  padding: 0.05rem 0.18rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--bingo-blue);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 0.18rem;
}

.link-button:hover {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--bingo-red);
}

.auth-gate-message {
  min-height: 1.25rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  text-align: center;
}

body.dark-mode .auth-gate-card {
  background:
    linear-gradient(135deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.96));
  border-color: rgba(96, 165, 250, 0.32);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 24px 70px rgba(0, 0, 0, 0.42);
}

body.dark-mode .auth-gate-title h1 {
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.5),
    0.045em 0.045em 0 rgba(251, 113, 133, 0.2);
}

@media (max-width: 520px) {
  .auth-gate-card {
    padding: 1rem;
  }

  .auth-gate-form label {
    grid-template-columns: 1fr;
    gap: 0.24rem;
  }

  .auth-gate-actions {
    grid-template-columns: 1fr;
  }

  .start-choice-actions {
    grid-template-columns: 1fr;
  }
}

.app-header {
  min-height: 2.6rem;
  margin-bottom: 0.12rem;
  padding: 0.34rem 0.48rem 0.34rem 0.58rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  border: 1px solid var(--header-border);
  border-radius: 10px;
  background:
    linear-gradient(90deg, rgba(225, 29, 72, 0.1), transparent 34%),
    repeating-linear-gradient(90deg, rgba(15, 23, 42, 0.035) 0 1px, transparent 1px 32px),
    var(--header-bg);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 6px 18px var(--header-shadow);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: visible;
  z-index: 20;
}

.app-header::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  background: linear-gradient(90deg, #111827, var(--header-fun-accent), #f59e0b, #2563eb, #111827);
  opacity: 0.88;
}

.bingo-ball-strip {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
}

.bingo-ball-strip span {
  width: 1.42rem;
  height: 1.42rem;
  border: 2px solid #111827;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 30%, #fff 0 28%, #f8fafc 29% 58%, #e2e8f0 59% 100%);
  color: #111827;
  display: inline-grid;
  place-items: center;
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 0.78rem;
  line-height: 1;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.75),
    0 2px 4px rgba(15, 23, 42, 0.16);
}

.bingo-ball-strip span:nth-child(2) {
  transform: translateY(1px);
}

.bingo-ball-strip span:nth-child(3) {
  transform: translateY(-1px);
}

.bingo-ball-strip span:nth-child(4) {
  transform: translateY(1px);
}

.app-header h1 {
  margin: 0;
  font-family: "Franklin Gothic Heavy", Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(1.05rem, 1.6vw, 1.4rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0;
  color: var(--header-accent);
  text-transform: uppercase;
  text-wrap: balance;
  max-width: min(68vw, 36rem);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.55),
    0.045em 0.045em 0 rgba(225, 29, 72, 0.14);
}

.app-title-group {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.app-title-group p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: 0;
}

.account-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  margin-left: auto;
  position: relative;
  z-index: 1;
}

.account-status {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
}

.header-save-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.32rem;
  min-height: 1.65rem;
  padding: 0.12rem 0.52rem;
  border: 1px solid rgba(148, 163, 184, 0.58);
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.82);
  color: #334155;
  font-size: 0.72rem;
  font-weight: 850;
  white-space: nowrap;
}

.header-save-status::before {
  content: "";
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.48);
}

.header-save-status.is-saved {
  color: #065f46;
  border-color: rgba(5, 150, 105, 0.42);
  background: linear-gradient(135deg, #ecfdf3, #d1fae5);
}

.header-save-status.is-dirty {
  color: #9f1239;
  border-color: rgba(225, 29, 72, 0.42);
  background: linear-gradient(135deg, #fff1f2, #ffe4e6);
}

.header-save-status.is-saving {
  color: #92400e;
  border-color: rgba(245, 158, 11, 0.52);
  background: linear-gradient(135deg, #fffbeb, #fde68a);
  animation: savePulse 1.15s ease-in-out infinite;
}

@keyframes savePulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18);
  }
}

.account-controls button {
  min-height: 1.8rem;
  padding: 0.18rem 0.58rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
}

.account-controls .sheet-library-nav-button {
  display: inline-flex;
  align-items: center;
  min-height: 1.8rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  text-decoration: none;
}

#sheetLibraryHeaderBtn {
  position: relative;
}

.sheet-library-nav-button {
  padding-inline: 0.78rem 0.88rem;
  border-color: rgba(37, 99, 235, 0.55);
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.92), rgba(29, 78, 216, 0.92));
  color: #fff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.24) inset,
    0 6px 16px rgba(37, 99, 235, 0.2);
}

.sheet-library-nav-button::before {
  content: "";
  display: inline-block;
  width: 0.58rem;
  height: 0.72rem;
  margin-right: 0.42rem;
  vertical-align: -0.1rem;
  border: 1.6px solid currentColor;
  border-radius: 0.12rem;
  box-shadow: 0.22rem 0.14rem 0 -0.08rem currentColor;
  opacity: 0.9;
}

.sheet-library-nav-button.has-count::after {
  content: attr(data-sheet-count);
  display: inline-grid;
  place-items: center;
  min-width: 1.1rem;
  height: 1.1rem;
  margin-left: 0.48rem;
  padding-inline: 0.28rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #1d4ed8;
  font-size: 0.66rem;
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset;
}

.sheet-library-nav-button:hover {
  border-color: rgba(96, 165, 250, 0.9);
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  box-shadow:
    0 0 0 3px var(--control-ring),
    0 8px 18px rgba(37, 99, 235, 0.26);
}

#sheetLibraryHeaderBtn.active {
  color: #fff;
  border-color: var(--bingo-blue);
  background: linear-gradient(135deg, var(--bingo-blue), #1d4ed8);
}

.header-utility-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  position: relative;
  z-index: 1;
}

.header-icon-button {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid #aeb8c5;
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.9);
  color: #111827;
  display: inline-grid;
  place-items: center;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 1px 2px rgba(15, 23, 42, 0.08);
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.header-icon-button:hover {
  background: #fff;
  border-color: #8fa0b4;
}

.header-icon-button:active {
  transform: translateY(1px) scale(0.96);
}

.header-tool-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pattern-print-name-guidance {
  grid-column: 1 / -1;
  margin-top: -0.35rem;
}

.account-menu-wrap {
  position: relative;
}

.account-menu {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  z-index: 80;
  width: min(260px, calc(100vw - 1rem));
  display: grid;
  gap: 0.42rem;
  padding: 0.58rem;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.72) inset,
    0 16px 42px rgba(15, 23, 42, 0.18);
}

.account-menu-email {
  color: #111827;
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.account-menu-meta {
  width: fit-content;
  padding: 0.12rem 0.42rem;
  border: 1px solid rgba(5, 150, 105, 0.35);
  border-radius: 999px;
  background: linear-gradient(135deg, #ecfdf3, #d1fae5);
  color: #065f46;
  font-size: 0.72rem;
  font-weight: 850;
}

.account-menu button {
  width: 100%;
  justify-content: center;
}

body.dark-mode .app-header h1 {
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.5),
    0.045em 0.045em 0 rgba(251, 113, 133, 0.18);
}

body.dark-mode .bingo-ball-strip span {
  border-color: #e5e7eb;
  background:
    radial-gradient(circle at 35% 30%, #fff 0 22%, #e2e8f0 23% 56%, #94a3b8 57% 100%);
  box-shadow:
    0 0 0 2px rgba(15, 23, 42, 0.75),
    0 2px 5px rgba(0, 0, 0, 0.28);
}

body.dark-mode .sheet-library-nav-button {
  border-color: rgba(96, 165, 250, 0.58);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.8), rgba(30, 64, 175, 0.84));
  color: #eff6ff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 8px 18px rgba(0, 0, 0, 0.28);
}

body.dark-mode .sheet-library-nav-button.has-count::after {
  background: rgba(219, 234, 254, 0.94);
  color: #1e3a8a;
}

body.dark-mode .header-icon-button {
  background: #111827;
  border-color: #64748b;
  color: #f8fafc;
}

body.dark-mode .header-icon-button:hover {
  background: #1e293b;
  border-color: #94a3b8;
}

body.dark-mode .header-save-status.is-saved {
  color: #bbf7d0;
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(6, 78, 59, 0.45);
}

body.dark-mode .header-save-status.is-dirty {
  color: #fecdd3;
  border-color: rgba(251, 113, 133, 0.42);
  background: rgba(127, 29, 29, 0.32);
}

body.dark-mode .header-save-status.is-saving {
  color: #fde68a;
  border-color: rgba(251, 191, 36, 0.44);
  background: rgba(120, 53, 15, 0.38);
}

body.dark-mode .sheet-library-start-card,
body.dark-mode .sheet-library-existing-card {
  border-color: rgba(71, 85, 105, 0.82);
  background: rgba(15, 23, 42, 0.62);
}

body.dark-mode .sheet-library-start-card {
  border-color: rgba(251, 113, 133, 0.34);
  background:
    linear-gradient(135deg, rgba(127, 29, 29, 0.22), rgba(30, 64, 175, 0.14));
}

body.dark-mode .sheet-library-start-card strong,
body.dark-mode .sheet-library-card-heading,
body.dark-mode .pattern-library-empty strong {
  color: #f8fafc;
}

body.dark-mode .sheet-library-start-card button {
  border-color: rgba(251, 113, 133, 0.46);
  background: rgba(127, 29, 29, 0.32);
  color: #fecdd3;
}

body.dark-mode .account-menu {
  border-color: rgba(96, 165, 250, 0.32);
  background: rgba(15, 23, 42, 0.98);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 18px 46px rgba(0, 0, 0, 0.42);
}

body.dark-mode .account-menu-email {
  color: #f8fafc;
}

body.dark-mode .account-menu-meta {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(6, 78, 59, 0.45);
  color: #bbf7d0;
}

body.dark-mode .link-button {
  color: #bfdbfe;
  background: transparent;
}

body.dark-mode .link-button:hover {
  color: #fecdd3;
  background: transparent;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 30px;
  height: 30px;
  user-select: none;
  cursor: pointer;
}

.theme-toggle input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.theme-toggle-track {
  width: 30px;
  height: 30px;
  border: 1px solid #aeb8c5;
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.9);
  color: #111827;
  display: inline-grid;
  place-items: center;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 1px 2px rgba(15, 23, 42, 0.08);
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.theme-toggle:hover .theme-toggle-track {
  background: #fff;
  border-color: #8fa0b4;
}

.theme-toggle:active .theme-toggle-track {
  transform: translateY(1px) scale(0.96);
}

.theme-icon {
  grid-area: 1 / 1;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.sun-icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.moon-icon {
  opacity: 0;
  transform: rotate(-20deg) scale(0.72);
}

body.dark-mode .theme-toggle-track {
  background: #111827;
  border-color: #64748b;
  color: #f8fafc;
}

body.dark-mode .sun-icon {
  opacity: 0;
  transform: rotate(30deg) scale(0.72);
}

body.dark-mode .moon-icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.app-main {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  flex: 1;
  min-height: calc(100vh - var(--app-header-height) - (var(--page-padding) * 2));
}

.sidebar {
  width: 430px;
  flex: 0 0 430px;
  max-width: 440px;
  min-width: 400px;
  display: grid;
  gap: 0.45rem;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  padding-right: 0.35rem;
}

.workspace {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0.35rem;
}

body.print-preview-mode .sidebar {
  display: none;
}

body.print-preview-mode .app-main {
  justify-content: center;
}

body.print-preview-mode .workspace {
  flex: 1 1 100%;
}

body.print-preview-mode .preview-workspace {
  min-height: calc(100vh - var(--app-header-height) - 3.5rem);
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.1rem 0.35rem 0;
  flex-wrap: wrap;
}

.preview-toolbar-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #425066;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.preview-zoom-control {
  display: inline-grid;
  grid-template-columns: auto minmax(140px, 220px) 3.2rem;
  align-items: center;
  gap: 0.45rem;
  min-height: 2rem;
  padding: 0.12rem 0.5rem;
  border: 1px solid var(--toolbar-border);
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.58);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset;
}

.preview-zoom-control input[type="range"] {
  appearance: none;
  width: 100%;
  height: 0.28rem;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--bingo-red) 0 var(--zoom-progress, 33.33%), #cbd5e1 var(--zoom-progress, 33.33%) 100%);
  cursor: pointer;
}

.preview-zoom-control input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid var(--bingo-red);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.22);
}

.preview-zoom-control input[type="range"]::-moz-range-thumb {
  width: 0.78rem;
  height: 0.78rem;
  border: 2px solid var(--bingo-red);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.22);
}

.preview-zoom-control output {
  color: #111827;
  font-size: 0.76rem;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.preview-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.16rem;
  min-height: 2rem;
  padding: 0.16rem;
  border: 1px solid var(--toolbar-border);
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.58);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset;
}

.preview-mode-toggle button {
  min-height: 1.55rem;
  padding: 0.16rem 0.58rem;
  border-radius: 999px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: #475569;
  font-size: 0.72rem;
  font-weight: 800;
}

.preview-mode-toggle button:hover {
  border-color: transparent;
  background: rgba(37, 99, 235, 0.08);
  box-shadow: none;
}

.preview-mode-toggle button.active {
  background: linear-gradient(135deg, var(--bingo-blue), #1d4ed8);
  color: #fff;
}

.print-preview-checks {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  max-width: min(100%, 680px);
  min-height: 1.7rem;
  padding: 0.26rem 0.6rem;
  border: 1px solid rgba(245, 158, 11, 0.46);
  border-radius: 999px;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.72rem;
  line-height: 1.2;
}

.print-preview-checks.hidden {
  display: none;
}

.print-preview-checks.is-ok {
  border-color: rgba(16, 185, 129, 0.42);
  background: #ecfdf3;
  color: #065f46;
}

.print-preview-checks strong {
  white-space: nowrap;
  font-weight: 950;
}

.print-preview-checks span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-section {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 0.55rem;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.36) inset,
    0 1px 2px rgba(15, 23, 42, 0.03);
}

.quick-tips-panel {
  display: grid;
  gap: 0.45rem;
  padding: 0.62rem;
  border: 1px solid rgba(245, 158, 11, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 251, 235, 0.92), rgba(239, 246, 255, 0.84));
  color: #334155;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 2px 7px rgba(15, 23, 42, 0.06);
}

.quick-tips-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.quick-tips-header h2 {
  margin: 0;
  color: #92400e;
  font-size: 0.78rem;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.quick-tips-header button {
  min-height: 1.55rem;
  width: 1.55rem;
  padding: 0;
  border-radius: 999px;
  font-size: 0.75rem;
}

.quick-tips-panel ul {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.22rem;
}

.quick-tips-panel li {
  font-size: 0.78rem;
  line-height: 1.3;
}

.quick-tips-panel .link-button {
  justify-self: start;
  font-size: 0.76rem;
}

body.dark-mode .quick-tips-panel {
  border-color: rgba(251, 191, 36, 0.34);
  background:
    linear-gradient(135deg, rgba(120, 53, 15, 0.28), rgba(30, 64, 175, 0.16));
  color: #dbeafe;
}

body.dark-mode .quick-tips-header h2 {
  color: #fde68a;
}

body.sheet-workspace-ready:not(.sheet-library-open) .sheet-library-section {
  display: none;
}

body.sheet-library-open::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 38;
  background: rgba(2, 6, 23, 0.58);
  backdrop-filter: blur(2px);
}

body.sheet-library-open .sheet-library-section {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 42;
  width: min(620px, calc(100vw - 2rem));
  max-height: min(760px, calc(100vh - 2rem));
  overflow: auto;
  transform: translate(-50%, -50%);
  padding: 0.9rem;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.1) inset,
    0 24px 70px rgba(0, 0, 0, 0.38);
}

body.sheet-library-open .sheet-library-chooser-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.18rem;
  margin-bottom: 0.7rem;
}

body.sheet-library-open .sheet-library-chooser-header > div {
  display: grid;
  gap: 0.18rem;
}

body.sheet-library-open .sheet-library-chooser-header .icon-button {
  flex: 0 0 auto;
}

body.sheet-library-open .sheet-library-chooser-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  letter-spacing: 0;
  text-transform: none;
}

body.sheet-library-open .sheet-library-chooser-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

body.sheet-library-open .sheet-library-section #sheetDirtyStatus,
body.sheet-library-open .sheet-library-section #currentSheetStatus,
body.sheet-library-open .sheet-library-section #sheetFitStatus,
body.sheet-library-open .sheet-library-section label:has(#sheetLibraryNameInput),
body.sheet-library-open .sheet-library-section #clearSheetLibraryBtn,
body.sheet-library-open .sheet-library-section #saveSheetLibraryBtn,
body.sheet-library-open .sheet-library-section #storageModeBadge {
  display: none;
}

body.sheet-library-open .sheet-library-section .editor-actions {
  align-items: stretch;
}

body.sheet-library-open .sheet-library-section .editor-actions:first-of-type {
  display: none;
}

body.sheet-library-open .sheet-library-section .editor-actions:last-of-type {
  display: grid;
  grid-template-columns: 1fr auto auto;
}

body.sheet-library-open .sheet-library-section #newSheetLibraryBtn {
  min-height: 2.2rem;
  font-weight: 850;
}

body.sheet-library-open .sheet-library-section #loadSheetLibraryBtn {
  min-height: 2.25rem;
  font-weight: 850;
}

.sheet-library-start-card,
.sheet-library-existing-card {
  display: grid;
  gap: 0.55rem;
  padding: 0.72rem;
  border: 1px solid rgba(148, 163, 184, 0.55);
  border-radius: 10px;
  background: rgba(248, 250, 252, 0.72);
}

.sheet-library-start-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border-color: rgba(225, 29, 72, 0.26);
  background:
    linear-gradient(135deg, rgba(255, 241, 242, 0.92), rgba(239, 246, 255, 0.84));
}

.sheet-library-start-card div {
  display: grid;
  gap: 0.12rem;
}

.sheet-library-start-card strong,
.sheet-library-card-heading {
  color: #111827;
  font-size: 0.88rem;
  font-weight: 900;
}

.sheet-library-start-card span,
.sheet-library-existing-card {
  color: var(--muted);
}

.sheet-library-start-card button {
  min-height: 2.05rem;
  padding-inline: 0.82rem;
  border-color: rgba(225, 29, 72, 0.44);
  background: linear-gradient(135deg, #fff7ed, #ffe4e6);
  color: #9f1239;
  font-weight: 850;
}

body.sheet-library-open .sheet-library-existing-card {
  gap: 0.38rem;
}

.sidebar-section h2 {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.section-header-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.2rem;
  padding: 0.06rem 0.42rem;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

.section-header-status.is-saved {
  color: #065f46;
  background: linear-gradient(135deg, #ecfdf3, #d1fae5);
  border-color: rgba(5, 150, 105, 0.45);
}

.section-header-status.is-dirty {
  color: #92400e;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border-color: rgba(245, 158, 11, 0.6);
}

.section-header-status.is-saving {
  color: #92400e;
  background: linear-gradient(135deg, #fffbeb, #fde68a);
  border-color: rgba(245, 158, 11, 0.6);
}

.section-toggle {
  border: 1px solid var(--section-toggle-border);
  background:
    radial-gradient(circle at 35% 30%, #fff 0 28%, #f8fafc 29% 58%, #e2e8f0 59% 100%);
  color: var(--bingo-red);
  border-radius: 999px;
  min-height: 24px;
  width: 24px;
  padding: 0;
  font-size: 0.8rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.section-toggle:hover {
  border-color: var(--bingo-red);
  box-shadow: 0 0 0 3px var(--control-ring);
}

.section-body {
  display: grid;
  gap: inherit;
}

.sidebar-section.collapsed .section-body {
  display: none;
}

.sidebar-section.collapsed h2 {
  margin-bottom: 0;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 0.28rem;
  background: var(--toolbar-bg);
  border: 1px solid var(--toolbar-border);
  border-radius: 8px;
  padding: 0.3rem;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(6px);
}

.export-quality-warnings {
  grid-column: 1 / -1;
  min-height: 1.25rem;
  padding: 0.18rem 0.42rem;
  border: 1px solid rgba(245, 158, 11, 0.46);
  border-radius: 7px;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.68rem;
  font-weight: 850;
  line-height: 1.2;
}

.export-quality-warnings.hidden {
  display: none;
}

.toolbar button {
  min-height: 34px;
  padding-inline: 0.4rem;
  white-space: nowrap;
  font-size: 0.84rem;
}

.toolbar .export-primary {
  font-weight: 800;
}

.toolbar .export-secondary {
  color: #1e3a8a;
  background:
    linear-gradient(135deg, rgba(239, 246, 255, 0.94), rgba(219, 234, 254, 0.94));
  border-color: rgba(37, 99, 235, 0.45);
}

.toolbar .export-secondary:hover {
  background:
    linear-gradient(135deg, #eff6ff, #bfdbfe);
}

#importSheetInput {
  display: none;
}

.section-grid {
  display: grid;
  gap: 0.36rem;
}

.advanced-settings {
  border-top: 1px solid #d3dbe6;
  margin-top: 0.1rem;
  padding-top: 0.35rem;
}

.print-sizing-panel {
  display: grid;
  gap: 0.42rem;
  padding: 0.58rem;
  border: 1px solid rgba(37, 99, 235, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(239, 246, 255, 0.86), rgba(255, 255, 255, 0.72));
}

.print-sizing-header {
  display: grid;
  gap: 0.12rem;
}

.print-sizing-header h3 {
  margin: 0;
  color: #1e3a8a;
  font-size: 0.84rem;
  line-height: 1.15;
}

.print-sizing-header p {
  margin: 0;
  color: #536173;
  font-size: 0.72rem;
  line-height: 1.3;
}

#resetPrintSizingBtn {
  min-height: 1.8rem;
  padding: 0.32rem 0.42rem;
  border-radius: 7px;
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1.1;
}

.group-reset-button {
  min-height: 1.65rem;
  justify-self: stretch;
  padding: 0.24rem 0.42rem;
  border-radius: 7px;
  font-size: 0.7rem;
  font-weight: 800;
}

.field-size-group {
  display: grid;
  gap: 0.36rem;
  padding: 0.48rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.4);
}

.field-guidance {
  margin: -0.08rem 0 0;
  color: #475569;
  font-size: 0.7rem;
  line-height: 1.3;
}

.qr-guidance {
  padding: 0.26rem 0.38rem;
  border: 1px solid transparent;
  border-radius: 7px;
}

.qr-guidance.is-good {
  border-color: rgba(5, 150, 105, 0.28);
  background: #ecfdf3;
  color: #047857;
}

.qr-guidance.is-small {
  border-color: rgba(245, 158, 11, 0.38);
  background: #fffbeb;
  color: #92400e;
}

.qr-guidance.is-risky {
  border-color: rgba(225, 29, 72, 0.36);
  background: #fff1f2;
  color: #be123c;
}

.print-readability-warnings {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  min-height: 1.35rem;
}

.readability-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.35rem;
  padding: 0.18rem 0.42rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 850;
  line-height: 1.15;
}

.readability-badge.is-ok {
  border-color: rgba(5, 150, 105, 0.36);
  background: #ecfdf3;
  color: #047857;
}

.readability-badge.is-warning {
  border-color: rgba(245, 158, 11, 0.45);
  background: #fffbeb;
  color: #92400e;
}

.size-control {
  display: grid;
  grid-template-columns: minmax(5.8rem, 0.72fr) minmax(0, 1.28fr);
  gap: 0.45rem;
  align-items: center;
}

.size-control span {
  color: #253044;
  font-size: 0.72rem;
  font-weight: 750;
}

.size-control input[type="range"] {
  width: 100%;
  min-height: 1.35rem;
  background:
    linear-gradient(90deg, var(--bingo-blue) var(--size-progress, 0%), #d8e1ec var(--size-progress, 0%));
  accent-color: var(--bingo-blue);
  cursor: pointer;
}

body.dark-mode .print-sizing-panel {
  border-color: rgba(96, 165, 250, 0.34);
  background:
    linear-gradient(180deg, rgba(30, 58, 138, 0.24), rgba(15, 23, 42, 0.48));
}

body.dark-mode .field-size-group {
  border-color: rgba(71, 85, 105, 0.68);
  background: rgba(15, 23, 42, 0.38);
}

body.dark-mode .export-quality-warnings {
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(120, 53, 15, 0.34);
  color: #fde68a;
}

body.dark-mode .field-guidance {
  color: #cbd5e1;
}

body.dark-mode .qr-guidance.is-good {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(6, 78, 59, 0.45);
  color: #bbf7d0;
}

body.dark-mode .qr-guidance.is-small,
body.dark-mode .export-preview-status.is-warning,
body.dark-mode .export-preview-warnings ul {
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(120, 53, 15, 0.34);
  color: #fde68a;
}

body.dark-mode .qr-guidance.is-risky {
  border-color: rgba(251, 113, 133, 0.42);
  background: rgba(127, 29, 29, 0.36);
  color: #fecdd3;
}

body.dark-mode .export-preview-status.is-ok {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(6, 78, 59, 0.45);
  color: #bbf7d0;
}

body.dark-mode .print-sizing-header h3,
body.dark-mode .size-control span {
  color: #bfdbfe;
}

body.dark-mode .print-sizing-header p {
  color: #cbd5e1;
}

body.dark-mode .readability-badge.is-ok {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(6, 78, 59, 0.45);
  color: #bbf7d0;
}

body.dark-mode .readability-badge.is-warning {
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(120, 53, 15, 0.34);
  color: #fde68a;
}

.advanced-settings summary {
  cursor: pointer;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 700;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 2rem;
  padding: 0.2rem 0.32rem;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 7px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.76), rgba(254, 243, 199, 0.38));
}

.advanced-settings summary::-webkit-details-marker {
  display: none;
}

.advanced-settings summary::before {
  content: ">";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  color: #fff;
  background: var(--bingo-gold);
  font-size: 0.72rem;
  line-height: 1;
  transition: transform 0.16s ease;
}

.advanced-settings[open] summary::before {
  transform: rotate(90deg);
}

.advanced-settings summary span:first-child {
  flex: 1 1 auto;
}

.summary-hint {
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 650;
  white-space: nowrap;
}

.advanced-settings[open] .summary-hint {
  color: #475569;
}

.summary-hint-open {
  display: none;
}

.advanced-settings[open] .summary-hint-closed {
  display: none;
}

.advanced-settings[open] .summary-hint-open {
  display: inline;
}

.advanced-settings-body {
  display: grid;
  gap: 0.36rem;
  margin-top: 0.42rem;
}

.data-tools {
  border-top: 1px dashed #c8d2df;
  margin-top: 0.1rem;
  padding-top: 0.35rem;
}

.advanced-actions {
  border-top: 1px dashed #c8d2df;
  margin-top: 0.1rem;
  padding-top: 0.35rem;
}

.data-tools summary {
  cursor: pointer;
  color: #64748b;
  font-size: 0.74rem;
  font-weight: 700;
}

.inline-pair {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 0.45rem;
  align-items: end;
}

.inline-pair > label:only-child {
  grid-column: 1 / -1;
}

.section-grid label,
.sidebar-section label,
.pattern-search-label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.78rem;
}

.sidebar-section label {
  color: #1f2937;
}

body.dark-mode .sidebar-section label,
body.dark-mode .pattern-search-label,
body.dark-mode .pattern-library-label,
body.dark-mode .pattern-library-picker-label {
  color: #e5e7eb;
}

body.dark-mode .muted,
body.dark-mode #currentSheetStatus,
body.dark-mode #sheetFitStatus,
body.dark-mode #sheetPatternCount {
  color: #cbd5e1;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
textarea,
select {
  border: 1px solid var(--input-border);
  border-radius: 6px;
  min-height: 30px;
  padding: 0.26rem 0.48rem;
  font-size: 0.86rem;
  background: var(--input-bg);
  color: var(--text);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus,
textarea:focus,
select:focus,
input[type="number"]:focus {
  outline: none;
  border-color: var(--bingo-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

input[type="file"] {
  color: var(--muted);
  font-size: 0.78rem;
}

input[type="file"]::file-selector-button {
  border: 1px solid rgba(148, 163, 184, 0.82);
  border-radius: 5px;
  background: #f8fafc;
  color: #111827;
  padding: 0.18rem 0.42rem;
  font: inherit;
  cursor: pointer;
}

body.dark-mode input[type="file"] {
  color: #cbd5e1;
}

body.dark-mode input[type="file"]::file-selector-button {
  border-color: #64748b;
  background: #e5e7eb;
  color: #0f172a;
}

textarea {
  min-height: 62px;
  resize: vertical;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.86rem;
  grid-template-columns: none;
  justify-content: flex-start;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.checkbox-row span {
  display: inline;
  line-height: 1.2;
}

button {
  border: 1px solid rgba(148, 163, 184, 0.82);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(241, 245, 249, 0.95));
  border-radius: 6px;
  padding: 0.28rem 0.52rem;
  min-height: 30px;
  cursor: pointer;
  color: #111;
  font-size: 0.86rem;
  font-weight: 500;
  transition: transform 0.12s ease, box-shadow 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

button:hover {
  background:
    linear-gradient(180deg, #fff, #eef2f7);
  border-color: var(--bingo-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

button:active {
  transform: translateY(1px) scale(0.985);
}

button.feedback-active {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

button.feedback-success {
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18);
  border-color: #15803d;
}

button.primary {
  background:
    linear-gradient(135deg, var(--bingo-red), #be123c);
  border-color: #be123c;
  color: white;
  box-shadow: 0 2px 5px rgba(190, 18, 60, 0.22);
}

button.primary:hover {
  background:
    linear-gradient(135deg, #fb315f, var(--bingo-red));
  border-color: #9f1239;
}

button.danger {
  background:
    linear-gradient(135deg, #7f1d1d, #b91c1c);
  border-color: #991b1b;
  color: white;
}

button.danger:hover {
  background:
    linear-gradient(135deg, #991b1b, #dc2626);
}

body.dark-mode button {
  border-color: #64748b;
  color: #e5e7eb;
  background: linear-gradient(180deg, #1e293b, #0f172a);
}

body.dark-mode button.primary,
body.dark-mode .pattern-card-action.primary {
  background: linear-gradient(135deg, var(--bingo-red), #be123c);
  color: #fff;
  border-color: #fb7185;
}

body.dark-mode button.primary:hover,
body.dark-mode .pattern-card-action.primary:hover {
  background: linear-gradient(135deg, #fb7185, var(--bingo-red));
}

body.dark-mode .toolbar .export-secondary {
  color: #dbeafe;
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.82), rgba(30, 41, 59, 0.86));
  border-color: #60a5fa;
}

body.dark-mode .toolbar .export-secondary:hover {
  background: linear-gradient(135deg, #1d4ed8, #334155);
}

body.dark-mode button.danger {
  background: #fee2e2;
  color: #7f1d1d;
  border-color: #fca5a5;
}

body.dark-mode button.danger:hover {
  background: #fecaca;
}

body.dark-mode .preview-toolbar-label {
  color: #cbd5e1;
}

body.dark-mode .preview-zoom-control {
  border-color: #475569;
  background: rgba(15, 23, 42, 0.62);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

body.dark-mode .preview-mode-toggle {
  border-color: #475569;
  background: rgba(15, 23, 42, 0.62);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

body.dark-mode .preview-mode-toggle button {
  color: #cbd5e1;
}

body.dark-mode .preview-mode-toggle button:hover {
  background: rgba(96, 165, 250, 0.12);
}

body.dark-mode .preview-mode-toggle button.active {
  background: linear-gradient(135deg, var(--bingo-blue), #1d4ed8);
  color: #fff;
}

body.dark-mode .print-preview-checks {
  border-color: rgba(251, 191, 36, 0.48);
  background: rgba(120, 53, 15, 0.38);
  color: #fde68a;
}

body.dark-mode .print-preview-checks.is-ok {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(6, 78, 59, 0.45);
  color: #bbf7d0;
}

body.dark-mode .preview-zoom-control input[type="range"] {
  background:
    linear-gradient(90deg, var(--bingo-red) 0 var(--zoom-progress, 33.33%), #475569 var(--zoom-progress, 33.33%) 100%);
}

body.dark-mode .preview-zoom-control input[type="range"]::-webkit-slider-thumb {
  border-color: var(--bingo-red);
  background: #0f172a;
}

body.dark-mode .preview-zoom-control input[type="range"]::-moz-range-thumb {
  border-color: var(--bingo-red);
  background: #0f172a;
}

body.dark-mode .preview-zoom-control output {
  color: #f8fafc;
}

body.dark-mode .advanced-settings summary {
  color: #e5e7eb;
  background:
    linear-gradient(90deg, rgba(30, 41, 59, 0.82), rgba(120, 53, 15, 0.18));
  border-color: rgba(148, 163, 184, 0.42);
}

body.dark-mode .summary-hint {
  color: #cbd5e1;
}

body.dark-mode .data-tools summary {
  color: #cbd5e1;
}

body.dark-mode .section-toggle {
  background:
    radial-gradient(circle at 35% 30%, #f8fafc 0 22%, #cbd5e1 23% 56%, #64748b 57% 100%);
  color: #be123c;
}

.editor-actions,
.toolbar {
  margin-top: 0;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 2.15rem;
  align-items: flex-start;
}

.pattern-modal {
  position: fixed;
  inset: 0;
  background: rgba(14, 22, 32, 0.46);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 80;
}

.pattern-modal.open {
  display: flex;
}

.start-choice-modal.open {
  background:
    radial-gradient(circle at 22% 18%, rgba(251, 191, 36, 0.18), transparent 18rem),
    radial-gradient(circle at 82% 16%, rgba(225, 29, 72, 0.18), transparent 20rem),
    radial-gradient(circle at 58% 82%, rgba(37, 99, 235, 0.16), transparent 22rem),
    #020617;
  backdrop-filter: none;
}

.hidden {
  display: none !important;
}

.pattern-modal-panel {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid #c8cfda;
  border-radius: 10px;
  padding: 0.9rem;
  display: grid;
  gap: 0.55rem;
  color: #111827;
}

.pattern-modal-panel label,
.pattern-modal-panel h2,
.pattern-modal-panel .muted,
.pattern-modal-panel #selectedPatternInfo {
  color: #111827;
}

.pattern-modal-panel .muted,
.pattern-modal-panel #selectedPatternInfo {
  color: #64748b;
}

.pattern-editor-modal-panel {
  width: min(460px, 100%);
  max-height: 92vh;
  overflow: auto;
}

.auth-modal-panel {
  width: min(390px, 100%);
}

.auth-recovery-copy {
  margin: 0 0 0.15rem;
  color: #475569;
  font-size: 0.86rem;
  line-height: 1.35;
}

.welcome-modal-panel {
  width: min(430px, 100%);
}

.start-choice-modal-panel {
  width: min(520px, 100%);
}

.new-sheet-modal-panel {
  width: min(440px, 100%);
}

.export-preview-modal-panel {
  width: min(860px, calc(100vw - 2rem));
  max-height: 92vh;
  overflow: auto;
}

.export-preview-warnings {
  display: grid;
  gap: 0.35rem;
}

.export-preview-status {
  padding: 0.42rem 0.55rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 850;
}

.export-preview-status.is-ok {
  border: 1px solid rgba(5, 150, 105, 0.34);
  background: #ecfdf3;
  color: #047857;
}

.export-preview-status.is-warning {
  border: 1px solid rgba(245, 158, 11, 0.44);
  background: #fffbeb;
  color: #92400e;
}

.export-preview-warnings ul {
  margin: 0;
  padding-left: 1.1rem;
  color: #92400e;
  font-size: 0.8rem;
  line-height: 1.35;
}

.export-preview-frame {
  max-height: 58vh;
  overflow: auto;
  padding: 0.75rem;
  border: 1px solid #d6deeb;
  border-radius: 8px;
  background: #0f172a;
}

.export-preview-sheet {
  margin: 0 auto;
  transform: scale(var(--export-preview-scale, 1));
  transform-origin: top center;
}

.welcome-copy {
  margin: 0;
  color: #475569;
  font-size: 0.88rem;
  line-height: 1.35;
}

.welcome-actions {
  display: grid;
  gap: 0.45rem;
}

.start-choice-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.start-choice-actions button {
  min-height: 5.2rem;
  display: grid;
  gap: 0.2rem;
  align-content: center;
  text-align: left;
  padding: 0.75rem 0.85rem;
  font-weight: 900;
  line-height: 1.1;
}

.start-choice-actions button span {
  color: #64748b;
  font-size: 0.76rem;
  font-weight: 750;
}

body.dark-mode .start-choice-actions button span {
  color: #cbd5e1;
}

.welcome-actions button,
.template-actions button {
  min-height: 2.2rem;
  font-weight: 850;
}

.template-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.starter-layout-grid button {
  display: grid;
  gap: 0.12rem;
  align-content: center;
  text-align: left;
  padding: 0.52rem 0.62rem;
  line-height: 1.1;
}

.starter-layout-grid button span {
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 700;
}

body.dark-mode .starter-layout-grid button span {
  color: #cbd5e1;
}

.admin-modal-panel {
  width: min(980px, calc(100vw - 2rem));
  max-height: 88vh;
  overflow: auto;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(270px, 0.75fr);
  gap: 0.9rem;
  align-items: start;
}

.admin-health-section {
  grid-column: 1 / -1;
}

.admin-section {
  display: grid;
  gap: 0.55rem;
  border: 1px solid #d7dee9;
  border-radius: 8px;
  padding: 0.75rem;
  background: linear-gradient(135deg, #fff, #f8fafc);
}

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.admin-section h3 {
  margin: 0;
  font-size: 0.92rem;
  color: #111827;
}

.admin-health-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.admin-health-item {
  border: 1px solid #d6deea;
  border-left: 4px solid #94a3b8;
  border-radius: 8px;
  padding: 0.5rem 0.58rem;
  background: #fff;
  min-width: 0;
}

.admin-health-item.is-ok {
  border-left-color: #059669;
}

.admin-health-item.is-warn {
  border-left-color: #f59e0b;
}

.admin-health-item.is-bad {
  border-left-color: #e11d48;
}

.admin-health-label {
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.025em;
  line-height: 1.2;
  text-transform: uppercase;
}

.admin-health-value {
  color: #111827;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.25;
  margin-top: 0.16rem;
  overflow-wrap: anywhere;
}

.admin-users-list {
  display: grid;
  gap: 0.42rem;
  max-height: 52vh;
  overflow: auto;
}

.admin-status {
  border: 1px solid #d6deea;
  border-radius: 7px;
  padding: 0.46rem 0.58rem;
  background: #f8fafc;
  color: #334155;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
}

.admin-status.success {
  border-color: rgba(5, 150, 105, 0.45);
  background: linear-gradient(135deg, #ecfdf3, #d1fae5);
  color: #065f46;
}

.admin-status.error {
  border-color: rgba(225, 29, 72, 0.48);
  background: linear-gradient(135deg, #fff1f2, #ffe4e6);
  color: #9f1239;
}

.admin-import-preview {
  border: 1px solid rgba(37, 99, 235, 0.35);
  border-radius: 7px;
  padding: 0.48rem 0.58rem;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  display: grid;
  gap: 0.18rem;
}

.admin-import-preview-title {
  color: #1e3a8a;
  font-size: 0.86rem;
  font-weight: 850;
  line-height: 1.2;
}

.admin-import-preview-meta {
  color: #475569;
  font-size: 0.76rem;
  line-height: 1.35;
}

.admin-user-card {
  border: 1px solid #d6deea;
  border-left: 4px solid var(--bingo-blue);
  border-radius: 8px;
  padding: 0.5rem 0.62rem;
  background: #fff;
}

.admin-user-email {
  color: #111827;
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.2;
}

.admin-user-meta {
  color: #64748b;
  font-size: 0.76rem;
  line-height: 1.35;
  margin-top: 0.12rem;
}

.help-modal-panel {
  width: min(760px, calc(100vw - 2rem));
  max-height: 88vh;
  overflow: auto;
}

.help-content {
  display: grid;
  gap: 0.8rem;
}

.help-content section {
  border: 1px solid #d7dee9;
  border-radius: 8px;
  padding: 0.72rem 0.82rem;
  background: linear-gradient(135deg, #fff, #f8fafc);
}

.help-content h3 {
  margin: 0 0 0.4rem;
  color: #111827;
  font-size: 0.92rem;
}

.help-content p {
  margin: 0;
  color: #334155;
  font-size: 0.86rem;
  line-height: 1.42;
}

.help-content dl {
  display: grid;
  grid-template-columns: minmax(8.5rem, 0.42fr) 1fr;
  gap: 0.34rem 0.72rem;
  margin: 0;
}

.help-content dt {
  color: #111827;
  font-weight: 800;
  font-size: 0.84rem;
}

.help-content dd {
  margin: 0;
  color: #475569;
  font-size: 0.84rem;
  line-height: 1.35;
}

.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.modal-header-row h2 {
  margin: 0;
}

.pattern-editor-modal-panel .pattern-editor-panel {
  border: none;
  box-shadow: none;
  background: transparent;
  padding: 0;
}

.pattern-modal-panel h2 {
  margin: 0;
  font-size: 1rem;
}

body.dark-mode .pattern-modal {
  background: rgba(2, 6, 23, 0.68);
}

body.dark-mode .start-choice-modal.open {
  background:
    radial-gradient(circle at 22% 18%, rgba(251, 191, 36, 0.18), transparent 18rem),
    radial-gradient(circle at 82% 16%, rgba(225, 29, 72, 0.18), transparent 20rem),
    radial-gradient(circle at 58% 82%, rgba(37, 99, 235, 0.16), transparent 22rem),
    #020617;
}

body.dark-mode .pattern-modal-panel {
  background:
    linear-gradient(135deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.98));
  border-color: rgba(96, 165, 250, 0.32);
  color: #f8fafc;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 24px 70px rgba(0, 0, 0, 0.46);
}

body.dark-mode .pattern-modal-panel label,
body.dark-mode .pattern-modal-panel h2,
body.dark-mode .pattern-modal-panel .checkbox-row span {
  color: #f8fafc;
}

body.dark-mode .pattern-modal-panel .muted,
body.dark-mode .pattern-modal-panel #selectedPatternInfo {
  color: #cbd5e1;
}

body.dark-mode .welcome-copy {
  color: #cbd5e1;
}

body.dark-mode .auth-recovery-copy {
  color: #cbd5e1;
}

body.dark-mode .pattern-editor-modal-panel input,
body.dark-mode .pattern-editor-modal-panel select {
  background: #0f172a;
  border-color: #64748b;
  color: #f8fafc;
}

body.dark-mode .pattern-editor-modal-panel input::placeholder {
  color: #94a3b8;
}

body.dark-mode .pattern-editor-modal-panel input:focus,
body.dark-mode .pattern-editor-modal-panel select:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.28);
}

.pattern-creator-grid {
  margin-top: 0.2rem;
  display: grid;
  width: 260px;
  max-width: 100%;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  aspect-ratio: 1 / 1;
  gap: 2px;
}

.muted {
  color: var(--muted);
  font-size: 0.82rem;
}

.sheet-dirty-status {
  display: none;
}

.library-status-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  min-height: 1.9rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid #c9d2dd;
  background: #f4f6f9;
  font-weight: 700;
}

.library-status-flag.is-on-sheet {
  color: #065f46;
  background: linear-gradient(135deg, #ecfdf3, #d1fae5);
  border-color: rgba(5, 150, 105, 0.45);
}

.library-status-flag.is-library-only {
  color: #1d4ed8;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-color: rgba(37, 99, 235, 0.38);
}

.storage-mode-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0.22rem 0.55rem;
  border: 1px solid rgba(148, 163, 184, 0.65);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 850;
  white-space: nowrap;
}

.storage-mode-badge.is-local {
  color: #1d4ed8;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-color: rgba(37, 99, 235, 0.38);
}

.storage-mode-badge.is-cloud {
  color: #065f46;
  background: linear-gradient(135deg, #ecfdf3, #d1fae5);
  border-color: rgba(5, 150, 105, 0.45);
}

.toast-container {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  gap: 0.45rem;
  z-index: 70;
  pointer-events: none;
}

.toast {
  min-width: 200px;
  max-width: 320px;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: rgba(255, 255, 255, 0.96);
  color: #111827;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.16);
  font-size: 0.84rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: auto;
  display: grid;
  gap: 0.45rem;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  border-color: #86efac;
  background: rgba(240, 253, 244, 0.97);
  color: #166534;
}

.toast.info {
  border-color: #bfdbfe;
  background: rgba(239, 246, 255, 0.97);
  color: #1d4ed8;
}

.toast button {
  justify-self: end;
  min-height: 28px;
  padding: 0.22rem 0.55rem;
  font-size: 0.8rem;
}

.sheet-empty-state {
  grid-column: 1 / -1;
  min-height: 3.2in;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px dashed #c7d0dc;
  border-radius: 12px;
  color: #5b6471;
  background: rgba(246, 248, 251, 0.7);
  padding: 1rem;
  font-size: 0.95rem;
  line-height: 1.4;
}

.sheet-dirty-status.is-dirty {
  color: #b45309;
}

.sheet-dirty-status.is-saved {
  color: #166534;
}

.pattern-library {
  display: grid;
  gap: 0.45rem;
  max-height: 360px;
  overflow: auto;
}

.pattern-library-picker-label {
  font-size: 0.82rem;
  color: #1f2937;
}

.library-state {
  border: 1px solid #d6deea;
  border-radius: 8px;
  padding: 0.62rem 0.68rem;
  color: #334155;
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
  line-height: 1.35;
}

.library-state.is-loading {
  border-color: rgba(37, 99, 235, 0.28);
  background: linear-gradient(135deg, #eff6ff, #fff);
  color: #1d4ed8;
  font-weight: 750;
}

.library-state.is-empty {
  color: #475569;
  background: rgba(248, 250, 252, 0.82);
}

.library-state.is-info {
  border-color: rgba(14, 165, 233, 0.28);
  background: linear-gradient(135deg, #f0f9ff, #fff);
  color: #075985;
}

.library-state.is-error {
  display: grid;
  gap: 0.38rem;
  border-color: rgba(225, 29, 72, 0.28);
  background: linear-gradient(135deg, #fff1f2, #fff);
  color: #9f1239;
}

.library-state-detail {
  color: #64748b;
  font-size: 0.74rem;
  overflow-wrap: anywhere;
}

.library-state button {
  width: fit-content;
  min-height: 1.8rem;
  padding: 0.14rem 0.62rem;
  border-radius: 999px;
  font-size: 0.74rem;
}

.sheet-library-list {
  display: grid;
  gap: 0.32rem;
  max-height: 260px;
  overflow: auto;
  padding-right: 0.1rem;
}

.sheet-library-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 0.72fr);
  gap: 0.35rem;
  margin: 0.22rem 0 0.34rem;
}

.sheet-library-tools input,
.sheet-library-tools select {
  min-height: 28px;
  font-size: 0.8rem;
}

.sheet-library-card {
  width: 100%;
  border: 1px solid #d3dae4;
  border-left: 4px solid rgba(148, 163, 184, 0.45);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 0.42rem 0.55rem;
  display: grid;
  gap: 0.1rem;
  text-align: left;
}

body.sheet-library-open .sheet-library-card {
  min-height: 66px;
  padding: 0.58rem 0.68rem;
}

body.sheet-library-open .sheet-library-card.selected {
  box-shadow:
    0 0 0 2px rgba(96, 165, 250, 0.42),
    0 8px 20px rgba(37, 99, 235, 0.16);
}

.sheet-library-card:hover {
  background: #fff;
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.08);
}

.sheet-library-card.selected {
  border-color: rgba(37, 99, 235, 0.58);
  border-left-color: var(--bingo-blue);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  background: linear-gradient(90deg, #eff6ff, #fff);
}

.sheet-library-card-header {
  display: grid;
  gap: 0.03rem;
}

.sheet-library-card-name {
  font-weight: 700;
  color: #111827;
  line-height: 1.1;
  font-size: 0.9rem;
}

.sheet-library-card-subtitle {
  color: #475569;
  font-size: 0.74rem;
  line-height: 1.15;
}

.sheet-library-card-meta {
  color: #64748b;
  font-size: 0.72rem;
}

.pattern-library-list {
  display: grid;
  gap: 0.35rem;
  max-height: 460px;
  overflow: auto;
  padding-right: 0.1rem;
}

.pattern-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}

.pattern-filter-chip {
  min-height: 1.75rem;
  padding: 0.12rem 0.56rem;
  border-radius: 999px;
  border-color: rgba(148, 163, 184, 0.68);
  background: rgba(255, 255, 255, 0.72);
  color: #334155;
  font-size: 0.74rem;
  font-weight: 800;
}

.pattern-filter-chip:hover {
  border-color: rgba(37, 99, 235, 0.46);
  background: #eff6ff;
}

.pattern-filter-chip.active {
  color: #fff;
  border-color: var(--bingo-blue);
  background: linear-gradient(135deg, var(--bingo-blue), #1d4ed8);
}

.pattern-library-empty {
  display: grid;
  gap: 0.45rem;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(248, 250, 252, 0.7);
  color: var(--muted);
}

.pattern-library-empty strong {
  color: #111827;
  font-size: 0.86rem;
}

.pattern-library-empty span {
  line-height: 1.35;
}

.pattern-library-empty-actions {
  display: flex;
  justify-content: flex-start;
}

.pattern-library-empty-actions button {
  min-height: 1.9rem;
  padding-inline: 0.7rem;
  font-size: 0.78rem;
  font-weight: 850;
}

.pattern-library-card {
  width: 100%;
  border: 1px solid #c8cfda;
  border-left: 4px solid var(--pattern-accent, #c8cfda);
  border-radius: 10px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--pattern-accent, #94a3b8) 10%, #fff), #fff 34%);
  padding: 0.42rem 0.62rem 0.42rem 0.48rem;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 0.55rem;
  align-items: center;
  text-align: left;
  min-height: 76px;
  overflow: visible;
}

.pattern-library-card:hover {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--pattern-accent, #94a3b8) 16%, #fff), #fff 38%);
  border-color: color-mix(in srgb, var(--pattern-accent, #94a3b8) 65%, #94a3b8);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.pattern-library-card.selected {
  border-color: var(--bingo-blue);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.22), 0 5px 14px rgba(37, 99, 235, 0.1);
  background: linear-gradient(90deg, #dbeafe, #fff);
}

.pattern-library-card-body {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto;
  gap: 0.35rem;
  align-content: stretch;
  min-height: 100%;
}

.pattern-library-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  min-height: 1.45rem;
  padding-right: 0.08rem;
}

.pattern-library-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  min-height: 1.55rem;
}

.pattern-library-card-name {
  font-weight: 700;
  color: #111827;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
}

.pattern-library-card-category {
  color: #475569;
  font-size: 0.74rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
}

.pattern-library-card-category::before {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  background: var(--pattern-accent, #94a3b8);
  flex: 0 0 auto;
}

.pattern-library-card-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 1.6rem;
  padding: 0.14rem 0.45rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
}

.pattern-library-card-status.on-sheet {
  color: #065f46;
  background: linear-gradient(135deg, #ecfdf3, #d1fae5);
  border-color: rgba(5, 150, 105, 0.45);
}

.pattern-library-card-status.library-only {
  color: #1d4ed8;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-color: rgba(37, 99, 235, 0.38);
}

.pattern-library-card-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.22rem;
  flex-wrap: wrap;
  min-height: 1.55rem;
}

.pattern-card-action {
  min-height: 28px;
  padding: 0.08rem 0.38rem;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1;
  border-color: #c3ccd8;
  background: #fff;
}

.pattern-card-action:hover {
  background: #eef3f8;
}

.pattern-card-action.primary {
  background: linear-gradient(135deg, var(--bingo-blue), #1d4ed8);
  border-color: #1d4ed8;
  color: #fff;
}

.pattern-card-action.primary:hover {
  background: linear-gradient(135deg, #3b82f6, var(--bingo-blue));
}

.pattern-library-card .grid-preview {
  width: 30px;
  gap: 1px;
  align-self: center;
  justify-self: center;
}

.pattern-library-card .mini-cell {
  border-width: 0;
  min-width: 0;
  min-height: 0;
}

.pattern-library-card .mini-cell.free-center::after {
  content: none;
}

.pattern-library-card .grid-preview.mini-silhouette {
  background: transparent;
}

.pattern-library-card .grid-preview.mini-silhouette .mini-cell {
  background: transparent;
}

.pattern-library-card .grid-preview.mini-silhouette .mini-cell.filled,
.pattern-library-card .grid-preview.mini-silhouette .mini-cell.marked {
  background: #111;
}

.pattern-library-card .grid-preview.mini-silhouette .mini-cell.marked::before {
  display: none;
}

body.dark-mode .sheet-library-card {
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(71, 85, 105, 0.86);
}

body.dark-mode .sheet-library-card:hover {
  background: rgba(30, 41, 59, 0.92);
  border-color: var(--bingo-blue);
}

body.dark-mode .sheet-library-card.selected {
  background: linear-gradient(90deg, rgba(30, 64, 175, 0.34), rgba(15, 23, 42, 0.76));
  border-color: var(--bingo-blue);
  border-left-color: var(--bingo-blue);
}

body.dark-mode .library-state {
  border-color: rgba(71, 85, 105, 0.82);
  background: rgba(15, 23, 42, 0.72);
  color: #cbd5e1;
}

body.dark-mode .library-state.is-loading {
  border-color: rgba(96, 165, 250, 0.42);
  background: rgba(30, 64, 175, 0.24);
  color: #dbeafe;
}

body.dark-mode .library-state.is-empty {
  background: rgba(15, 23, 42, 0.62);
  color: #aab4c3;
}

body.dark-mode .library-state.is-info {
  border-color: rgba(56, 189, 248, 0.42);
  background: rgba(12, 74, 110, 0.24);
  color: #bae6fd;
}

body.dark-mode .library-state.is-error {
  border-color: rgba(251, 113, 133, 0.42);
  background: rgba(127, 29, 29, 0.22);
  color: #fecdd3;
}

body.dark-mode .library-state-detail {
  color: #aab4c3;
}

body.dark-mode .pattern-filter-chip {
  border-color: rgba(71, 85, 105, 0.88);
  background: rgba(15, 23, 42, 0.78);
  color: #cbd5e1;
}

body.dark-mode .pattern-filter-chip:hover {
  border-color: rgba(96, 165, 250, 0.52);
  background: rgba(30, 64, 175, 0.26);
}

body.dark-mode .pattern-filter-chip.active {
  color: #0f172a;
  border-color: var(--bingo-blue);
  background: linear-gradient(135deg, var(--bingo-blue), #dbeafe);
}

body.dark-mode .pattern-library-empty {
  border-color: rgba(71, 85, 105, 0.82);
  background: rgba(15, 23, 42, 0.62);
}

body.dark-mode .help-content section {
  border-color: rgba(71, 85, 105, 0.9);
  background: linear-gradient(135deg, #111827, #0f172a);
}

body.dark-mode .admin-section {
  border-color: rgba(71, 85, 105, 0.9);
  background: linear-gradient(135deg, #111827, #0f172a);
}

body.dark-mode .admin-user-card {
  border-color: rgba(71, 85, 105, 0.9);
  border-left-color: var(--bingo-blue);
  background: rgba(15, 23, 42, 0.82);
}

body.dark-mode .admin-health-item {
  border-color: rgba(71, 85, 105, 0.9);
  background: rgba(15, 23, 42, 0.82);
}

body.dark-mode .admin-health-item.is-ok {
  border-left-color: #34d399;
}

body.dark-mode .admin-health-item.is-warn {
  border-left-color: #fbbf24;
}

body.dark-mode .admin-health-item.is-bad {
  border-left-color: #fb7185;
}

body.dark-mode .admin-health-label {
  color: #aab4c3;
}

body.dark-mode .admin-health-value {
  color: #f8fafc;
}

body.dark-mode .admin-status {
  border-color: rgba(71, 85, 105, 0.9);
  background: rgba(15, 23, 42, 0.82);
  color: #cbd5e1;
}

body.dark-mode .admin-status.success {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(6, 78, 59, 0.45);
  color: #bbf7d0;
}

body.dark-mode .admin-status.error {
  border-color: rgba(251, 113, 133, 0.5);
  background: rgba(127, 29, 29, 0.45);
  color: #fecdd3;
}

body.dark-mode .admin-import-preview {
  border-color: rgba(96, 165, 250, 0.45);
  background: rgba(30, 64, 175, 0.28);
}

body.dark-mode .admin-import-preview-title {
  color: #dbeafe;
}

body.dark-mode .admin-import-preview-meta {
  color: #cbd5e1;
}

body.dark-mode .storage-mode-badge.is-local {
  color: #dbeafe;
  background: rgba(30, 64, 175, 0.32);
  border-color: rgba(96, 165, 250, 0.45);
}

body.dark-mode .storage-mode-badge.is-cloud {
  color: #bbf7d0;
  background: rgba(6, 78, 59, 0.45);
  border-color: rgba(52, 211, 153, 0.4);
}

body.dark-mode .admin-section h3,
body.dark-mode .admin-user-email {
  color: #f8fafc;
}

body.dark-mode .admin-user-meta {
  color: #cbd5e1;
}

body.dark-mode .help-content h3,
body.dark-mode .help-content dt {
  color: #f8fafc;
}

body.dark-mode .help-content p,
body.dark-mode .help-content dd {
  color: #cbd5e1;
}

body.dark-mode .sheet-library-card-name,
body.dark-mode .pattern-library-card-name,
body.dark-mode .pattern-library-picker-label {
  color: #f8fafc;
}

body.dark-mode .sheet-library-card-subtitle,
body.dark-mode .sheet-library-card-meta,
body.dark-mode .pattern-library-card-category {
  color: #cbd5e1;
}

body.dark-mode .pattern-library-card {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--pattern-accent, #94a3b8) 24%, #0f172a), rgba(15, 23, 42, 0.92) 42%);
  border-color: rgba(71, 85, 105, 0.9);
}

body.dark-mode .pattern-library-card:hover {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--pattern-accent, #94a3b8) 32%, #0f172a), rgba(30, 41, 59, 0.95) 42%);
}

body.dark-mode .pattern-library-card.selected {
  background: linear-gradient(90deg, rgba(30, 64, 175, 0.38), rgba(15, 23, 42, 0.9));
  border-color: var(--bingo-blue);
}

.pattern-library-controls {
  display: grid;
  gap: 0.55rem;
}

.pattern-library-label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.86rem;
  color: #1f2937;
}

.pattern-library-select-row {
  display: flex;
  gap: 0.45rem;
  align-items: flex-end;
}

.pattern-library-select-row select {
  flex: 1 1 auto;
}

.pattern-library-select-row button {
  flex: 0 0 auto;
}

.pattern-library-action-row {
  margin-top: 0.05rem;
}

.pattern-library-action-row button {
  width: 100%;
}

.section-divider {
  border: 0;
  height: 1px;
  background: #d8dfeb;
  margin: 0.6rem 0;
}

.pattern-library-item {
  border: 1px solid #c8cfda;
  padding: 0.42rem;
  display: grid;
  gap: 0.3rem;
  cursor: pointer;
  background: #fff;
}

.pattern-library-item.selected {
  border-color: #111827;
  background: #f4f6fa;
}

.pattern-library-item:hover {
  background: #f7f9fc;
}

.pattern-library-item header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem;
}

.pattern-number {
  color: #607086;
  font-size: 0.73rem;
}

.pattern-library-item-name {
  font-weight: 600;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-preview,
.pattern-block-grid,
.editor-cell {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
}

.grid-preview {
  width: 78px;
}

.grid-label {
  aspect-ratio: auto;
  text-align: center;
  font-size: calc(var(--sheet-grid-label-size) * var(--sheet-pattern-scale));
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: 0.035em;
  color: #fff;
  background: #6a6a6a;
  min-height: calc(0.54rem * var(--sheet-pattern-scale));
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-cell,
.pattern-block-grid .cell,
.editor-cell {
  aspect-ratio: 1 / 1;
  border: var(--sheet-grid-line-width, 1px) solid #6f7782;
  background: #fff;
  position: relative;
  min-height: 0;
  min-width: 0;
  padding: 0;
  width: 100%;
  height: auto;
}

.mini-cell.filled,
.pattern-block-grid .cell.filled,
.editor-cell.filled {
  background: #000;
}

.mini-cell.marked::before,
.pattern-block-grid .cell.marked::before,
.editor-cell.marked::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: calc(0.22rem * var(--sheet-pattern-scale, 1));
  height: calc(0.22rem * var(--sheet-pattern-scale, 1));
  border-radius: 50%;
  background: #111;
  z-index: 1;
}

.editor-cell.marked::before {
  width: 0.42rem;
  height: 0.42rem;
}

.mini-cell.free-center::after,
.pattern-block-grid .cell.free-center::after,
.editor-cell.free-center::after {
  content: "FREE";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #7f8794;
  font-size: calc(0.34rem * var(--sheet-pattern-scale, 1));
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.15;
  transform: translate(-50%, -54%) scaleY(1.18);
  white-space: nowrap;
  z-index: 1;
  text-transform: uppercase;
  pointer-events: none;
}

.editor-cell.free-center::after {
  font-size: 0.72rem;
  color: #7f8794;
}

.mini-cell.free-center.filled::after,
.pattern-block-grid .cell.free-center.filled::after,
.editor-cell.free-center.filled::after {
  color: #f4f6f8;
}

.editor-grid {
  margin: 0.45rem auto 0;
  display: grid;
  width: 260px;
  max-width: 100%;
  gap: 2px;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  aspect-ratio: 1 / 1;
}

body.dark-mode .editor-grid {
  background: rgba(148, 163, 184, 0.28);
  border: 1px solid rgba(148, 163, 184, 0.38);
  border-radius: 9px;
  padding: 3px;
}

body.dark-mode .editor-cell {
  background: #f8fafc;
  border-color: #64748b;
  box-shadow: none;
}

body.dark-mode .editor-cell:hover {
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.24);
}

body.dark-mode .editor-cell.filled {
  background: #020617;
}

body.dark-mode .editor-cell.marked::before {
  background: #020617;
}

body.dark-mode .editor-cell.free-center::after {
  color: #64748b;
}

body.dark-mode .editor-cell.free-center.filled::after {
  color: #e5e7eb;
}

.editor-grid.hidden {
  display: none;
}

.preview-workspace {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background:
    radial-gradient(circle at top, var(--preview-glow), transparent 38%),
    linear-gradient(180deg, var(--preview-bg-top) 0%, var(--preview-bg-bottom) 100%);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 0.45rem 0.6rem 2.4rem;
  overflow: auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.pattern-editor-panel {
  position: static;
}

#sheetContainer {
  width: min(100%, calc((100vh - (var(--app-header-height) + (var(--page-padding) * 1.1))) * 8.5 / 11));
  height: auto;
  display: block;
  aspect-ratio: 8.5 / 11;
  margin: 0 auto;
  flex: 0 0 auto;
  position: relative;
}

.sheet-direct-toolbar {
  position: absolute;
  z-index: 8;
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  align-items: center;
  gap: 0.18rem;
  padding: 0.18rem;
  border: 1px solid rgba(37, 99, 235, 0.36);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.24);
}

.sheet-direct-toolbar.hidden {
  display: none;
}

.sheet-direct-toolbar span {
  padding-inline: 0.38rem;
  font-size: 0.7rem;
  font-weight: 850;
  white-space: nowrap;
}

.sheet-direct-toolbar button {
  min-width: 1.55rem;
  min-height: 1.45rem;
  padding: 0.1rem 0.34rem;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
}

.sheet-direct-toolbar button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sheet-direct-toolbar button.is-danger {
  border-color: rgba(251, 113, 133, 0.5);
  background: rgba(190, 18, 60, 0.72);
}

.sheet-direct-toolbar button.is-danger:hover {
  background: rgba(225, 29, 72, 0.82);
}

.sheet-direct-toolbar button.is-secondary {
  border-color: rgba(147, 197, 253, 0.46);
  background: rgba(30, 64, 175, 0.62);
}

.sheet-direct-toolbar button.is-secondary:hover {
  background: rgba(37, 99, 235, 0.72);
}

.sheet-direct-toolbar button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.sheet-viewport {
  width: 100%;
  height: 100%;
  transform-origin: top center;
}

.sheet-paper {
  --sheet-pattern-scale: 1;
  --sheet-fit-scale: 1;
  --sheet-grid-line-width: 1px;
  --sheet-grid-border-width: 1.5px;
  background: white;
  color: #111;
  width: 100%;
  height: 100%;
  aspect-ratio: 8.5 / 11;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transform: scale(var(--sheet-fit-scale));
  transform-origin: top left;
  will-change: transform;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9),
    0 22px 55px rgba(31, 41, 55, 0.22);
  padding: 0.18in 0.22in 0.14in;
  border: 1.5px solid #303030;
}

.sheet-header {
  display: grid;
  grid-template-columns: minmax(1.05in, 1fr) minmax(2.9in, 3.8in) minmax(1.05in, 1fr);
  grid-template-areas:
    "left title right"
    "left subtitle right";
  column-gap: 0.45rem;
  align-items: start;
  row-gap: 0;
  padding-bottom: 0.14rem;
  flex: 0 0 auto;
}

.sheet-title {
  margin: 0 0 -0.18rem;
  grid-area: title;
  font-size: 1.24rem;
  letter-spacing: 0;
  text-align: center;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-weight: 900;
  text-transform: uppercase;
  width: 100%;
  max-width: 3.5in;
  justify-self: center;
  line-height: 0.66;
}

.sheet-direct-editable {
  cursor: text;
  transition: box-shadow 0.14s ease, background-color 0.14s ease;
  border-radius: 4px;
}

.sheet-setting-hotspot {
  cursor: pointer;
}

.sheet-setting-focus-target {
  outline: 2px solid #2563eb;
  outline-offset: 3px;
  border-radius: 5px;
  background: rgba(37, 99, 235, 0.06);
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.08);
}

.sheet-direct-editable:hover {
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.22);
  background: rgba(37, 99, 235, 0.03);
}

.sheet-direct-editable.editing {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
  background: rgba(255, 255, 255, 0.92);
  outline: none;
}

.sheet-subtitle {
  grid-area: subtitle;
  text-align: center;
  margin-top: var(--sheet-header-spacing, -0.62rem);
  margin-bottom: -0.34rem;
  font-size: 0.98rem;
  color: #111;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-weight: 900;
  text-transform: uppercase;
  line-height: 0.68;
  transform: translateY(calc(var(--sheet-header-spacing, -0.62rem) * 0.38));
  width: 100%;
  max-width: 3.5in;
  justify-self: center;
}

.sheet-instructions {
  display: contents;
}

.sheet-instructions :first-child {
  grid-area: left;
  text-align: left;
  align-self: center;
  justify-self: start;
  max-width: 1.18in;
  font-size: 0.66rem;
  line-height: 1.22;
  color: #222;
  padding-top: 0.02rem;
}

.sheet-instructions :last-child {
  grid-area: right;
  text-align: right;
  align-self: center;
  justify-self: end;
  max-width: 1.18in;
  font-size: 0.66rem;
  line-height: 1.22;
  color: #222;
  padding-top: 0.02rem;
}

.sheet-grid {
  --sheet-grid-column-gap: 0.105rem;
  --sheet-grid-row-gap: 0.18rem;
  --sheet-block-padding: 0.08rem;
  --sheet-number-size: 0.88rem;
  --sheet-name-size: 0.88rem;
  --sheet-note-size: 0.18rem;
  --sheet-grid-label-size: 0.49rem;
  --sheet-grid-footer-clearance: 0.32rem;
  --sheet-cell-base: 18.7px;
  margin-top: 0.02rem;
  margin-bottom: 0.02rem;
  padding-top: 0;
  padding-left: 0;
  padding-bottom: calc(var(--sheet-grid-footer-clearance) * var(--sheet-pattern-scale));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  column-gap: calc(var(--sheet-grid-column-gap) * var(--sheet-pattern-scale));
  row-gap: calc(var(--sheet-grid-row-gap) * var(--sheet-pattern-scale));
  align-items: start;
  align-content: start;
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
}

.pattern-block {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: calc(1.08rem * var(--sheet-pattern-scale)) 0 calc(0.18rem * var(--sheet-pattern-scale));
  position: relative;
  display: grid;
  grid-template-rows: auto calc(1.72rem * var(--sheet-pattern-scale));
  justify-items: center;
  gap: calc(0.045rem * var(--sheet-pattern-scale));
  min-width: 0;
  overflow: visible;
}

body.dark-mode .sheet-paper,
body.dark-mode .sheet-paper * {
  color-scheme: light;
}

body.dark-mode .sheet-paper {
  background: #fff;
  color: #111;
  border-color: #303030;
}

body.dark-mode .sheet-paper .pattern-block,
body.dark-mode .sheet-paper .pattern-block:hover,
body.dark-mode .sheet-paper .pattern-block:active {
  border: none;
  background: transparent;
  color: #111;
  box-shadow: none;
}

body.dark-mode .sheet-paper .pattern-block.selected {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  border-radius: 6px;
  background: rgba(37, 99, 235, 0.04);
}

body.dark-mode .sheet-paper .pattern-block.drop-target {
  outline: 2px dashed #0f766e;
  outline-offset: 3px;
  border-radius: 6px;
  background: rgba(15, 118, 110, 0.05);
}

body.dark-mode .sheet-paper .sheet-setting-focus-target {
  outline-color: #2563eb;
  background: rgba(37, 99, 235, 0.06);
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.08);
}

body.dark-mode .sheet-paper .sheet-subtitle,
body.dark-mode .sheet-paper .sheet-instructions span,
body.dark-mode .sheet-paper .pattern-block-name,
body.dark-mode .sheet-paper #sheetFooterLeft,
body.dark-mode .sheet-paper #sheetTipsText {
  color: #111;
}

body.dark-mode .sheet-paper .pattern-block-number {
  color: #111;
  background: #fff;
  border-color: #303030;
}

.pattern-block.selected {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  border-radius: 6px;
  background: rgba(37, 99, 235, 0.04);
}

.pattern-block.dragging {
  opacity: 0.5;
}

.pattern-block.drop-target {
  outline: 2px dashed #0f766e;
  outline-offset: 3px;
  border-radius: 6px;
  background: rgba(15, 118, 110, 0.05);
}

.pattern-block-number {
  position: absolute;
  left: calc(-0.06rem * var(--sheet-pattern-scale));
  top: calc(0.04rem * var(--sheet-pattern-scale));
  width: calc(1.34rem * var(--sheet-pattern-scale));
  height: calc(1.34rem * var(--sheet-pattern-scale));
  border: 1.5px solid #303030;
  border-radius: 999px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Arial Black", Arial, sans-serif;
  font-size: calc(0.78rem * var(--sheet-pattern-scale));
  font-weight: 800;
  color: #111;
  text-align: center;
  line-height: 1;
  z-index: 2;
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 3px #303030;
}

.pattern-block-number::after {
  content: none;
}

.pattern-block-grid {
  position: relative;
  z-index: 1;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: auto repeat(5, 1fr);
  width: min(100%, calc((var(--sheet-cell-base) * 5 + 4px) * var(--sheet-pattern-scale)));
  max-width: 100%;
  gap: 1px;
  justify-items: stretch;
  background: #595959;
  padding: 1px;
  border: var(--sheet-grid-border-width, 1.5px) solid #5f5f5f;
  margin-top: calc(0.04rem * var(--sheet-pattern-scale));
}

.pattern-block-name {
  position: relative;
  z-index: 1;
  font-weight: 600;
  text-align: center;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: calc(var(--sheet-name-size) * var(--sheet-pattern-scale));
  line-height: 0.88;
  margin-top: calc(0.02rem * var(--sheet-pattern-scale));
  width: min(100%, calc((var(--sheet-cell-base) * 5 + 4px) * var(--sheet-pattern-scale)));
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: normal;
  color: #111;
  min-height: calc(1.72rem * var(--sheet-pattern-scale));
  max-height: calc(1.72rem * var(--sheet-pattern-scale));
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

#sheetFitStatus.warning {
  color: #9a4b00;
  font-weight: 700;
}

@media print {
  .pattern-block.selected {
    outline: none;
    background: transparent;
  }

  .sheet-setting-focus-target {
    outline: none;
    background: transparent;
    box-shadow: none;
  }

  .pattern-block.dragging,
  .pattern-block.drop-target {
    outline: none;
    background: transparent;
    opacity: 1;
  }

  .sheet-direct-editable,
  .sheet-direct-editable:hover,
  .sheet-direct-editable.editing {
    box-shadow: none;
    background: transparent;
  }
}

.pattern-block-note {
  color: #4b4b4b;
  text-align: center;
  font-size: calc(var(--sheet-note-size) * var(--sheet-pattern-scale));
  line-height: 1.1;
}

.sheet-footer {
  --sheet-footer-height: 0.72in;
  margin-top: 0.06rem;
  display: grid;
  grid-template-columns: minmax(1.7in, 1fr) minmax(1.2in, 1fr);
  gap: 0.16rem;
  padding-top: 0.02rem;
  font-size: 0.32rem;
  min-height: var(--sheet-footer-height);
  align-items: end;
  flex: 0 0 auto;
}

.sheet-footer #sheetFooterLeft,
.sheet-footer #sheetTips {
  min-height: 0.4rem;
  max-height: none;
  display: flex;
  align-items: flex-end;
}

.sheet-footer #sheetTips {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 0.24rem;
  justify-content: flex-end;
  justify-self: end;
  max-width: 100%;
  padding: 0.05rem 0.08rem;
  width: min(100%, 2.35in);
  max-height: var(--sheet-footer-height);
  overflow: hidden;
}

.sheet-footer #sheetTips[data-footer-layout="qr-only"] {
  width: min(100%, 0.9in);
}

.sheet-footer #sheetTips[data-footer-layout="qr-only"] #sheetTipsText,
.sheet-footer #sheetTips[data-footer-layout="tips-only"] #sheetTipsImage {
  display: none !important;
}

.sheet-footer #sheetTips[data-footer-layout="tips-only"] {
  width: min(100%, 1.5in);
}

.sheet-footer #sheetTips[data-footer-layout="tips-only"] #sheetTipsText {
  max-width: 1.5in;
}

#sheetTipsText {
  line-height: 1.05;
  max-width: 1.28in;
  font-size: 0.28rem;
  text-align: right;
  overflow-wrap: anywhere;
  order: 1;
}

.tips img {
  width: var(--sheet-qr-size, 0.5in);
  height: var(--sheet-qr-size, 0.5in);
  max-height: calc(var(--sheet-footer-height) - 0.1rem);
  max-width: min(100%, calc(var(--sheet-footer-height) - 0.1rem));
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
  order: 2;
  align-self: flex-end;
}

#sheetFooterLeft {
  justify-content: flex-start;
  overflow-wrap: anywhere;
  font-size: 0.28rem;
  line-height: 1.08;
}

@media (max-width: 1160px) {
  .app-header {
    flex-wrap: wrap;
  }

  .app-main {
    align-items: stretch;
  }

  .sidebar {
    width: 340px;
    flex-basis: 340px;
  }
}

@media (max-width: 980px) {
  .app-main {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: none;
  }

  .preview-workspace {
    width: 100%;
    min-height: 0;
  }

  .workspace {
    grid-template-rows: auto 1fr;
  }

  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .preview-workspace {
    padding-inline: 0.35rem;
  }

  #sheetContainer {
    width: min(100%, 680px);
  }
}

@media (max-width: 700px) {
  .app-shell {
    padding: 0.7rem;
  }

  .account-controls {
    order: 4;
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-left: 0;
  }

  .header-utility-controls {
    margin-left: auto;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .preview-toolbar,
  .preview-mode-toggle,
  .preview-zoom-control,
  .template-actions {
    grid-template-columns: 1fr;
  }

  .sheet-direct-toolbar {
    max-width: calc(100% - 12px);
    grid-auto-flow: row;
    grid-template-columns: auto auto auto auto;
  }

  .sheet-direct-toolbar span {
    grid-column: 1 / -1;
  }

  .help-content dl {
    grid-template-columns: 1fr;
  }

  .help-content dd {
    padding-bottom: 0.25rem;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: 8.5in 11in;
    margin: 0;
  }

  body {
    background: white;
    padding: 0;
    min-height: auto;
  }

  .app-header,
  .sidebar,
  .editor-dock,
  .workspace > *:not(.preview-workspace),
  .toolbar,
  .sheet-direct-toolbar,
  .sheet-actions {
    display: none !important;
  }

  .app-shell,
  .app-main,
  .workspace,
  .preview-workspace,
  #sheetContainer,
  .sheet-viewport,
  .sheet-paper {
    margin: 0;
    padding: 0;
    max-width: none;
    max-height: none;
    min-height: 0;
  }

  .app-shell,
  .app-main,
  .workspace {
    display: block;
    width: auto;
    min-height: 0;
    height: auto;
    overflow: visible;
  }

  .preview-workspace {
    background: white;
    border-radius: 0;
    padding: 0;
    overflow: visible;
    display: block;
    min-height: 0;
    height: auto;
  }

  #sheetContainer {
    width: 8.5in;
    height: 11in;
    aspect-ratio: auto;
    overflow: hidden;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .sheet-viewport {
    width: 8.5in;
    height: 11in;
    overflow: hidden;
  }

  .sheet-paper {
    box-shadow: none;
    width: 8.5in;
    height: 11in;
    aspect-ratio: auto;
    transform: none !important;
    padding: 0.18in 0.22in 0.14in;
    border: 1.5px solid #303030;
    overflow: hidden;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .sheet-footer {
    --sheet-footer-height: 0.72in;
    margin-top: 0.04rem;
    padding-top: 0.02rem;
  }

  .sheet-grid,
  .pattern-block-grid,
  .mini-cell,
  .pattern-block-grid .cell {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
