/* Shared visual finish, loaded after each page's structural styles. */
:root {
  --control-height: 44px;
  --control-radius: 12px;
  --glass: rgba(255, 253, 250, .94);
  --shadow-soft: 0 6px 24px rgba(50, 40, 26, .06);
}
.button, .button.compact, .password-toggle-button, .config-setup-progress button {
  min-height: var(--control-height);
  border-radius: var(--control-radius);
  font-size: .875rem;
  font-weight: 650;
  line-height: 1.3;
  padding: 10px 16px;
  gap: 8px;
  box-shadow: none;
}
.button:disabled { cursor: not-allowed; }
.button.secondary { border: 1px solid var(--border-strong); background: #fffdfa; }
.button.primary { border: 1px solid #b89b73; background: #dfc9a8; }
.button.primary:hover:not(:disabled) { background: #d4ba95; }
.button.danger { color: #842a20; border-color: #dfb9b3; background: #fff3f0; }
.button-icon { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.field input:not([type=checkbox]), .field select, .event-list-tools input, .event-list-tools select {
  min-height: 46px; border-radius: var(--control-radius); font-size: 1rem;
}
input[type=checkbox] { accent-color: #8e704a; }
.topbar, .panel, .login-card { border-radius: 18px; }
.topbar { padding: 12px; gap: 10px; }
.topbar .event-identity { font-size: .8125rem; line-height: 1.4; }
.topbar > #logoutButton { margin-left: 0 !important; }
.project-tools > summary { min-height: var(--control-height); }
.project-tools[open] > summary { background: #f0e5d5; border-color: #b89b73; }
.project-tools-panel { background: #fffdfa; padding: 20px; }
.project-tools-panel #loadImageButton { width: 100%; min-height: 44px; }
.project-tools-panel #loadImageButton::before, .project-tools-panel #loadImageButton::after { content: none; }
.project-tools-panel #loadImageButton .button-label { display: inline !important; font-size: .875rem !important; white-space: normal; }
.project-tools-panel .layout-code-input { min-height: 44px; font-size: 1rem; }
.project-tools-panel .layout-code-copy-button { height: 44px; width: 44px; flex-basis: 44px; }
.project-tools-panel .layout-code-label { display: block; margin-bottom: 8px; }
.grid-controls { gap: 6px; }
.grid-tool-button, .grid-random-fill-button, .focus-mode-button, .library-filter-button { min-width: 44px; width: 44px; min-height: 44px; padding: 8px; }
.grid-size-control { min-height: 44px; border-radius: 12px; }
.stage-header { gap: 12px; margin-bottom: 10px; }
.confirm-dialog-title { line-height: 1.25; }
.confirm-dialog-message, .guest-credentials-intro { line-height: 1.55; }
.confirm-dialog-actions { gap: 10px; }
.guest-credentials-dialog { background: #fcfaf6; }
.guest-credentials-group { box-shadow: none; }
.guest-credentials-group-title { line-height: 1.4; }
.guest-credentials-group input { min-height: 44px; }
/* Login: balanced desktop composition, visible branding on small screens. */
.login-shell { max-width: 1040px; gap: clamp(32px, 6vw, 80px); padding-block: 64px; }
.login-hero { gap: 24px; }
.login-logo { width: 176px; }
.login-hero-copy h1 { max-width: 12ch; font-size: clamp(2.8rem, 4.6vw, 4.5rem); line-height: 1.06; letter-spacing: -.045em; }
.login-hero-copy h1 span { color: #695337; }
.login-grid-preview { width: 216px; padding: 12px; gap: 8px; box-shadow: none; }
.login-grid-preview span { border-radius: 8px; }
.login-card { background: rgba(255, 253, 250, .97); padding: 32px; gap: 24px; }
.login-card h2 { font-size: 1.75rem; }
.login-form-stack { gap: 18px; }
.login-form-stack #errorMsg:empty { display: none; }
.login-form-stack .button { min-height: 48px; }
.password-toggle-button { padding-inline: 12px; color: var(--text); }
.language-switcher { min-height: 44px; }
/* Admin: consistent content rhythm and a status badge distinct from actions. */
.config-shell { width: min(1440px, calc(100% - 32px)); margin: 16px auto; gap: 16px; }
.config-header { padding: 20px; gap: 20px; }
.config-brand { align-items: flex-start; flex: 1 1 460px; }
.config-title-wrap h1 { font-size: clamp(1.4rem, 2.5vw, 2rem); overflow-wrap: anywhere; }
.config-title-wrap p { font-size: .9375rem; }
.config-toolbar { align-items: center; gap: 8px; }
.admin-identity { color: var(--muted); font-size: .8125rem; padding: 8px; }
.config-panel { padding: 24px; gap: 20px; }
.config-column, .config-layout { gap: 16px; }
.config-section-head p { line-height: 1.5; }
.config-section-head h2 { line-height: 1.3; margin-bottom: 6px; }
.config-section-head .eyebrow { margin-bottom: 4px; font-size: .72rem; }
.config-form { gap: 18px; }
.config-setup-progress button { font-size: .8rem; padding: 8px; }
.config-panel .field label { font-size: .75rem; letter-spacing: .045em; }
.config-panel .regen-icon-button { width: 44px; min-width: 44px; padding: 8px; }
.event-card { padding: 20px; border-radius: 14px; gap: 16px; }
.event-card-actions { padding: 12px; gap: 8px; }
.event-card-actions .button { min-height: 44px; padding: 10px 12px; font-size: .8125rem; }
.event-card-header h3 { font-size: 1.125rem; line-height: 1.4; }
.event-list { padding-right: 0; }
@media (max-width: 1040px) {
  .config-toolbar { width: 100%; justify-content: flex-start; }
  .admin-identity { margin-right: auto; }
}
@media (max-width: 920px) {
  body:not(.config-page) > .page-shell { width: calc(100% - 16px); height: calc(100dvh - 16px); min-height: 0; margin: 8px auto; gap: 8px; }
  .stage-panel { padding: 6px; }
  .stage-header { gap: 6px; padding: 0; margin-bottom: 6px; }
  .grid-controls { gap: 4px; }
  .grid-size-control { padding: 4px 8px; }
  .grid-tool-button, .grid-random-fill-button { flex-basis: 44px; }
  .stage-board-wrap:not(.is-frame-zoomed) { padding: 12px 4px 100px; }
  .empty-stage-hint { bottom: 52px; padding: 0 12px; }
  .empty-stage-hint p { font-size: .8125rem; line-height: 1.4; padding: 8px 12px; border-radius: 12px; box-shadow: none; }
  .mobile-library-toggle { right: 20px; bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px)); min-height: 44px; background: #dfc9a8 !important; border: 1px solid #b89b73; }
  .tutorial-button { left: 20px; right: auto; bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px)); width: 44px; height: 44px; min-height: 44px; padding: 0; }
  .guest-credentials-dialog .confirm-dialog-actions .button { padding: 10px 12px; }
}
@media (max-width: 860px) {
  .login-shell { min-height: 100dvh; width: min(440px, calc(100% - 32px)); padding: 72px 0 32px; gap: 20px; align-content: center; }
  .login-hero { position: static; width: auto; transform: none; opacity: 1; z-index: auto; }
  .login-logo { width: 120px; }
  .login-card { padding: 24px; }
}
@media (max-width: 720px) {
  .topbar { gap: 6px; padding: 6px; }
  .topbar > .button, .topbar > #logoutButton, .topbar .project-tools > summary {
    width: 100%; min-height: 52px; height: 52px; padding: 6px 2px; flex-direction: column; gap: 5px; border-radius: 12px;
  }
  .topbar .button-label, .topbar #guestCredentialsButton .button-label, .topbar #logoutButton .button-label {
    font-size: .6875rem !important; line-height: 1.2 !important; font-weight: 650;
  }
  .topbar .event-identity { margin: 0; padding: 2px 4px; }
  .project-tools-panel { top: 108px; }
  .project-tools-panel .button { flex-direction: row; height: auto; }
  .config-shell { width: calc(100% - 24px); margin: 12px auto; }
  .config-header { padding: 16px; gap: 16px; }
  .config-brand { gap: 10px; }
  .config-brand .brand-mark { width: 32px; height: 38px; }
  .config-title-wrap p { font-size: .875rem; }
  .config-toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  .config-toolbar .admin-identity { grid-column: 1 / -1; padding: 0; }
  .config-toolbar a { grid-column: 1 / -1; }
  .config-panel { padding: 18px; gap: 16px; }
  .event-card { padding: 14px; }
  .event-card-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 8px; }
  .event-card-actions .button { white-space: normal; text-align: center; }
  .config-setup-navigation .button { max-width: 70%; white-space: normal; }
}
@media (max-width: 370px) {
  .grid-controls { gap: 2px; }
  .stage-header { gap: 2px; }
  .grid-size-control { padding-inline: 5px; }
  .login-card { padding: 20px; }
}
@media (max-height: 560px) and (max-width: 920px) {
  .stage-board-wrap:not(.is-frame-zoomed) { padding-bottom: 8px; }
  .empty-stage-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
/* Icon-only grid tools retain their accessible text without visual overflow. */
.button.grid-random-fill-button { font-size: 0; gap: 0; }
.topbar > .button { min-height: 44px; }
.guest-credentials-group-actions { gap: 8px; margin-bottom: 12px; }
.guest-credentials-row { gap: 14px; }
.guest-credentials-field > span { font-size: .8125rem; font-weight: 650; color: var(--muted); }
.guest-credentials-password-hint { margin-top: 8px; line-height: 1.4; }
/* Role-hidden actions must win over legacy toolbar display overrides. */
#guestCredentialsButton[hidden] { display: none !important; }
@media (max-width: 720px) {
  .topbar.no-guest > .button { flex-direction: column !important; padding: 6px 2px !important; gap: 5px !important; margin: 0 !important; }
  .topbar.no-guest > .button .button-label { font-size: .6875rem !important; line-height: 1.2 !important; }
}
/* Usage statistics share the admin card rhythm and remain readable on phones. */
.usage-panel { grid-column: 1 / -1; }
.usage-metrics-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0; }
.usage-metric { display: flex; flex-direction: column; justify-content: space-between; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: #fffdfa; }
.usage-metric dt { color: var(--muted); font-size: .8125rem; line-height: 1.4; }
.usage-metric dd { margin: 0; font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.usage-explanation, .usage-event > p { margin: 0; color: var(--muted); font-size: .8125rem; line-height: 1.6; }
.usage-breakdown > summary { cursor: pointer; padding-block: 12px; min-height: 44px; font-weight: 650; }
.usage-event-list { display: grid; gap: 16px; margin-top: 8px; }
.usage-event { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border); }
.usage-event h3 { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.usage-event .usage-metric dd { font-size: 1.25rem; }
.usage-panel .inline-message { line-height: 1.6; }
@media (max-width: 720px) {
  .usage-metrics-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .usage-metric { padding: 12px; }
}
