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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a1a;
    color: #ffffff;
    overflow: hidden;
}

.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 10, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.auth-overlay.hidden {
    display: none;
}

.auth-card {
    background: #2d2d2d;
    border: 1px solid #404040;
    border-radius: 12px;
    padding: 2rem 2.5rem;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.auth-card h2 {
    color: #00d4ff;
    margin-bottom: 0.75rem;
}

.auth-card p {
    color: #d0d0d0;
    margin-bottom: 1.5rem;
}

.auth-card .disabled {
    opacity: 0.6;
    pointer-events: none;
}

.auth-error {
    color: #ff6b6b;
    margin-top: 1rem;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.header {
    background: #2d2d2d;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #404040;
    max-height: 120px;
    transition: max-height 1s ease, padding 1s ease, border-width 1s ease, opacity 1s ease;
}

.header h1 {
    font-size: 1.5rem;
    color: #00d4ff;
}

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

.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #444;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
}

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

.user-name {
    font-size: 0.9rem;
    color: #d0d0d0;
}

.user-actions {
    background: transparent;
    border: 1px solid #555;
    color: #d0d0d0;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
}

.user-actions:hover {
    background: #3a3a3a;
}

.status-indicator {
    font-size: 1.5rem;
}

.status-indicator.online {
    color: #00ff00;
}

.status-indicator.offline {
    color: #ff0000;
}

/* Main viewer */
.viewer-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000000;
    overflow: hidden;
    position: relative;
}

.comic-display {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
}

.comic-display img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.comic-display.fit-height img {
    height: 100%;
    width: auto;
    max-width: none;
}

.comic-display.fit-width img {
    width: 100%;
    height: auto;
    max-height: none;
}

.comic-display.fit-width {
    align-items: flex-start;
}

.welcome-screen {
    text-align: center;
    padding: 2rem;
    max-width: 600px;
}

.welcome-screen h2 {
    color: #00d4ff;
    margin-bottom: 1rem;
}

.instructions {
    margin-top: 2rem;
    background: #2d2d2d;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: left;
}

.instructions h3 {
    color: #00d4ff;
    margin-bottom: 1rem;
}

.instructions ul {
    list-style-position: inside;
}

.instructions li {
    margin-bottom: 0.5rem;
}

/* Controls */
.controls {
    background: #2d2d2d;
    padding: 1rem 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    border-top: 2px solid #404040;
    max-height: 120px;
    transition: max-height 1s ease, padding 1s ease, border-width 1s ease, opacity 1s ease;
}

#app.ui-hidden .header,
#app.ui-hidden .controls {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    opacity: 0;
    pointer-events: none;
}

.nav-btn {
    background: #00d4ff;
    color: #000;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.nav-btn:hover {
    background: #00a8cc;
}

.nav-btn:disabled {
    background: #555;
    cursor: not-allowed;
}

#page-counter {
    font-size: 1.1rem;
    min-width: 120px;
    text-align: center;
}

/* Debug panel */
.debug-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 300px;
    max-height: 200px;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid #00d4ff;
    padding: 1rem;
    font-family: monospace;
    font-size: 0.8rem;
    overflow-y: auto;
    display: none;
}

.debug-panel.visible {
    display: block;
}

#debug-output {
    white-space: pre-wrap;
    color: #00ff00;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 2rem;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Page Error State */
.page-error {
    text-align: center;
    padding: 2rem;
    color: #fff;
}

.page-error .error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.page-error h3 {
    color: #ff6b6b;
    margin-bottom: 0.5rem;
}

.page-error p {
    color: #aaa;
    margin-bottom: 1.5rem;
}

.page-error .retry-btn {
    background: #00d4ff;
    color: #000;
    border: none;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
    font-weight: bold;
}

.page-error .retry-btn:hover {
    background: #00a8cc;
}

/* Settings panel */
.settings-panel {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.settings-panel.visible {
    display: flex;
}

.settings-header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.settings-header h2 {
    color: #00d4ff;
    margin-bottom: 0.5rem;
}

.settings-header p {
    color: #ccc;
    font-size: 0.9rem;
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.settings-item {
    background: #2d2d2d;
    border: 1px solid #404040;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 320px;
    transition: border 0.2s, box-shadow 0.2s;
}

.settings-item.selected {
    border-color: #00d4ff;
    box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.25);
}

.settings-label {
    font-weight: 600;
}

.settings-value {
    color: #00d4ff;
    font-variant-numeric: tabular-nums;
}

.settings-footer {
    text-align: center;
}

.settings-close {
    background: #00d4ff;
    color: #000;
    border: none;
    padding: 0.6rem 1.5rem;
    font-size: 1rem;
    border-radius: 4px;
    cursor: pointer;
}

.settings-close:hover {
    background: #00a8cc;
}

.settings-card {
    background: #1f1f1f;
    border: 1px solid #404040;
    border-radius: 10px;
    padding: 1.5rem 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
