/* ═══════════════════════════════════════════════
   gray.gift — Inside the Cloud
   ═══════════════════════════════════════════════ */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-deep: #1a1a1e;
    --bg-mid: #222226;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --bg-input: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.09);
    --border-hover: rgba(255, 255, 255, 0.18);
    --accent: #c8c8d0;
    --accent-hover: #e4e4ec;
    --accent-dim: rgba(200, 200, 208, 0.12);
    --text: #eaeaef;
    --text-90: rgba(234, 234, 239, 0.9);
    --text-80: rgba(234, 234, 239, 0.75);
    --text-60: rgba(234, 234, 239, 0.55);
    --text-50: rgba(234, 234, 239, 0.42);
    --text-30: rgba(234, 234, 239, 0.25);
    --success: #6dd895;
    --error: #e87272;
    --warning: #d4a24c;
    --info: #6b9fd8;
    --radius: 8px;
    --radius-lg: 12px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --max-width: 1200px;
    --transition: 0.2s ease;
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: linear-gradient(168deg, #1e1e22 0%, #1a1a1e 40%, #16161a 100%);
    background-attachment: fixed;
    color: var(--text-90);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; display: block; }

/* ── Container ── */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* ── Header ── */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(26, 26, 30, 0.92);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border-hover);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    gap: 16px;
}

.site-logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent) !important;
    letter-spacing: -0.02em;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.main-nav a {
    color: var(--text-80);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color var(--transition);
}
.main-nav a:hover { color: var(--accent); }

.nav-user {
    color: var(--accent) !important;
    font-weight: 600;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-80);
    font-size: 1.5rem;
    cursor: pointer;
}

/* ── Main ── */
main.container {
    padding-top: 32px;
    padding-bottom: 60px;
    min-height: calc(100vh - 120px);
}

/* ── Footer ── */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 20px 0;
}
.footer-inner { text-align: center; color: var(--text-30); font-size: 0.85rem; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-90);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateY(-1px);
    color: var(--text);
}

.btn.btn-primary,
a.btn-primary {
    background: linear-gradient(135deg, #e0e0e8, #c8c8d0);
    color: #1a1a1e !important;
    border-color: rgba(255, 255, 255, 0.25);
    font-weight: 700;
}
.btn.btn-primary:hover,
a.btn-primary:hover {
    background: linear-gradient(135deg, #f0f0f4, #dcdce4);
    border-color: rgba(255, 255, 255, 0.4);
    color: #1a1a1e !important;
}

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-block { display: flex; justify-content: center; width: 100%; }

.btn-danger { border-color: var(--error); color: var(--error); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.15); }

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all var(--transition);
}
.card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* ── Story Cards ── */
.story-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.story-card-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-bottom: 1px solid var(--border);
}

.story-card-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.story-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.story-card-author {
    font-size: 0.82rem;
    color: var(--text-50);
    margin-bottom: 8px;
}

.story-card-desc {
    font-size: 0.85rem;
    color: var(--text-60);
    flex: 1;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.story-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* ── Tags ── */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

.tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid rgba(200, 200, 208, 0.2);
}

/* ── Forms ── */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-80);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.9rem;
    font-family: var(--font);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-30);
    margin-top: 4px;
}

.form-error {
    font-size: 0.82rem;
    color: var(--error);
    margin-top: 4px;
}

/* ── Auth Forms ── */
.auth-container {
    max-width: 440px;
    margin: 60px auto;
}

.auth-container h1 {
    font-size: clamp(24px, 5vw, 36px);
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.auth-container .auth-subtitle {
    color: var(--text-50);
    margin-bottom: 32px;
    font-size: 0.95rem;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.88rem;
    color: var(--text-50);
}

/* ── Flash Messages ── */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    font-size: 0.9rem;
    border: 1px solid;
}
.flash-success { background: rgba(74, 222, 128, 0.1); border-color: var(--success); color: var(--success); }
.flash-error { background: rgba(248, 113, 113, 0.1); border-color: var(--error); color: var(--error); }
.flash-warning { background: rgba(245, 158, 11, 0.1); border-color: var(--warning); color: var(--warning); }
.flash-info { background: rgba(59, 130, 246, 0.1); border-color: var(--info); color: var(--info); }

/* ── Star Ratings ── */
.star-rating { display: inline-flex; align-items: center; gap: 1px; }
.star { font-size: 1rem; }
.star.filled { color: var(--accent); }
.star.half { color: var(--accent); opacity: 0.6; }
.star.empty { color: var(--text-30); }
.rating-count { font-size: 0.8rem; color: var(--text-50); margin-left: 4px; }

.star-input { display: inline-flex; gap: 2px; cursor: pointer; }
.star-input .star {
    font-size: 1.5rem;
    cursor: pointer;
    transition: color var(--transition), transform var(--transition);
}
.star-input .star:hover { transform: scale(1.2); }
.star-input .star.active { color: var(--accent); }

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 32px;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border);
    color: var(--text-60);
    transition: all var(--transition);
}
.page-link:hover { border-color: var(--accent); color: var(--accent); }
.page-link.active {
    background: var(--accent);
    color: #1a1a1e;
    border-color: var(--accent);
    font-weight: 700;
}

/* ── Hero ── */
.hero {
    text-align: center;
    padding: 60px 0 40px;
}

.hero h1 {
    font-size: clamp(28px, 6vw, 48px);
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
}

.hero p {
    font-size: clamp(16px, 2.5vw, 20px);
    color: var(--text-60);
    max-width: 600px;
    margin: 0 auto 28px;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ── Section Headers ── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.section-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text);
}

/* ── Status Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-draft { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.badge-published { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.badge-archived { background: rgba(255, 255, 255, 0.08); color: var(--text-50); }
.badge-rpg { background: var(--accent-dim); color: var(--accent); }

/* ── Tables ── */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
.data-table th {
    font-weight: 600;
    color: var(--text-60);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.data-table tr:hover td {
    background: var(--bg-card);
}

/* ── Reading View ── */
.reader-container {
    max-width: 720px;
    margin: 0 auto;
}

.segment-body {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-90);
    margin-bottom: 32px;
}

.segment-body p { margin-bottom: 16px; }
.segment-body strong { color: var(--text); }
.segment-body em { color: var(--text-80); }
.segment-body img {
    border-radius: var(--radius);
    margin: 20px 0;
    border: 1px solid var(--border);
}

.choices-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.choice-btn {
    display: block;
    width: 100%;
    padding: 14px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-90);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}
.choice-btn:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
    color: var(--text);
    transform: translateX(4px);
}
.choice-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.choice-requirement {
    display: block;
    font-size: 0.78rem;
    color: var(--text-50);
    margin-top: 4px;
}

/* ── RPG Sidebar ── */
.rpg-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
    font-size: 0.85rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-80);
}

.stat-name { font-weight: 600; color: var(--text-60); }
.stat-value { color: var(--accent); font-weight: 700; }

.inventory-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--accent-dim);
    border-radius: 20px;
    font-size: 0.78rem;
    color: var(--accent);
}

/* ── Ending Screen ── */
.ending-card {
    text-align: center;
    padding: 40px;
    margin-top: 20px;
}
.ending-card h2 {
    font-size: 1.5rem;
    color: var(--accent);
    margin-bottom: 12px;
}

/* ── Comments ── */
.comment {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: none; }
.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.comment-author { font-weight: 600; font-size: 0.88rem; color: var(--text); }
.comment-time { font-size: 0.78rem; color: var(--text-30); }
.comment-body { font-size: 0.9rem; color: var(--text-80); line-height: 1.5; }

/* ── Profile ── */
.profile-header {
    display: flex;
    gap: 24px;
    align-items: center;
    margin-bottom: 32px;
}
.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    object-fit: cover;
    background: var(--bg-card);
}
.profile-info h1 { font-size: 1.5rem; margin-bottom: 4px; }
.profile-info .profile-role {
    font-size: 0.82rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.profile-info .profile-bio {
    color: var(--text-60);
    font-size: 0.9rem;
    margin-top: 8px;
}

.profile-stats {
    display: flex;
    gap: 24px;
    margin-top: 12px;
}
.profile-stat {
    text-align: center;
}
.profile-stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
}
.profile-stat-label {
    font-size: 0.75rem;
    color: var(--text-50);
    text-transform: uppercase;
}

/* ── Leaderboard ── */
.leaderboard-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.leaderboard-rank {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-30);
    min-width: 32px;
    text-align: center;
}
.leaderboard-rank.top-3 { color: var(--accent); }

/* ── Achievement Badges ── */
.achievement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.achievement-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
}
.achievement-badge.locked { opacity: 0.3; }
.achievement-icon { font-size: 2rem; }
.achievement-name { font-weight: 600; font-size: 0.88rem; }
.achievement-desc { font-size: 0.78rem; color: var(--text-50); }

/* ── Editor ── */
.segment-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.segment-list-item:hover { background: var(--bg-card); }

.segment-list-title { font-weight: 600; font-size: 0.9rem; }
.segment-list-meta { font-size: 0.78rem; color: var(--text-50); }

.choice-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    padding: 8px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* ── Search & Filters ── */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}
.search-bar .form-control { flex: 1; }

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

/* ── Utility ── */
.text-center { text-align: center; }
.text-muted { color: var(--text-50); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .main-nav { display: none; }
    .main-nav.open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: rgba(26, 26, 30, 0.98);
        padding: 20px;
        gap: 12px;
        border-bottom: 1px solid var(--border);
    }
    .mobile-menu-toggle { display: block; }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
    }

    .profile-stats {
        justify-content: center;
    }

    .hero { padding: 40px 0 24px; }

    .choice-row {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 480px) {
    .hero-actions { flex-direction: column; align-items: center; }
    .search-bar { flex-direction: column; }
}
