:root {
    --bg: #09090b;
    --bg-elevated: #18181b;
    --card: rgba(24, 24, 27, 0.6);
    --border: rgba(63, 63, 70, 0.5);
    --border-hover: rgba(99, 102, 241, 0.4);
    --fg: #fafafa;
    --fg-secondary: #a1a1aa;
    --muted: #71717a;
    --accent: #818cf8;
    --accent-glow: rgba(129, 140, 248, 0.15);
    --accent-bright: #a5b4fc;
    --error: #f43f5e;
    --error-bg: rgba(244, 63, 94, 0.1);
    --success: #22c55e;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --font: 'Inter', -apple-system, sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--fg);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== BACKGROUND ===== */
.bg-mesh {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background:
        radial-gradient(ellipse 80% 50% at 20% 10%, rgba(129, 140, 248, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 80%, rgba(99, 102, 241, 0.05) 0%, transparent 60%),
        radial-gradient(ellipse 50% 50% at 50% 50%, rgba(129, 140, 248, 0.02) 0%, transparent 80%);
}

.bg-grid {
    position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.03;
    background-image:
        linear-gradient(rgba(255,255,255,0.5) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.5) 1px, transparent 1px);
    background-size: 64px 64px;
}

/* ===== NAV ===== */
nav {
    position: sticky; top: 0; z-index: 100;
    background: rgba(9, 9, 11, 0.7);
    backdrop-filter: blur(20px) saturate(1.2);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    max-width: 1140px; margin: 0 auto;
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.875rem 1.5rem;
}

.logo { display: flex; align-items: center; gap: 0.875rem; }

.logo-img-wrap {
    width: 38px; height: 38px; border-radius: var(--radius-xs);
    overflow: hidden; border: 1px solid var(--border);
    flex-shrink: 0;
}
.logo-img-wrap img { width: 100%; height: 100%; object-fit: cover; }

.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-name { font-weight: 800; font-size: 1.1rem; letter-spacing: -0.02em; }
.logo-sub { font-size: 0.7rem; color: var(--muted); font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }

.nav-badge {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.75rem; font-weight: 600; color: var(--success);
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.15);
    padding: 0.4rem 0.85rem; border-radius: 100px;
}
.badge-dot {
    width: 6px; height: 6px; border-radius: 50%; background: var(--success);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
    animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ===== HERO ===== */
main {
    position: relative; z-index: 10;
    max-width: 1140px; margin: 0 auto; padding: 3rem 1.5rem 4rem;
}

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

.hero-badge {
    display: inline-flex; align-items: center; gap: 0.375rem;
    font-size: 0.8rem; font-weight: 600; color: var(--accent-bright);
    background: var(--accent-glow);
    border: 1px solid rgba(129, 140, 248, 0.2);
    padding: 0.4rem 1rem; border-radius: 100px;
    margin-bottom: 1.25rem;
}

.hero h1 {
    font-size: clamp(1.8rem, 4.5vw, 2.75rem);
    font-weight: 900; line-height: 1.15;
    letter-spacing: -0.03em; margin-bottom: 0.75rem;
}

.gradient-text {
    background: linear-gradient(135deg, #818cf8 0%, #c084fc 50%, #f472b6 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    color: var(--fg-secondary); font-size: 1.05rem;
    max-width: 520px; margin: 0 auto; line-height: 1.6;
}

/* ===== CARDS ===== */
.container-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;
}
@media (max-width: 800px) { .container-grid { grid-template-columns: 1fr; } }

.glass-card {
    background: var(--card);
    backdrop-filter: blur(16px) saturate(1.1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: border-color 0.3s ease;
}
.glass-card:hover { border-color: var(--border-hover); }

.card-header {
    display: flex; align-items: center; gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.card-header h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.card-desc { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }

.card-icon {
    width: 38px; height: 38px; border-radius: var(--radius-xs);
    background: var(--accent-glow);
    border: 1px solid rgba(129, 140, 248, 0.15);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.icon-preview { background: rgba(34, 197, 94, 0.1); border-color: rgba(34, 197, 94, 0.15); color: #4ade80; }
.icon-history { background: rgba(251, 191, 36, 0.1); border-color: rgba(251, 191, 36, 0.15); color: #fbbf24; }

/* ===== FORM ===== */
.form-body { display: flex; flex-direction: column; gap: 1.125rem; }

.field label {
    display: block; font-size: 0.8rem; font-weight: 600;
    color: var(--fg-secondary); margin-bottom: 0.4rem;
    letter-spacing: 0.01em;
}
.req { color: var(--error); }

.input-wrap {
    position: relative; display: flex; align-items: center;
}
.input-wrap svg {
    position: absolute; left: 0.875rem; color: var(--muted);
    pointer-events: none; flex-shrink: 0;
}
.input-wrap input {
    padding-left: 2.5rem;
}

input[type="text"], input[type="url"], textarea, .select-input {
    width: 100%; padding: 0.75rem 0.875rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--fg); font-family: var(--font); font-size: 0.9rem;
    transition: all 0.2s ease;
}
input:focus, textarea:focus, .select-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder, textarea::placeholder { color: var(--muted); }

textarea { resize: none; height: 72px; line-height: 1.5; }

/* Select */
.select-input {
    cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

/* Field Row */
.field-row { display: flex; gap: 0.875rem; }
.flex-1 { flex: 1; }

/* File Upload */
.file-upload-box {
    display: block; padding: 1.25rem;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-xs);
    text-align: center; cursor: pointer;
    transition: all 0.25s ease;
    position: relative; min-height: 130px;
}
.file-upload-box:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.upload-placeholder {
    display: flex; flex-direction: column;
    align-items: center; gap: 0.375rem;
    color: var(--muted); font-size: 0.85rem; font-weight: 500;
}
.upload-icon-wrap {
    width: 48px; height: 48px; border-radius: 12px;
    background: rgba(129, 140, 248, 0.08);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 0.25rem; color: var(--accent);
}
.upload-hint { font-size: 0.72rem; color: var(--muted); font-weight: 400; }

.image-preview-container {
    position: relative; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
}
.image-preview-container img {
    max-width: 100%; max-height: 180px;
    border-radius: var(--radius-xs); object-fit: contain;
}
.remove-img-btn {
    position: absolute; top: -8px; right: -8px;
    width: 22px; height: 22px;
    background: var(--error); color: white;
    border: 2px solid var(--bg-elevated);
    border-radius: 50%; cursor: pointer;
    font-size: 14px; font-weight: 700; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s ease;
}
.remove-img-btn:hover { transform: scale(1.15); }

/* Toggle */
.play-icon-option {
    display: flex; align-items: center; gap: 0.875rem;
    padding: 0.875rem; border-radius: var(--radius-xs);
    background: var(--bg); border: 1px solid var(--border);
}
.toggle-wrap { position: relative; flex-shrink: 0; }
.toggle-wrap input { display: none; }
.toggle-label {
    display: block; width: 40px; height: 22px;
    background: var(--border); border-radius: 100px;
    cursor: pointer; position: relative;
    transition: background 0.25s ease;
}
.toggle-label::after {
    content: ''; position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    background: white; border-radius: 50%;
    transition: transform 0.25s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle-wrap input:checked + .toggle-label {
    background: var(--accent);
}
.toggle-wrap input:checked + .toggle-label::after {
    transform: translateX(18px);
}
.toggle-text { display: flex; flex-direction: column; }
.toggle-text span { font-size: 0.85rem; font-weight: 600; }
.toggle-text small { font-size: 0.72rem; color: var(--muted); margin-top: 0.1rem; }

/* Primary Button */
.btn-primary {
    width: 100%; padding: 0.875rem;
    background: var(--accent);
    color: var(--bg); font-weight: 700; font-size: 0.95rem;
    border: none; border-radius: var(--radius-xs);
    cursor: pointer; font-family: var(--font);
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(129, 140, 248, 0.25);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(129, 140, 248, 0.35);
    background: var(--accent-bright);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
    opacity: 0.6; cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ===== PREVIEW ===== */
.social-preview {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden; background: var(--bg);
}

.preview-img-container {
    position: relative; width: 100%;
    padding-top: 56.25%;
    background: var(--bg-elevated); overflow: hidden;
}
.preview-img-container img {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover; display: none;
}
.img-placeholder {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--border);
}

/* Red Bar */
.red-bar-overlay {
    position: absolute; bottom: 0; left: 0;
    width: 100%; height: 5px;
    background: rgba(0, 0, 0, 0.4);
    display: none; z-index: 2;
}
.red-bar-overlay::after {
    content: ''; position: absolute; left: 0; top: 0;
    width: 35%; height: 100%; background: #FF0000;
}

/* Play Icon Overlay */
.preview-img-container.has-play-icon::before {
    content: ''; position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 48px; height: 48px;
    background: rgba(0,0,0,0.55);
    border-radius: 50%; z-index: 3;
    backdrop-filter: blur(4px);
}
.preview-img-container.has-play-icon::after {
    content: ''; position: absolute;
    top: 50%; left: 50%;
    transform: translate(-38%, -50%);
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
    border-left: 16px solid white;
    z-index: 4; margin-left: 3px;
}

.preview-content { padding: 0.875rem 1rem; }
.preview-domain {
    font-size: 0.7rem; color: var(--accent);
    text-transform: uppercase; letter-spacing: 0.06em;
    font-weight: 600; display: block; margin-bottom: 0.2rem;
}
.preview-content h3 {
    font-size: 1rem; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 0.15rem;
}
.preview-content p {
    font-size: 0.82rem; color: var(--muted);
    display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
    line-height: 1.45;
}

/* Result Box */
.result-box {
    margin-top: 1.25rem; padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}
.result-box label {
    font-size: 0.78rem; color: var(--muted);
    font-weight: 600; display: block; margin-bottom: 0.5rem;
}
.copy-group { display: flex; gap: 0.5rem; }
.copy-group input {
    flex: 1; background: var(--bg-elevated);
    font-family: var(--mono); font-size: 0.82rem;
    color: var(--accent-bright);
    padding: 0.7rem 0.875rem;
}
.btn-copy {
    padding: 0 1.1rem;
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid rgba(129, 140, 248, 0.2);
    border-radius: var(--radius-xs);
    cursor: pointer; font-family: var(--font);
    display: flex; align-items: center; gap: 0.4rem;
    font-weight: 600; font-size: 0.82rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.btn-copy:hover {
    background: rgba(129, 140, 248, 0.25);
    border-color: rgba(129, 140, 248, 0.4);
}

/* ===== HISTORY ===== */
.history-section { margin-top: 0; }

.history-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 1.25rem;
}

.history-grid { display: grid; gap: 0.75rem; }

.history-item {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 0.875rem 1rem;
    border-radius: var(--radius-xs);
    display: flex; flex-direction: column; gap: 0.35rem;
    transition: all 0.2s ease;
}
.history-item:hover { border-color: var(--border-hover); }

.history-url {
    font-family: var(--mono); color: var(--accent);
    font-size: 0.82rem; font-weight: 500;
    word-break: break-all; line-height: 1.5;
}
.history-meta { font-size: 0.78rem; color: var(--muted); }

.history-stats { margin: 0.25rem 0 0.125rem 0; font-size: 0.78rem; }
.views-badge {
    background: rgba(129, 140, 248, 0.1);
    color: var(--accent-bright);
    padding: 0.2rem 0.6rem; border-radius: 100px;
    font-weight: 600; font-size: 0.7rem;
    display: inline-flex; align-items: center; gap: 0.3rem;
    border: 1px solid rgba(129, 140, 248, 0.1);
}
.views-badge::before { content: '👁'; font-size: 0.75rem; }

.history-actions { display: flex; gap: 0.5rem; margin-top: 0.375rem; }
.btn-action {
    flex: 1; padding: 0.45rem;
    border: none; border-radius: 6px;
    cursor: pointer; font-weight: 600;
    font-size: 0.78rem; font-family: var(--font);
    transition: all 0.15s ease;
}
.btn-copy-small {
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid rgba(129, 140, 248, 0.15);
}
.btn-copy-small:hover { background: rgba(129, 140, 248, 0.2); }
.btn-delete {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(244, 63, 94, 0.15);
}
.btn-delete:hover { background: rgba(244, 63, 94, 0.18); }

.btn-refresh {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--muted); padding: 0.5rem;
    border-radius: var(--radius-xs); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.25s ease; flex-shrink: 0;
}
.btn-refresh:hover {
    color: var(--fg);
    border-color: var(--border-hover);
    background: var(--accent-glow);
}
.btn-refresh.loading svg { animation: spin 0.7s linear infinite; }

.empty-state {
    text-align: center; color: var(--muted);
    padding: 2.5rem 0; font-size: 0.9rem;
}

/* ===== TOAST ===== */
.toast {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    background: var(--bg-elevated);
    border: 1px solid rgba(129, 140, 248, 0.25);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-xs);
    display: flex; align-items: center; gap: 0.6rem;
    transform: translateX(calc(100% + 2rem));
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 9999; color: var(--accent-bright); font-weight: 600;
    font-size: 0.85rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    backdrop-filter: blur(12px);
}
.toast.show { transform: translateX(0); }

/* ===== AUTH ===== */
.auth-overlay {
    position: fixed; inset: 0;
    background: var(--bg);
    z-index: 99999;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
.auth-overlay.hidden {
    opacity: 0 !important; visibility: hidden !important;
    pointer-events: none !important;
}

.auth-card {
    position: relative;
    background: var(--bg-elevated);
    padding: 2.5rem 2rem;
    border-radius: var(--radius);
    width: 90%; max-width: 360px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: 0 25px 60px rgba(0,0,0,0.5);
    overflow: hidden;
}
.auth-glow {
    position: absolute; top: -80px; left: 50%;
    transform: translateX(-50%);
    width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(129, 140, 248, 0.15) 0%, transparent 70%);
    pointer-events: none;
}
.auth-logo {
    position: relative; z-index: 1;
    margin-bottom: 1rem;
}
.auth-logo img {
    width: 56px; height: 56px;
    border-radius: 14px; object-fit: cover;
    border: 2px solid var(--border);
}
.auth-card h2 {
    position: relative; z-index: 1;
    color: var(--fg); margin: 0 0 0.3rem 0;
    font-size: 1.4rem; font-weight: 800;
    letter-spacing: -0.02em;
}
.auth-card p {
    position: relative; z-index: 1;
    color: var(--muted); font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.auth-input-wrap {
    position: relative; display: flex;
    align-items: center; margin-bottom: 0.75rem;
}
.auth-input-wrap svg {
    position: absolute; left: 0.875rem;
    color: var(--muted); pointer-events: none;
}
.auth-input-wrap input {
    width: 100%; padding: 0.75rem 0.875rem 0.75rem 2.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--fg); font-family: var(--font);
    font-size: 0.9rem;
    transition: all 0.2s ease;
    box-sizing: border-box;
}
.auth-input-wrap input:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.auth-input-wrap input::placeholder { color: var(--muted); }

.btn-auth {
    position: relative; z-index: 1;
    width: 100%; padding: 0.8rem;
    background: var(--accent); color: var(--bg);
    border: none; border-radius: var(--radius-xs);
    font-weight: 700; font-size: 0.95rem;
    font-family: var(--font);
    cursor: pointer; display: flex;
    align-items: center; justify-content: center; gap: 0.5rem;
    transition: all 0.25s ease; margin-top: 0.25rem;
    box-shadow: 0 4px 15px rgba(129, 140, 248, 0.25);
}
.btn-auth:hover {
    background: var(--accent-bright);
    box-shadow: 0 8px 25px rgba(129, 140, 248, 0.35);
    transform: translateY(-1px);
}
.btn-auth:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

.auth-error {
    position: relative; z-index: 1;
    color: var(--error) !important;
    display: none; margin-top: 1rem !important;
    margin-bottom: 0 !important;
    font-size: 0.82rem !important; font-weight: 500 !important;
    background: var(--error-bg);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px solid rgba(244, 63, 94, 0.15);
}

.auth-success-anim {
    display: flex; justify-content: center;
    margin-bottom: 12px;
}
.auth-spinner-large {
    width: 40px; height: 40px;
    border: 3px solid rgba(129, 140, 248, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ===== UTILS ===== */
.hidden { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Selection */
::selection { background: rgba(129, 140, 248, 0.3); color: var(--fg); }