:root {
    /* Bookmark Blue Palette */
    --primary: #3498DB;
    --primary-hover: #2E86C1;
    --secondary: #2980B9;
    --accent: #2ECC71;
    --bg-main: #0A0F1A;
    --bg-panel: rgba(18, 26, 43, 0.6);
    --bg-panel-hover: rgba(28, 40, 65, 0.8);
    --border-color: rgba(52, 152, 219, 0.2);
    --border-hover: rgba(52, 152, 219, 0.5);
    
    /* Text Colors */
    --text-main: #FDFEFE;
    --text-muted: #85929E;
    --text-inverse: #ffffff;
    
    /* Semantic */
    --error: #E74C3C;
    --error-bg: rgba(231, 76, 60, 0.1);
    --warning: #F1C40F;
    --success: #2ECC71;
    
    /* UI Constants */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-full: 9999px;
    --transition: 200ms ease;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    --glass-blur: blur(16px);
    --focus-ring: 0 0 0 3px rgba(52, 152, 219, 0.4);
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden; /* App layout handles internal scrolling */
}

/* Base Elements */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

a {
    color: var(--primary);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(52, 152, 219, 0.3); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Glassmorphism Classes */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
}

/* Layout */
.app-layout {
    display: flex;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
}

/* Sidebar */
.sidebar {
    width: 260px;
    display: flex;
    flex-direction: column;
    height: 100%;
    border-right: 1px solid var(--border-color);
    border-radius: 0;
    z-index: 10;
}

.sidebar-header {
    padding: 1.5rem;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.03em;
}

.sidebar-nav {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all var(--transition);
    text-align: left;
}

.nav-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--primary);
    background: rgba(52, 152, 219, 0.1);
    font-weight: 600;
}

.nav-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

.icon-btn {
    color: var(--text-muted);
    padding: 0.25rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    transition: all var(--transition);
}

.icon-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

.icon-btn.active {
    color: var(--primary);
}

.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0 0.5rem;
}

.tag-pill {
    background: rgba(52, 152, 219, 0.15);
    color: var(--primary);
    border: 1px solid rgba(52, 152, 219, 0.3);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.tag-pill:hover, .tag-pill.active {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    gap: 1rem;
    z-index: 5;
}

.search-bar {
    flex-grow: 1;
    max-width: 600px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-bar svg {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
}

.search-bar .shortcut-hint {
    position: absolute;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: monospace;
    pointer-events: none;
}

.search-bar input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    color: var(--text-main);
    font-size: 0.95rem;
    transition: all var(--transition);
}

.search-bar input:focus {
    background: rgba(0, 0, 0, 0.5);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
    outline: none;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.custom-select {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.6rem 2rem 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2385929E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1em;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    transition: all var(--transition);
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
    border: none;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
}

.btn-danger {
    background: rgba(231, 76, 60, 0.1);
    color: var(--error);
    border: 1px solid var(--error);
}
.btn-danger:hover {
    background: var(--error);
    color: #fff;
}

.content-body {
    padding: 2rem;
    overflow-y: auto;
    flex-grow: 1;
}

.views-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 2rem;
}

.views-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
}

.badge {
    background: rgba(52, 152, 219, 0.1);
    color: var(--primary);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

/* Bookmark Grid */
.bookmarks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    padding-bottom: 4rem;
}

.bookmark-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: all var(--transition);
    position: relative;
    text-decoration: none;
    color: inherit;
}

.bookmark-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border-color: var(--border-hover);
    text-decoration: none;
}

.card-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.favicon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: #fff;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.favicon img { width: 100%; height: 100%; object-fit: cover; }

.card-title-wrap {
    flex-grow: 1;
    min-width: 0;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.card-url {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    margin-top: 0.1rem;
}

.card-desc {
    font-size: 0.85rem;
    color: #b0bdc9;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.card-tags {
    display: flex;
    gap: 0.4rem;
    flex-wrap: nowrap;
    overflow: hidden;
}

.card-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0.3;
    transition: opacity 0.2s;
}

.bookmark-card:hover .card-actions {
    opacity: 1;
}

.card-btn {
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.card-btn:hover {
    color: var(--text-main);
    background: rgba(255,255,255,0.1);
}
.card-btn.favorited {
    color: var(--warning);
    opacity: 1;
}
.card-btn.reading {
    color: var(--accent);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.2s;
}
.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-main);
    width: 100%;
    max-width: 500px;
    max-height: 90vh; /* Prevent modal from exceeding viewport */
    overflow-y: auto; /* Enable scrolling if content is too long */
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.modal-overlay.hidden .modal-content {
    transform: translateY(20px);
}
.settings-modal {
    max-width: 650px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    font-size: 1.25rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}
.form-group.half { flex: 1; }

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}
.required { color: var(--error); }

.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea,
.form-group select {
    width: 100%;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    color: var(--text-main);
    font-family: inherit;
    transition: border 0.2s;
}

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

.input-with-action {
    display: flex;
    gap: 0.5rem;
}
.input-with-action input {
    flex-grow: 1;
}

/* Checkboxes */
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    user-select: none;
}
.mt-4 { margin-top: 1rem; }
.checkbox-label input { display: none; }
.custom-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    position: relative;
    transition: all 0.2s;
    flex-shrink: 0;
}
.checkbox-label input:checked + .custom-checkbox {
    background: var(--primary);
    border-color: var(--primary);
}
.checkbox-label input:checked + .custom-checkbox::after {
    content: '';
    position: absolute;
    left: 4px; top: 1px;
    width: 4px; height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

/* Tag Suggestions */
.tag-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}
.suggestion-pill {
    font-size: 0.75rem;
    color: var(--text-muted);
    border: 1px dashed var(--border-color);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.suggestion-pill:hover {
    color: var(--text-main);
    border-style: solid;
    border-color: var(--primary);
}

.form-feedback {
    font-size: 0.8rem;
    color: var(--error);
}
.form-feedback.hidden { display: none; }

/* Settings Modal Specifics */
.settings-body {
    padding-right: 0.5rem;
}
.settings-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.settings-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.settings-section h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}
.settings-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}
.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.action-card {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
}
.action-card p {
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-grow: 1;
    margin-bottom: 0.5rem;
}
.btn-group {
    display: flex;
    gap: 0.5rem;
}
.shortcuts-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.shortcuts-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}
kbd {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-family: monospace;
    font-size: 0.8rem;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-muted);
    gap: 1rem;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}
.toast {
    background: var(--bg-panel);
    border-left: 4px solid var(--primary);
    padding: 1rem;
    border-radius: 4px;
    box-shadow: var(--shadow);
    color: white;
    font-size: 0.9rem;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
}

.toast.error {
    border-left-color: var(--error);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

/* Responsive */
@media (max-width: 768px) {
    .app-layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
    .sidebar-nav { display: none; } /* Mobile sidebar hides nav by default or uses bottom nav in a real app */
    .action-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; gap: 0; }
    .top-bar { flex-direction: column; align-items: stretch; }
}
