@import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@300;400;500&family=Geist:wght@300;400;500;600&display=swap');

/* ─────────────────────────────────────────────────────────────
   LIGHT THEME
───────────────────────────────────────────────────────────── */

:root {
    --bg: #f9f9f8;
    --surface: #ffffff;
    --surface-2: #f4f3f1;
    --surface-3: #eeecea;

    --border: #e5e3df;
    --border-focus: #a8a29e;

    --text: #1c1917;
    --text-2: #78716c;
    --text-3: #a8a29e;

    --success: #16a34a;
    --success-bg: #f0fdf4;
    --success-border: #bbf7d0;

    --error: #dc2626;

    --sql-kw: #185FA5;

    --font: 'Geist', system-ui, sans-serif;
    --font-mono: 'Geist Mono', 'Fira Code', monospace;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
}

/* ─────────────────────────────────────────────────────────────
   DARK THEME
───────────────────────────────────────────────────────────── */

[data-theme="dark"] {
    --bg: #0f0f0f;

    --surface: #171717;
    --surface-2: #1f1f1f;
    --surface-3: #252525;

    --border: #2a2a2a;
    --border-focus: #525252;

    --text: #fafafa;
    --text-2: #a3a3a3;
    --text-3: #525252;

    --success: #22c55e;
    --success-bg: #052e16;
    --success-border: #166534;

    --error: #f87171;

    --sql-kw: #60a5fa;
}

/* ─────────────────────────────────────────────────────────────
   RESET
───────────────────────────────────────────────────────────── */

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

html,
body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    scroll-behavior: smooth;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 999px;
}

/* ─────────────────────────────────────────────────────────────
   HOME
───────────────────────────────────────────────────────────── */

.home {
    min-height: 100vh;

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    padding: 2rem;
}

.home-inner {
    width: 100%;
    max-width: 560px;
    text-align: center;
}

.home-logo {
    width: 54px;
    height: 54px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    background: var(--text);
    border-radius: var(--radius);

    margin-bottom: 1.8rem;
}

.home-logo-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-logo {
    height: 42px;
    width: auto;
}

.brand-meta {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.brand-subtitle {
    font-size: 0.82rem;
    opacity: 0.7;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.version-pill {
    font-size: 0.78rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    border: 1px solid rgba(128,128,128,0.25);
    opacity: 0.8;
}

.hero-symbols {
    font-size: 1rem;
    letter-spacing: 0.35rem;
    opacity: 0.65;
    margin-bottom: 1.2rem;
}

.home-title {
    font-size: 2.3rem;
    font-weight: 600;
    letter-spacing: -0.04em;

    margin-bottom: .65rem;

    line-height: 1.05;
}

.home-sub {
    font-size: .95rem;
    line-height: 1.7;

    color: var(--text-2);

    margin-bottom: 2rem;
}

.home-ops {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;

    gap: .45rem;

    margin-bottom: 2.4rem;
}

.op-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;

    padding: .35rem .75rem;

    border-radius: 999px;

    border: 1px solid var(--border);

    background: var(--surface);

    font-size: .78rem;

    color: var(--text-2);
}

.op-pill .sym {
    font-family: var(--font-mono);
    color: var(--text);
    font-weight: 500;
}

.home-cta {
    display: inline-flex;
    align-items: center;
    gap: .5rem;

    padding: .75rem 1.35rem;

    background: var(--text);
    color: white;

    border-radius: var(--radius);

    font-size: .88rem;
    font-weight: 500;

    text-decoration: none;

    transition: opacity .15s ease;
}

.home-cta:hover {
    opacity: .84;
}

.home-theme-btn {
    position: fixed;
    top: 1rem;
    right: 1rem;
}

/* ─────────────────────────────────────────────────────────────
   COMPILER PAGE
───────────────────────────────────────────────────────────── */

.compiler-page {
    height: 100vh;

    display: flex;
    flex-direction: column;

    overflow: hidden;

    background: var(--bg);
}

/* ─────────────────────────────────────────────────────────────
   NAVBAR
───────────────────────────────────────────────────────────── */

.nav {
    height: 54px;
    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 1rem;

    background: var(--surface);

    border-bottom: 1px solid var(--border);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: .65rem;

    text-decoration: none;

    color: var(--text);

    font-size: .9rem;
    font-weight: 600;
}

.nav-brand-mark {
    width: 30px;
    height: 30px;

    display: grid;
    place-items: center;

    border-radius: 8px;

    background: var(--surface-2);

    border: 1px solid var(--border);
}

.nav-brand-logo-img {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.nav-pill {
    display: inline-flex;
    align-items: center;
    gap: .45rem;

    padding: .28rem .7rem;

    border-radius: 999px;

    font-size: .72rem;

    color: var(--success);

    background: var(--success-bg);

    border: 1px solid var(--success-border);
}

.nav-pill::before {
    content: "";

    width: 6px;
    height: 6px;

    border-radius: 50%;

    background: var(--success);
}

.nav-back {
    text-decoration: none;

    color: var(--text-2);

    font-size: .82rem;

    transition: color .15s ease;
}

.nav-back:hover {
    color: var(--text);
}

.btn-theme {
    width: 32px;
    height: 32px;

    display: grid;
    place-items: center;

    background: transparent;

    border: 1px solid var(--border);

    border-radius: var(--radius-sm);

    cursor: pointer;

    color: var(--text-2);

    transition: all .15s ease;
}

.btn-theme:hover {
    border-color: var(--border-focus);
    color: var(--text);
}

.btn-theme svg {
    width: 15px;
    height: 15px;
}

/* ─────────────────────────────────────────────────────────────
   FIXED EDITOR
───────────────────────────────────────────────────────────── */

.editor-fixed {
  flex-shrink: 0;

    background: var(--surface);

    border-bottom: 1px solid var(--border);

    z-index: 20;

    display: flex;
    flex-direction: column;
    align-items: center;

    
}

/* ─────────────────────────────────────────────────────────────
   TOOLBAR
───────────────────────────────────────────────────────────── */

.toolbar {
    width: 100%;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-wrap: wrap;

    gap: .75rem;

    position: relative;

    overflow: visible;

    padding: .8rem 1rem;


}

.tb-group {
    display: flex;
    align-items: center;
    gap: .45rem;
}

.tb-group-end {
    margin-left: 1rem;
}

.tb-sep {
    width: 1px;
    height: 24px;

    background: var(--border);
}

.tb-label {
    font-size: .68rem;
    letter-spacing: .08em;
    text-transform: uppercase;

    color: var(--text-3);
}

/* ─────────────────────────────────────────────────────────────
   DROPDOWNS
───────────────────────────────────────────────────────────── */

.tb-dropdown {
    position: relative;

    display: flex;
    align-items: center;
}

.tb-trigger {
    display: flex;
    align-items: center;
    gap: .45rem;

    height: 38px;

    padding: 0 .95rem;

    border: 1px solid var(--border);

    border-radius: 10px;

    background: var(--surface);

    color: var(--text-2);

    font-size: .8rem;
    font-family: var(--font);

    cursor: pointer;

    transition: all .15s ease;
}

.tb-trigger:hover {
    background: var(--surface-3);
    color: var(--text);
}

.tb-trigger.active {
    color: var(--text);

    border-color: var(--border-focus);

    box-shadow: 0 0 0 1px var(--border-focus);
}

.chevron {
    width: 11px;
    height: 11px;

    transition: transform .15s ease;
}

.tb-trigger.active .chevron {
    transform: rotate(180deg);
}

/* ─────────────────────────────────────────────────────────────
   DROPDOWN MENU
───────────────────────────────────────────────────────────── */

.tb-menu {
    position: absolute;

    top: calc(100% + .45rem);
    left: 50%;

    transform: translateX(-50%);

    min-width: 220px;

    display: flex;
    flex-direction: column;

    padding: .45rem;

    border-radius: 14px;

    background: var(--surface);

    border: 1px solid var(--border);

    box-shadow:
        0 12px 32px rgba(0,0,0,.14);

    z-index: 999;

    animation: menuIn .12s ease;
}

.tb-menu-wide {
    min-width: 360px;
}

@keyframes menuIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.tb-menu-item {
    width: 100%;

    display: flex;
    align-items: center;

    gap: .75rem;

    border: none;

    background: transparent;

    border-radius: 10px;

    padding: .7rem .8rem;

    cursor: pointer;

    text-align: left;

    transition: background .12s ease;
}

.tb-menu-item:hover {
    background: var(--surface-2);
}

.menu-sym {
    min-width: 28px;

    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 500;

    text-align: center;
}

.menu-name {
    font-size: .82rem;

    color: var(--text-2);
}

/* ─────────────────────────────────────────────────────────────
   SNIPPETS
───────────────────────────────────────────────────────────── */

.tb-menu-item-snippet {
    flex-direction: column;
    align-items: flex-start;

    gap: .2rem;
}

.menu-code {
    font-family: var(--font-mono);

    font-size: .75rem;

    color: var(--text);
}

.menu-desc {
    font-size: .68rem;

    color: var(--text-3);
}

/* ─────────────────────────────────────────────────────────────
   INLINE BUTTONS
───────────────────────────────────────────────────────────── */

.cmp-key,
.hist-key {
    display: inline-flex;
    align-items: center;
    gap: .4rem;

    height: 36px;

    padding: 0 .8rem;

    background: var(--surface);

    border: 1px solid var(--border);

    border-radius: 9px;

    color: var(--text-2);

    font-size: .78rem;
    font-family: var(--font);

    cursor: pointer;

    transition: all .12s ease;
}

.cmp-key {
    font-family: var(--font-mono);
}

.cmp-key:hover,
.hist-key:hover {
    background: var(--surface-3);

    border-color: var(--border-focus);

    color: var(--text);
}

.cmp-key:active,
.hist-key:active {
    transform: scale(.97);
}

.hist-count {
    min-width: 18px;

    padding: 0 .35rem;

    border-radius: 999px;

    font-size: .64rem;

    background: var(--surface-3);

    border: 1px solid var(--border);
}

/* ─────────────────────────────────────────────────────────────
   INPUT AREA
───────────────────────────────────────────────────────────── */

.input-area {
    width: 100%;
    max-width: 1200px;

    padding: 1rem;
}

.input-label {
    display: block;

    margin-bottom: .45rem;

    font-size: .68rem;
    letter-spacing: .08em;
    text-transform: uppercase;

    color: var(--text-3);
}

.ra-input {
    width: 100%;

    padding: .85rem 1rem;

    border-radius: var(--radius);

    border: 1px solid var(--border);

    background: var(--bg);

    color: var(--text);

    font-family: var(--font-mono);
    font-size: .94rem;

    line-height: 1.7;

    resize: none;
    outline: none;

    transition: all .15s ease;
}

.ra-input:focus {
    border-color: var(--border-focus);

    box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}

.ra-input::placeholder {
    color: var(--text-3);
}

.input-footer {
    display: flex;
    align-items: center;

    gap: .55rem;

    margin-top: .7rem;
}

.btn-run {
    display: inline-flex;
    align-items: center;
    gap: .45rem;

    padding: .55rem 1rem;

    border: none;

    border-radius: var(--radius-sm);

    background: var(--text);

    color: white;

    font-size: .8rem;
    font-weight: 500;

    cursor: pointer;

    transition: all .15s ease;
}

.btn-run:hover:not(:disabled) {
    opacity: .85;
}

.btn-run:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.btn-ghost {
    padding: .55rem .9rem;

    border-radius: var(--radius-sm);

    border: 1px solid var(--border);

    background: transparent;

    color: var(--text-2);

    font-size: .8rem;

    cursor: pointer;

    transition: all .15s ease;
}

.btn-ghost:hover {
    border-color: var(--border-focus);
    color: var(--text);
}

.input-hint {
    margin-left: auto;

    font-size: .68rem;

    color: var(--text-3);
}

/* ─────────────────────────────────────────────────────────────
   OUTPUT AREA
───────────────────────────────────────────────────────────── */


.scroll-top-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--surface);

  opacity: 0;
    
  pointer-events: none;

  transform: translateY(8px);

   transition:opacity .18s ease,transform .18s ease;
}
.scroll-top-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.output-area {
    flex: 1;

    width: 100%;
    overflow-y: auto;

    display: flex;
    flex-direction: column;

    align-items: center;

    gap: .9rem;

    padding: 1rem;

    background: var(--bg);

    min-height: 0;

}

.output-empty {
    flex: 1;

    display: flex;
    align-items: center;
    justify-content: center;

    color: var(--text-3);

    font-size: .82rem;
}

/* ─────────────────────────────────────────────────────────────
   RESULT CARD
───────────────────────────────────────────────────────────── */

.result {
    width: 100%;
    max-width: 1200px;

    overflow: hidden;

    border-radius: var(--radius-lg);

    background: var(--surface);

    border: 1px solid var(--border);

    animation: fadeIn .18s ease;

    flex-shrink: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: .55rem .9rem;

    background: var(--surface-2);

    border-bottom: 1px solid var(--border);
}

.result-status {
    font-size: .72rem;
    font-weight: 500;
}

.result-status.ok {
    color: var(--success);
}

.result-status.err {
    color: var(--error);
}

.result-meta-group {
    display: flex;
    align-items: center;

    gap: .45rem;
}

.result-elapsed {
    padding: .12rem .45rem;

    border-radius: 999px;

    border: 1px solid var(--border);

    background: var(--surface);

    color: var(--text-2);

    font-size: .66rem;

    font-family: var(--font-mono);
}

.result-meta {
    color: var(--text-3);

    font-size: .66rem;

    font-family: var(--font-mono);
}

.result-input-row {
    padding: .5rem .9rem;

    border-bottom: 1px solid var(--border);

    font-family: var(--font-mono);

    font-size: .76rem;

    color: var(--text-2);
}

.result-body {
    padding: .9rem;
}

.result-sql {
    white-space: pre-wrap;
    word-break: break-word;

    line-height: 1.7;

    font-family: var(--font-mono);
    font-size: .88rem;
}

.sql-kw {
    color: var(--sql-kw);
    font-weight: 500;
}

.result-error {
    color: var(--error);

    font-family: var(--font-mono);

    font-size: .82rem;

    line-height: 1.7;
}

.result-footer {
    display: flex;
    justify-content: flex-end;

    padding: .5rem .9rem;

    border-top: 1px solid var(--border);
}

.btn-copy {
    padding: .25rem .6rem;

    border-radius: var(--radius-sm);

    border: 1px solid var(--border);

    background: transparent;

    color: var(--text-2);

    font-size: .7rem;

    cursor: pointer;

    transition: all .15s ease;
}

.btn-copy:hover {
    border-color: var(--border-focus);
    color: var(--text);
}

.btn-copy.copied {
    color: var(--success);
    border-color: var(--success-border);
}

/* ─────────────────────────────────────────────────────────────
   MODAL
───────────────────────────────────────────────────────────── */

.modal-backdrop {
     position: fixed;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 1rem;

    background: rgba(0,0,0,.35);

    z-index: 100;
}

.modal {
    width: min(660px, 96vw);

    display: flex;

    max-height: 70vh;

    display: flex;
    flex-direction: column;

    overflow: hidden;

    border-radius: var(--radius-lg);

    background: var(--surface);

    border: 1px solid var(--border);

    animation: slideUp .18s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: .8rem 1rem;

    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: .88rem;
    font-weight: 500;
}

.modal-close {
    border: none;

    background: transparent;

    color: var(--text-2);

    cursor: pointer;

    font-size: 1rem;
}

.modal-body {
    overflow-y: auto;
}

.modal-empty {
    padding: 2rem;

    text-align: center;

    color: var(--text-3);

    font-size: .82rem;
}

.history-row {
    display: flex;
    align-items: center;

    gap: .75rem;

    padding: .7rem 1rem;

    border-bottom: 1px solid var(--border);

    transition: background .12s ease;
}

.history-row:hover {
    background: var(--surface-2);
}

.history-code {
    flex: 1;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-family: var(--font-mono);

    font-size: .78rem;
}

.history-use {
    padding: .25rem .65rem;

    border-radius: var(--radius-sm);

    border: 1px solid var(--border);

    background: transparent;

    color: var(--text-2);

    font-size: .72rem;

    cursor: pointer;

    transition: all .15s ease;
}

.history-use:hover {
    border-color: var(--border-focus);
    color: var(--text);
}

/* ─────────────────────────────────────────────────────────────
   SPINNER
───────────────────────────────────────────────────────────── */

.spinner {
    width: 13px;
    height: 13px;

    border-radius: 50%;

    border: 1.5px solid rgba(255,255,255,.25);
    border-top-color: white;

    animation: spin .6s linear infinite;
}

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