:root {
    --primary: #a1c4fd;
    --primary-light: #c2e9fb;
    --secondary: #ffcfd2;
    --bg-main: #fefaf6;
    --card-bg: rgba(255, 255, 255, 0.8);
    --text-main: #5c4b51;
    --text-dim: #8d7d77;
    --glass-border: #fff;
    --glass-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

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

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

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

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
    position: relative;
    z-index: 10;
}

/* Background Decoration (Matching Portal) */
.background-decor {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 1;
    opacity: 0.5;
    pointer-events: none;
}

.blob-1 {
    width: 300px;
    height: 300px;
    background: #ffcfd2;
    top: -100px;
    right: -100px;
    animation: drift 20s infinite alternate;
}

.blob-2 {
    width: 250px;
    height: 250px;
    background: #faedcd;
    bottom: -50px;
    left: -50px;
    animation: drift 15s infinite alternate-reverse;
}

@keyframes drift {
    from { transform: translate(0, 0); }
    to { transform: translate(40px, 30px); }
}

/* Header & Nav */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.back-btn, .manage-btn {
    text-decoration: none;
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: none;
    cursor: pointer;
}

.manage-btn.active {
    background: var(--text-main);
    color: white;
}

.back-btn:hover, .manage-btn:hover {
    color: var(--text-main);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.05);
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.8rem;
    color: var(--text-main);
}

.gradient-text {
    background: linear-gradient(135deg, #a1c4fd, #c2e9fb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-dim);
    font-size: 1rem;
    font-weight: 500;
    background: white;
    display: inline-block;
    padding: 0.4rem 1.2rem;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
}

/* Search Area */
.search-area {
    display: flex;
    gap: 1rem;
    align-items: center;
    max-width: 600px;
    margin: 0 auto 2.5rem auto;
}

.search-container {
    position: relative;
    margin-bottom: 2.5rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

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

#searchInput {
    width: 100%;
    background: #fff;
    border: 2px solid #fff;
    border-radius: 20px;
    padding: 0.8rem 1rem 0.8rem 3rem;
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.04);
}

#searchInput:focus {
    outline: none;
    border-color: var(--secondary);
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.08);
}

.add-link-btn {
    background: var(--secondary);
    color: var(--text-main);
    border: none;
    border-radius: 20px;
    padding: 0.7rem 1.2rem;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    white-space: nowrap;
    animation: fadeIn 0.3s ease;
}

.hidden { display: none; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(92, 75, 81, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show { display: flex; }

.modal-content {
    background: #fff;
    padding: 2.5rem;
    border-radius: 32px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.12);
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-content h2 { margin-bottom: 1.5rem; font-size: 1.5rem; color: var(--text-main); }

.form-group { margin-bottom: 1.2rem; text-align: left; }
.form-group label { display: block; margin-bottom: 0.5rem; font-size: 0.85rem; font-weight: 700; color: var(--text-dim); }
.form-group input, .form-group select {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: 14px;
    border: 1px solid #eee;
    background: #fafafa;
    outline: none;
    font-family: inherit;
    transition: border-color 0.3s ease;
}
.form-group input:focus { border-color: var(--primary); }
.form-group small { display: block; margin-top: 0.4rem; color: var(--text-dim); font-size: 0.7rem; }

.modal-actions { display: flex; gap: 1rem; margin-top: 2rem; }
.btn-primary, .btn-secondary {
    flex: 1; padding: 0.9rem; border: none; border-radius: 16px; cursor: pointer; font-weight: 700; font-size: 0.9rem; transition: all 0.2s ease;
}
.btn-primary { background: var(--text-main); color: white; }
.btn-primary:hover { background: #3f3238; transform: translateY(-2px); }
.btn-secondary { background: #f5f5f5; color: var(--text-dim); }
.btn-secondary:hover { background: #eee; }

/* Edit Mode Actions */
.edit-actions { display: flex; gap: 0.5rem; margin-left: auto; }
.mini-btn {
    width: 34px; height: 34px; border-radius: 12px; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 0.85rem;
    transition: all 0.2s ease;
}
.mini-btn.edit { background: #f0f7ff; color: #4a90e2; }
.mini-btn.delete { background: #fee2e2; color: #ef4444; }
.mini-btn:hover { transform: scale(1.1); }

.link-card.edit-mode { 
    border: 2px dashed var(--secondary);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.01); }
    100% { transform: scale(1); }
}

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

.link-card {
    background: var(--card-bg);
    border: 2px solid #fff;
    border-radius: 24px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.04);
}

.link-card:hover {
    transform: translateY(-6px);
    border-color: var(--secondary);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
}

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

.card-icon {
    width: 44px;
    height: 44px;
    background: var(--bg-main);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--text-dim);
}

.link-card:nth-child(even) .card-icon { background: #fdf2f2; color: #ff9a9e; }
.link-card:nth-child(odd) .card-icon { background: #f0f7ff; color: #a1c4fd; }

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

.card-info .category {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-weight: 600;
    margin-bottom: 0.1rem;
}

.card-value {
    background: #fff;
    padding: 0.6rem;
    border-radius: 12px;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 1px solid #fdf2f2;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.updated-date {
    font-size: 0.75rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: #fff;
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    border: 1px solid #fdf2f2;
}

.copy-btn {
    width: 100%;
    padding: 0.8rem;
    background: var(--text-main);
    border: none;
    border-radius: 14px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.copy-btn.mini {
    width: auto;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 10px;
}

.copy-btn:hover {
    background: #3f3238;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* Footer */
footer {
    padding: 3rem 0;
    text-align: center;
}

.status-badge {
    background: #ecfdf5;
    color: #059669;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-main);
    color: white;
    padding: 0.8rem 1.8rem;
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    transition: all 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    z-index: 1000;
}

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

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