:root {
    --bg-main: #1A0F0A;
    --bg-surface: #261611;
    --bg-elevated: #362018;

    --primary: #E17055;
    --primary-hover: #D65A3D;

    --secondary: #FAB1A0;
    --accent: #00CEC9;

    --text-primary: #FFEAE3;
    --text-secondary: #BFA59C;
    --text-muted: #8A7269;

    --border: #4A2E25;
    --error: #FF7675;

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);

    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Utilities */
.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.spacer {
    flex: 1;
}

/* Layout */
.app-layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    flex-shrink: 0;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.brand-icon {
    font-size: 1.5rem;
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
}

.brand span {
    color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

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

.btn-outline:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
    background-color: var(--bg-elevated);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover,
.icon-btn.active {
    background-color: var(--bg-elevated);
    color: var(--text-primary);
}

/* Sidebar Sections */
.sidebar-section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-weight: 700;
}

.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-item:hover {
    background-color: var(--bg-elevated);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: rgba(225, 112, 85, 0.1);
    color: var(--primary);
}

/* Tags Cloud */
.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-pill {
    padding: 4px 10px;
    background-color: var(--bg-elevated);
    color: var(--text-secondary);
    border-radius: 100px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.tag-pill:hover,
.tag-pill.active {
    background-color: rgba(0, 206, 201, 0.1);
    color: var(--accent);
    border-color: var(--accent);
}

/* Main Workspace */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    gap: 24px;
}

.search-bar {
    position: relative;
    flex: 1;
    max-width: 500px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 16px 10px 40px;
    border-radius: 100px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: all 0.2s;
    outline: none;
}

.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(225, 112, 85, 0.1);
}

.view-toggles {
    display: flex;
    background-color: var(--bg-surface);
    border-radius: var(--radius-sm);
    padding: 4px;
    border: 1px solid var(--border);
}

/* Content Area */
.content-header {
    padding: 24px 32px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.count-badge {
    background-color: var(--bg-surface);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--border);
}

.bookmark-container {
    padding: 24px 32px;
    overflow-y: auto;
    flex: 1;
}

/* Grid View */
.bookmark-container.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    align-content: start;
}

/* Bookmark Card */
.bm-card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    cursor: grab;
    position: relative;
}

.bm-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

.bm-card:active {
    cursor: grabbing;
}

.bm-thumb {
    height: 140px;
    background-color: var(--bg-elevated);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Abstract placeholder for thumbnails when image fails/not present */
.bm-thumb-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-elevated) 0%, #2A1A14 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.05);
    font-weight: 800;
}

.bm-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

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

.card-btn {
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border: none;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.card-btn:hover {
    background: var(--primary);
}

.card-btn.btn-fav {
    color: #fff;
}

.card-btn.btn-fav.active {
    color: var(--accent);
}

.card-btn.btn-delete:hover {
    background: var(--error);
}

.bm-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.bm-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.bm-favicon {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-top: 3px;
    background: var(--bg-elevated);
}

.bm-info {
    flex: 1;
    min-width: 0;
}

.bm-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.bm-details {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bm-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    margin-top: 4px;
}

.bm-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
    padding-top: 12px;
}

.bm-tag {
    font-size: 0.7rem;
    color: var(--accent);
    background: rgba(0, 206, 201, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.bm-cat-tag {
    font-size: 0.7rem;
    color: var(--secondary);
    background: rgba(250, 177, 160, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

/* List View */
.bookmark-container.list-view {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.list-view .bm-card {
    flex-direction: row;
    height: 80px;
    align-items: center;
}

.list-view .bm-thumb {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
}

.list-view .bm-content {
    flex-direction: row;
    align-items: center;
    padding: 0 16px;
}

.list-view .bm-header {
    width: 30%;
    margin-right: 16px;
}

.list-view .bm-desc {
    -webkit-line-clamp: 1;
    line-clamp: 1;
    width: 40%;
    margin: 0 16px 0 0;
}

.list-view .bm-footer {
    margin: 0;
    padding: 0;
    flex: 1;
    justify-content: flex-end;
}

.list-view .bm-actions {
    position: relative;
    top: auto;
    right: auto;
    margin-left: 16px;
    opacity: 1;
    background: none;
}

.list-view .card-btn {
    background: var(--bg-elevated);
}

/* Modals */
.modal-backdrop {
    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: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-backdrop.show {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-backdrop.show .modal {
    transform: translateY(0);
}

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

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-group input,
.input-group textarea {
    background: var(--bg-main);
    border: 1px solid var(--border);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

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

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Highlight for search */
mark {
    background-color: rgba(225, 112, 85, 0.3);
    color: var(--text-primary);
    border-radius: 2px;
}

/* Dragging styling */
.bm-card.dragging {
    opacity: 0.5;
    border: 2px dashed var(--primary);
}