:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --secondary: #a855f7;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3 {
    font-family: 'Outfit', sans-serif;
}

.container {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1rem;
    position: relative;
    z-index: 10;
}

/* Background Decoration */
.blob-wrap {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.background-decor {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
}

.blob-1 {
    width: 300px;
    height: 300px;
    background: var(--primary);
    top: -100px;
    right: -100px;
}

.blob-2 {
    width: 250px;
    height: 250px;
    background: var(--secondary);
    bottom: -50px;
    left: -50px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-dim);
    font-size: 1.1rem;
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 2rem;
    animation: fadeIn 1s ease-out;
}

.add-btn {
    flex-shrink: 0;
    padding: 0.9rem 1.4rem;
    background: var(--primary);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s ease;
    white-space: nowrap;
}

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

.sync-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-dim);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.sync-btn:hover {
    background: rgba(255,255,255,0.15);
    color: var(--text-main);
}

/* Search */
.search-container {
    position: relative;
    flex: 1;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
}

#searchInput {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem 1rem 1rem 3rem;
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

/* Link Grid */
.link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: 1.5rem;
    width: 100%;
}

.link-card {
    min-width: 0;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(12px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    animation: scaleIn 0.5s ease-out;
}

.link-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--glass-shadow);
    border-color: rgba(255, 255, 255, 0.2);
}

.card-top {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary-light);
}

.card-info h3 {
    font-size: 1.2rem;
    font-weight: 700;
}

.card-info .category {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-value {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.75rem;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 1.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
}

.copy-btn {
    flex: 1;
    padding: 0.75rem;
    background: var(--primary);
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.copy-btn:hover { background: var(--primary-light); }
.copy-btn:active { transform: scale(0.98); }

.edit-btn, .delete-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.edit-btn {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
}
.edit-btn:hover { background: rgba(99, 102, 241, 0.4); }

.delete-btn {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}
.delete-btn:hover { background: rgba(239, 68, 68, 0.3); }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.hidden { display: none; }

.modal-box {
    background: #1e293b;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    animation: scaleIn 0.2s ease-out;
}

.modal-box h2 {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
}

.form-group small {
    font-size: 0.78rem;
    opacity: 0.7;
}

.required {
    color: #f87171;
}

.form-group input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.btn-cancel, .btn-save {
    flex: 1;
    padding: 0.8rem;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-dim);
}
.btn-cancel:hover { background: rgba(255, 255, 255, 0.15); }

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

.btn-download {
    flex: 1;
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--primary-light);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-download:hover { background: rgba(99,102,241,0.15); }
.btn-download:disabled, .btn-save:disabled { opacity: 0.5; cursor: not-allowed; }

/* Icon Picker */
.icon-picker-preview {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.icon-preview-box {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    background: rgba(99,102,241,0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--primary-light);
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
    gap: 4px;
    max-height: 180px;
    overflow-y: auto;
    padding: 4px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
}

.icon-option {
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1.5px solid transparent;
    border-radius: 8px;
    color: var(--text-dim);
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

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

.icon-option.selected {
    background: rgba(99,102,241,0.25);
    border-color: var(--primary);
    color: var(--primary-light);
}

.sync-note {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 1.2rem;
    line-height: 1.5;
}

.sync-status {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    display: none;
}
.sync-status:not(:empty) { display: block; }
.sync-status.ok  { background: rgba(16,185,129,0.15); color: #10b981; }
.sync-status.err { background: rgba(239,68,68,0.15);  color: #f87171; }

/* Footer */
footer {
    margin-top: 4rem;
    text-align: center;
    padding: 2rem 0;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.footer-content p {
    color: var(--text-dim);
    font-size: 0.9rem;
}

.status-badge {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #10b981;
    color: white;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* Animations */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* Card top as link */
.card-top-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    border-radius: 10px;
    transition: opacity 0.2s;
}
.card-top-link:hover { opacity: 0.75; }

/* Mobile Adjustments */
@media (max-width: 600px) {
    h1 { font-size: 2rem; }

    .container { padding: 1.2rem 0.75rem; }

    .toolbar { gap: 0.5rem; }

    .add-btn {
        padding: 0.75rem 0.9rem;
        font-size: 0.85rem;
    }

    .sync-btn {
        width: 40px;
        height: 40px;
    }

    #searchInput {
        font-size: 0.9rem;
        padding: 0.8rem 0.8rem 0.8rem 2.6rem;
        min-width: 0;
    }

    .link-grid { grid-template-columns: 1fr; }

    .modal {
        align-items: flex-end;
        padding: 0;
    }

    .modal-box {
        padding: 1.4rem;
        max-height: 92vh;
        overflow-y: auto;
        border-radius: 20px 20px 0 0;
        width: 100%;
        max-width: 100%;
    }

    .modal-actions { flex-wrap: wrap; }
    .btn-cancel { flex: 1 1 100%; order: 1; }
    .btn-download { order: -1; }
    .btn-save { order: -1; }

    .icon-grid { max-height: 140px; }
}
