/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f4f7fa;
    --surface: #ffffff;
    --primary: #0e7c6b;
    --primary-light: #e6f5f2;
    --primary-hover: #0a6053;
    --text: #1a2332;
    --text-secondary: #5a6b7f;
    --border: #e2e8f0;
    --border-focus: #0e7c6b;
    --error: #d14545;
    --error-bg: #fef2f2;
    --success: #0e7c6b;
    --success-bg: #e6f5f2;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.header {
    background: linear-gradient(135deg, #0a6053 0%, #0e7c6b 40%, #14a085 100%);
    color: white;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(14,124,107,0.25);
}
.header-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}
.logo-icon {
    width: 36px;
    height: 36px;
    color: white;
}
.logo-icon svg { width: 100%; height: 100%; }
.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}
.logo-text span {
    font-size: 0.75rem;
    opacity: 0.8;
    font-weight: 400;
}
.header-badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.25);
}

/* ===== Main ===== */
.main {
    flex: 1;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 28px 24px 40px;
}

/* ===== Mode Tabs ===== */
.mode-tabs {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 4px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}
.mode-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}
.mode-tab:hover { background: var(--bg); color: var(--text); }
.mode-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}
.mode-tab svg { flex-shrink: 0; }

/* ===== Mode Panels ===== */
.mode-panel { display: none; }
.mode-panel.active { display: block; }

/* ===== Card ===== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 20px;
    animation: fadeUp 0.35s ease;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.card-header {
    padding: 20px 24px 0;
}
.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}
.card-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0;
}
.card-body {
    padding: 20px 24px 24px;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}
.select-wrapper {
    position: relative;
}
.select-wrapper::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--text-secondary);
    pointer-events: none;
}
select {
    width: 100%;
    padding: 12px 40px 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.2s;
}
select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-light);
}

textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    resize: vertical;
    min-height: 140px;
    transition: border-color 0.2s;
}
textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-light);
    background: var(--surface);
}
textarea::placeholder {
    color: #a0aec0;
}

/* ===== Buttons ===== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 180px;
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-copy, .btn-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid rgba(14,124,107,0.2);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-copy:hover, .btn-download:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== Spinner ===== */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Result Card ===== */
.result-card { border-left: 4px solid var(--primary); }
.result-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.result-text {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.9rem;
    line-height: 1.8;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
}

/* ===== Error Card ===== */
.error-card {
    border-left: 4px solid var(--error);
}
.error-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: var(--error);
}
.error-content svg { flex-shrink: 0; margin-top: 2px; }

/* ===== Drop Zone ===== */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s;
    background: var(--bg);
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}
.drop-zone.drag-over {
    transform: scale(1.01);
}
.drop-icon {
    color: var(--text-secondary);
    margin-bottom: 8px;
    transition: color 0.25s;
}
.drop-zone:hover .drop-icon { color: var(--primary); }
.drop-text {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 4px;
}
.drop-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--success-bg);
    border: 1px solid rgba(14,124,107,0.2);
    border-radius: var(--radius-sm);
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 500;
}
.file-info .remove-file {
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font);
    padding: 2px 8px;
    border-radius: 4px;
}
.file-info .remove-file:hover {
    background: var(--error-bg);
}

/* ===== Batch Results ===== */
.batch-summary {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.summary-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
}
.summary-chip.total {
    background: var(--bg);
    color: var(--text);
}
.summary-chip.success {
    background: var(--success-bg);
    color: var(--success);
}
.summary-chip.error {
    background: var(--error-bg);
    color: var(--error);
}

.batch-results-list {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.result-item {
    display: flex;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    transition: background 0.15s;
}
.result-item:last-child { border-bottom: none; }
.result-item:hover { background: var(--bg); }
.result-item .index {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.8rem;
}
.result-item .index.error {
    background: var(--error-bg);
    color: var(--error);
}
.result-item .content {
    flex: 1;
    min-width: 0;
}
.result-item .content .output {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    word-break: break-word;
    color: var(--text);
}
.result-item .content .error-msg {
    color: var(--error);
    font-weight: 500;
}

/* ===== Progress Bar ===== */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 16px;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #14a085);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}
.progress-text {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== Template Editor ===== */
.template-editor {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: 16px 18px;
    font-family: var(--font);
    font-size: 0.88rem;
    line-height: 2.1;
    color: var(--text);
    word-break: break-word;
}
.tpl-fixed {
    color: var(--text);
}
.tpl-var-input {
    color: #c0392b;
    border: none;
    border-bottom: 2px solid #c0392b;
    background: transparent;
    font-family: var(--font);
    font-size: 0.88rem;
    outline: none;
    padding: 0 3px 1px;
    vertical-align: baseline;
    min-width: 60px;
    transition: border-color 0.15s, background 0.15s;
}
.tpl-var-input::placeholder { color: #e8a0a0; font-style: italic; }
.tpl-var-input:focus {
    border-bottom-color: #922b21;
    background: #fff8f8;
    border-radius: 3px 3px 0 0;
}
.tpl-var-input.tpl-var-opt {
    color: #c0705a;
    border-bottom-color: #d4998a;
}
.tpl-var-input.tpl-var-opt::placeholder { color: #e8c5bc; }
.tpl-var-textarea {
    display: block;
    width: 100%;
    margin: 6px 0 2px;
    padding: 10px 14px;
    color: #c0392b;
    border: 2px solid #c0392b;
    border-radius: var(--radius-sm);
    background: #fff8f8;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.82rem;
    line-height: 1.7;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.tpl-var-textarea::placeholder { color: #e8a0a0; font-style: italic; }
.tpl-var-textarea:focus {
    border-color: #922b21;
    background: #fff5f5;
    box-shadow: 0 0 0 3px rgba(192,57,43,0.1);
}

/* ===== File Format Hint ===== */
.format-hint {
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.format-hint strong {
    color: var(--text);
    display: block;
    margin-bottom: 6px;
}
.format-hint pre {
    margin: 0;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.78rem;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text);
    line-height: 1.6;
}

/* ===== Predict Hint ===== */
.predict-hint {
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: flex;
    align-items: flex-start;
    gap: 6px;
    flex-wrap: wrap;
}
.predict-hint .missing-label {
    font-weight: 600;
    color: var(--error);
    white-space: nowrap;
}
.predict-hint .missing-field {
    display: inline-block;
    background: var(--error-bg);
    color: var(--error);
    border-radius: 4px;
    padding: 1px 7px;
    font-size: 0.78rem;
    font-weight: 500;
    margin: 2px 2px;
}

/* ===== Threshold Control ===== */
.label-hint {
    font-weight: 400;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-left: 4px;
}
.threshold-text {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.9rem;
    color: var(--primary);
    background: var(--surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.threshold-text::placeholder {
    color: #a0aec0;
    font-family: var(--font);
    font-style: italic;
}
.threshold-text:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.threshold-hint {
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.threshold-hint code {
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 3px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.75rem;
    color: var(--primary);
}

/* ===== Minimal Genome Result Panel ===== */
.minimal-genome-panel {
    margin: 4px 0 16px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--primary-light), #f6fbfa);
    border: 1px solid rgba(14,124,107,0.25);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
}
.mg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(14,124,107,0.18);
}
.mg-tag {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 3px 10px;
    border-radius: 999px;
}
.mg-section-count {
    font-size: 0.78rem;
    color: var(--primary);
    font-weight: 600;
}
.mg-section + .mg-section {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed rgba(14,124,107,0.3);
}
.mg-section-head {
    margin-bottom: 8px;
}
.mg-threshold {
    display: inline-block;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.78rem;
    color: var(--primary);
    background: rgba(255,255,255,0.85);
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid rgba(14,124,107,0.25);
    font-weight: 600;
}
.mg-block + .mg-block {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dotted rgba(14,124,107,0.2);
}
.mg-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.mg-block-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}
.mg-block-stats {
    font-size: 0.78rem;
    color: var(--primary);
    font-weight: 500;
}
.mg-set-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.mg-set {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    max-height: 220px;
    overflow-y: auto;
    word-break: break-word;
    white-space: pre-wrap;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 20px 24px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .header-inner { height: 56px; }
    .logo-text h1 { font-size: 1.1rem; }
    .header-badge { display: none; }
    .main { padding: 16px; }
    .card-header, .card-body { padding-left: 16px; padding-right: 16px; }
    .batch-summary { flex-direction: column; gap: 8px; }
    .mode-tab { padding: 10px 8px; font-size: 0.82rem; }
}
