:root {
    /* Dark Theme (Default) */
    --primary-color: #818cf8;
    --primary-hover: #6366f1;
    --text-main: #ffffff;
    --text-muted: #cbd5e1;
    /* Slightly lighter muted for better contrast */

    /* Adjusted for Visibility */
    --glass-bg: rgba(30, 41, 59, 0.25);
    /* Slightly more transparent */
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --glass-overlay: rgba(15, 23, 42, 0.1);
    /* Much clearer overlay (was 0.5) */

    --card-bg: rgba(33, 43, 60, 0.2);
    /* More transparent card */
    --card-border: rgba(255, 255, 255, 0.08);
    --card-hover-bg: rgba(40, 50, 70, 0.45);

    --input-bg: rgba(0, 0, 0, 0.4);
    /* Darker input for contrast against img */
    --modal-bg: rgba(30, 41, 59, 0.95);

    --action-btn-bg: rgba(15, 23, 42, 0.8);
    --action-btn-hover: var(--primary-color);
    --action-btn-content: var(--text-muted);

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Light Theme Variables */
body.light-theme {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --text-main: #0f172a;
    --text-muted: #475569;

    --glass-bg: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    --glass-overlay: rgba(255, 255, 255, 0.1);

    --card-bg: rgba(255, 255, 255, 0.2);
    --card-border: rgba(0, 0, 0, 0.05);
    --card-hover-bg: rgba(255, 255, 255, 0.45);

    --input-bg: rgba(0, 0, 0, 0.03);
    --modal-bg: rgba(255, 255, 255, 0.98);

    --action-btn-bg: rgba(255, 255, 255, 0.9);
    --action-btn-hover: var(--primary-color);
    --action-btn-content: #334155;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    color: var(--text-main);
    background-color: #0f172a;
    height: 100vh;
    overflow: hidden;
    letter-spacing: -0.01em;
}

.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -2;
    transform: scale(1.0);
    /* Removed zoom */
    transition: opacity 0.5s ease;
}

.glass-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--glass-overlay);
    backdrop-filter: blur(0);
    -webkit-backdrop-filter: blur(0);
    z-index: -1;
}

.app-container {
    display: flex;
    height: 100vh;
    padding: 24px;
    gap: 32px;
    max-width: 1800px;
    margin: 0 auto;
}

/* Sidebar */
.sidebar {
    width: 88px;
    padding: 32px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    z-index: 10;
    border-radius: 24px;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.logo i {
    font-size: 32px;
    color: var(--primary-color);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.nav-rail {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    width: 100%;
    align-items: center;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    width: 52px;
    height: 52px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow: hidden;
}

.top-header {
    height: 88px;
    border-radius: 20px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.welcome-section h1 {
    font-weight: 700;
    font-size: 24px;
    margin-bottom: 2px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    /* Text shadow for better readability on img */
}

.subtitle {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.glass-input-wrapper {
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0 16px;
    height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 260px;
    transition: all 0.2s;
}

.glass-input-wrapper:focus-within {
    border-color: var(--glass-border);
    background: rgba(0, 0, 0, 0.6);
}

.glass-input-wrapper i {
    color: var(--text-muted);
    font-size: 16px;
}

.glass-input-wrapper input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    width: 100%;
    font-family: var(--font-family);
    font-size: 14px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    height: 40px;
    padding: 0 20px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    font-family: var(--font-family);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.content-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
    padding-bottom: 40px;
}

.content-scroll-area::-webkit-scrollbar {
    width: 0;
}


/* --- HORIZONTAL CARD REFINEMENT --- */
.cards-grid {
    display: grid;
    /* Adaptive generic grid */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 4px;
}

.link-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    text-align: left;
    position: relative;
    text-decoration: none;
    color: var(--text-main);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.link-card:hover {
    transform: translateY(-4px);
    background: var(--card-hover-bg);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
    z-index: 5;
}

/* Icon Container */
.card-icon {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    /* Stronger border for visibility */
    transition: transform 0.3s ease;
}

.link-card:hover .card-icon {
    transform: scale(1.05);
}

.card-icon img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

/* Text Container */
.card-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    min-width: 0;
}

.card-title {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 2px;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: -0.01em;
    color: var(--text-main);
}

.card-url {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.8;
    /* Increased opacity */
}

/* Action Buttons */
.card-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transform: translateX(5px);
    transition: all 0.2s ease;
}

.link-card:hover .card-actions {
    opacity: 1;
    transform: translateX(0);
}

.action-btn {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: none;
    background: var(--action-btn-bg);
    color: var(--action-btn-content);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.action-btn:hover {
    background: var(--action-btn-hover);
    color: white;
}

.action-btn.delete:hover {
    background: #ef4444;
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    width: 480px;
    background: var(--modal-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 32px;
    transform: scale(0.95);
    transition: all 0.3s;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

.modal-backdrop.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}

.form-group {
    margin-bottom: 16px;
}

.preview-container {
    width: 100%;
    height: 160px;
    border-radius: 14px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    border: 2px dashed var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
}

#bg-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    /* Hidden by default until loaded */
}

.glass-input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text-main);
    font-family: var(--font-family);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.glass-input:focus {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary-color);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 8px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}

.preset-bgs {
    display: flex;
    gap: 12px;
}

.bg-preset {
    width: 60px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid var(--glass-border);
    background-size: cover;
    background-position: center;
    cursor: pointer;
    transition: all 0.2s;
}

.bg-preset:hover {
    border-color: var(--primary-color);
}

.sortable-ghost {
    opacity: 0.4;
    background: var(--primary-color);
}