:root {
    --bg: #0a0b10;
    --bg-soft: #14151e;
    --card-bg: #171922;
    --card-bg-hover: #1c1f2b;
    --border: #262939;
    --text: #f2f3f7;
    --text-muted: #8b90a3;
    --accent: #6366f1;
    --accent-2: #a855f7;
    --success-bg: #14532d33;
    --success-text: #4ade80;
    --error-bg: #7f1d1d33;
    --error-text: #f87171;
    --radius: 18px;
    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color-scheme: dark;
}

html[data-theme="light"] {
    --bg: #f6f7fb;
    --bg-soft: #ffffff;
    --card-bg: #ffffff;
    --card-bg-hover: #f2f3f8;
    --border: #e3e5ec;
    --text: #14151f;
    --text-muted: #666b7d;
    --accent: #6366f1;
    --accent-2: #a855f7;
    --success-bg: #dcfce7;
    --success-text: #15803d;
    --error-bg: #fee2e2;
    --error-text: #b91c1c;
    color-scheme: light;
}

html, body { transition: background-color 0.25s ease, color 0.25s ease; }

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

/* ===== Ambient background glow ===== */
.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.25;
    pointer-events: none;
    z-index: 0;
}
.bg-glow-1 {
    width: 500px; height: 500px;
    background: var(--accent);
    top: -150px; left: -100px;
}
.bg-glow-2 {
    width: 450px; height: 450px;
    background: var(--accent-2);
    bottom: -150px; right: -100px;
}

html[data-theme="light"] .bg-glow {
    opacity: 0.12;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 24px 80px;
    position: relative;
    z-index: 1;
}

/* ===== Site header (frontend navbar) ===== */
.site-header {
    position: relative;
    z-index: 2;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 11, 16, 0.6);
    backdrop-filter: blur(10px);
}
.site-header-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.site-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.05rem;
}
.btn.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 18px;
    font-size: 0.88rem;
    margin-top: 0;
}
.btn.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--card-bg);
}

/* ===== Theme toggle ===== */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
    transition: border-color 0.2s ease, transform 0.15s ease, background 0.2s ease;
}
.theme-toggle:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}
.theme-toggle:active { transform: translateY(0); }
.theme-toggle-floating {
    position: fixed;
    top: 20px;
    right: 20px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ===== Hero (frontend) ===== */
.hero {
    text-align: center;
    padding: 56px 24px 24px;
    position: relative;
    z-index: 1;
}
.hero-badge {
    display: inline-block;
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}
.hero h1 {
    font-size: 2.8rem;
    font-weight: 800;
    margin: 0 0 10px;
    letter-spacing: -0.03em;
}
.text-gradient {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero p {
    color: var(--text-muted);
    margin: 0 0 28px;
    font-size: 1.05rem;
}

.search-box {
    max-width: 380px;
    margin: 24px auto 0;
    position: relative;
}
.search-box .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    opacity: 0.6;
    font-size: 0.95rem;
    line-height: 1;
    pointer-events: none;
}
.search-box input[type="text"] {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 12px 18px 12px 46px !important;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.92rem;
}
.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.no-results {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
}

/* ===== Tiles grid ===== */
.tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 18px;
    margin-top: 8px;
}

.tile {
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    overflow: hidden;
    animation: tileIn 0.5s ease backwards;
    animation-delay: var(--delay, 0s);
}

@keyframes tileIn {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

.tile::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--tile-color, var(--accent)) 0%, transparent 65%);
    opacity: 0.1;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.tile:hover {
    transform: translateY(-5px);
    box-shadow: 0 16px 36px -12px var(--tile-color, var(--accent));
    border-color: var(--tile-color, var(--accent));
    background: var(--card-bg-hover);
}
.tile:hover::before { opacity: 0.18; }

.tile-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.tile-icon {
    font-size: 2rem;
    line-height: 1;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--tile-color, var(--accent)) 18%, transparent);
    border-radius: 14px;
}

.tile-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.tile-desc {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.tile-arrow {
    font-size: 1rem;
    color: var(--tile-color, var(--accent));
    opacity: 0.7;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.tile:hover .tile-arrow {
    transform: translate(2px, -2px);
    opacity: 1;
}

/* ===== Empty state ===== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { margin: 0 0 8px; font-size: 1.2rem; }
.empty-state p { margin: 0 0 20px; }

/* ===== Footer ===== */
.site-footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent); }

/* ===== Login page ===== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.login-icon { font-size: 2.6rem; margin-bottom: 8px; }
.login-card h1 { margin: 0 0 6px; font-size: 1.5rem; }
.muted { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 20px; }

.login-form { text-align: left; display: flex; flex-direction: column; gap: 6px; }
.login-form label { font-size: 0.85rem; color: var(--text-muted); margin-top: 8px; }

input[type=text], input[type=password], input[type=url], input[type=color] {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 14px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: var(--font);
    width: 100%;
}
input[type=color] { padding: 4px; height: 44px; cursor: pointer; }
input:focus { outline: none; border-color: var(--accent); }

.btn {
    display: inline-block;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    font-family: var(--font);
}
.btn-primary { background: var(--accent); color: #fff; margin-top: 18px; }
.btn-primary:hover { background: #5457e5; }
.btn-secondary { background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); }

.back-link {
    display: inline-block;
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.back-link:hover { color: var(--accent); }

.alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 16px;
}
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert-success { background: var(--success-bg); color: var(--success-text); }

/* ===== Admin topbar ===== */
.topbar {
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
}
.topbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.brand { font-weight: 700; font-size: 1.1rem; }
.topbar nav { display: flex; align-items: center; gap: 18px; font-size: 0.9rem; }
.topbar nav a:hover { color: var(--accent); }
.logout-link { color: var(--error-text); }

/* ===== Admin forms/cards ===== */
.form-card, .list-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 28px;
}
.form-card h2, .list-card h2 {
    margin: 0 0 20px;
    font-size: 1.15rem;
}

.form-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.form-group label { font-size: 0.85rem; color: var(--text-muted); }

.form-actions { display: flex; gap: 12px; margin-top: 4px; }

/* ===== Admin link list ===== */
.admin-links-list { display: flex; flex-direction: column; gap: 10px; }

.admin-link-row {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    padding: 12px 16px;
}

.admin-link-icon { font-size: 1.4rem; }

.admin-link-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}
.admin-link-info strong { font-size: 0.98rem; }
.admin-link-url {
    font-size: 0.8rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-link-desc { font-size: 0.8rem; color: var(--text-muted); }

.admin-link-actions {
    display: flex;
    gap: 10px;
    font-size: 1.05rem;
}
.admin-link-actions a { opacity: 0.85; }
.admin-link-actions a:hover { opacity: 1; }

@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.9rem; }
    .tiles-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}