:root {
    --primary: #475569;
    /* Slate 600 */
    --primary-hover: #334155;
    /* Slate 700 */
    --accent: #4338ca;
    /* Indigo 700 - for subtle highlights */
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #0f172a;
    --text-muted: #475569;
    --border: #cbd5e1;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

[x-cloak] {
    display: none !important;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 800px;
    padding: 2rem;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0;
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-content {
    padding: 2.5rem;
}

.tabs {
    display: flex;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 1rem;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-muted);
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: var(--text);
    background: #f1f5f9;
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: #ffffff;
}

/* Sub-tabs / Segmented Control */
.segmented-control {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: calc(var(--radius) + 2px);
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}

.segmented-btn {
    flex: 1;
    padding: 0.625rem;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-muted);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.segmented-btn:hover:not(.active) {
    color: var(--text);
    background: rgba(0, 0, 0, 0.05);
}

.segmented-btn.active {
    background: white;
    color: var(--accent);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-top: 0;
    margin-bottom: 0.5rem;
    text-align: center;
    color: var(--text);
    letter-spacing: -0.025em;
}

p.subtitle {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 2rem;
    font-size: 0.875rem;
}

.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg);
}

.upload-area:hover {
    border-color: var(--accent);
    background: #ffffff;
}

input[type="file"] {
    display: none;
}

.lookup-section {
    margin-top: 2rem;
    animation: fadeIn 0.4s ease-out;
}

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

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

.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease;
    box-shadow: var(--shadow);
}

input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(67, 56, 202, 0.1);
}

.suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    margin-top: 0.25rem;
    max-height: 400px;
    overflow-y: auto;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text);
    transition: background 0.2s;
}

.suggestion-item:hover,
.suggestion-item.highlighted {
    background: #f1f5f9;
    color: var(--accent);
}

.suggestion-item:not(:last-child) {
    border-bottom: 1px solid #f1f5f9;
}

.definition-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    min-height: 100px;
    line-height: 1.6;
}

.definition-box b {
    color: var(--text);
    font-weight: 700;
}

.definition-box i {
    color: #4f46e5;
    /* Indigo 600 - Academic but distinct */
    font-style: italic;
}

.status {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e1;
}

.status-indicator.ready {
    background: #10b981;
}

.status-indicator.busy {
    background: #f59e0b;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.meta-item {
    position: relative;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-size: 0.75rem;
}

.meta-item label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
}

.meta-item label small {
    display: block;
    font-weight: 400;
    font-size: 0.65rem;
    margin-top: 0.125rem;
}

.stages-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

.stage-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: all 0.3s ease;
    opacity: 0.5;
}

.stage-card.stage-active {
    opacity: 1;
    border-color: var(--accent);
    box-shadow: var(--shadow);
    background: #ffffff;
}

.stage-card.stage-done {
    opacity: 1;
    background: #f0fdf4;
    border-color: #10b981;
}

.stage-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stage-name {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text);
}

.stage-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

.stage-status {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: right;
}

.stage-done .stage-status {
    color: #059669;
}

.stage-active .stage-status {
    color: var(--accent);
}

.progress-container {
    background: #e2e8f0;
    border-radius: 999px;
    height: 6px;
    overflow: hidden;
}

.stage-done .progress-bar {
    background: #10b981;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    transition: width 0.15s ease-out;
}

.btn-convert {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    margin-top: 2rem;
    transition: background 0.2s;
}

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

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

.btn-download {
    width: 100%;
    padding: 1rem;
    background: #10b981;
    color: white;
    border: none;
    border-radius: var(--radius);
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2);
}

.btn-download:hover {
    background: #059669;
    transform: translateY(-1px);
}

.btn-download:active {
    transform: translateY(0);
}