/* === SatisIsland - Discord Dark Theme === */

:root {
    --bg-primary: #313338;
    --bg-secondary: #2b2d31;
    --bg-tertiary: #1e1f22;
    --bg-accent: #404249;
    --bg-hover: #35373c;
    --bg-active: #404249;
    --text-primary: #f2f3f5;
    --text-secondary: #b5bac1;
    --text-muted: #949ba4;
    --text-link: #00a8fc;
    --brand-primary: #5865f2;
    --brand-hover: #4752c4;
    --danger: #da373c;
    --success: #23a55a;
    --warning: #f0b232;
    --divider: #3f4147;
    --scrollbar: #1a1b1e;
    --scrollbar-thumb: #555960;

    --sidebar-width: 240px;
    --header-height: 48px;
    --avatar-size: 40px;

    --font-primary: 'gg sans', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: var(--font-primary);
    font-size: 16px;
    color: var(--text-primary);
    background: var(--bg-primary);
    line-height: 1.375;
}

a {
    color: var(--text-link);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--scrollbar);
}
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

/* === App Container === */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 16px;
    display: flex;
    align-items: center;
    border-bottom: 2px solid var(--bg-tertiary);
    box-shadow: 0 1px 0 rgba(0,0,0,.2);
}

.server-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === Channel List === */
.channel-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.channel-category {
    padding: 16px 8px 0;
}

.category-name {
    display: block;
    padding: 0 8px;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-muted);
}

.channel-link {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    margin: 1px 8px;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 15px;
    text-decoration: none;
    transition: background 0.1s, color 0.1s;
}
.channel-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}
.channel-link.active {
    background: var(--bg-active);
    color: var(--text-primary);
    font-weight: 500;
}
.channel-link.locked {
    opacity: 0.5;
}

.channel-hash {
    margin-right: 6px;
    font-size: 18px;
    font-weight: 500;
    color: var(--text-muted);
}
.channel-link.active .channel-hash,
.channel-link:hover .channel-hash {
    color: var(--text-secondary);
}

.channel-lock {
    margin-left: auto;
    font-size: 12px;
}

/* === User Panel === */
.user-panel {
    padding: 8px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.user-avatar-default {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-accent);
    font-size: 16px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-actions {
    display: flex;
    gap: 4px;
}

.user-action-btn {
    padding: 4px;
    font-size: 16px;
    text-decoration: none;
    border-radius: 4px;
    opacity: 0.7;
    transition: opacity 0.1s;
}
.user-action-btn:hover {
    opacity: 1;
    text-decoration: none;
}

/* === Main Content === */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* === Header === */
.content-header {
    height: var(--header-height);
    padding: 0 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--bg-tertiary);
    background: var(--bg-primary);
    flex-shrink: 0;
}

.header-channel-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-actions {
    margin-left: auto;
}

.lang-switch {
    padding: 4px 12px;
    font-size: 14px;
    color: var(--text-secondary);
    border: 1px solid var(--divider);
    border-radius: 4px;
    text-decoration: none;
    transition: background 0.1s;
}
.lang-switch:hover {
    background: var(--bg-hover);
    text-decoration: none;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 12px 4px 0;
}

/* === Content Area === */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

/* === Messages === */
.messages-container {
    padding: 0 16px;
}

.message {
    display: flex;
    padding: 4px 0;
    margin-top: 16px;
    gap: 16px;
}
.message:first-child {
    margin-top: 0;
}

.message-avatar {
    width: var(--avatar-size);
    height: var(--avatar-size);
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    cursor: pointer;
}

.message-body {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.message-author {
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.message-timestamp {
    font-size: 12px;
    color: var(--text-muted);
}

.message-text {
    font-size: 15px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
}

/* === Attachments === */
.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.attachment-img {
    max-width: 400px;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.1s;
}
.attachment-img:hover {
    opacity: 0.9;
}

/* === Spoiler === */
.spoiler {
    position: relative;
    cursor: pointer;
}
.spoiler img,
.spoiler .series-thumbnail {
    filter: blur(44px);
    transition: filter 0.3s;
}
.spoiler.revealed img,
.spoiler.revealed .series-thumbnail {
    filter: none;
}

.spoiler-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.7);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    pointer-events: none;
    z-index: 2;
}
.spoiler.revealed .spoiler-overlay {
    display: none;
}

/* === Series Card (Gallery) === */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 0 16px;
}

.series-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    transition: background 0.1s;
    cursor: pointer;
}
.series-card:hover {
    background: var(--bg-hover);
}

.series-card-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.series-card-body {
    padding: 12px;
}

.series-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.series-card-meta {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
    align-items: center;
}

.series-type {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.type-normal { background: var(--success); color: #fff; }
.type-ex { background: var(--brand-primary); color: #fff; }
.type-sp { background: var(--warning); color: #000; }
.type-dx { background: var(--danger); color: #fff; }

.series-card-locked {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 32px;
}

/* === Series Detail === */
.series-detail {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 16px;
}

.series-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
}

.series-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-muted);
}

.series-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.thumbnail-wrapper {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 380px;
}

.series-thumbnail {
    width: 100%;
    border-radius: 8px;
}

.series-content {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.series-download {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.series-password {
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.password-value {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 3px;
    font-family: monospace;
    user-select: all;
}

/* === Series Notification in Timeline === */
.message-series-link {
    display: inline-block;
    margin-top: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    color: var(--text-link);
    font-weight: 600;
    transition: background 0.1s;
}
.message-series-link:hover {
    background: var(--bg-accent);
    text-decoration: none;
}

/* === Locked Notice === */
.locked-notice {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 16px;
    text-align: center;
    color: var(--text-muted);
}

.locked-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.locked-notice p {
    font-size: 16px;
    margin-bottom: 16px;
    max-width: 400px;
}

/* === Loading === */
.loading-spinner {
    display: flex;
    justify-content: center;
    padding: 32px;
}
.loading-spinner::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid var(--divider);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
    font-family: var(--font-primary);
}
.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--brand-primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--brand-hover);
}

.btn-secondary {
    background: var(--bg-accent);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-mega {
    background: #d9272e;
    color: #fff;
}
.btn-mega:hover {
    background: #b71c1c;
}

.btn-google {
    background: #4285f4;
    color: #fff;
    width: 100%;
    padding: 12px;
    font-size: 16px;
}
.btn-google:hover {
    background: #3367d6;
}

.btn-discord {
    background: #5865f2;
    color: #fff;
    width: 100%;
    padding: 12px;
    font-size: 16px;
}
.btn-discord:hover {
    background: #4752c4;
}

.btn-login {
    width: 100%;
    text-align: center;
    padding: 8px;
    background: var(--brand-primary);
    color: #fff;
    border-radius: 4px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 13px;
}

.btn-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* === Age Gate === */
/* === Splash === */
.splash-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-tertiary);
}

.splash-container {
    text-align: center;
    padding: 16px;
}

.splash-card {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 48px 40px;
    max-width: 480px;
    width: 100%;
}

.splash-logo {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.splash-subtitle {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.splash-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.splash-lang-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 32px;
    min-width: 160px;
    border-radius: 8px;
    background: var(--bg-accent);
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.15s, transform 0.15s;
}

.splash-lang-btn:hover {
    background: var(--brand-primary);
    text-decoration: none;
    transform: translateY(-2px);
}

.splash-lang-flag {
    font-size: 36px;
    line-height: 1;
}

.splash-lang-label {
    font-size: 18px;
    font-weight: 600;
}

/* === Age Gate / Login / Error === */
.age-gate-body, .login-body, .error-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-tertiary);
}

.age-gate-container, .login-container, .error-container {
    text-align: center;
    padding: 16px;
}

.age-gate-card, .login-card {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 32px;
    max-width: 440px;
    width: 100%;
}

.age-gate-logo, .login-logo {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.age-gate-description, .login-description {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.age-gate-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.age-gate-lang {
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-muted);
}

.login-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-skip {
    display: block;
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-muted);
}

/* === Error === */
.error-code {
    font-size: 72px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.error-message {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* === Settings === */
.settings-page {
    max-width: 700px;
    margin: 0 auto;
    padding: 16px;
}

.settings-section {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

.settings-heading {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--divider);
}
.settings-row:last-child {
    border-bottom: none;
}

.settings-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.settings-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.settings-form {
    margin-top: 12px;
}

.tier-badge {
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 700;
}
.tier-free { background: var(--bg-accent); color: var(--text-primary); }
.tier-basic { background: var(--brand-primary); color: #fff; }
.tier-premium { background: var(--warning); color: #000; }
.tier-ultimate { background: var(--danger); color: #fff; }

/* === Load More === */
.load-more-btn {
    display: block;
    width: calc(100% - 32px);
    margin: 16px auto;
    padding: 10px;
    text-align: center;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-family: var(--font-primary);
    transition: background 0.1s;
}
.load-more-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.no-more-messages {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 14px;
}

/* === Pagination === */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 16px;
}

.pagination a, .pagination span {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
    text-decoration: none;
}
.pagination a {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}
.pagination a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.pagination .current {
    background: var(--brand-primary);
    color: #fff;
}

/* === Image Lightbox === */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}
.lightbox.active {
    display: flex;
}
.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
}

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -var(--sidebar-width);
        top: 0;
        height: 100%;
        z-index: 100;
        transition: left 0.2s;
    }
    .sidebar.open {
        left: 0;
    }
    .mobile-menu-btn {
        display: block;
    }
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 99;
    }
    .mobile-overlay.active {
        display: block;
    }

    .attachment-img {
        max-width: 100%;
        max-height: 250px;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}
