:root {
    --bg: #0B0C15;
    --bg-card: #151629;
    --bg-input: #1E2040;
    --orange: #FF6B35;
    --orange-hover: #FF8C5A;
    --text: #E4E4F0;
    --text-dim: #8888AA;
    --border: #2A2D4A;
    --green: #4CAF50;
    --red: #F44336;
    --at-color: #8B5CF6;
    --nt-color: #FF6B35;
    --radius: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===== HEADER ===== */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.4em;
    font-weight: 700;
    background: linear-gradient(135deg, var(--orange), #FFB347);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.user-area { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--text-dim); font-size: 0.9em; }
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.2s;
}
.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:hover { background: var(--orange-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg-input); }
.btn-sm { padding: 4px 10px; font-size: 0.8em; }

/* ===== AUTH MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 200;
    justify-content: center;
    align-items: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 90%; max-width: 420px;
}
.modal h2 { margin-bottom: 20px; font-size: 1.3em; }
.modal h2 span { color: var(--orange); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; color: var(--text-dim); font-size: 0.85em; }
.form-group input, .form-group textarea {
    width: 100%;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95em;
    resize: vertical;
}
.form-group textarea { min-height: 80px; font-family: inherit; }
.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--orange);
}
.modal-footer { margin-top: 20px; text-align: center; }
.modal-footer a { color: var(--orange); cursor: pointer; text-decoration: none; }
.modal-footer a:hover { text-decoration: underline; }
.error-msg { color: var(--red); font-size: 0.85em; margin-bottom: 12px; display: none; }

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    overflow-x: auto;
    position: sticky;
    top: 64px;
    z-index: 99;
}
.tab {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--orange); border-bottom-color: var(--orange); }

/* ===== SECTION HEADER ===== */
.section-header {
    padding: 20px 24px 12px;
    color: var(--text-dim);
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.section-header.at { color: var(--at-color); }
.section-header.nt { color: var(--nt-color); }

/* ===== BOOK CARDS GRID ===== */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 24px;
}
.book-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}
.book-card:hover {
    border-color: var(--orange);
    transform: translateY(-2px);
}
.book-card .book-abbrev {
    position: absolute;
    top: 12px; right: 16px;
    font-size: 2.5em;
    font-weight: 800;
    color: var(--border);
    opacity: 0.5;
}
.book-card h3 { font-size: 1.1em; margin-bottom: 4px; }
.book-card .book-section { color: var(--text-dim); font-size: 0.8em; margin-bottom: 8px; }
.book-card .book-meta { display: flex; gap: 16px; font-size: 0.8em; color: var(--text-dim); }
.book-card .book-meta span { display: flex; align-items: center; gap: 4px; }
.book-card .note-indicator {
    position: absolute;
    bottom: 12px; right: 16px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--border);
}
.book-card .note-indicator.has-notes { background: var(--orange); }

.book-card.at { border-left: 3px solid var(--at-color); }
.book-card.nt { border-left: 3px solid var(--nt-color); }

/* ===== BOOK DETAIL VIEW ===== */
.book-detail {
    display: none;
    max-width: 800px;
    margin: 24px auto;
    padding: 0 24px;
}
.book-detail.active { display: block; }

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    cursor: pointer;
    margin-bottom: 20px;
    font-size: 0.9em;
}
.back-btn:hover { color: var(--text); }

.book-info {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}
.book-info h2 { font-size: 1.8em; margin-bottom: 8px; }
.book-info .info-meta { 
    display: flex; flex-wrap: wrap; gap: 16px;
    color: var(--text-dim); font-size: 0.85em; margin-bottom: 16px;
}
.book-info .info-meta span { 
    background: var(--bg-input); padding: 4px 10px; border-radius: 6px; 
}
.book-summary {
    color: var(--text-dim);
    line-height: 1.8;
    font-size: 0.95em;
}

/* ===== NOTES FORM ===== */
.notes-section { margin-bottom: 24px; }
.notes-section h3 { margin-bottom: 16px; font-size: 1.1em; }
.notes-section h3 span { color: var(--orange); }

.note-field { margin-bottom: 16px; }
.note-field label { 
    display: block; margin-bottom: 6px; 
    color: var(--text-dim); font-size: 0.85em; font-weight: 600;
}
.note-field textarea {
    width: 100%; min-height: 100px;
    padding: 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9em;
    font-family: inherit;
    resize: vertical;
    line-height: 1.6;
}
.note-field textarea:focus {
    outline: none;
    border-color: var(--orange);
}

.save-status {
    font-size: 0.8em;
    color: var(--green);
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.3s;
}
.save-status.visible { opacity: 1; }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    header { padding: 12px 16px; }
    .books-grid { grid-template-columns: 1fr; padding: 16px; }
    .book-detail { padding: 0 16px; }
    .tabs { padding: 0 12px; gap: 0; }
    .tab { padding: 10px 14px; font-size: 0.85em; }
}
