/* ============ TOKENS ============ */
:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-2: #f3f4f6;
    --surface-3: #edeef1;
    --text: #111827;
    --text-muted: #6b7280;
    --text-faint: #9aa1ac;
    --border: rgba(17, 24, 39, 0.09);
    --border-strong: rgba(17, 24, 39, 0.16);
    --accent: #0e9f6e;
    --accent-strong: #057a55;
    --accent-soft: rgba(14, 159, 110, 0.1);
    --accent-text: #057a55;
    --info: #3b82f6;
    --info-soft: rgba(59, 130, 246, 0.1);
    --warn: #b45309;
    --warn-soft: rgba(217, 119, 6, 0.12);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.1);
    --pin: #c2410c;
    --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04);
    --shadow-md: 0 4px 12px rgba(17, 24, 39, 0.06),
        0 1px 2px rgba(17, 24, 39, 0.04);
    --shadow-lg: 0 16px 40px rgba(17, 24, 39, 0.1),
        0 2px 8px rgba(17, 24, 39, 0.05);
    --shadow-xl: 0 24px 60px rgba(17, 24, 39, 0.16),
        0 4px 12px rgba(17, 24, 39, 0.06);
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --sp1: 4px;
    --sp2: 8px;
    --sp3: 12px;
    --sp4: 16px;
    --sp5: 20px;
    --sp6: 24px;
    --sp7: 32px;
    --sp8: 40px;
    --sp9: 56px;
    --font-display: "Fraunces", ui-serif, Georgia, serif;
    --font-ui: "Inter", ui-sans-serif, -apple-system, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, monospace;
    color-scheme: light;
    --brain-blue: #2563EB;
    --brain-cyan: #06B6D4;
    --brain-green: #22C55E;
    --brain-purple: #8B5CF6;
    --loader-color: #475569;
    --loader-background: rgba(255, 255, 255, 0.15);
}

html.dark {
    --bg: #0f1117;
    --surface: #161b22;
    --surface-2: #1b212b;
    --surface-3: #212934;
    --text: #f3f4f6;
    --text-muted: #9ca3af;
    --text-faint: #6b7280;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --accent: #34d399;
    --accent-strong: #10b981;
    --accent-soft: rgba(52, 211, 153, 0.14);
    --accent-text: #6ee7b7;
    --info: #60a5fa;
    --info-soft: rgba(96, 165, 250, 0.14);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.14);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.14);
    --pin: #fb923c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.45);
    --shadow-xl: 0 28px 70px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
    --brain-blue: #60A5FA;
    --brain-cyan: #67E8F9;
    --brain-green: #4ADE80;
    --brain-purple: #C084FC;
    --loader-color: #E5E7EB;
    --loader-background: rgba(17, 24, 39, 0.15);
}
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    font-size: 14px;
    transition: background 0.25s ease, color 0.25s ease;
}
a {
    color: inherit;
    text-decoration: none;
}
button {
    font-family: inherit;
    cursor: pointer;
}
::selection {
    background: var(--accent-soft);
    color: var(--accent-text);
}
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 8px;
    border: 3px solid var(--bg);
}

h1,
h2,
h3 {
    font-family: var(--font-display);
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--text);
}
.mono {
    font-family: var(--font-mono);
}
.muted {
    color: var(--text-muted);
}
.faint {
    color: var(--text-faint);
}

.theme-toggle {
    display: flex;
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px;
    gap: 1px;
}
.theme-toggle button {
    width: 26px;
    height: 26px;
    border-radius: 18px;
    border: none;
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-faint);
}
.theme-toggle button.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}
.theme-toggle svg {
    width: 14px;
    height: 14px;
}


/* ============ BUTTONS ============ */
.btn {
    height: 34px;
    padding: 0 14px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn svg {
    width: 14px;
    height: 14px;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
    background: var(--accent-strong);
}
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover {
    background: var(--surface-2);
}
.btn-ghost {
    background: none;
    color: var(--text-muted);
}
.btn-ghost:hover {
    background: var(--surface-2);
    color: var(--text);
}
.btn-danger {
    background: none;
    color: var(--danger);
    border-color: var(--border);
}
.btn-danger:hover {
    background: var(--danger-soft);
}
.btn-sm {
    height: 29px;
    padding: 0 10px;
    font-size: 12.5px;
    border-radius: 7px;
}
.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.checkbox {
    width: 16px;
    border: 1.5px solid var(--border-strong);
    height: 16px;
    cursor: pointer;
    display: inline-flex;
    background: var(--surface);
    flex-shrink: 0;
    align-items: center;
    border-radius: 5px;
    justify-content: center;
}

.checkbox.checked {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox svg {
    color: #fff;
    width: 10px;
    height: 10px;
    display: none;
}

.checkbox.checked svg {
    display: block;
}


/* ============ FORMS ============ */
.field {
    margin-bottom: var(--sp4);
}
.field-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}
.field-hint {
    font-size: 11.5px;
    color: var(--text-faint);
    font-weight: 400;
}
.input,
.textarea,
.select {
    width: 100%;
    padding: 0 12px;
    height: 36px;
    border-radius: 9px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: all 0.15s;
}
.input:focus,
.textarea:focus,
.select:focus {
    box-shadow: 0 0 1px 0 var(--accent-soft);
    border-color: var(--accent);
}
.textarea {
    height: auto;
    padding: 10px 12px;
    resize: vertical;
    min-height: 80px;
}
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239CA3AF' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 30px;
}
.input-mono {
    font-family: var(--font-mono);
    font-size: 12.5px;
}
.input-group {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    overflow: hidden;
    height: 36px;
}
.input-group-prefix {
    padding: 0 10px;
    background: var(--surface-2);
    color: var(--text-faint);
    font-size: 12.5px;
    height: 100%;
    display: flex;
    align-items: center;
    border-right: 1px solid var(--border-strong);
}
.input-group input {
    border: none;
    height: 100%;
    flex: 1;
    padding: 0 10px;
    background: none;
    outline: none;
    color: var(--text);
    font-size: 13px;
}

.radio,
.check {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1.5px solid var(--border-strong);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.radio.on {
    border-color: var(--accent);
}
.radio.on::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}
.check {
    border-radius: 5px;
}
.check.on {
    background: var(--accent);
    border-color: var(--accent);
}
.option-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 0;
}
.option-row label {
    font-size: 13px;
}
.option-desc {
    font-size: 11.5px;
    color: var(--text-faint);
    margin-top: 1px;
}

.toggle {
    width: 36px;
    height: 21px;
    border-radius: 20px;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    position: relative;
    flex-shrink: 0;
}
.toggle.on {
    background: var(--accent);
    border-color: var(--accent);
}
.toggle::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #fff;
    transition: all 0.15s;
    box-shadow: var(--shadow-sm);
}
.toggle.on::after {
    left: 17px;
}

/* ============ AUTH / LOGIN ============ */
.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
}
.auth-shell a:hover {
    color: var(--accent);
}
.auth-brand {
    position: relative;
    background: linear-gradient(155deg, #0b4530, #0e9f6e 55%, #34d399);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: var(--sp8);
}
html.dark .auth-brand {
    background: linear-gradient(155deg, #052018, #057a55 55%, #10b981);
}
.auth-brand::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.5;
    background-image: radial-gradient(
            circle at 15% 20%,
            rgba(255, 255, 255, 0.18),
            transparent 40%
        ),
        radial-gradient(
            circle at 85% 75%,
            rgba(255, 255, 255, 0.14),
            transparent 45%
        );
}
.auth-brand-top {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 9px;
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 600;
    color: #fff;
}
.auth-brand-logo {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
}
.auth-brand-mid {
    position: relative;
    z-index: 1;
    max-width: 420px;
}
.auth-brand-mid h1 {
    color: #fff;
    font-size: 34px;
    line-height: 1.18;
    font-weight: 500;
}
.auth-brand-mid p {
    color: rgba(255, 255, 255, 0.82);
    font-size: 14.5px;
    margin-top: 14px;
    line-height: 1.6;
}
.auth-quote {
    position: relative;
    z-index: 1;
    border-top: 1px solid rgba(255, 255, 255, 0.22);
    padding-top: 20px;
    max-width: 420px;
}
.auth-quote p {
    color: rgba(255, 255, 255, 0.92);
    font-size: 14px;
    font-style: italic;
    line-height: 1.6;
    font-family: var(--font-display);
}
.auth-quote .who {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
}
.auth-quote .who-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
}
.auth-quote .who-name {
    font-size: 12.5px;
    font-weight: 600;
    color: #fff;
}
.auth-quote .who-role {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.72);
}

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp6);
    position: relative;
}
.auth-panel-toggle {
    position: absolute;
    top: var(--sp6);
    right: var(--sp6);
}
.auth-box {
    width: 100%;
    max-width: 360px;
}
.auth-box-logo {
    gap: 9px;
    display: none;
    align-items: center;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: var(--sp7);
}
.auth-head {
    text-align: center;
    margin-bottom: var(--sp7);
}
.auth-head h1 {
    font-size: 25px;
    margin-bottom: 6px;
}
.auth-head p {
    color: var(--text-muted);
    font-size: 13.5px;
}
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: var(--sp5) 0;
    color: var(--text-faint);
    font-size: 11.5px;
}
.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}
.oauth-btn {
    width: 100%;
    height: 38px;
    border-radius: 9px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 9px;
    transition: all 0.15s;
}
.oauth-btn:hover {
    background: var(--surface-2);
}
.oauth-btn svg {
    width: 16px;
    height: 16px;
}
.field-pw-wrap {
    position: relative;
}
.field-pw-wrap .input {
    padding-right: 38px;
}
.pw-eye {
    top: 50%;
    right: 10px;
    color: var(--text-faint);
    border: none;
    display: flex;
    position: absolute !important;
    transform: translateY(-50%);
    background: transparent;
}
.pw-eye svg {
    width: 16px;
    height: 16px;
}
.auth-row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 2px 0 var(--sp5);
}
.auth-check-label {
    gap: 8px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    font-size: 12.5px;
    align-items: center;
}
.auth-foot {
    color: var(--text-muted);
    display: flex;
    font-size: 13px;
    text-align: center;
    margin-top: var(--sp7);
    flex-direction: column;
}
.auth-foot .brain {
    display: flex;
    margin-top: 5px;
    align-items: center;
    justify-content: center;
}
.auth-foot .brain svg {
    margin-right: 5px;
}
.auth-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    padding: 4px 10px;
    border-radius: 100px;
    width: fit-content;
}

/* tooltip */
[data-tip] {
    position: relative;
}
[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: #fff;
    font-size: 11px;
    padding: 5px 8px;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 80;
    box-shadow: var(--shadow-md);
}
html.dark [data-tip]:hover::after {
    background: #f3f4f6;
    color: #111827;
}

/* alerts / toasts */
.alert {
    display: flex;
    gap: 11px;
    padding: 13px 15px;
    border-radius: var(--r-md);
    border: 1px solid;
    font-size: 13px;
}
.alert svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    margin-top: 1px;
}
.alert-info {
    background: var(--info-soft);
    border-color: transparent;
    color: var(--info);
}
.alert-warn {
    background: var(--warn-soft);
    border-color: transparent;
    color: var(--warn);
}
.alert p {
    color: var(--text);
    margin-top: 2px;
}

.toast-wrap {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    gap: 10px;
    border: 1px solid var(--border-strong);
    display: flex;
    padding: 12px 15px;
    font-size: 13px;
    min-width: 260px;
    max-width: 280px;
    animation: toastin 0.25s ease;
    align-items: center;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    border-radius: var(--r-md);
}
@keyframes toastin {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
.toast-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-text);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.toast-icon.error {
    background-color: var(--danger);
}
.toast-icon svg {
    width: 11px;
    height: 11px;
}

.auth-foot .brain svg {
    filter: drop-shadow(0 0 2px var(--brain-blue));
    animation: think 2s ease-in-out infinite;
}

.busy {
    inset: 0;
    opacity: 1;
    display: flex;
    z-index: 99999;
    position: fixed;
    transition: .25s;
    visibility: visible;
    background: var(--loader-background);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(1px);
}

.content-card {
	gap: 18px;
	padding: 15px 15px;
	display: flex;
	background: white;
    box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.25);
	align-items: center;
	border-radius: 4px;
	flex-direction: column;
}

.busy .content-card .msg {
	color: #111827;
	display: flex;
	font-size: 12px;
	font-weight: 500;
	align-items: center;
	flex-direction: column;
}

.busy .dots {
    gap: 5px;
    display: flex;
    margin-bottom: 8px;
}

.busy .dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3B82F6;
    animation: bounce 1.2s infinite;
}

.busy .dots span:nth-child(2) {
    animation-delay: .2s;
}

.busy .dots span:nth-child(3) {
    animation-delay: .4s;
}

@keyframes bounce{

    0%,80%,100%{
        transform:scale(.5);
        opacity:.4;
    }

    40%{
        transform:scale(1);
        opacity:1;
    }

}

@keyframes think {
    0%, 100% {
        fill: var(--brain-blue);
        filter: drop-shadow(0 0 3px var(--brain-blue));
    }

    25% {
        fill: var(--brain-cyan);
        filter: drop-shadow(0 0 6px var(--brain-cyan));
    }

    50% {
        fill: var(--brain-purple);
        filter: drop-shadow(0 0 8px var(--brain-purple));
    }

    75% {
        fill: var(--brain-green);
        filter: drop-shadow(0 0 6px var(--brain-green));
    }
}

@media (max-width: 980px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid-2 {
        grid-template-columns: 1fr;
    }
    .editor-layout {
        grid-template-columns: 1fr;
    }
    .settings-layout {
        grid-template-columns: 1fr;
    }
    .media-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .nav-main {
        display: none;
    }
    .hamburger {
        display: flex;
    }
    .kbd-search {
        width: 170px;
    }
}
@media (max-width: 640px) {
    .grid-4,
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    .media-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .kbd-search {
        display: none;
    }
    .topnav-inner {
        padding: 0 var(--sp4);
    }
    .main {
        padding: var(--sp4);
    }
}
