:root {
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #272035;
  background: #fff;
  font-synthesis: none;
  --purple: #7828c8;
  --line: #eae5f0;
  --number-scale: 1;
}
* { box-sizing: border-box; }
body { margin: 0; height: 100svh; min-height: 100svh; display: flex; flex-direction: column; }
button, input, textarea { font: inherit; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid #b983ee; outline-offset: 4px; }
[hidden] { display: none !important; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 32px 8px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand img { width: 46px; height: 46px; object-fit: contain; flex-shrink: 0; }
.brand-title { font-size: clamp(18px, 2vw, 26px); font-weight: 650; line-height: 1.5; letter-spacing: -.025em; }
.header-identity { display: flex; align-items: center; gap: 24px; min-width: 0; }
.display-footer { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; flex-shrink: 0; }
.with-qr .display-footer { grid-template-columns: 120px minmax(0, 1fr) 120px; gap: 12px; }
.with-qr .display-caption { grid-column: 2; grid-row: 1; }
.corner-qr { grid-column: 3; grid-row: 1; display: flex; flex-direction: column; align-items: center; justify-self: end; width: 120px; }
.corner-qr img { width: 112px; height: 112px; image-rendering: pixelated; }
.corner-qr span { font-size: 12px; color: #786f83; text-align: center; line-height: 1.3; margin: 0 0 4px; }
body.admin .corner-qr { display: none; }
.options { position: relative; z-index: 10; }
.options summary { list-style: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; color: #7c7186; }
.options summary::-webkit-details-marker { display: none; }
.options summary:hover, .options[open] summary { background: #f4eef9; }
.options summary svg { width: 23px; height: 23px; fill: currentColor; }
.options-menu { position: absolute; right: 0; top: calc(100% + 8px); width: 248px; padding: 7px; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 12px 35px #3720431a; background: #fff; }
.options-menu a, .options-menu button { display: block; width: 100%; border: 0; background: transparent; color: #4c3a59; text-align: left; padding: 13px 12px; border-radius: 8px; font-size: 15px; }
.options-menu a:hover, .options-menu button:hover { background: #f7f2fc; }
#connection { display: block; border-top: 1px solid var(--line); margin: 5px 7px 0; padding: 12px 5px 6px; font-size: 13px; color: #8c8296; }
#connection.offline { color: #a44722; }

main { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; padding: 0 32px 18px; }
.display { width: 100%; flex: 1; min-height: 0; display: flex; flex-direction: column; text-align: center; }
.subtitle { margin: 4px 0 0; font-size: clamp(26px, 4.4vw, 72px); font-weight: 650; line-height: 1.15; letter-spacing: -.025em; text-align: center; overflow-wrap: anywhere; white-space: pre-line; }
.number-space { flex: 1; display: grid; place-items: center; min-height: 0; container-type: size; }
.number { color: var(--purple); font-size: min(54vw, calc(43vw * var(--number-scale)), calc(53svh * var(--number-scale)), 92cqh); line-height: 1.05; font-weight: 800; letter-spacing: -.065em; padding-right: .065em; font-variant-numeric: tabular-nums; }
.display-caption { color: #8c8296; font-size: clamp(17px, 2vw, 27px); margin: 4px 0 14px; line-height: 1.4; white-space: pre-line; overflow-wrap: anywhere; }
.offline-notice { position: fixed; z-index: 5; bottom: 0; left: 0; right: 0; margin: 0; background: #fff1e7; padding: 9px 16px; text-align: center; font-size: 14px; color: #8e451e; }

.admin-panel { width: 100%; max-width: 460px; border: 1px solid var(--line); border-radius: 18px; padding: 24px; margin: 20px 0 0; background: #fff; box-shadow: 0 8px 35px #47226106; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.panel-heading h1, .settings-form h2 { font-size: 17px; letter-spacing: -.3px; margin: 0; font-weight: 650; }
.text-link { border: 0; background: none; padding: 3px 0; color: var(--purple); font-size: 14px; cursor: pointer; white-space: nowrap; }
label { display: block; font-size: 14px; color: #71647d; margin-bottom: 9px; }
input, textarea { min-width: 0; width: 100%; border: 1px solid #dcd3e7; border-radius: 10px; background: #fff; color: #272035; padding: 12px 13px; font-size: 16px; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #a097a9; }
.login-row, .set-row { display: flex; gap: 10px; }
.primary, .secondary { border-radius: 10px; padding: 13px 18px; font-size: 15px; font-weight: 600; white-space: nowrap; }
.primary { color: #fff; background: var(--purple); border: 1px solid var(--purple); }
.primary:hover { background: #6621ad; }
.secondary { border: 1px solid #e2d7ec; color: #6a427f; background: #fff; }
.secondary:hover { background: #f7f2fc; }
button:disabled { opacity: .45; cursor: default; }
.next-button { width: 100%; min-height: 62px; display: flex; align-items: center; justify-content: space-between; font-size: 18px; }
.next-button span { font-size: 23px; font-variant-numeric: tabular-nums; }
.secondary-controls { display: flex; gap: 10px; margin-top: 12px; }
.secondary-controls > * { flex: 1; }
.set-form, .settings-form { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 20px; }
.settings-form h2 { margin-bottom: 22px; }
.advanced-options { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 6px; }
.advanced-options > summary { cursor: pointer; padding: 15px 0; color: #71647d; font-size: 15px; font-weight: 600; }
.advanced-options .settings-form { border: 0; margin: 0; padding-top: 10px; }
.settings-form > input, .settings-form > textarea { margin-bottom: 20px; }
.size-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.size-heading output { font-size: 14px; color: var(--purple); font-weight: 650; }
input[type="range"] { padding: 0; margin: 6px 0; accent-color: var(--purple); cursor: pointer; border: 0; height: 24px; }
.range-labels { display: flex; justify-content: space-between; color: #8c8296; font-size: 13px; margin: 0 0 20px; }
#save-settings { width: 100%; }
.checkbox-label { display: flex; gap: 10px; align-items: center; margin-top: 8px; color: #4c3a59; cursor: pointer; }
.checkbox-label input { width: 19px; height: 19px; flex-shrink: 0; accent-color: var(--purple); }
.field-note { font-size: 13px; color: #8c8296; margin: 0 0 22px 29px; line-height: 1.5; }
.message { font-size: 14px; line-height: 1.5; color: #71468b; margin: 14px 0 0; }
.message:empty { display: none; }
.limit-note { font-size: 14px; line-height: 1.5; color: #71647d; margin: 15px 0 0; }
body.admin { height: auto; }
body.admin .display { flex: 0; max-width: 900px; }
body.admin .number-space { container-type: normal; }
body.admin .subtitle { font-size: clamp(23px, 3vw, 40px); }
body.admin .number { font-size: min(54vw, calc(30vw * var(--number-scale)), calc(25svh * var(--number-scale))); }
body.admin .display-caption { font-size: 17px; margin-bottom: 0; }
body.fullscreen { height: 100svh; }
body.fullscreen .admin-panel { display: none; }
body.fullscreen .number-space { container-type: size; }
body.fullscreen .display { flex: 1; max-width: none; }
body.fullscreen .subtitle { font-size: clamp(26px, 4.4vw, 72px); }
body.fullscreen .number { font-size: min(54vw, calc(48vw * var(--number-scale)), calc(62svh * var(--number-scale)), 92cqh); }
body.fullscreen .display-caption { font-size: clamp(17px, 2vw, 27px); margin-bottom: 14px; }
@media (max-width: 600px) {
  .topbar { padding: 10px 16px 6px; }
  .brand { gap: 9px; }
  .brand img { width: 38px; height: 38px; }
  .brand-title { font-size: 1.1rem; }
  .corner-qr { display: none; }
  .with-qr .display-footer { grid-template-columns: minmax(0, 1fr); }
  .with-qr .display-caption { grid-column: 1; }
  main { padding: 0 18px 16px; }
  .subtitle { margin-top: 4px; font-size: clamp(26px, 5.7vw, 34px); }
  .display-caption { margin-bottom: 6px; }
  .admin-panel { padding: 20px; margin-top: 20px; }
  body.admin .number { font-size: min(54vw, calc(32vw * var(--number-scale)), calc(22svh * var(--number-scale))); }
  body.admin .subtitle { font-size: 25px; }
  body.fullscreen .subtitle { font-size: clamp(26px, 5.7vw, 34px); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
