/* ============================================
   FIGMA SCOPE — Dark Glass Design System
   ============================================ */

:root {
    --bg-deep:        #06080f;
    --bg-surface:     #0c1021;
    --bg-elevated:    #131830;
    --bg-glass:       rgba(15, 23, 55, 0.55);
    --bg-input:       rgba(255, 255, 255, 0.04);

    --border:         rgba(100, 140, 200, 0.13);
    --border-strong:  rgba(124, 111, 255, 0.30);

    --text-1:         #f1f5f9;
    --text-2:         #94a3b8;
    --text-3:         #8896ab;

    --accent-purple:  #a78bfa;
    --accent-blue:    #60a5fa;
    --accent-cyan:    #22d3ee;
    --accent-green:   #34d399;
    --accent-pink:    #f472b6;
    --accent-red:     #f87171;

    --gradient-main:  linear-gradient(135deg, #a78bfa 0%, #60a5fa 50%, #22d3ee 100%);
    --gradient-warm:  linear-gradient(135deg, #f472b6 0%, #a78bfa 100%);

    --glow-purple:    0 0 30px rgba(167, 139, 250, 0.18);
    --glow-blue:      0 0 30px rgba(96, 165, 250, 0.15);

    --radius-sm:      8px;
    --radius:         12px;
    --radius-lg:      20px;

    --transition:     0.2s cubic-bezier(0.4, 0, 0.2, 1);

    --font-sans:      'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --font-mono:      'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

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

html, body {
    background: var(--bg-deep);
    color: var(--text-1);
    font-family: var(--font-sans);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* Subtle background grid */
body::before {
    content: '';
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    inset: 0;
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.025) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}
body::after {
    content: '';
    position: fixed;
    top: -200px; right: -200px;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.12), transparent 70%);
    filter: blur(40px);
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   LAYOUT
   ============================================ */

.app {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

.header {
    margin-bottom: 32px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.brand-logo {
    width: 32px;
    height: 32px;
}

.brand-name {
    font-size: 22px;
    font-weight: 700;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

h1.brand-name {
    margin: 0;
}

.tagline {
    color: var(--text-3);
    font-size: 14px;
}

/* ============================================
   INPUT CARD
   ============================================ */

.input-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.field {
    margin-bottom: 16px;
}

.field:last-child { margin-bottom: 0; }

.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-1);
    padding: 12px 16px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
    transition: var(--transition);
    width: 100%;
}

.input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.1);
}

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

.icon-btn {
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-2);
    padding: 12px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-1);
}

.actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    align-items: center;
}

.btn {
    background: var(--gradient-main);
    color: #0a0a1a;
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 16px rgba(167, 139, 250, 0.25);
    letter-spacing: -0.01em;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(167, 139, 250, 0.35);
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--border);
    box-shadow: none;
    font-weight: 500;
}

.btn-ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-1);
    transform: none;
    box-shadow: none;
}

.tab:focus-visible,
.btn:focus-visible,
.btn-ghost:focus-visible,
.icon-btn:focus-visible {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
}

.status {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-3);
    font-family: var(--font-mono);
}

.status.error { color: var(--accent-red); }
.status.success { color: var(--accent-green); }

.fetch-hint {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 8px;
}

/* ============================================
   TABS
   ============================================ */

.results {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    display: none;
}

.results.visible { display: block; }

.tabs {
    display: flex;
    gap: 4px;
    padding: 12px 16px 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
    position: relative;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 1px;
    width: 40px;
    background: linear-gradient(to right, transparent, var(--bg-glass));
    pointer-events: none;
    z-index: 1;
}

.tab {
    background: none;
    border: none;
    color: var(--text-3);
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
}

.tab:hover { color: var(--text-1); }

.tab.active {
    color: var(--accent-purple);
    background: rgba(167, 139, 250, 0.06);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-main);
}

.tab-count {
    display: inline-block;
    background: rgba(167, 139, 250, 0.15);
    color: var(--accent-purple);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 8px;
    margin-left: 6px;
    font-family: var(--font-mono);
}

.tab-panel {
    display: none;
    padding: 28px;
    min-height: 200px;
}

.tab-panel.active { display: block; }

/* ============================================
   OVERVIEW PANEL
   ============================================ */

.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
    padding: 20px;
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-1);
    letter-spacing: -0.02em;
    font-family: var(--font-mono);
}

.stat-value.text {
    font-size: 18px;
    font-family: var(--font-sans);
    word-break: break-word;
}

.stat-meta {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 4px;
    font-family: var(--font-mono);
}

.thumbnail-wrap {
    margin-top: 16px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-input);
    max-width: 600px;
}

.thumbnail-wrap img {
    display: block;
    width: 100%;
    height: auto;
}

/* ============================================
   PAGES PANEL
   ============================================ */

.pages-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.page-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
    padding: 16px 20px;
    transition: var(--transition);
}

.page-row:hover {
    border-color: var(--border-strong);
    background: rgba(167, 139, 250, 0.04);
}

.page-name {
    font-weight: 600;
    color: var(--text-1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 500px;
}

.page-meta {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-3);
}

/* ============================================
   FRAMES TREE
   ============================================ */

.tree {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.7;
}

.tree-node {
    padding: 2px 0;
}

.tree-node-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.tree-node-row:hover {
    background: rgba(167, 139, 250, 0.06);
}

.tree-toggle {
    display: inline-block;
    width: 16px;
    color: var(--text-3);
    user-select: none;
}

.tree-icon {
    font-size: 12px;
    width: 16px;
    text-align: center;
}

.tree-name {
    color: var(--text-1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 400px;
}

.tree-type {
    color: var(--text-3);
    font-size: 11px;
}

.tree-children {
    margin-left: 24px;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    padding-left: 8px;
}

.tree-children.collapsed { display: none; }

/* ============================================
   COLOR SWATCHES
   ============================================ */

.swatch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.swatch {
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
}

.swatch:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
}

.swatch.near-dupe {
    border-color: var(--accent-pink);
}

.near-dupe-badge {
    display: inline-block;
    background: rgba(244, 114, 182, 0.15);
    color: var(--accent-pink);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 6px;
    margin-left: 4px;
    font-family: var(--font-mono);
}

.swatch-color {
    height: 80px;
    width: 100%;
    background-image:
        linear-gradient(45deg, rgba(255,255,255,0.04) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.04) 75%),
        linear-gradient(45deg, rgba(255,255,255,0.04) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.04) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    position: relative;
}

.swatch-color::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    inset: 0;
    background: var(--swatch-color);
}

.swatch-info {
    padding: 12px;
}

.swatch-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 4px;
    word-break: break-word;
}

.swatch-hex {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-3);
}

/* ============================================
   STYLE LISTS
   ============================================ */

.style-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.style-row {
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.style-name {
    font-weight: 600;
    color: var(--text-1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 300px;
}

.style-meta {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-3);
}

/* ============================================
   RAW JSON
   ============================================ */

.json-wrap {
    background: #0d1117;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    max-height: 600px;
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    color: #e6edf3;
    white-space: pre-wrap;
    word-break: break-all;
}

.json-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-3);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ============================================
   TOAST
   ============================================ */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    color: var(--text-1);
    padding: 12px 20px;
    border-radius: 100px;
    font-size: 13px;
    opacity: 0;
    transition: var(--transition);
    pointer-events: none;
    z-index: 998;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    max-width: calc(100vw - 48px);
}

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

/* ============================================
   LOADING
   ============================================ */

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.15);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

/* ============================================
   TOKEN WARNING
   ============================================ */

.token-warning {
    margin-top: 8px;
    font-size: 11px;
    color: var(--accent-green);
    opacity: 0.8;
}

.token-help-link {
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    color: var(--accent-purple);
    text-decoration: none;
    font-size: 11px;
    margin-left: 8px;
}

.token-help-link:hover {
    text-decoration: underline;
}

.remember-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text-3);
    cursor: pointer;
}

.remember-label input[type="checkbox"] {
    accent-color: var(--accent-purple);
}

/* ============================================
   LOADING OVERLAY
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(6, 8, 15, 0.6);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-overlay[hidden] {
    display: none;
}

.loading-overlay .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
    text-align: center;
    padding: 40px 0 0;
    font-size: 12px;
    color: var(--text-3);
}

.footer-sep {
    margin: 0 6px;
    opacity: 0.4;
}

.footer a {
    color: var(--accent-purple);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* ============================================
   LEGAL PAGES
   ============================================ */

.legal-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    max-width: 720px;
}

.legal-title {
    font-size: 24px;
    font-weight: 700;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.legal-updated {
    font-size: 12px;
    color: var(--text-3);
    margin-bottom: 32px;
}

.legal-section {
    margin-bottom: 28px;
}

.legal-section:last-child {
    margin-bottom: 0;
}

.legal-section h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 10px;
}

.legal-section p {
    color: var(--text-2);
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 8px;
}

.legal-section p:last-child {
    margin-bottom: 0;
}

.legal-section ul {
    list-style: none;
    padding: 0;
}

.legal-section li {
    color: var(--text-2);
    font-size: 14px;
    line-height: 1.7;
    padding-left: 20px;
    position: relative;
    margin-bottom: 6px;
}

.legal-section li::before {
    content: '·';
    position: absolute;
    left: 6px;
    color: var(--accent-purple);
    font-weight: 700;
}

.legal-section code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent-cyan);
}

.legal-section a {
    color: var(--accent-purple);
    text-decoration: none;
}

.legal-section a:hover {
    text-decoration: underline;
}

@media (max-width: 640px) {
    .legal-card { padding: 24px; }
}

/* ============================================
   PANEL SEARCH + ACTIONS
   ============================================ */

.panel-search {
    margin-bottom: 16px;
    max-width: 300px;
}

.panel-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.usage-badge {
    display: inline-block;
    background: rgba(167, 139, 250, 0.15);
    color: var(--accent-purple);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 6px;
    margin-left: 4px;
    font-family: var(--font-mono);
    vertical-align: middle;
}

/* ============================================
   ISSUES TAB
   ============================================ */

.issue-section-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 16px 0 8px;
}

.issue-section-label:first-child {
    padding-top: 0;
}

.issue-tag {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.hidden-tag {
    background: rgba(248, 113, 113, 0.15);
    color: var(--accent-red);
}

.locked-tag {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.font-summary {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
}

.font-summary-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.font-tag {
    display: inline-block;
    background: rgba(96, 165, 250, 0.15);
    color: var(--accent-blue);
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 6px;
    margin: 2px 4px 2px 0;
    font-family: var(--font-mono);
}

/* ============================================
   FAQ SECTION
   ============================================ */

.faq-section {
    margin-top: 40px;
    max-width: 720px;
}

.faq-heading {
    font-size: 20px;
    font-weight: 700;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
}

.faq-item {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
}

.faq-question {
    padding: 16px 20px;
    font-weight: 600;
    color: var(--text-1);
    cursor: pointer;
    list-style: none;
    font-size: 14px;
}

.faq-question::-webkit-details-marker {
    display: none;
}

.faq-question::before {
    content: '+';
    color: var(--accent-purple);
    font-weight: 700;
    margin-right: 12px;
    font-family: var(--font-mono);
}

.faq-item[open] .faq-question::before {
    content: '−';
}

.faq-answer {
    padding: 0 20px 16px;
}

.faq-answer p {
    color: var(--text-2);
    font-size: 14px;
    line-height: 1.7;
}

.faq-answer a {
    color: var(--accent-purple);
    text-decoration: none;
}

.faq-answer a:hover {
    text-decoration: underline;
}

.learn-more {
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-3);
}

.learn-more a {
    color: var(--accent-purple);
    text-decoration: none;
}

.learn-more a:hover {
    text-decoration: underline;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 900px) {
    .overview-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
    .swatch-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .style-row { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 640px) {
    .app { padding: 24px 16px 60px; }
    .input-card { padding: 20px; }
    .actions { flex-wrap: wrap; }
    .status { margin-left: 0; width: 100%; }
}
