/* CSS Custom Properties */
:root {
    color-scheme: light;
    --primary-gradient: linear-gradient(135deg, #F09819 0%, #FF5E00 100%);
    --toolbar-gradient: linear-gradient(135deg, #F09819 0%, #FFD700 100%);
    --button-gradient: linear-gradient(45deg, #eee239 0%, #F09819 51%, #eee239 100%);
    --dark-gradient: linear-gradient(135deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.95) 100%);
    --focus-ring: 0 0 0 3px rgba(240, 152, 25, 0.4);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.3);
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    --footer-height: 24px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

html {
    height: 100%;
    overflow-x: hidden;
    overscroll-behavior: none;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overscroll-behavior: none;
    color: black;
    background: linear-gradient(#eee239, orange) no-repeat fixed;
    background-color: orange;
    min-height: 100vh;
    margin: 0;
    padding: 0 0 calc(var(--footer-height) + env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
}

main {
    max-width: 900px;
    margin: auto;
    padding: 0.5rem;
    text-align: center;
}

.button {
    margin: 5px;
    padding: 12px;
    text-align: center;
    background-size: 200% auto;
    color: black;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all var(--transition-slow);
    display: block;
    font-weight: 500;
    font-size: 0.85rem;
    background-image: var(--button-gradient);
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    box-shadow: var(--shadow-md);
    min-width: 70px;
    position: relative;
    overflow: hidden;
    will-change: transform, box-shadow;
}

/* Shimmer effect */
.button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.6s ease;
}

.button:hover::before {
    left: 100%;
}

.button:active {
    transform: scale(0.95);
    box-shadow: var(--shadow-md);
}

.button:hover {
    background-position: right center;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 16px rgba(240, 152, 25, 0.4);
    border-color: rgba(255, 255, 255, 0.3);
}

.button:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.button:disabled:hover {
    transform: none;
    box-shadow: none;
}

input {
    margin: 5px;
    padding: 10px;
    appearance: none;
    max-width: 100%;
    font-size: 0.75rem;
    box-sizing: border-box;
    text-align: center;
    border-radius: 10px;
    opacity: 0.9;
    background-color: #eee239;
}

.rotate {
    /* Position and transform set by JavaScript maximizeRotatedImage() */
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 4px !important;
    background: transparent !important;
    display: block !important;
    visibility: visible !important;
}

/* Rotated state is handled purely by JavaScript inline styles (DirkJan pattern) */

.normal {
    transform: rotate(0deg);
    width: 100%;
    max-width: 900px;
    height: auto;
    display: block;
    margin: 0 auto;
    cursor: pointer;
    pointer-events: auto;
}

#comic-wrapper {
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    transition: all 0.3s ease;
}

#comic {
    transition: transform 0.5s ease-out, opacity 0.4s ease-out;
    opacity: 1;
    cursor: pointer;
    position: relative;
    transform: translateX(0);
    transform-origin: center center;
}

#comic.dissolve {
    opacity: 0;
}

#comic.no-transition {
    transition: none !important;
}

/* Outgoing comic clone for pixelation morph - sits on top and pixelates away */
.comic-pixelate-outgoing {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 900px;
    height: auto;
    pointer-events: none;
    z-index: 2;
    transform-origin: center center;
    transition: filter 0.6s ease-in-out, opacity 0.6s ease-in-out;
    filter: blur(0px);
    opacity: 1;
}

.comic-pixelate-outgoing.morph-out {
    filter: blur(20px);
    opacity: 0;
}

/* Incoming comic starts blurred, then sharpens */
#comic.morph-in {
    filter: blur(20px);
    opacity: 0.5;
}

#comic.morph-resolve {
    transition: filter 0.6s ease-in-out, opacity 0.6s ease-in-out;
    filter: blur(0px);
    opacity: 1;
}

/* Outgoing comic clone for filmstrip effect */
.comic-outgoing {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 900px;
    height: auto;
    transition: transform 0.5s ease-out;
    pointer-events: none;
    z-index: 2;
}

/* Slide animations - no opacity fade, just movement */
#comic.slide-out-left,
.comic-outgoing.slide-out-left {
    transform: translateX(calc(-100% - 20px));
}

#comic.slide-out-right,
.comic-outgoing.slide-out-right {
    transform: translateX(calc(100% + 20px));
}

#comic.slide-in-left {
    transform: translateX(calc(100% + 20px));
}

#comic.slide-in-right {
    transform: translateX(calc(-100% - 20px));
}

.fullscreen-landscape {
    max-height: 95vh;
    max-width: 95vw;
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
    border-radius: 4px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transform-origin: center center;
    z-index: 10001;
    cursor: pointer;
    pointer-events: auto;
}

/* Fullscreen overlay */
#comic-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 10000;
    display: flex;
    align-items: stretch;
    justify-content: center;
    overflow: hidden;
}

/* Fullscreen toolbar styles */
.fullscreen-toolbar {
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 16px;
    margin: 0;
    width: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
                0 4px 12px rgba(0, 0, 0, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.15);
    -webkit-backdrop-filter: blur(25px);
    backdrop-filter: blur(25px);
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    position: fixed;
    z-index: 10002;
}

.fullscreen-toolbar .toolbar-button {
    width: 48px;
    height: 48px;
    margin: 0;
    border-radius: 14px;
}

.fullscreen-toolbar .toolbar-svg {
    width: 24px;
    height: 24px;
}

/* Rotated toolbar (portrait mode with 90° rotation) */
.fullscreen-toolbar.rotated {
    flex-direction: column;
    padding: 16px 10px;
    max-height: 80vh;
    max-width: 70px;
    top: 50%;
    left: 20px;
    bottom: auto;
    transform: translateY(-50%);
    gap: 10px;
}

.fullscreen-toolbar.rotated .toolbar-button {
    margin: 0;
}

#rotated-comic {
    margin: 0 !important;
    transition: transform 0.4s ease-out, opacity 0.4s ease-out;
    opacity: 1;
}

#rotated-comic.dissolve {
    opacity: 0;
}

/* Slide animations for rotated comics (with 90deg rotation) */
#rotated-comic.rotate.slide-out-left,
.rotated-comic-outgoing.rotate.slide-out-left {
    transform: translate(-50%, calc(-50% - 100vh - 20px)) rotate(90deg) !important;
}

#rotated-comic.rotate.slide-out-right,
.rotated-comic-outgoing.rotate.slide-out-right {
    transform: translate(-50%, calc(-50% + 100vh + 20px)) rotate(90deg) !important;
}

#rotated-comic.rotate.slide-in-left {
    transform: translate(-50%, calc(-50% + 100vh + 20px)) rotate(90deg) !important;
}

#rotated-comic.rotate.slide-in-right {
    transform: translate(-50%, calc(-50% - 100vh - 20px)) rotate(90deg) !important;
}

/* Slide animations for landscape fullscreen (no rotation) */
#rotated-comic.fullscreen-landscape.slide-out-left,
.rotated-comic-outgoing.fullscreen-landscape.slide-out-left {
    transform: translate(calc(-50% - 100vw - 20px), -50%) !important;
}

#rotated-comic.fullscreen-landscape.slide-out-right,
.rotated-comic-outgoing.fullscreen-landscape.slide-out-right {
    transform: translate(calc(-50% + 100vw + 20px), -50%) !important;
}

#rotated-comic.fullscreen-landscape.slide-in-left {
    transform: translate(calc(-50% + 100vw + 20px), -50%) !important;
}

#rotated-comic.fullscreen-landscape.slide-in-right {
    transform: translate(calc(-50% - 100vw - 20px), -50%) !important;
}

/* Outgoing rotated comic clone for filmstrip effect */
.rotated-comic-outgoing {
    pointer-events: none;
}

/* Blur morph for rotated comic */
.rotated-comic-morph-outgoing {
    pointer-events: none;
    transition: filter 0.6s ease-in-out, opacity 0.6s ease-in-out !important;
    filter: blur(0px);
    opacity: 1;
}

.rotated-comic-morph-outgoing.morph-out {
    filter: blur(15px);
    opacity: 0 !important;
}

#rotated-comic.fullscreen-landscape {
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
}

/* Rotate SVG icons in rotated toolbar */
.fullscreen-toolbar.rotated .toolbar-button:nth-child(1) .toolbar-svg,
.fullscreen-toolbar.rotated .toolbar-button:nth-child(2) .toolbar-svg,
.fullscreen-toolbar.rotated .toolbar-button:nth-child(5) .toolbar-svg {
    transform: rotate(90deg);
}

.fullscreen-toolbar.rotated .toolbar-button:nth-child(3) .toolbar-svg,
.fullscreen-toolbar.rotated .toolbar-button:nth-child(4) .toolbar-svg,
.fullscreen-toolbar.rotated .toolbar-button:nth-child(6) .toolbar-svg,
.fullscreen-toolbar.rotated .toolbar-button:nth-child(7) .toolbar-svg {
    transform: rotate(-90deg);
}

.fullscreen-toolbar:not(.rotated) .toolbar-svg {
    transform: none;
}

/* Landscape toolbar (device rotated to landscape) */
.fullscreen-toolbar.landscape-toolbar {
    flex-direction: row;
    padding: 10px 15px;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    top: auto;
    max-width: 90vw;
    gap: 8px;
}

.fullscreen-toolbar.landscape-toolbar .toolbar-button {
    margin: 0;
}

.fullscreen-toolbar.landscape-toolbar .toolbar-svg {
    transform: none;
}

/* Date picker styling */
.date-input-container {
    position: relative;
    margin: 5px;
    border-radius: 10px;
    background-image: linear-gradient(45deg, #eee239 0%, #F09819 51%, #eee239 100%);
    background-size: 200% auto;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-slow);
    overflow: hidden;
}

.date-input-container:hover {
    background-position: right center;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

.date-center-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

input[type="date"] {
    width: auto;
    height: 42px;
    margin: 0;
    padding: 0;
    font-size: 0.85rem;
    font-weight: 500;
    background: transparent;
    border: none;
    color: black;
    text-align: center;
    appearance: none;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

input[type="date"]::-webkit-datetime-edit {
    width: 100%;
    text-align: center;
}

@media (max-width: 768px) {
    input[type="date"] {
        opacity: 0;
    }
    
    .date-center-wrapper {
        position: relative;
    }
    
    .date-center-wrapper::before {
        content: attr(data-display-date);
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.85rem;
        font-weight: 500;
        pointer-events: none;
    }
}

.logo {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    padding: 0;
    margin: 0 auto;
}

.logo img {
    max-width: min(95%, 900px);
    margin: 25px auto 5px;
    display: block;
}

#comic-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 100px auto 0;
    padding: 20px 0;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

#comic-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    background: linear-gradient(#eee239, orange) no-repeat fixed;
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#settingsDIV {
    margin-top: 25px;
    padding: 0 8px;
}

.hidden-during-fullscreen {
    display: none !important;
}

#controls-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    padding: 0 8px;
    flex-wrap: wrap;
    gap: 10px;
}

#installBtn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    margin: 0;
    max-width: 150px;
    z-index: 1000;
    display: none;
}

#support-container {
    flex: 1;
}

.kofi-button-styled {
    position: relative;
    top: 2px;
    margin-left: 3px;
}

.vertical {
    max-height: 300px;
    width: auto;
    margin: 0 auto;
    cursor: pointer;
    transition: all 0.3s ease;
    display: block;
}

.thumbnail-container {
    position: relative;
    display: inline-block;
    margin: 0 auto;
}

.thumbnail-notice {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(238, 226, 57, 0.8);
    color: black;
    padding: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    border-radius: 0 0 10px 10px;
}

.fullscreen-vertical {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: auto !important;
    max-height: 95vh !important;
    max-width: 95vw !important;
    height: auto !important;
    object-fit: contain;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* ========================================
   DRAGGABLE TOOLBAR
   ======================================== */

.toolbar {
    position: fixed;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    width: min(95%, 900px);
    max-width: min(95%, 900px);
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.6) 0%, rgba(80, 80, 80, 0.4) 51%, rgba(0, 0, 0, 0.6) 100%);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3),
                0 2px 8px rgba(0, 0, 0, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    z-index: 100;
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    box-sizing: border-box;
}

.toolbar:active {
    cursor: grabbing;
}

.toolbar-button {
    background: var(--primary-gradient);
    background-size: 200% auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    width: 56px;
    height: 56px;
    min-width: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 16px rgba(240, 152, 25, 0.3),
                0 2px 4px rgba(0, 0, 0, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    will-change: transform, background-position;
    flex-shrink: 0;
}

.toolbar-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.6s ease;
    z-index: 0;
}

.toolbar-button:hover::before {
    left: 100%;
}

.toolbar-button:hover {
    transform: translateY(-3px) scale(1.05);
    background-position: right center;
    box-shadow: 0 8px 24px rgba(240, 152, 25, 0.4), 0 4px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.3);
}

.toolbar-button:active {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 4px 12px rgba(240, 152, 25, 0.3),
                0 2px 4px rgba(0, 0, 0, 0.2),
                inset 0 2px 4px rgba(0, 0, 0, 0.1);
    background-position: right center;
}

.toolbar-button:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    transform: translateY(-2px) scale(1.03);
}

.toolbar-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    background: linear-gradient(45deg, #999 0%, #666 51%, #999 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toolbar-button:disabled:hover {
    transform: none;
    background-position: left center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toolbar-button:disabled::before {
    display: none;
}

.toolbar-svg {
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
    color: #333;
    stroke: #333;
    fill: none;
    display: block;
}

.toolbar-svg path,
.toolbar-svg polyline,
.toolbar-svg line,
.toolbar-svg circle,
.toolbar-svg rect {
    stroke: #333;
    color: #333;
}

.toolbar-svg circle[fill="currentColor"],
.toolbar-svg rect[fill="currentColor"],
.toolbar-svg path[fill="currentColor"] {
    fill: #333;
}

/* Tooltip styling for toolbar buttons */
.toolbar-button[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.95);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    border-radius: 8px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10000;
    opacity: 0;
    animation: tooltipFadeIn 0.2s ease-out 0.5s forwards;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4),
                0 2px 6px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

@keyframes tooltipFadeIn {
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Hidden date picker for toolbar */
#DatePicker {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

/* ========================================
   MODERN SETTINGS PANEL
   ======================================== */
.settings-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3),
                0 10px 30px rgba(0, 0, 0, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.8);
    z-index: 10000;
    width: 320px;
    max-width: 90vw;
    display: none;
    flex-direction: column;
    border: 2px solid rgba(240, 152, 25, 0.3);
    overflow: hidden;
    transition: none;
}

.settings-panel.visible {
    display: flex;
}

.settings-panel.visible.animate {
    animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.settings-header {
    background: var(--toolbar-gradient);
    padding: 16px 20px;
    margin: -5px -5px 0 -5px;
    cursor: move;
    display: flex;
    justify-content: space-between;
    align-items: center;
    -webkit-user-select: none;
    user-select: none;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: var(--shadow-sm);
}

.settings-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #333;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

.settings-close {
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #333;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 300;
}

.settings-close:hover {
    background: rgba(0, 0, 0, 0.2);
    transform: rotate(90deg);
}

.settings-content {
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(240, 152, 25, 0.05);
    border-radius: 10px;
    transition: all var(--transition-fast);
}

.setting-item:hover {
    background: rgba(240, 152, 25, 0.1);
    transform: translateX(2px);
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    cursor: pointer;
    accent-color: #F09819;
    margin: 0;
    flex-shrink: 0;
    -webkit-appearance: checkbox;
    -moz-appearance: checkbox;
    appearance: auto;
    position: static;
}

/* Override legacy checkbox styling for settings panel */
.setting-item input[type="checkbox"]::before,
.setting-item input[type="checkbox"]::after {
    content: none !important;
    display: none !important;
}

.setting-item label {
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    color: #333;
    margin: 0;
    flex: 1;
    line-height: 20px;
    display: flex;
    align-items: center;
}

.setting-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(240, 152, 25, 0.3), transparent);
    margin: 12px 0;
}

.setting-item-select {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.setting-item-select .labels {
    font-size: 13px;
    color: #666;
    font-weight: 500;
    flex: none;
}

.source-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid rgba(240, 152, 25, 0.4);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    appearance: auto;
    -webkit-appearance: auto;
    accent-color: #F09819;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.source-select:focus {
    outline: none;
    border-color: #F09819;
    box-shadow: 0 0 0 3px rgba(240, 152, 25, 0.2);
}

.source-select:hover {
    border-color: #F09819;
}

.setting-backup {
    flex-direction: column;
    gap: 12px;
    padding: 16px 12px;
    background: rgba(240, 152, 25, 0.08);
}

.backup-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: var(--primary-gradient);
    background-size: 200% auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: #333;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.backup-button:hover {
    background-position: right center;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(240, 152, 25, 0.3);
}

.backup-button:active {
    transform: translateY(0);
}

.backup-button svg {
    width: 18px;
    height: 18px;
    stroke: #333;
}

.backup-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    background: #ccc;
    color: #888;
}

.hidden-file-input {
    display: none;
}

/* ========================================
   ICON BUTTONS CONTAINER
   ======================================== */
.settings-icons-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 16px;
    padding-right: 8px;
}

.icon-button {
    background: var(--primary-gradient);
    background-size: 200% auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.icon-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.6s ease;
}

.icon-button:hover::before {
    left: 100%;
}

.icon-button:hover {
    transform: translateY(-3px) scale(1.08);
    background-position: right center;
    box-shadow: 0 8px 20px rgba(240, 152, 25, 0.4), var(--shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.icon-button:active {
    transform: translateY(-1px) scale(1.03);
}

/* Disable sticky :active state on touch devices */
@media (hover: none) and (pointer: coarse) {
    .icon-button:active {
        transform: none;
    }
    
    /* Explicit touch active state that we control via JS */
    .icon-button.touch-active {
        transform: translateY(-1px) scale(1.03);
        transition: transform 0.1s ease;
    }
}

.icon-button:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.icon-button svg {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
    color: #333;
    stroke: #333;
}

.icon-button svg path,
.icon-button svg polyline,
.icon-button svg line,
.icon-button svg circle,
.icon-button svg rect {
    stroke: #333;
}

/* Mobile responsive */
@media (max-width: 768px) {
    #comic-container {
        margin-top: 80px;
    }
    
    .toolbar {
        width: min(95%, 900px);
        max-width: min(95%, 900px);
        padding: 12px 10px;
        gap: 6px;
        border-radius: 16px;
        left: 10px;
        transform: none;
    }
    
    .toolbar-button {
        width: 50px;
        height: 50px;
        min-width: 50px;
        border-radius: 14px;
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        outline: none;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .toolbar-button:active {
        transform: translateY(-1px) scale(1.02);
        background-position: right center;
        box-shadow: 0 4px 12px rgba(240, 152, 25, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2), inset 0 2px 4px rgba(0, 0, 0, 0.1);
        transition: transform 0.1s ease;
    }
    
    .toolbar-button:focus-visible {
        outline: none;
        transform: translateY(-3px) scale(1.05);
    }
    
    .toolbar-svg {
        width: 26px;
        height: 26px;
    }
    
    /* Touch device specific - reset hover on pure touch */
    @media (hover: none) and (pointer: coarse) {
        .toolbar-button:hover {
            transform: none;
            background-position: left center;
        }
        
        /* Disable sticky :active state */
        .toolbar-button:active {
            transform: none;
        }
        
        /* Explicit touch active state controlled via JS */
        .toolbar-button.touch-active {
            transform: translateY(-1px) scale(1.02);
            background-position: right center;
            box-shadow: 0 4px 12px rgba(240, 152, 25, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2), inset 0 2px 4px rgba(0, 0, 0, 0.1);
            transition: transform 0.1s ease;
        }
    }
    
    .settings-panel {
        width: 280px;
    }
    
    .settings-icons-container {
        gap: 12px;
    }
    
    .icon-button {
        width: 44px;
        height: 44px;
    }
    
    .icon-button svg {
        width: 22px;
        height: 22px;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    #comic-container {
        margin-top: 70px;
    }
    
    .toolbar {
        width: min(95%, 900px);
        max-width: min(95%, 900px);
        padding: 10px 8px;
        gap: 4px;
        left: 8px;
    }
    
    .toolbar-button {
        width: 46px;
        height: 46px;
        min-width: 46px;
        border-radius: 12px;
    }
    
    .toolbar-svg {
        width: 24px;
        height: 24px;
    }
    
    .settings-panel {
        width: 260px;
    }
    
    .icon-button {
        width: 40px;
        height: 40px;
    }
    
    .icon-button svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 380px) {
    .toolbar {
        gap: 3px;
        padding: 6px 8px;
    }
    
    .toolbar-button,
    .toolbar-datepicker-btn {
        width: 42px;
        height: 42px;
        min-width: 42px;
    }
    
    .toolbar-svg {
        width: 22px;
        height: 22px;
    }
}

/* In-app notification toast */
.notification-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.95) 0%, rgba(40, 40, 40, 0.95) 100%);
    color: #fff;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
                0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    z-index: 11000;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 90vw;
    width: auto;
    min-width: 280px;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.notification-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.notification-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    color: #F09819;
}

.notification-content {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
}

.notification-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.notification-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.notification-close svg {
    width: 20px;
    height: 20px;
}

@media (max-width: 768px) {
    .notification-toast {
        top: 60px;
        min-width: 240px;
        padding: 12px 16px;
    }
    
    .notification-content {
        font-size: 13px;
    }
}

/* Copyright Footer */
.copyright-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 4px 10px env(safe-area-inset-bottom, 0px);
    line-height: 1.6;
    font-size: 0.65rem;
    color: rgba(0, 0, 0, 0.5);
    background: rgba(238, 226, 57, 0.9);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 10;
}

.copyright-footer a {
    color: rgba(0, 0, 0, 0.6);
    text-decoration: none;
}

.copyright-footer a:hover {
    text-decoration: underline;
}