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

:root {
    --ink: #1a1a2e;
    --warm: #c8956c;
    --warm-light: #d4a882;
    --warm-bg: rgba(200, 149, 108, 0.08);
    --cream: #faf6f1;
    --mist: #e8e2da;
    --slate: #6b6b7b;
    --white: #ffffff;
    --green: #4a9e6e;
    --green-bg: rgba(74, 158, 110, 0.08);
    --red: #c45c5c;
    --red-bg: rgba(196, 92, 92, 0.08);
}

body {
    font-family: 'DM Sans', sans-serif;
    color: var(--ink);
    background: var(--cream);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ===== AUTH SCREENS ===== */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    background: var(--white);
    border-radius: 20px;
    padding: 48px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 24px 80px rgba(26, 26, 46, 0.08);
}

.auth-card .logo {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 28px;
    text-align: center;
    margin-bottom: 8px;
}
.auth-card .logo span { color: var(--warm); }

.auth-card .subtitle {
    text-align: center;
    color: var(--slate);
    font-size: 15px;
    margin-bottom: 36px;
}

.auth-card h2 {
    font-family: 'Syne', sans-serif;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
    text-align: center;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--mist);
    border-radius: 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    color: var(--ink);
    background: var(--white);
    transition: border-color 0.2s;
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--warm);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.6;
}

.form-group .hint {
    font-size: 12px;
    color: var(--slate);
    margin-top: 4px;
    line-height: 1.5;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--ink);
    color: var(--white);
    width: 100%;
}
.btn-primary:hover { background: #2a2a4e; }

.btn-warm {
    background: var(--warm);
    color: var(--white);
}
.btn-warm:hover { background: var(--warm-light); }

.btn-outline {
    background: transparent;
    color: var(--ink);
    border: 1.5px solid var(--mist);
}
.btn-outline:hover { border-color: var(--warm); color: var(--warm); }

.btn-ghost {
    background: transparent;
    color: var(--slate);
    padding: 8px 16px;
}
.btn-ghost:hover { color: var(--ink); }

.btn-danger {
    background: var(--red-bg);
    color: var(--red);
}
.btn-danger:hover { background: var(--red); color: var(--white); }

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--slate);
}
.auth-switch a {
    color: var(--warm);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}
.auth-switch a:hover { text-decoration: underline; }

.error-msg {
    background: var(--red-bg);
    color: var(--red);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    text-align: center;
}

/* ===== APP LAYOUT ===== */
.app-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 48px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.app-nav .logo {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 22px;
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
}
.app-nav .logo span { color: var(--warm); }

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-user {
    font-size: 14px;
    color: var(--slate);
    margin-right: 8px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 48px 60px;
    width: 100%;
    flex: 1;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 36px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 32px;
    letter-spacing: -1px;
}

.page-header h1 em {
    font-style: normal;
    color: var(--warm);
}

/* ===== STATS BAR ===== */
.stats-bar {
    display: flex;
    gap: 20px;
    margin-bottom: 36px;
}

.stat-card {
    background: var(--white);
    border-radius: 14px;
    padding: 24px 28px;
    flex: 1;
    box-shadow: 0 2px 12px rgba(26, 26, 46, 0.04);
}

.stat-card .stat-num {
    font-family: 'Syne', sans-serif;
    font-size: 32px;
    font-weight: 800;
    color: var(--warm);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--slate);
    font-weight: 500;
}

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-chip {
    padding: 7px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    border: 1.5px solid var(--mist);
    background: var(--white);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--slate);
}
.filter-chip:hover { border-color: var(--warm); color: var(--warm); }
.filter-chip.active {
    background: var(--ink);
    color: var(--white);
    border-color: var(--ink);
}

/* ===== STORY CARDS ===== */
.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px;
}

.story-card {
    background: var(--white);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 4px 24px rgba(26, 26, 46, 0.04);
    cursor: pointer;
    transition: all 0.25s;
    position: relative;
    border: 1.5px solid transparent;
}
.story-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(26, 26, 46, 0.08);
    border-color: var(--mist);
}

.story-card .card-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--warm);
    font-weight: 600;
    margin-bottom: 12px;
}

.story-card h3 {
    font-family: 'Syne', sans-serif;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--ink);
    line-height: 1.3;
}

.story-card .card-excerpt {
    font-size: 14px;
    line-height: 1.65;
    color: var(--slate);
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.story-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.story-tags .tag {
    background: var(--cream);
    color: var(--ink);
    font-size: 11px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 20px;
}

.favorite-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.2s;
}
.favorite-btn:hover, .favorite-btn.active { opacity: 1; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 80px 24px;
    background: var(--white);
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(26, 26, 46, 0.04);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.empty-state h3 {
    font-family: 'Syne', sans-serif;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
}

.empty-state p {
    color: var(--slate);
    font-size: 16px;
    max-width: 440px;
    margin: 0 auto 28px;
    line-height: 1.6;
}

/* ===== PROJECT FORM (MODAL) ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 46, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
}

.modal {
    background: var(--white);
    border-radius: 20px;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 40px;
    box-shadow: 0 40px 120px rgba(26, 26, 46, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
}

.modal-header h2 {
    font-family: 'Syne', sans-serif;
    font-size: 24px;
    font-weight: 700;
}

.modal-header .close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--slate);
    padding: 4px;
    line-height: 1;
}
.modal-header .close-btn:hover { color: var(--ink); }

.modal .step-indicator {
    display: flex;
    gap: 8px;
    margin-bottom: 28px;
}

.modal .step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mist);
    transition: background 0.3s;
}
.modal .step-dot.active { background: var(--warm); }
.modal .step-dot.done { background: var(--green); }

.step-title {
    font-family: 'Syne', sans-serif;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
}

.step-desc {
    font-size: 14px;
    color: var(--slate);
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 28px;
    gap: 12px;
}

/* ===== STORY DETAIL VIEW ===== */
.story-detail {
    max-width: 760px;
    margin: 0 auto;
}

.story-detail .back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--slate);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 24px;
    cursor: pointer;
    transition: color 0.2s;
}
.story-detail .back-link:hover { color: var(--ink); }

.story-detail-card {
    background: var(--white);
    border-radius: 20px;
    padding: 48px;
    box-shadow: 0 8px 40px rgba(26, 26, 46, 0.06);
}

.story-detail-card .card-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--warm);
    font-weight: 600;
    margin-bottom: 12px;
}

.story-detail-card h2 {
    font-family: 'Syne', sans-serif;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 24px;
    line-height: 1.2;
}

.star-section {
    margin-bottom: 24px;
}

.star-section .star-label {
    font-family: 'Syne', sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--warm);
    margin-bottom: 8px;
}

.star-section p {
    font-size: 16px;
    line-height: 1.7;
    color: var(--ink);
}

.narrative-section {
    background: var(--cream);
    border-radius: 14px;
    padding: 28px;
    margin: 32px 0;
}

.narrative-section .narrative-label {
    font-family: 'Syne', sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--warm);
    margin-bottom: 12px;
}

.narrative-section p {
    font-size: 16px;
    line-height: 1.8;
    color: var(--ink);
    font-style: italic;
}

.detail-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--mist);
    flex-wrap: wrap;
}

/* ===== LOADING SPINNER ===== */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--mist);
    border-top-color: var(--warm);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(250, 246, 241, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    gap: 16px;
}

.loading-overlay .loading-text {
    font-family: 'Syne', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
}

.loading-overlay .loading-sub {
    font-size: 14px;
    color: var(--slate);
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 32px;
    right: 32px;
    background: var(--ink);
    color: var(--white);
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 12px 40px rgba(26, 26, 46, 0.2);
    z-index: 300;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .app-nav { padding: 16px 20px; }
    .main-content { padding: 0 20px 40px; }
    .stats-bar { flex-direction: column; gap: 12px; }
    .stories-grid { grid-template-columns: 1fr; }
    .story-detail-card { padding: 28px; }
    .modal { padding: 28px; }
    .page-header h1 { font-size: 24px; }
    .auth-card { padding: 32px; }
}
