/* ─── Fonts ─── */
@font-face {
    font-family: 'DM Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/dm-sans-v17-latin-regular.woff2') format('woff2');
}

@font-face {
    font-family: 'DM Sans';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/dm-sans-v17-latin-500.woff2') format('woff2');
}

@font-face {
    font-family: 'DM Sans';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../fonts/dm-sans-v17-latin-600.woff2') format('woff2');
}

@font-face {
    font-family: 'DM Sans';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/dm-sans-v17-latin-700.woff2') format('woff2');
}

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/jetbrains-mono-v24-latin-regular.woff2') format('woff2');
}

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/jetbrains-mono-v24-latin-500.woff2') format('woff2');
}

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../fonts/jetbrains-mono-v24-latin-600.woff2') format('woff2');
}

/* ─── Reset & Base ─── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'DM Sans', system-ui, sans-serif;
    background-color: #0F1112;
    color: #e5e7eb;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* ─── Colors & Variables ─── */
:root {
    --surface-0: #0F1112;
    --surface-1: #111314;
    --surface-2: #161819;
    --surface-3: #1A1C1E;
    --surface-4: #1E2022;
    --amber-accent: #F6A623;
    --amber-hover: #FBBF24;
    --amber-dim: rgba(246, 166, 35, 0.1);
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --cyan-accent: #22D3EE;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
}

/* ─── Grid Background ─── */
.grid-bg {
    background-image:
        linear-gradient(rgba(246, 166, 35, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(246, 166, 35, 0.03) 1px, transparent 1px);
    background-size: 48px 48px;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
    width: 5px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.14);
}

/* ─── Selection ─── */
::selection {
    background-color: rgba(246, 166, 35, 0.2);
    color: #F6A623;
}

/* ─── Layout ─── */
.container {
    max-width: 768px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ─── Header ─── */
header {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--border-subtle);
    background-color: rgba(15, 17, 18, 0.8);
    backdrop-filter: blur(12px);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 3.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

/* ─── Tab Navigation ─── */
.tab-nav {
    display: flex;
    gap: 0.25rem;
}

.tab-btn {
    padding: 0.375rem 0.875rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-tertiary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.01em;
}

.tab-btn:hover {
    color: var(--text-secondary);
    background: var(--surface-2);
}

.tab-btn.active {
    color: var(--amber-accent);
    background: var(--amber-dim);
    border-color: rgba(246, 166, 35, 0.15);
}

/* ─── Tab Content ─── */
.tab-content {
    display: none;
    animation: fadeIn 0.2s ease;
}

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

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

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

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

.logo-text {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.logo-badge {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-family: 'JetBrains Mono', monospace;
}

/* ─── Status Bar ─── */
.status-bar {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.status-dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    transition: all 0.3s;
}

.status-dot.loading {
    background-color: var(--amber-accent);
    animation: pulse-slow 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.status-dot.ok {
    background-color: #34d399;
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.4);
}

.status-dot.err {
    background-color: #f87171;
}

.status-text {
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-tertiary);
}

@keyframes pulse-slow {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ─── Main Content ─── */
main {
    padding: 2.5rem 0;
}

.content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

/* ─── Hero Section ─── */
.hero h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
}

.hero p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.7;
    max-width: 42rem;
}

/* ─── Section Label ─── */
.section-label {
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--amber-accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    display: block;
}

/* ─── Drop Zone ─── */
.drop-zone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
    text-align: center;
    border: 2px dashed var(--border-hover);
    border-radius: 0.5rem;
    background-color: var(--surface-1);
    cursor: pointer;
    transition: all 0.2s;
}

.drop-zone:hover {
    border-color: #6b7280;
}

.drop-zone.drop-active {
    border-color: var(--amber-accent);
    background-color: rgba(246, 166, 35, 0.04);
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.drop-zone svg {
    width: 2rem;
    height: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-tertiary);
}

.drop-zone-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.drop-zone-text .highlight {
    color: var(--amber-accent);
    font-weight: 500;
}

.drop-zone-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-family: 'JetBrains Mono', monospace;
    margin-top: 0.25rem;
}

/* ─── File Processing Banner ─── */
.file-processing {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.875rem;
    margin-top: 0.75rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.08));
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-2);
    animation: fadeInSlide 0.2s ease-out;
}

.file-processing.hidden {
    display: none;
}

.processing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.4;
        transform: scale(0.85);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

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

/* ─── File List ─── */
.file-list {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    background-color: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.file-item svg {
    width: 1rem;
    height: 1rem;
    color: var(--text-tertiary);
    flex-shrink: 0;
    stroke-width: 1.5;
}

.file-item .file-name {
    flex: 1;
    font-weight: 500;
    color: #d1d5db;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-item .file-size {
    color: var(--text-tertiary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.file-item .file-remove {
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    opacity: 0;
    transition: all 0.2s;
    background: none;
    border: none;
    padding: 0;
}

.file-item:hover .file-remove {
    opacity: 1;
}

.file-item .file-remove:hover {
    color: #f87171;
}

/* ─── File Summary ─── */
.file-summary {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
}

.file-summary.hidden {
    display: none;
}

.file-total {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-secondary);
}

.shuffle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.shuffle-label:hover {
    color: #d1d5db;
}

.shuffle-label span {
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
}

/* ─── Checkbox ─── */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1rem;
    height: 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border-hover);
    border-radius: 3px;
    cursor: pointer;
    vertical-align: middle;
    position: relative;
}

input[type="checkbox"]:checked {
    background: var(--amber-accent);
    border-color: var(--amber-accent);
}

input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 1px;
    width: 5px;
    height: 8px;
    border: solid var(--surface-0);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ─── Vocab Chips ─── */
.vocab-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.vocab-chip {
    padding: 0.375rem 0.875rem;
    border: 1px solid var(--border-subtle);
    border-radius: 0.375rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    background-color: var(--surface-2);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.15s;
}

.vocab-chip:hover {
    border-color: var(--text-tertiary);
    color: var(--text-secondary);
}

.vocab-chip.active {
    border-color: rgba(246, 166, 35, 0.3);
    color: var(--amber-accent);
    background-color: rgba(246, 166, 35, 0.1);
    box-shadow: 0 0 8px rgba(246, 166, 35, 0.12);
}

/* ─── Buttons ─── */
.btn {
    width: 100%;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 0.375rem;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn svg {
    width: 1rem;
    height: 1rem;
}

.btn-primary {
    background-color: var(--amber-accent);
    color: var(--surface-0);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--amber-hover);
}

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

.btn-secondary {
    border: 1px solid rgba(246, 166, 35, 0.2);
    background-color: rgba(246, 166, 35, 0.05);
    color: var(--amber-accent);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    padding: 0.625rem 1.5rem;
}

.btn-secondary:hover {
    background-color: rgba(246, 166, 35, 0.1);
    border-color: rgba(246, 166, 35, 0.3);
}

.btn-secondary.hidden {
    display: none;
}

/* ─── Progress ─── */
.progress-wrap {
    display: flex;
    flex-direction: column;
}

.progress-wrap.hidden {
    display: none;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
}

.progress-label {
    font-family: 'JetBrains Mono', monospace;
    color: #d1d5db;
}

.progress-eta {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-2);
    font-size: 0.8125rem;
}

.progress-rate {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-tertiary);
}

.progress-bar {
    width: 100%;
    background-color: var(--surface-3);
    border-radius: 9999px;
    height: 0.25rem;
    overflow: hidden;
}

.progress-fill {
    background-color: var(--amber-accent);
    height: 100%;
    border-radius: 9999px;
    transition: width 0.3s ease-out;
    width: 0%;
}

/* ─── Tokenizer ─── */
.tokenizer-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tokenizer-input {
    width: 100%;
    background-color: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: 0.5rem;
    padding: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    color: var(--text-primary);
    resize: vertical;
    min-height: 6rem;
    transition: border-color 0.2s;
}

.tokenizer-input:focus {
    outline: none;
    border-color: var(--cyan-accent);
}

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

.tokenizer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.tokenizer-actions .btn {
    width: auto;
    padding: 0.625rem 1.25rem;
}

.tokenizer-stats {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stat-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background-color: var(--surface-2);
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border-subtle);
}

.tokenizer-output {
    background-color: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: 0.5rem;
    padding: 1rem;
    max-height: 24rem;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    align-items: flex-start;
}

.tokenizer-output.hidden {
    display: none;
}

.token {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    background-color: var(--surface-2);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    transition: all 0.15s;
    cursor: default;
}

.token:hover {
    background-color: var(--surface-3);
    border-color: var(--amber-accent);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.token .token-id {
    color: var(--text-tertiary);
    font-size: 0.65rem;
    margin-left: 0.25rem;
}

/* ─── Log Output ─── */
.log-output {
    background-color: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: 0.5rem;
    padding: 1.25rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    height: 20rem;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.7;
}

/* ─── Footer ─── */
footer {
    border-top: 1px solid var(--border-subtle);
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 0;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-family: 'JetBrains Mono', monospace;
}

/* ─── Utilities ─── */
.section-gap {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ─── Vocab Status ─── */
.vocab-status {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    background-color: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
}

.vocab-status-icon svg {
    width: 1rem;
    height: 1rem;
    color: var(--text-tertiary);
}

.vocab-status.loaded .vocab-status-icon svg {
    color: #34d399;
}

#vocabStatusText {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.vocab-actions {
    display: flex;
    gap: 0.75rem;
}

.vocab-actions .btn {
    flex: 1;
}

/* ─── Utilities ─── */
.hidden {
    display: none !important;
}