* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #e5e7eb;
    touch-action: manipulation;
}

body {
    display: flex;
    flex-direction: column;
}

/* --- TOPBAR --- */
#topbar {
    min-height: 54px;
    flex-shrink: 0;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
    z-index: 100;
    gap: 8px;
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

#logo {
    font-weight: 700;
    font-size: 16px;
    color: #2563eb;
    white-space: nowrap;
}

.board-title-pill {
    font-size: 13px;
    color: #374151;
    font-weight: 600;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.board-title-pill.editable {
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 8px;
    padding: 4px 8px;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, border-color .15s;
}

.board-title-pill.editable:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.save-status {
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #dcfce7;
    color: #166534;
    white-space: nowrap;
}

.save-status.saving { background: #fef3c7; color: #92400e; }
.save-status.readonly { background: #f3f4f6; color: #4b5563; }
.save-status.mode-play { background: #ede9fe; color: #5b21b6; }
.save-status.mode-guest { background: #e0f2fe; color: #075985; }

.top-icon-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    background: #f3f4f6;
    font-size: 16px;
    touch-action: manipulation;
}

/* --- PRESENZA LIVE --- */
.presence-wrap {
    position: relative;
}

.presence-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    background: #f8fafc;
    color: #1f2937;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.presence-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}

.presence-popover {
    display: none;
    position: absolute;
    top: 40px;
    left: 0;
    width: 240px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
    border: 1px solid #e5e7eb;
    padding: 10px;
    z-index: 3500;
}

.presence-popover.show {
    display: block;
}

.presence-title {
    font-size: 12px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.presence-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
}

.presence-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #1f2937;
}

.presence-user img {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #cbd5e1;
}

.presence-role {
    margin-left: auto;
    font-size: 11px;
    color: #6b7280;
}

/* --- CENTER TOOLS & JAMBOARD PAGE SWITCHER --- */
#centerTools {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: nowrap;
}

#centerTools button {
    padding: 6px 9px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: #f3f4f6;
    font-size: 13px;
    white-space: nowrap;
    touch-action: manipulation;
}

#centerTools button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#centerTools button:hover:not(:disabled) {
    background: #e5e7eb;
}

.page-switcher,
.zoom-pill,
.history-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: 2px 4px;
    border-radius: 10px;
    flex-shrink: 0;
}

.zoom-pill {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.history-pill {
    background: #eef2ff;
    border: 1.5px solid #818cf8;
}

#centerTools .history-pill button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    padding: 0;
    border-radius: 7px;
    background: #ffffff;
    color: #1d4ed8;
    box-shadow: 0 1px 2px rgba(30, 64, 175, 0.16);
}

#centerTools .history-pill button:hover:not(:disabled) {
    background: #2563eb;
    color: #ffffff;
}

#centerTools .history-pill button:disabled {
    background: #f1f5f9;
    color: #64748b;
    opacity: 0.78;
    box-shadow: none;
    cursor: not-allowed;
}

#centerTools .page-switcher button,
#centerTools .zoom-pill button {
    background: transparent;
    padding: 4px 7px;
    font-weight: 700;
}

#centerTools .page-switcher button {
    color: #1d4ed8;
}

#centerTools .zoom-pill button {
    color: #334155;
}

#centerTools .page-switcher button:hover:not(:disabled) {
    background: #dbeafe;
}

#centerTools .zoom-pill button:hover:not(:disabled) {
    background: #e2e8f0;
}

.page-menu {
    display: none;
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 230px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .2);
    border: 1px solid #e5e7eb;
    padding: 8px;
    z-index: 3500;
}

.page-menu.show {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.page-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    background: #f9fafb;
}

.page-menu-item.active {
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 700;
}

.page-menu-del {
    border: none;
    background: #fee2e2;
    color: #b91c1c;
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 11px;
    cursor: pointer;
}

.inline-form { margin: 0; }

.top-action-btn, .login-cta-btn {
    padding: 7px 12px;
    border: none;
    border-radius: 9px;
    background: #2563eb;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    touch-action: manipulation;
}

.save-copy-btn { background: #059669; }
.community-btn { background: #0f766e; }
.login-cta-btn { background: #111827; }
.settings-btn { background: #475569; }
.restore-home-btn { background: #d97706; }
.chat-btn { background: #4f46e5; position: relative; }

.chat-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

/* --- RATING POPOVER --- */
.rating-wrap {
    position: relative;
}

.rating-pill-btn {
    padding: 6px 10px;
    border: 1px solid #fcd34d;
    border-radius: 9px;
    background: #fef3c7;
    color: #92400e;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    touch-action: manipulation;
}

.rating-popover {
    display: none;
    position: absolute;
    top: 40px;
    right: 0;
    width: 240px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .2);
    border: 1px solid #e5e7eb;
    padding: 12px;
    z-index: 3600;
    text-align: center;
}

.rating-popover.show {
    display: block;
}

.stars-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 6px 0 8px;
}

.star-btn {
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    color: #cbd5e1;
    cursor: pointer;
    padding: 2px;
    transition: transform .1s, color .15s;
}

.star-btn:hover,
.star-btn.filled {
    color: #f59e0b;
    transform: scale(1.1);
}

.star-btn.static {
    cursor: default;
    transform: none !important;
}

.rating-summary-text {
    font-size: 12px;
    color: #4b5563;
}

.rating-owner-note {
    margin-top: 6px;
    font-size: 11px;
    color: #6b7280;
}

/* --- MODALE IMPOSTAZIONI BOARD --- */
.settings-modal-content {
    max-width: 540px;
    text-align: left;
}

.settings-modal-content h3 {
    text-align: center;
    margin-bottom: 8px;
}

.settings-section-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    margin: 10px 0 6px;
}

.settings-perms-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.perm-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 13px;
    color: #1e293b;
    cursor: pointer;
}

.perm-check input {
    width: auto !important;
    margin: 0 !important;
    flex-shrink: 0;
}

.home-state-box {
    margin-top: 14px;
    padding: 12px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 12px;
}

.home-state-status {
    font-size: 12.5px;
    font-weight: 600;
    color: #92400e;
    margin-bottom: 4px;
}

.home-state-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.home-state-actions .modal-btn {
    flex: 1 1 150px;
    font-size: 12.5px;
    padding: 8px 10px;
}

/* --- CHAT UNICA --- */
.chat-drawer {
    display: none;
    width: 330px;
    max-width: 92vw;
    flex-shrink: 0;
    background: #ffffff;
    border-left: 1px solid #e5e7eb;
    flex-direction: column;
    z-index: 1200;
    height: 100%;
}

.chat-drawer.open {
    display: flex;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
}

.chat-header-title {
    font-weight: 700;
    font-size: 14.5px;
    color: #1e293b;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-icon-btn {
    border: none;
    background: #e2e8f0;
    color: #1e293b;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.chat-subtitle {
    padding: 6px 12px;
    font-size: 11.5px;
    color: #64748b;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #ffffff;
}

.chat-empty {
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
    margin-top: 24px;
}

.chat-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 92%;
}

.chat-msg.self {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg img {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid #cbd5e1;
}

.chat-bubble {
    background: #f1f5f9;
    color: #0f172a;
    padding: 7px 10px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.35;
    word-break: break-word;
}

.chat-msg.self .chat-bubble {
    background: #2563eb;
    color: #ffffff;
}

.chat-meta {
    font-size: 10.5px;
    color: #64748b;
    margin-bottom: 2px;
    font-weight: 600;
}

.chat-msg.self .chat-meta {
    color: #dbeafe;
    text-align: right;
}

.chat-form {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid #e5e7eb;
    background: #f8fafc;
}

.chat-form input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    font-size: 13.5px;
}

.chat-send-btn {
    padding: 8px 13px;
    border: none;
    border-radius: 9px;
    background: #2563eb;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
}

.community-toggle-box {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 10px;
    padding: 10px 12px;
    text-align: left;
    color: #065f46;
}

/* --- WORKSPACE FLEX --- */
#workspace {
    display: flex;
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow: hidden;
    position: relative;
}

#toolbar {
    width: 66px;
    flex-shrink: 0;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px 6px;
    overflow-y: auto;
    overflow-x: hidden;
    touch-action: manipulation;
}

#toolbar > button,
#toolbar .tool-group > button {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border: none;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: #ffffff;
    cursor: pointer;
    position: relative;
    touch-action: manipulation;
}

#toolbar > button:hover:not(:disabled),
#toolbar .tool-group > button:hover:not(:disabled) {
    background: #f3f4f6;
}

#toolbar button.active {
    background: #dbeafe;
    outline: 2px solid #2563eb;
}

#toolbar button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.tool-group { position: relative; }

.submenu {
    display: none;
    position: fixed;
    left: 74px;
    background: #fff;
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 8px 26px rgba(0, 0, 0, .2);
    z-index: 2500;
    max-width: 276px;
    max-height: calc(100dvh - 110px);
    overflow-y: auto;
}

.submenu.show {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.submenu-grid {
    display: grid;
    grid-template-columns: repeat(4, 42px);
    gap: 6px;
}

.submenu-grid button {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    background: #f8fafc;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.submenu-grid button:hover {
    background: #e2e8f0;
}

.submenu-tile-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.submenu-tile-grid button {
    min-width: 56px;
    min-height: 52px;
    padding: 6px 4px;
    border: 1px solid #f1f5f9;
    border-radius: 11px;
    background: #f8fafc;
    font-size: 18px;
    line-height: 1.1;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    touch-action: manipulation;
}

.submenu-tile-grid button:hover {
    background: #e2e8f0;
}

.submenu-tile-grid .sub-lbl {
    font-size: 10px;
    font-weight: 600;
    color: #475569;
    line-height: 1;
    white-space: nowrap;
}

.submenu-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.submenu-label {
    font-size: 12px;
    font-weight: 600;
    color: #4b5563;
}

.submenu-row select {
    padding: 5px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 12px;
}

.submenu-row input[type="color"] {
    width: 46px;
    height: 30px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 1px;
    cursor: pointer;
}

.submenu-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #374151;
    cursor: pointer;
}

#canvasContainer {
    flex: 1;
    min-width: 0;
    min-height: 0;
    position: relative;
    overflow: hidden;
    background: #e5e7eb;
    touch-action: none;
}

canvas#board {
    display: block;
    touch-action: none;
}

#eraserCursor {
    display: none;
    position: absolute;
    pointer-events: none;
    border: 2px solid #ef4444;
    background: rgba(239, 68, 68, 0.12);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 60;
}

#domEffectsLayer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 70;
}

.delete-poof {
    position: absolute;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(239,68,68,0.35) 0%, rgba(239,68,68,0) 70%);
    transform: translate(-50%, -50%) scale(0.5);
    animation: poofFade 280ms ease-out forwards;
}

@keyframes poofFade {
    to {
        transform: translate(-50%, -50%) scale(1.9);
        opacity: 0;
    }
}

#boardToastContainer {
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3800;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    max-width: 92vw;
}

.board-toast {
    background: rgba(15, 23, 42, 0.92);
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.24);
    animation: toastInOut 3.1s ease forwards;
    white-space: nowrap;
}

@keyframes toastInOut {
    0% { opacity: 0; transform: translateY(-8px); }
    12% { opacity: 1; transform: translateY(0); }
    85% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-6px); }
}

.bg-quick-btn {
    background: #eff6ff !important;
    color: #1d4ed8;
    border: 1px solid #bfdbfe !important;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

#backgroundPanel {
    display: none;
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
    z-index: 2000;
    width: 380px;
    max-width: 92vw;
    max-height: calc(100dvh - 80px);
    overflow-y: auto;
}

.background-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.background-header h3 { margin: 0; font-size: 16px; }

.close-panel-btn {
    border: none;
    background: #ef4444;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 15px;
    touch-action: manipulation;
}

.background-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.background-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 8px;
    text-align: center;
    cursor: pointer;
    background: #fafafa;
    font-size: 12px;
}

.background-card:hover { border-color: #2563eb; }
.bg-icon { font-size: 22px; margin-bottom: 4px; }

#backgroundColorPicker {
    width: 100%;
    height: 28px;
    border: none;
    background: none;
    cursor: pointer;
    margin-bottom: 2px;
}

/* --- AZIONI CONTESTUALI OGGETTO --- */
#objectActions {
    display: none;
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    background: #fff;
    padding: 6px 8px;
    border-radius: 14px;
    box-shadow: 0 6px 24px rgba(15, 23, 42, .22);
    border: 1px solid #e2e8f0;
    z-index: 1500;
    gap: 5px;
    align-items: center;
    max-width: 95vw;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

#objectActions::-webkit-scrollbar { display: none; }

#objectActions button {
    height: 36px;
    padding: 0 10px;
    border: none;
    border-radius: 9px;
    background: #f3f4f6;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    touch-action: manipulation;
}

#objectActions button:hover { background: #e5e7eb; }
#objectActions button.action-danger { background: #fee2e2; color: #b91c1c; }
#objectActions button.action-danger:hover { background: #fecaca; }

.action-color-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 38px;
    padding: 0 8px;
    border-radius: 9px;
    background: #f3f4f6;
    font-size: 14px;
    cursor: pointer;
}

.action-color-wrap input {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
}

/* --- MODALI (PULSANTI COMPATTI, MAI A TUTTA LARGHEZZA) --- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 4000;
    padding: 16px;
    overflow-y: auto;
}

.modal-content {
    width: 100%;
    max-width: 480px;
    background: #fff;
    margin: 26px auto;
    padding: 20px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .22);
}

.modal-content input:not([type="checkbox"]),
.modal-content select,
.modal-content textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 15px;
    margin-bottom: 12px;
}

.modal-content textarea { height: 130px; resize: vertical; }

.modal-hint {
    font-size: 13px;
    color: #4b5563;
    margin-bottom: 12px;
}

.modal-actions-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-btn {
    width: auto;
    min-width: auto;
    padding: 9px 14px;
    border: none;
    border-radius: 9px;
    background: #f3f4f6;
    color: #1f2937;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    touch-action: manipulation;
}

.modal-btn.primary { background: #2563eb; color: #fff; }
.modal-btn.danger { background: #ef4444; color: #fff; }

.viewer-modal-content {
    max-width: 1200px;
    height: 86vh;
    margin: 2vh auto;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#viewerToolbar {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
}

#viewerTitle { font-weight: 700; font-size: 15px; }

#viewerClose {
    border: none;
    background: #ef4444;
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
}

#viewerFrame { width: 100%; flex: 1; border: none; background: #fff; }

.save-indicator {
    display: none;
    margin: 8px 0;
    padding: 8px;
    background: #dcfce7;
    border: 1px solid #16a34a;
    color: #166534;
    border-radius: 8px;
    font-size: 13px;
}

.qr-wrap { margin: 14px 0; }
.qr-wrap img { max-width: 190px; }

#waveContainer {
    position: relative;
    width: 100%;
    height: 120px;
    touch-action: none;
    user-select: none;
    background: #f8fafc;
    border-radius: 10px;
    margin-bottom: 10px;
}

#waveform { width: 100%; height: 120px; }

.marker {
    position: absolute;
    top: 0;
    width: 8px;
    height: 120px;
    background: #ef4444;
    z-index: 10;
    cursor: ew-resize;
    border-radius: 4px;
}

#startMarker { left: 0; }
#endMarker { right: 0; }

.audio-time-label {
    font-size: 13px;
    color: #4b5563;
    margin-bottom: 10px;
    font-variant-numeric: tabular-nums;
}

.record-status { font-size: 16px; margin: 10px 0; font-weight: 600; }

.pixabay-modal-content { max-width: 960px; }

.pixabay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.media-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    justify-content: center;
}

.media-tab {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #f9fafb;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    touch-action: manipulation;
}

.media-tab.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.pixabay-search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.pixabay-search-row input { flex: 1; margin-bottom: 0; }

.pixabay-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 10px;
    max-height: 54vh;
    overflow-y: auto;
    text-align: left;
}

.media-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.media-card img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.media-card-body {
    padding: 8px;
    font-size: 12px;
    color: #1f2937;
    font-weight: 600;
}

.audio-result-card {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #f9fafb;
    flex-wrap: wrap;
}

.resize-presets {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.bg-remove-preview-wrap {
    width: 100%;
    max-height: 280px;
    overflow: auto;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    margin-bottom: 12px;
    background-image: linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
        linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    display: flex;
    justify-content: center;
    padding: 8px;
}

#bgRemovePreview { max-width: 100%; max-height: 250px; }

.checkbox-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    margin-bottom: 12px;
}

.checkbox-row input { width: auto; margin: 0; }

.caa-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
    gap: 10px;
    max-height: 45vh;
    overflow-y: auto;
}

.caa-preview-card {
    border: 2px solid #1e293b;
    border-radius: 12px;
    padding: 8px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.caa-preview-card img { width: 82px; height: 82px; object-fit: contain; }

.caa-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
}

.caa-badge.ai { background: #f3e8ff; color: #7e22ce; }

/* --- MENU COMPATTO BOARD (⋯) --- */
.board-more-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.board-more-menu {
    display: none;
    position: absolute;
    top: 42px;
    right: 0;
    width: 230px;
    max-width: calc(100vw - 16px);
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22);
    border: 1px solid #e5e7eb;
    padding: 6px;
    z-index: 3850;
}

.board-more-menu.show {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* --- TABLET PORTRAIT, SMARTPHONE PORTRAIT E LANDSCAPE: MASSIMA PULIZIA TOP & BOTTOM --- */
@media (max-width: 960px), (max-height: 520px) {
    .board-title-pill,
    .save-status,
    .desktop-only-action,
    .topbar-right .btn-label,
    .bg-quick-btn .btn-label {
        display: none !important;
    }

    #topbar {
        min-height: 44px;
        height: auto;
        flex-wrap: wrap;
        padding: 4px 8px;
        gap: 4px 6px;
    }

    .topbar-left { flex: 1 1 auto; min-width: 0; overflow: hidden; gap: 5px; }
    .topbar-right { flex: 0 0 auto; overflow: visible; gap: 5px; }

    .top-action-btn, .login-cta-btn {
        padding: 6px 9px;
        font-size: 12px;
        border-radius: 9px;
    }

    #centerTools {
        order: 3;
        flex: 1 0 100%;
        width: 100%;
        justify-content: space-between;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        gap: 4px;
        padding: 4px 2px 2px;
        border-top: 1px solid #f1f5f9;
    }

    #centerTools::-webkit-scrollbar { display: none; }

    #centerTools button {
        padding: 4px 7px;
        font-size: 12.5px;
    }

    .rating-popover {
        position: fixed;
        top: 52px;
        right: 10px;
        max-width: calc(100vw - 20px);
    }

    #workspace {
        flex-direction: column-reverse;
    }

    #toolbar {
        width: 100%;
        height: auto;
        min-height: 52px;
        border-right: none;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.06);
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: space-evenly;
        align-items: center;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 5px 8px calc(5px + env(safe-area-inset-bottom, 0px));
        gap: 4px;
    }

    #toolbar > button,
    #toolbar .tool-group > button {
        width: 42px;
        height: 40px;
        font-size: 19px;
        border-radius: 11px;
    }

    .submenu.show {
        left: 50% !important;
        transform: translateX(-50%);
        bottom: calc(60px + env(safe-area-inset-bottom, 0px));
        top: auto !important;
        width: min(360px, calc(100vw - 16px));
        max-width: none;
        max-height: calc(100dvh - 155px);
        padding: 10px;
    }

    .submenu-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .submenu-grid button {
        width: 100%;
        height: 42px;
    }

    #objectActions {
        bottom: calc(60px + env(safe-area-inset-bottom, 0px));
        max-width: calc(100vw - 14px);
        padding: 5px 7px;
    }

    #objectActions button {
        height: 34px;
        padding: 0 8px;
        font-size: 13px;
    }

    .chat-drawer.open {
        position: fixed;
        right: 0;
        top: 50px;
        bottom: calc(54px + env(safe-area-inset-bottom, 0px));
        height: auto;
        width: min(360px, 100vw);
        box-shadow: -6px 0 24px rgba(0, 0, 0, .2);
        z-index: 3400;
    }

    .settings-perms-grid {
        grid-template-columns: 1fr;
    }
}

/* --- SMARTPHONE LANDSCAPE (ORIZZONTALE): MASSIMO SPAZIO VERTICALE PER LA BOARD --- */
@media (max-height: 520px) and (min-width: 500px) {
    #topbar {
        min-height: 40px;
        height: 40px;
        flex-wrap: nowrap;
        padding: 2px 8px;
        gap: 6px;
    }

    .topbar-left {
        flex: 0 1 auto;
        gap: 4px;
    }

    .topbar-right {
        flex: 0 0 auto;
        gap: 4px;
    }

    .topbar-right .btn-label,
    .bg-quick-btn .btn-label {
        display: none !important;
    }

    .top-icon-btn,
    .user-avatar-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .top-action-btn,
    .login-cta-btn {
        height: 30px;
        padding: 0 8px;
        font-size: 12px;
        border-radius: 8px;
    }

    #logo {
        font-size: 14px;
    }

    .presence-pill {
        padding: 2px 7px;
        font-size: 11px;
    }

    #centerTools {
        order: 0;
        flex: 0 1 auto;
        width: auto;
        justify-content: center;
        border-top: none;
        padding: 0;
        gap: 3px;
    }

    #centerTools button {
        padding: 3px 6px;
        font-size: 11.5px;
    }

    #centerTools .history-pill button {
        width: 28px;
        height: 25px;
        padding: 0;
    }

    .page-switcher,
    .zoom-pill,
    .history-pill {
        padding: 1px 3px;
    }

    .rating-popover {
        top: 44px;
    }

    #workspace {
        flex-direction: row !important;
    }

    #toolbar {
        width: 48px;
        height: 100%;
        min-height: 0;
        flex-direction: column;
        justify-content: flex-start;
        border-top: none;
        border-right: 1px solid #e5e7eb;
        box-shadow: none;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 4px 3px;
        gap: 4px;
    }

    #toolbar > button,
    #toolbar .tool-group > button {
        width: 38px;
        height: 34px;
        font-size: 17px;
        border-radius: 9px;
    }

    .submenu.show {
        left: 54px !important;
        right: auto !important;
        top: 44px !important;
        bottom: auto !important;
        transform: none !important;
        width: min(310px, calc(100vw - 64px));
        max-height: calc(100dvh - 52px);
        padding: 8px;
    }

    #objectActions {
        left: calc(50% + 24px);
        bottom: 8px;
        max-width: calc(100vw - 66px);
        padding: 4px 6px;
    }

    #objectActions button {
        height: 30px;
        padding: 0 7px;
        font-size: 12px;
    }

    #backgroundPanel {
        top: 44px;
        max-height: calc(100dvh - 52px);
    }

    .chat-drawer.open {
        top: 40px;
        bottom: 0;
        width: min(320px, 58vw);
    }

    .modal {
        padding: 8px;
    }

    .modal-content {
        margin: 8px auto;
        padding: 14px;
    }
}

@media (max-width: 640px) {
    .desktop-only-tool {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .topbar-right .btn-label,
    .bg-quick-btn .btn-label {
        display: none;
    }

    .top-icon-btn {
        width: 32px;
        height: 32px;
        font-size: 15px;
    }

    .top-action-btn, .login-cta-btn {
        height: 32px;
        padding: 0 9px;
    }

    #logo { font-size: 15px; }
}

/* --- USER AVATAR DROPDOWN MENU --- */
.user-menu-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.user-avatar-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 2px solid #2563eb;
    border-radius: 50%;
    background: #eff6ff;
    overflow: hidden;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    touch-action: manipulation;
}

.user-avatar-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 42px;
    right: 0;
    width: 220px;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.2);
    border: 1px solid #e5e7eb;
    padding: 6px;
    z-index: 3800;
}

.user-dropdown.show {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-dropdown-header {
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: #1f2937;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.user-dropdown-item:hover {
    background: #f1f5f9;
}

.user-dropdown-item.danger {
    color: #dc2626;
}

.user-lang-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    border-top: 1px solid #f1f5f9;
    margin-top: 4px;
}

.aleboard-lang-select {
    width: auto;
    padding: 4px 6px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    font-size: 12px;
    background: #ffffff;
}

#objectActions button.active {
    background: #dbeafe;
    color: #1d4ed8;
    outline: 1.5px solid #2563eb;
}

/* --- AI PROMPT ROW & GOOGLE DRIVE MODAL --- */
.ai-generate-row {
    display: none;
    gap: 10px;
    margin-bottom: 12px;
    align-items: center;
}

.ai-generate-row input {
    flex: 1;
    margin-bottom: 0;
}

.drive-status-box {
    display: none;
    margin: 8px 0 12px;
    padding: 9px 12px;
    border-radius: 10px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    font-size: 13px;
    text-align: left;
}

.drive-status-box.error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.drive-files-list {
    margin-top: 12px;
    max-height: 210px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
}

.drive-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    font-size: 13px;
}

.drive-file-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- ANIMAZIONE DADI POPUP --- */
#diceOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 4500;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.dice-anim-box {
    position: relative;
    min-width: 240px;
    max-width: 90vw;
    background: #ffffff;
    border-radius: 20px;
    padding: 28px 34px 20px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
    text-align: center;
}

.dice-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: #f1f5f9;
    color: #334155;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.dice-close-btn:hover {
    background: #fee2e2;
    color: #dc2626;
}

.dice-anim-faces {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 10px;
}

.dice-anim-die {
    font-size: 64px;
    line-height: 1;
    display: inline-block;
    animation: diceBounce 0.2s infinite alternate;
}

.dice-anim-die.settled {
    animation: none;
    transform: none;
}

.dice-anim-label {
    font-size: 17px;
    font-weight: 700;
    color: #1d4ed8;
}

.dice-autoclose-hint {
    margin-top: 8px;
    font-size: 11.5px;
    color: #64748b;
    min-height: 16px;
}

@keyframes diceBounce {
    from { transform: translateY(0) rotate(-6deg); }
    to { transform: translateY(-6px) rotate(6deg); }
}

/* --- ADATTAMENTO IMMAGINE DI SFONDO --- */
.bg-fit-bar {
    margin-top: 12px;
    padding: 10px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.bg-fit-title {
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 8px;
}

.bg-fit-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.bg-fit-quick-toast {
    display: none;
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1600;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(8px);
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    padding: 6px 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
    align-items: center;
    gap: 5px;
    max-width: calc(100% - 20px);
    overflow-x: auto;
    scrollbar-width: none;
}

.bg-fit-quick-toast::-webkit-scrollbar {
    display: none;
}

.bg-fit-quick-lbl {
    font-size: 12px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    padding: 0 4px;
}

.bg-fit-btn {
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #334155;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 9px;
    border-radius: 9px;
    cursor: pointer;
    white-space: nowrap;
    touch-action: manipulation;
    flex-shrink: 0;
}

.bg-fit-btn:hover {
    background: #e2e8f0;
}

.bg-fit-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.bg-fit-close {
    border: none;
    background: #f1f5f9;
    color: #475569;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bg-fit-close:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* --- BRAND LOGO & PWA INSTALL (BOARD WORKSPACE) --- */
.board-brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    flex-shrink: 0;
}

.board-logo-img {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.28);
}

.pwa-install-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.52);
    backdrop-filter: blur(4px);
    z-index: 6000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.pwa-install-modal.open {
    display: flex;
}

.pwa-modal-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 20px 44px rgba(15, 23, 42, 0.24);
    border: 1px solid #e2e8f0;
}

.pwa-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: #f1f5f9;
    color: #475569;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pwa-modal-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding-right: 26px;
}

.pwa-modal-logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    flex-shrink: 0;
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.22);
}

.pwa-modal-head h3 {
    margin: 0 0 3px;
    font-size: 18px;
    color: #0f172a;
}

.pwa-modal-head p {
    margin: 0;
    font-size: 13px;
    color: #475569;
    line-height: 1.4;
}

.pwa-modal-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 16px;
}

.pwa-step {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13.5px;
    line-height: 1.45;
    color: #1e293b;
}

.pwa-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.pwa-btn-primary,
.pwa-btn-secondary {
    border: none;
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.pwa-btn-primary {
    background: #2563eb;
    color: #ffffff;
}

.pwa-btn-secondary {
    background: #f1f5f9;
    color: #1e293b;
}

.pwa-offline-pill {
    display: none;
    position: fixed;
    bottom: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6100;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
}

.pwa-offline-pill.show {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* --- MODALITÀ QUADERNO (PAGINE IMPILATE IN VERTICALE) --- */
.board-canvas-host {
    position: relative;
    width: 100%;
    height: 100%;
}

#canvasContainer.notebook-mode {
    overflow-y: auto;
    overflow-x: hidden;
    touch-action: pan-y;
    background: #cbd5e1;
    padding: 20px 12px 96px;
}

.notebook-stack-wrap {
    max-width: 820px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.notebook-pages-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.notebook-page-card {
    width: 100%;
    background: #ffffff;
    border-radius: 14px;
    border: 2px solid #cbd5e1;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.12);
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.notebook-page-card.active {
    border-color: #2563eb;
    box-shadow: 0 14px 32px rgba(37, 99, 235, 0.2);
}

.notebook-page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 13px;
    font-weight: 700;
    color: #334155;
}

.notebook-page-body {
    position: relative;
    width: 100%;
    background: #ffffff;
    cursor: pointer;
    overflow: hidden;
}

#canvasContainer.notebook-mode .board-canvas-host {
    width: 100%;
    height: 100%;
    touch-action: none;
}

.notebook-page-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.notebook-page-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 14px;
    font-weight: 600;
}

.notebook-page-del {
    border: none;
    background: #fee2e2;
    color: #b91c1c;
    border-radius: 7px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.notebook-page-del:hover {
    background: #fecaca;
}

.notebook-add-page-btn {
    border: 2px dashed #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 15px;
    font-weight: 700;
    border-radius: 14px;
    padding: 13px 26px;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.notebook-add-page-btn:hover {
    background: #dbeafe;
    transform: translateY(-1px);
}

.ephemeral-reg-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 8px 16px;
    background: linear-gradient(90deg, #eff6ff 0%, #fef3c7 100%);
    border-bottom: 1px solid #bfdbfe;
    color: #1e3a8a;
    font-size: 12.5px;
    line-height: 1.4;
    z-index: 95;
}

.ephemeral-reg-text {
    flex: 1 1 280px;
}

.ephemeral-reg-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.ephemeral-reg-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 9px;
    font-size: 12.5px;
    font-weight: 700;
    text-decoration: none;
    background: #ffffff;
    color: #1e3a8a;
    border: 1px solid #93c5fd;
    white-space: nowrap;
}

.ephemeral-reg-btn.primary {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

.ephemeral-reg-btn.primary:hover {
    background: #1d4ed8;
}

.ale-donor-badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    border: 1px solid #f59e0b;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
}

.ale-donor-badge-pill.sm {
    padding: 2px 8px;
    font-size: 11px;
    margin-left: 6px;
}

@media (max-width: 640px) {
    .ephemeral-reg-banner {
        padding: 8px 10px;
        font-size: 12px;
        gap: 8px;
    }
    .ephemeral-reg-btn {
        padding: 5px 10px;
        font-size: 12px;
    }
}
