:root {
    --bg-color: #f4f4f7;
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --accent-color: #ff0000;
    --hover-color: #3b82f6;
    --text-color: #1e293b;
    --toolbar-bg: rgba(255, 255, 255, 0.85);
    --toolbar-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
}

.dark-theme {
    --bg-color: #1a1b1e;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #94a3b8;
    --text-color: #f1f5f9;
    --toolbar-bg: rgba(30, 41, 59, 0.88);
    --toolbar-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --border-color: #334155;
    --card-bg: #1e293b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
}

/* ===================================================
   MODE E-INK (Ultra-Contraste, N&B pur, Zéro animation)
   Optimisé pour Onyx Boox Tab Ultra, Note Air, etc.
   =================================================== */
.eink-theme {
    --bg-color: #ffffff !important;
    --card-bg: #ffffff !important;
    --text-color: #000000 !important;
    --primary-color: #000000 !important;
    --primary-hover: #222222 !important;
    --secondary-color: #222222 !important;
    --border-color: #000000 !important;
    --toolbar-bg: #ffffff !important;
    --toolbar-shadow: none !important;
    --success-color: #000000 !important;
    --warning-color: #000000 !important;
    --danger-color: #000000 !important;
}

/* Suppression TOTALE des animations, transitions et flous sur E-Ink */
.eink-theme,
.eink-theme * {
    transition: none !important;
    animation: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

html.eink-theme,
body.eink-theme,
.eink-theme {
    background-color: #ffffff !important;
    background: #ffffff !important;
    color: #000000 !important;
}

.eink-theme .toolbar {
    background: #ffffff !important;
    border-bottom: 2px solid #000000 !important;
}

.eink-theme .logo {
    color: #000000 !important;
}

.eink-theme .logo .version-badge {
    background: #000000 !important;
    color: #ffffff !important;
    border: 1px solid #000000;
}

.eink-theme .tool-group {
    background: #ffffff !important;
    border: 1px solid #000000 !important;
    border-radius: 6px;
}

.eink-theme .tool-btn {
    border: 1px solid transparent;
    color: #000000 !important;
    border-radius: 4px;
}

.eink-theme .tool-btn:hover {
    background: #e2e2e2 !important;
    color: #000000 !important;
}

.eink-theme .tool-btn.active {
    background: #000000 !important;
    color: #ffffff !important;
    border: 1px solid #000000 !important;
}

.eink-theme .color-circle,
.eink-theme .color-marker {
    background-color: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
    border-radius: 4px !important;
    width: 26px !important;
    height: 26px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    box-shadow: none !important;
}

.eink-theme .color-letter {
    display: inline-block !important;
    color: #000000 !important;
    font-size: 0.85rem !important;
    font-weight: 900 !important;
    line-height: 1 !important;
}

.eink-theme .color-circle.active,
.eink-theme .color-marker.active {
    background-color: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #000000 !important;
    outline: 2px solid #000000 !important;
    outline-offset: 1px !important;
    transform: none !important;
}

.eink-theme .color-circle.active .color-letter,
.eink-theme .color-marker.active .color-letter {
    color: #ffffff !important;
}

.eink-theme .sync-group {
    background: #ffffff !important;
    border: 2px solid #000000 !important;
}

.eink-theme .sync-badge {
    border: 1px solid #000000 !important;
    background: #ffffff !important;
    color: #000000 !important;
    font-weight: 700;
}

.eink-theme .sync-badge .dot {
    background: #000000 !important;
}

.eink-theme .sync-badge.connected {
    background: #000000 !important;
    color: #ffffff !important;
}

.eink-theme .sync-badge.connected .dot {
    background: #ffffff !important;
}

.eink-theme .action-btn {
    background: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
    border-radius: 6px;
}

.eink-theme .action-btn.primary,
.eink-theme .action-btn.server-save {
    background: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #000000 !important;
}

.eink-theme .action-btn:hover {
    background: #e2e2e2 !important;
    color: #000000 !important;
}

.eink-theme .action-btn.primary:hover,
.eink-theme .action-btn.server-save:hover {
    background: #222222 !important;
    color: #ffffff !important;
}

.eink-theme .editor-container {
    background: #ffffff !important;
    background-color: #ffffff !important;
}

.eink-theme .page-container {
    border: 2px solid #000000 !important;
    border-radius: 0 !important;
    background: #ffffff !important;
}

.eink-theme .page-container.active-page {
    outline: 4px solid #000000 !important;
    outline-offset: 2px !important;
}

.eink-theme .drop-zone {
    border: 3px solid #000000 !important;
    background: #ffffff !important;
    color: #000000 !important;
}

.eink-theme .drop-zone i {
    color: #000000 !important;
}

.eink-theme .bottom-bar {
    background: #ffffff !important;
    border-top: 2px solid #000000 !important;
}

.eink-theme .remote-viewport-box {
    border: 3px solid #000000 !important;
    box-shadow: none !important;
    background: transparent !important;
    transition: none !important;
}

.eink-theme .remote-viewport-tag {
    background: #000000 !important;
    color: #ffffff !important;
    border: 1px solid #000000 !important;
    box-shadow: none !important;
    font-weight: 900 !important;
}

/* ==========================================
   Mode APK Allégé & Épuré pour Boox / Tablette
   ========================================== */
html.app-mode #btn-upload,
html.app-mode #btn-export-png,
html.app-mode #btn-copy-clipboard,
html.app-mode #btn-save-local,
html.app-mode .sync-group,
html.app-mode .view-tools,
html.app-mode #btn-theme-toggle,
html.app-mode #btn-fullscreen,
html.app-mode #btn-select,
html.app-mode #btn-text,
html.app-mode #btn-clear,
body.app-mode #btn-upload,
body.app-mode #btn-export-png,
body.app-mode #btn-copy-clipboard,
body.app-mode #btn-save-local,
body.app-mode .sync-group,
body.app-mode .view-tools,
body.app-mode #btn-theme-toggle,
body.app-mode #btn-fullscreen,
body.app-mode #btn-select,
body.app-mode #btn-text,
body.app-mode #btn-clear {
    display: none !important;
}

html.app-mode .tool-group.draw-tools,
body.app-mode .tool-group.draw-tools {
    display: flex !important;
}

html.app-mode #btn-pen,
html.app-mode #btn-highlighter,
html.app-mode #btn-eraser,
body.app-mode #btn-pen,
body.app-mode #btn-highlighter,
body.app-mode #btn-eraser {
    display: inline-flex !important;
}

.eink-theme .page-nav button,
.eink-theme .zoom-controls button {
    border: 1px solid #000000 !important;
    color: #000000 !important;
    border-radius: 4px;
}

.eink-theme dialog {
    border: 3px solid #000000 !important;
    background: #ffffff !important;
    color: #000000 !important;
    border-radius: 6px !important;
}

.eink-theme dialog::backdrop {
    background: rgba(0, 0, 0, 0.4) !important;
}

.eink-theme .pin-display-box {
    border: 3px solid #000000 !important;
    background: #ffffff !important;
}

.eink-theme .pin-digits {
    color: #000000 !important;
}

.eink-theme .pin-input,
.eink-theme .dialog-text-input {
    border: 2px solid #000000 !important;
    color: #000000 !important;
    background: #ffffff !important;
}

.eink-theme .password-toggle-btn {
    color: #000000 !important;
}

.eink-theme .toast {
    border: 2px solid #000000 !important;
    background: #ffffff !important;
    color: #000000 !important;
}

.eink-theme .toast i {
    color: #000000 !important;
}

/* ===================================================
   Styles de base & Optimisation Tactile / Stylet
   =================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    touch-action: pan-x pan-y;
}

/* Toolbar */
.toolbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0.45rem 0.85rem;
    background: var(--toolbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--toolbar-shadow);
    gap: 0.65rem;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--primary-color);
    gap: 0.5rem;
    user-select: none;
}

.logo .version-badge {
    font-size: 0.65rem;
    background: var(--primary-color);
    color: white;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 500;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.2rem;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 10px;
}

.tool-btn {
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    color: var(--secondary-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    touch-action: manipulation;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--primary-color);
}

.tool-btn.active {
    background: var(--primary-color);
    color: white;
}

.colors {
    gap: 0.5rem;
    padding: 0 0.4rem;
}

.size-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.5rem;
    color: var(--secondary-color);
}

.size-selector input {
    cursor: pointer;
    width: 55px;
}

#size-value {
    font-size: 0.85rem;
    width: 18px;
    text-align: right;
}

.color-circle, .color-marker {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s;
    touch-action: manipulation;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.color-letter {
    display: none;
    pointer-events: none;
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1;
}

.color-circle:hover, .color-marker:hover {
    transform: scale(1.25);
}

.color-circle.active, .color-marker.active {
    border-color: white;
    box-shadow: 0 0 0 2px var(--primary-color);
}

/* Sync Group & Badge */
.sync-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.4rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 10px;
}

.sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
    touch-action: manipulation;
}

.sync-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #94a3b8;
}

.sync-badge.offline {
    background: rgba(148, 163, 184, 0.15);
    color: var(--secondary-color);
}

.sync-badge.waiting {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.sync-badge.waiting .dot {
    background-color: #f59e0b;
    animation: pulse 1.5s infinite;
}

.sync-badge.connected {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.sync-badge.connected .dot {
    background-color: #10b981;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

.spacer {
    flex-grow: 1;
}

.actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
    font-family: inherit;
    touch-action: manipulation;
}

.action-btn.primary {
    background: var(--primary-color);
    color: white;
}

.action-btn.primary:hover {
    background: var(--primary-hover);
}

.action-btn.server-save {
    background: #059669;
    color: white;
}

.action-btn.server-save:hover {
    background: #047857;
}

.action-btn.server-save:disabled {
    background: #6ee7b7;
    cursor: not-allowed;
}

.action-btn.secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--secondary-color);
}

.action-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-color);
}

/* Editor Main Area & Optimisations Stylet Boox */
.editor-container {
    flex-grow: 1;
    position: relative;
    overflow-y: auto;
    overflow-x: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    -webkit-overflow-scrolling: touch;
}

.pdf-viewer {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 2rem;
    margin: 0 auto;
    min-width: min-content;
}

.page-container {
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.35);
    border-radius: 4px;
    background: white;
    margin: 0 auto;
    flex-shrink: 0;
    overflow: hidden;
    transition: outline 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    content-visibility: auto;
    contain-intrinsic-size: auto 800px;
}

.page-container .pdf-canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.page-container .canvas-container {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 2;
}

/* Cadre indicateur du champ de vision de l'ordinateur sur la tablette */
.remote-viewport-box {
    position: absolute;
    box-sizing: border-box;
    border: 2.5px solid #000000;
    border-radius: 4px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.8), inset 0 0 0 1px rgba(255, 255, 255, 0.8), 0 3px 10px rgba(0, 0, 0, 0.3);
    background: rgba(0, 0, 0, 0.02);
    pointer-events: none !important;
    z-index: 10;
    transition: top 0.06s ease-out, left 0.06s ease-out, width 0.06s ease-out, height 0.06s ease-out;
}

.remote-viewport-tag {
    position: absolute;
    top: 4px;
    left: 4px;
    background: #000000;
    color: #ffffff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    user-select: none;
    letter-spacing: 0.3px;
    opacity: 0.9;
}

/* Gestes tactiles sur le canvas selon le mode de stylet */
html.stylus-wacom .canvas-container,
html.stylus-wacom .canvas-container canvas,
html.stylus-wacom .page-container canvas {
    border-radius: 4px;
    touch-action: pan-x pan-y !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

html.stylus-capacitive .canvas-container canvas.upper-canvas {
    touch-action: none !important;
}

html.stylus-capacitive .canvas-container,
html.stylus-capacitive .canvas-container canvas,
html.stylus-capacitive .page-container canvas {
    border-radius: 4px;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

.loading-pdf {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem;
    color: var(--secondary-color);
    font-size: 1.25rem;
}

.loading-pdf i {
    font-size: 2.5rem;
    color: var(--primary-color);
}

/* Drop Zone */
.drop-zone {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    max-width: 580px;
    padding: 2.5rem 1.5rem;
    border: 3px dashed var(--border-color);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--secondary-color);
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.3s;
    gap: 1.25rem;
}

.drop-zone.drag-over {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
}

.drop-content i {
    font-size: 3.5rem;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
}

.drop-zone-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Bottom Bar */
.bottom-bar {
    position: sticky;
    bottom: 0;
    background: var(--toolbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    padding: 0.4rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    z-index: 1000;
}

.page-nav,
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--secondary-color);
}

.page-nav button,
.zoom-controls button {
    background: transparent;
    border: none;
    color: var(--secondary-color);
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    transition: all 0.15s;
    touch-action: manipulation;
}

.page-nav button:hover,
.zoom-controls button:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.1);
}

#zoom-level,
#page-count {
    font-weight: 500;
    min-width: 75px;
    text-align: center;
    font-size: 0.9rem;
}

.credits {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    font-size: 0.6rem;
    color: var(--secondary-color);
    line-height: 1.2;
}

.credits a {
    color: var(--primary-color);
    text-decoration: none;
}

.credits a:hover {
    text-decoration: underline;
}

/* Native Modern Dialogs */
dialog {
    margin: auto;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    max-width: 440px;
    width: 90vw;
    font-family: inherit;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
}

.dialog-card {
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dialog-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
}

.dialog-close-btn {
    background: transparent;
    border: none;
    color: var(--secondary-color);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.2rem;
}

.dialog-close-btn:hover {
    color: var(--text-color);
}

/* PIN Display */
.pin-display-box {
    background: rgba(0, 0, 0, 0.2);
    border: 2px dashed var(--primary-color);
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.pin-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--secondary-color);
}

.pin-digits {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: var(--primary-color);
    font-family: monospace;
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
    margin-right: -0.3em;
}

.pin-instructions {
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--secondary-color);
    text-align: center;
}

/* PIN Input on Guest / Tablet */
.pin-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.pin-input {
    width: 220px;
    padding: 0.75rem;
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    text-align: center;
    font-family: monospace;
    background: rgba(0, 0, 0, 0.2);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-color);
    outline: none;
    transition: border-color 0.2s;
}

.pin-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Password and Text Dialog Inputs */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.dialog-text-input {
    width: 100%;
    padding: 0.75rem 2.8rem 0.75rem 0.85rem;
    font-size: 1rem;
    font-family: inherit;
    background: rgba(0, 0, 0, 0.2);
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.dialog-text-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.password-toggle-btn {
    position: absolute;
    right: 0.6rem;
    background: transparent;
    border: none;
    color: var(--secondary-color);
    cursor: pointer;
    padding: 0.4rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.2s;
}

.password-toggle-btn:hover {
    color: var(--text-color);
}

.dialog-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.dialog-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    border-radius: 10px;
    font-size: 0.9rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-round {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #64748b;
    transition: 0.25s;
    border-radius: 24px;
}

.slider-round:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.25s;
    border-radius: 50%;
}

input:checked + .slider-round {
    background-color: var(--primary-color);
}

input:checked + .slider-round:before {
    transform: translateX(20px);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 4.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
    border-radius: 10px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: auto;
    max-width: 350px;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}
.toast.success i {
    color: var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}
.toast.error i {
    color: var(--danger-color);
}

.toast.info {
    border-left: 4px solid var(--primary-color);
}
.toast.info i {
    color: var(--primary-color);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.toast.fade-out {
    animation: toast-out 0.25s ease-out forwards;
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
}

.hidden {
    display: none !important;
}

/* Configuration Modal & Stylus Mode Selector */
.config-section {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.config-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.stylus-mode-selector {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.stylus-radio-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    user-select: none;
}

.stylus-radio-card:hover {
    border-color: var(--hover-color);
    background: rgba(59, 130, 246, 0.05);
}

.stylus-radio-card.active,
.stylus-radio-card:has(input:checked) {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
}

.stylus-radio-card input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.stylus-radio-content {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
}

.stylus-radio-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.stylus-radio-subtitle {
    font-size: 0.8rem;
    color: var(--secondary-color);
}

.stylus-mode-description {
    background: rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
    font-size: 0.88rem;
    line-height: 1.5;
    animation: toast-in 0.2s ease-out;
}

.stylus-desc-card {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.desc-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    align-self: flex-start;
}

.desc-badge.wacom-badge {
    background: rgba(37, 99, 235, 0.15);
    color: var(--primary-color);
}

.desc-badge.cap-badge {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success-color);
}

.desc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.desc-list li {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    color: var(--text-color);
}

.desc-list li code {
    background: rgba(0, 0, 0, 0.15);
    padding: 1px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85em;
}

.desc-recom {
    font-size: 0.82rem;
    color: var(--secondary-color);
    border-top: 1px dashed var(--border-color);
    padding-top: 0.5rem;
    margin-top: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* E-Ink Theme overrides for Config */
.eink-theme .stylus-radio-card {
    border: 2px solid #000000 !important;
    background: #ffffff !important;
    color: #000000 !important;
}

.eink-theme .stylus-radio-card.active,
.eink-theme .stylus-radio-card:has(input:checked) {
    background: #000000 !important;
    color: #ffffff !important;
}

.eink-theme .stylus-radio-card.active .stylus-radio-title,
.eink-theme .stylus-radio-card.active .stylus-radio-subtitle,
.eink-theme .stylus-radio-card:has(input:checked) .stylus-radio-title,
.eink-theme .stylus-radio-card:has(input:checked) .stylus-radio-subtitle {
    color: #ffffff !important;
}

.eink-theme .stylus-mode-description {
    border: 2px solid #000000 !important;
    background: #ffffff !important;
    color: #000000 !important;
}

.eink-theme .desc-badge {
    border: 1px solid #000000 !important;
    background: #ffffff !important;
    color: #000000 !important;
}

.eink-theme .desc-list li {
    color: #000000 !important;
}

.eink-theme .desc-recom {
    border-top-color: #000000 !important;
    color: #000000 !important;
}

/* Mobile & Tablet Optimizations */
@media (max-width: 768px) {
    .toolbar {
        padding: 0.35rem 0.5rem;
        gap: 0.35rem;
    }
    .tool-btn {
        width: 34px;
        height: 34px;
        font-size: 0.95rem;
    }
    .logo span {
        display: none;
    }
    .action-btn span {
        display: none;
    }
    .action-btn {
        padding: 0.4rem 0.6rem;
    }
    .bottom-bar {
        padding: 0.3rem 0.75rem;
        gap: 0.5rem;
    }
    .credits {
        display: none;
    }
}
