:root{
    --bg:#0f1113; /* very dark gray */
    --panel:#161718;
    --muted:#9aa0a6;
    --accent:#dfe3e6; /* near-white */
    --glass: rgba(255,255,255,0.04);
    --glass-2: rgba(255,255,255,0.02);
    --radius:14px;
    --mono-1:#e9ecef;
    --mono-2:#bfc6cc;
}
* {
    box-sizing: border-box;
}

@media (max-width: 768px) {
    /* 1. Stack header elements */
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px; /* Space between the logo/brand and the controls */
    }
    /* 2. Make the search bar and controls full width */
    .controls {
        width: 100%;
        flex-wrap: wrap; /* Allows buttons to wrap if necessary */
        gap: 8px; /* Reduce gap between buttons */
    }

    /* 3. Make the search input full width */
    .search {
        width: 100%; /* Makes the search container full width */
        min-width: unset; /* Remove the large min-width constraint */
    }

    /* 4. Make buttons stack/fill the width if possible */
    .btn {
        flex-grow: 1; /* Allows buttons to take up available space */
        min-width: 100px;
    }

    /* 5. Reduce overall body padding */
    body {
        padding: 15px;
    }
}
@media (max-width: 600px) {
    /* Force grid to a single column */
    .grid {
        grid-template-columns: 1fr; /* One fractional unit, meaning one full-width column */
    }

    /* Adjust Card size/layout for better use of space */
    .card {
        flex-direction: row; /* Change to horizontal layout on mobile */
        align-items: center;
        gap: 15px;
        padding: 15px;
    }

    /* Shrink the thumbnail */
    .thumb {
        height: 80px; /* Reduced height */
        width: 80px; /* Fixed width */
        flex-shrink: 0; /* Keep size fixed */
        border-radius: 8px;
    }

    .meta {
        padding: 0;
    }
}
@media (max-width: 450px) {
    /* Adjust Auth Card padding/margins */
    .auth-card, .upload-card {
        width: 90%;
        max-width: 400px;
        margin: 0; /* Less top/bottom margin, slight side margin */
        padding: 30px 20px;
    }
    
    /* Ensure the reader container doesn't have excess padding on small screens */
    .reader-container {
        padding: 5px;
    }

    .auth-container {
        padding: 20px;
    }
}

html {
    height: 100%;
    margin: 0;
    padding: 0;
}
body {
    font-family: "Montserrat", sans-serif;
    color: #e0e0e0; /* Light text */
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    height: 100%;
    overflow-x: hidden;
    background-image: url('https://t4.ftcdn.net/jpg/01/36/56/49/360_F_136564967_2F3S1E04Wb4durBhjwyDaLefdeo6udnn.jpg');
    background-color: rgb(33, 33, 33, .9); /* Dark background */
    background-blend-mode: multiply;
    backdrop-filter: blur(10px);
    background-repeat: repeat-y;
    background-size: cover;
}
/* body:has(.auth-container), body:has(.upload-container) {
    align-items: center;
} */

.container {
    width: 90%;
    max-width: 1100px;
    padding: 20px 10px;
}

/* Header Styles (similar to Image 1) */
.header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #333;
    margin-bottom: 20px;
}

.glowing-text {
  /* color: #fff; /* White text color */
  margin-left: 8px;
  text-shadow: 
    0 0 5px #fff,  /* Initial white glow */
    0 0 10px #fff, /* Stronger white glow */
    0 0 20px #00f, /* Blue glow */
    0 0 30px #00f, /* Stronger blue glow */
    0 0 40px #00f; /* Even stronger blue glow */
}

.logo {
    display: flex;  
    flex-direction: row;
    align-items: flex-start;
}

/* .aw {
    background-color: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-weight: bold;
    margin-right: 10px;
} */
/* .icon{
    width:56px;
    height:56px;
    border-radius:12px;
    background:linear-gradient(180deg,var(--mono-1),var(--mono-2));
    display:flex;
    align-items:center;
    justify-content:center;
    color:#0b0b0b;
    font-weight:700;
    font-size:20px;
    box-shadow:0 6px 24px rgba(0,0,0,0.6)
} */

.logo span {
    font-size: 24px;
    font-weight: bold;
    color: #fff;
}

.logo .tagline {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
}

.search-bar {
    display: flex;
    align-items: center;
}

body:has(.auth-container) and body:not(:has(.account)) .search-bar, body:has(.upload-container) .search-bar, body:has(.reader-container) .search-bar {
    display: none;
}

.search-input {
    background-color: #1f1f1f;
    border: none;
    padding: 12px 15px;
    border-radius: 5px;
    color: #fff;
    width: 250px;
    height: 100%;
    margin-right: 10px;
    transition: background-color 0.3s ease;
}

.search-button, .upload-button, .logout-button, .button {
    background-color: #171b1f; 
    color: white;
    border: none;
    
    padding: 10px 5px; /* 10px vertical, 5px horizontal */
    
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    margin-left: 10px;
    font-size: 12px;
    gap: 0px;
    display: flex;
    align-items: center;
    
    width: 70px; 
    
    /* Ensure icon stays centered in the small box */
    justify-content: center;
    line-height: 1;
    overflow: hidden;
    white-space: nowrap;
}

.search-button, .upload-button, .logout-button, body:not(:has(.reader-container)) .button {
    transition: width .6s ease, background-color 0.3s ease, padding 0.3s ease, gap 0.5s ease, transform .5s;
    width: 45px; 
}

.search-button span:last-child, 
.upload-button span:last-child, 
.logout-button span:last-child {
    /* Hide the text by default but keep it as part of the flow */
    font-size: 0%;
    transition: .3s ease;
    /* Optional: Add slight gap if needed, but Flexbox gap is better */
    
    margin-left: 0;
}

/* Hover State: Reveal Text and Expand Button */
.search-button:hover, 
.upload-button:hover, 
.logout-button:hover, 
body:not(:has(.reader-container)) .button:hover {
    background-color: #0056b3;
    
    /* EXPAND: Set a width large enough to show the icon + text (adjust this number) */
    width: 180px; 

    /* Optional: Restore padding for better look when expanded */
    padding: 10px 30px;
    align-items: center;
    text-align: center;
    gap: 5px;
}

/* Hover State: Reveal the Text Span */
.search-button:hover span:last-child, 
.upload-button:hover span:last-child, 
.logout-button:hover span:last-child {
    opacity: 1; /* Make the text visible */
    margin-left: 6px; /* Add a slight gap between the icon and text */
    font-size: 1em;
}

.login-button {
    background-color: #007bff; /* A distinct blue */
    color: white;
    border: none;
    cursor: pointer;
    text-decoration: none;
    font-size: 10px;
    width: 100%;
    margin-left: 0;
    margin-bottom: 10px;
    transition: background-color 0.3s ease;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.search-button:hover, .upload-button:hover, .logout-button:hover, .button:hover {
    background-color: #132a44;
}

.search-input:hover {
    background-color: #242424;
}

/* Results Section */
.results-section h2 {
    color: #fff;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.story-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.story-card-link {
    text-decoration: none;
    color: inherit;
}

/* Story Card (similar to Image 2) */
.story-card {
    background-color: #2b2b2b; /* Slightly lighter dark for cards */
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.story-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
}

.card-thumbnail {
    flex-shrink: 0;
    width: 100px; /* Fixed width for thumbnail */
    height: 120px; /* Fixed height */
    overflow: hidden;
    border-right: 1px solid #444;
}

.card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-details {
    padding: 15px;
    flex-grow: 1;
}

.card-title {
    font-size: 1.2em;
    font-weight: bold;
    margin-top: 0;
    margin-bottom: 5px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-chapter {
    font-size: 0.9em;
    color: #aaa;
    margin-bottom: 10px;
}

.card-meta {
    display: flex;
    gap: 5px;
    align-items: center;
    /* line-height: 0.5; */
    justify-content: space-between;
    font-size: .7em;
    color: #888;
    margin-top: 8px;
}

.card-time {
    display: flex;
    align-items: center; /* Vertically centers the icon and the text */
    gap: 8px; /* Space between the icon and the date/time text */
    /* Normalize line height for better appearance */
    line-height: 1; 
}

.card-time .material-symbols-rounded {
    font-size: 1.5em; /* Should be the same size as the parent font-size */
}

/* Authentication Forms (Login/Register) */
.auth-container, .upload-container {
    background-color: #2b2b2b;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 600px;
    margin: 40px auto;
    align-items: center;
}

.auth-container h2, .upload-container h2 {
    color: #fff;
    text-align: center;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
    text-align: center;
    width: 100%;
}

.form-group label {
    display: block;
    text-align: left;
    margin-bottom: 8px;
    color: #e0e0e0;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="file"],
.form-group textarea {
    background-color: var(--glass-2);
    border: 1px solid var(--glass);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
    width: 100%;
    padding: 10px;
    border-radius: 5px;
    color: var(--accent);
    box-sizing: border-box;
}

.auth-container button[type="submit"], .upload-container button[type="submit"] {
    width: 100%;
    padding: 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease, transform .5s, box-shadow .5s;
}

.auth-container button[type="submit"]:hover, .upload-container button[type="submit"]:hover {
    background-color: #0056b3;
    transform: translateY(-5px);
    box-shadow: 0 5px 10px rgba(0,0,0,.4);
}

.auth-container p, .upload-container p {
    text-align: center;
    margin-top: 20px;
    color: #aaa;
}

.auth-container a, .upload-container a {
    color: #007bff;
    text-decoration: none;
}

.auth-container a:hover, .upload-container a:hover {
    text-decoration: underline;
}

.error-message {
    color: #ff6347; /* Tomato red */
    text-align: center;
    margin-bottom: 15px;
}

.success-message {
    color: #32cd32; /* Lime green */
    text-align: center;
    margin-bottom: 15px;
}

/* Reader Styles */
.reader-container {
    /* 1. Use theme variables for visual consistency */
    background-color: var(--panel); 
    border-radius: var(--radius); 
    
    /* 2. Sizing: Use 100% width up to a readable max-width (e.g., 800px) */
    width: 100%; 
    max-width: 800px; /* Crucial for readability; adjust this number */
    
    /* 3. Centering and Spacing */
    margin: 5px auto; /* Centers the container on the page with vertical margin */
    padding: 30px; /* Increase padding for a cleaner look */
    min-height: calc(100vh - 80px); 
    max-height: calc(100vh - 40px);

    /* 4. Shadow for depth */
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4); 

    display: flex;
    flex-direction: column;

    /* 5. Ensure internal content fits the new padding */
    box-sizing: border-box; 
}

.reader-topbar, .reader-bottombar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #444;
    margin-bottom: 20px;
}

.reader-bottombar {
    border-top: 1px solid #444;
    border-bottom: none;
    margin-top: 20px;
    margin-bottom: 0;
}

.reader-title {
    font-size: 1.8em;
    font-weight: bold;
    color: #fff;
    flex-grow: 1;
    text-align: center;
}

.reader-author {
    font-size: 1em;
    color: #aaa;
    margin-left: 10px;
}

.story-content {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 10px; /* Space for scrollbar */
    line-height: 1.8;
    font-size: 1em;
    font-family: "Merriweather Sans", sans-serif;
    font-weight: 300;
}

.story-content pre {
    white-space: pre-wrap; /* Preserve whitespace and wrap text */
    word-wrap: break-word; /* Break long words */
    margin: 0;
    font-family: inherit; /* Use body font */
}

/* Account Page */
.account-page-layout {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 5px;
}

/* --- PROFILE HEADER: RED, GREEN, BLUE Blocks Container --- */
.profile-header-container {
    display: grid;
    /* Define the grid layout for desktop: 
        Col 1: Avatar (Red) | Col 2: Info (Green) | Col 3: Search (Blue) */
    grid-template-columns: 150px 1fr 1fr; 
    gap: 20px;
    margin-bottom: 25px;
    align-items: stretch; /* Stretch content to fill container height */
}

/* Mobile Layout */
@media (max-width: 768px) {
    .profile-header-container {
        /* Stack Red/Green vertically, and Blue takes full width */
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    .profile-avatar-block {
        /* Full width on mobile, stack avatar and info */
        display: flex;
        justify-content: center;
    }
}

/* --- 1. RED Block: Profile Picture --- */
.profile-avatar-block {
    background-color: #2b2b2b; /* RED Color */
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 4px 10px rgba(0,0,0,.4);
    /* Ensure the block maintains its height in the grid */
    display: flex;
    align-items: flex-start; /* Align image to top */
    justify-content: center;
}
.profile-avatar-block img {
    width: 120px;
    height: 120px;
    border-radius: 50%; /* Circular image */
    object-fit: cover;
    border: 4px solid #fff3; /* Light border */
}

/* --- 2. GREEN Block: Info & Logout --- */
.profile-info-block {
    background-color: #2b2b2b; /* GREEN Color */
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 4px 10px rgba(0,0,0,.4);
    display: flex;
    flex-direction: column; /* Stack info and logout button */
    justify-content: space-between; /* Push logout to the bottom */
    color: #bcbcbc;
    font-size: 0.95em;
}
.profile-info-block strong {
    color: #ffffff;
}

.logout-btn {
    /* Style for Logout button (at the very bottom of green block) */
    background: #222222;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color .3s, transform .5s, box-shadow .5s;
    width: 100%;
    margin-top: 8px; /* Spacing from info above */
}
.logout-btn:hover {
    background: #363636;
    transform: translateY(-5px);
    box-shadow: 0 5px 10px rgba(0,0,0,.4);
}

/* --- 3. BLUE Block: Search Bar --- */
.stories-search-block {
    background-color: #2b2b2b; /* BLUE Color */
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 4px 10px rgba(0,0,0,.4);
    /* Align content to bottom for aesthetics */
    display: flex;
    flex-direction: column;
    justify-content: flex-end; 
}
.search-form {
    display: flex;
    width: 100%;
}
.search-input-full {
    padding: 12px;
    width: 100%;
    border-radius: 6px;
    border: none;
    background-color: #222222; /* Darker blue input */
    color: white;
    font-size: 1em;
    outline: none;
}
.search-input-full::placeholder {
    color: #9aa0a6;
}


/* --- 4. PINK Block: Stories List --- */
.story-list-section {
    background-color: #2b2b2b; /* PINK/Purple Color */
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,.4);
}
.story-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 15px;
}
/* .story-card {
    background-color: #6a0572;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,.2);
    transition: transform 0.2s;
}
.story-card:hover {
    transform: translateY(-3px);
} */
/* .card-title {
    margin: 0 0 5px 0;
    font-size: 1.1em;
    color: white;
}
.card-meta {
    font-size: 0.8em;
    color: #f0c4f0;
}*/
.card-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
} 
.action-btn {
    padding: 8px 15px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.2s;
    font-size: 0.9em;
}
.read-btn {
    background-color: #222222;
    color: #ffffff;
}
.read-btn:hover {
    background-color: #363636;
}
.delete-btn {
    background-color: #ff6347; /* Tomato red */
    color: white;
}
.delete-btn:hover {
    background-color: #e55337;
}

/* Basic responsiveness */
@media (max-height: 920px) {
    body:has(.reader-container) {
        .header {
            display: none;
        }
    }
}
@media (max-width: 920px) {
    body:has(.reader-container) {
        overflow-y: hidden;
        padding: 0;
    }
    body:not(:has(.reader-container)) {
        padding: 20px;
    }
    body:not(:has(.story-grid)) .header {
        display: none;
        /* flex-direction: column;
        align-items: flex-start; */
    }
    .header {
        flex-direction: column;
    }
    .search-bar {
        width: 100%;
        margin-top: 15px;
        flex-wrap: wrap;
        align-items: center;
    }
    .search-input {
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }
    .search-button, .upload-button, .logout-button, .button {
        width: 100%;
        text-align: center;
        margin-left: 0;
        margin-bottom: 10px;
    }
    .auth-card, .upload-card {
        width: 90%;
        max-width: 800px;
        margin: 80px auto; /* Less top/bottom margin, slight side margin */
        padding: 30px 50px;
    }
    .reader-topbar, .reader-bottombar {
        flex-direction: column;
        gap: 10px;
    }
    .reader-title {
        text-align: left;
    }
    .container {
        padding: 0 0; /* Reduce global horizontal padding */
        width: 100%;
        max-width: 100%;
        max-height: 100%;
    }
    /* .container:has(.header) {
        padding: 20px 10px;
    } */
    .reader-container {
        /* Override max-width to allow it to span the viewport */
        width: 100vw;
        min-width: 100vw;
        max-width: 100vw;
        height: 100vh;
        min-height: 100vh;
        max-height: 100vh;
        /* Remove external margins to stick to the edges */
        margin: 0;
        /* Reduce internal padding for more space */
        padding: 20px 15px;
        /* Optional: Remove box-shadow and border-radius to look borderless */
        box-shadow: none; 
        border-radius: 0;
    }
}