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

:root {
  --green-900: #14532d;
  --green-800: #166534;
  --green-700: #15803d;
  --green-600: #16a34a;
  --green-500: #22c55e;
  --green-100: #dcfce7;
  --green-50: #f0fdf4;
  --gray-900: #111827;
  --gray-800: #1f2937;
  --gray-700: #374151;
  --gray-600: #4b5563;
  --gray-500: #6b7280;
  --gray-400: #9ca3af;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50: #f9fafb;
  --white: #ffffff;
  --red-500: #ef4444;
  --red-50: #fef2f2;
  --blue-600: #2563eb;
  --blue-50: #eff6ff;
  --amber-500: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ── Header ── */
.header {
  background: linear-gradient(135deg, var(--green-900) 0%, var(--green-700) 100%);
  color: var(--white); position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-md);
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  height: 56px; display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--white); }
.logo-icon { font-size: 1.5rem; }
.logo-icon-svg { flex-shrink: 0; vertical-align: middle; }
.logo-text { font-size: 1.15rem; font-weight: 400; }
.logo-text strong { font-weight: 700; }
.nav-badge {
  background: rgba(255,255,255,.15); padding: 4px 12px;
  border-radius: 20px; font-size: .82rem;
}

/* ── Hero / Search ── */
.hero {
  background: linear-gradient(135deg, var(--green-800) 0%, var(--green-600) 100%);
  color: var(--white); padding: 40px 16px 48px;
}
.hero-inner { max-width: 800px; margin: 0 auto; text-align: center; }
.hero-inner h1 { font-size: 1.8rem; font-weight: 700; }
.hero-sub { opacity: .85; margin-top: 6px; font-size: .92rem; }

.search-box { margin-top: 28px; }
.search-input-wrap { position: relative; }
#searchInput {
  width: 100%; padding: 14px 20px; font-size: 1.05rem;
  border: 2px solid transparent; border-radius: var(--radius-lg);
  outline: none; transition: box-shadow .2s;
  font-family: inherit; background: var(--white); color: var(--gray-900);
}
#searchInput:focus { box-shadow: 0 0 0 4px rgba(255,255,255,.3); }
#searchInput::placeholder { color: var(--gray-400); }

/* ── Mode Tabs ── */
.mode-tabs {
  display: flex; justify-content: center; gap: 0;
  margin-bottom: -1px; position: relative; z-index: 2;
}
.mode-tab {
  padding: 10px 24px; font-size: .9rem; font-weight: 600;
  border: 2px solid transparent; border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: rgba(255,255,255,.25); color: rgba(255,255,255,.8);
  cursor: pointer; transition: background .15s, color .15s;
}
.mode-tab:hover { background: rgba(255,255,255,.35); color: var(--white); }
.mode-tab.active {
  background: var(--white); color: var(--green-800);
  border-color: var(--white);
}

/* ── Batch Box ── */
.batch-box {
  background: var(--white); border-radius: 0 var(--radius-lg) var(--radius-lg) var(--radius-lg);
  padding: 28px 28px 24px; box-shadow: var(--shadow-md);
}
.batch-input-area { margin-bottom: 18px; }
#batchInput {
  width: 100%; min-height: 170px; padding: 16px 18px;
  font-family: "SF Mono", Menlo, Consolas, "Noto Sans Mono", monospace;
  font-size: .86rem; line-height: 1.75;
  border: 2px solid var(--gray-300); border-radius: var(--radius);
  resize: vertical; color: var(--gray-900); background: var(--gray-50);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
#batchInput:focus {
  outline: none; border-color: var(--green-600);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(22,163,74,.10);
}
#batchInput::placeholder { color: var(--gray-400); font-style: italic; }

/* ── Batch Hint Bar ── */
.batch-hint-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 12px; padding: 10px 16px;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1px solid #bbf7d0; border-radius: var(--radius-sm);
  flex-wrap: wrap;
}
.batch-hint-content {
  display: flex; align-items: center; gap: 8px;
  font-size: .82rem; color: var(--gray-600); line-height: 1.6;
  flex: 1; min-width: 200px;
}
.batch-hint-icon { font-size: 1rem; flex-shrink: 0; }
.batch-hint-content kbd {
  display: inline-block; padding: 1px 6px;
  font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .78rem;
  background: var(--white); border: 1px solid var(--gray-300);
  border-radius: 4px; box-shadow: 0 1px 0 var(--gray-300);
}

/* ── Example Button ── */
.btn-example {
  padding: 7px 16px; font-size: .82rem; font-weight: 600;
  border: 1px solid var(--green-300); border-radius: var(--radius-sm);
  background: var(--white); color: var(--green-700);
  cursor: pointer; white-space: nowrap;
  transition: all .15s;
}
.btn-example:hover {
  background: var(--green-50); border-color: var(--green-500);
  box-shadow: 0 2px 6px rgba(22,163,74,.12);
}
.btn-example:active { transform: scale(.97); }

/* ── Batch Examples ── */
.batch-examples {
  margin-top: 14px; padding: 16px 18px;
  background: var(--gray-50); border-radius: var(--radius-sm);
  border: 1px dashed var(--gray-300);
}
.examples-label {
  font-size: .8rem; font-weight: 700; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: 10px; display: block;
}
.example-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.example-col {
  background: var(--white); border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200); overflow: hidden;
}
.example-title {
  font-size: .75rem; font-weight: 700; color: var(--gray-500);
  background: var(--gray-100); padding: 6px 12px;
  text-transform: uppercase; letter-spacing: .03em;
}
.example-pre {
  margin: 0; padding: 10px 12px;
  font-family: "SF Mono", Menlo, Consolas, "Noto Sans Mono", monospace;
  font-size: .78rem; line-height: 1.65; color: var(--gray-700);
  background: transparent; overflow-x: auto; white-space: pre;
}

/* ── Batch Buttons ── */
.batch-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

.btn-batch-primary,
.btn-batch-download,
.btn-batch-clear {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px; font-size: .92rem; font-weight: 600;
  border: none; border-radius: var(--radius);
  cursor: pointer; transition: all .18s;
  font-family: inherit;
}
.btn-svg { width: 18px; height: 18px; flex-shrink: 0; }

.btn-batch-primary {
  background: linear-gradient(135deg, var(--green-700) 0%, var(--green-600) 100%);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(22,163,74,.25);
}
.btn-batch-primary:hover {
  background: linear-gradient(135deg, var(--green-800) 0%, var(--green-700) 100%);
  box-shadow: 0 4px 14px rgba(22,163,74,.35);
  transform: translateY(-1px);
}
.btn-batch-primary:active { transform: translateY(0); box-shadow: 0 1px 4px rgba(22,163,74,.2); }
.btn-batch-primary:disabled {
  background: var(--gray-400); box-shadow: none; cursor: not-allowed; transform: none;
}

.btn-batch-download {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
}
.btn-batch-download:hover {
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
  box-shadow: 0 4px 14px rgba(37,99,235,.35);
  transform: translateY(-1px);
}
.btn-batch-download:active { transform: translateY(0); box-shadow: 0 1px 4px rgba(37,99,235,.2); }

.btn-batch-clear {
  background: var(--white); color: var(--gray-600);
  border: 1.5px solid var(--gray-300);
}
.btn-batch-clear:hover {
  background: var(--gray-100); border-color: var(--gray-400); color: var(--gray-800);
}
.btn-batch-clear:active { background: var(--gray-200); transform: scale(.97); }

.batch-status { margin-top: 16px; font-size: .9rem; color: var(--gray-600); min-height: 22px; }
.batch-status .match-ok { color: var(--green-700); font-weight: 600; }
.batch-status .match-warn { color: var(--amber-500); font-weight: 600; }

/* ── Batch Summary ── */
.batch-summary {
  margin-bottom: 12px; padding: 14px 18px;
  background: var(--green-50); border-radius: var(--radius);
  font-size: .88rem; color: var(--gray-700);
}
.batch-summary .not-found-list {
  margin-top: 8px; padding: 10px 14px; background: var(--red-50);
  border-radius: var(--radius-sm); color: var(--red-500);
  font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .82rem;
  max-height: 120px; overflow-y: auto; word-break: break-all;
}

.search-suggestions {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--white); color: var(--gray-900);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow-lg); max-height: 300px; overflow-y: auto;
  display: none; z-index: 50;
}
.search-suggestions.active { display: block; }
.suggestion-item {
  padding: 10px 16px; cursor: pointer; display: flex;
  justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--gray-100);
}
.suggestion-item:hover, .suggestion-item.active { background: var(--green-50); }
.suggestion-id { font-weight: 600; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .9rem; }
.suggestion-chr { font-size: .78rem; color: var(--gray-500); }

.search-filters {
  margin-top: 12px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.search-filters select {
  padding: 10px 14px; border: none; border-radius: var(--radius);
  font-size: .9rem; font-family: inherit; background: rgba(255,255,255,.9);
  color: var(--gray-800); cursor: pointer; outline: none;
}

/* ── Buttons ── */
.btn-search {
  padding: 10px 24px; border: none; border-radius: var(--radius);
  font-size: .95rem; font-weight: 600; cursor: pointer;
  background: var(--white); color: var(--green-800);
  display: flex; align-items: center; gap: 6px;
  transition: transform .1s, box-shadow .1s;
}
.btn-search:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-search:active { transform: translateY(0); }

.btn-sm {
  padding: 6px 14px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
  font-size: .85rem; cursor: pointer; background: var(--white); color: var(--gray-700);
  transition: background .15s;
}
.btn-sm:hover { background: var(--gray-100); }
.btn-primary {
  background: var(--green-700); color: var(--white); border-color: var(--green-700);
}
.btn-primary:hover { background: var(--green-800); }
.btn-primary:disabled { background: var(--gray-400); border-color: var(--gray-400); cursor: not-allowed; }
.btn-xs {
  padding: 3px 10px; font-size: .78rem; border: 1px solid var(--gray-300);
  border-radius: 4px; cursor: pointer; background: var(--white); color: var(--green-700);
}
.btn-xs:hover { background: var(--green-50); border-color: var(--green-500); }

/* ── Main Content ── */
.main { flex: 1; padding: 24px 16px; }
.main-inner { max-width: 1200px; margin: 0 auto; }

.results-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; flex-wrap: wrap; gap: 12px;
}
.results-count { font-weight: 600; color: var(--gray-700); }
.results-query { font-size: .85rem; color: var(--gray-500); margin-left: 8px; }
.results-actions { display: flex; gap: 8px; }

/* ── Table ── */
.table-wrap {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow-x: auto;
}
.gene-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.gene-table thead { background: var(--gray-50); }
.gene-table th {
  padding: 12px 16px; text-align: left; font-weight: 600;
  color: var(--gray-600); font-size: .82rem; text-transform: uppercase;
  letter-spacing: .03em; white-space: nowrap;
  border-bottom: 2px solid var(--gray-200);
}
.gene-table td {
  padding: 10px 16px; border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}
.gene-table tbody tr { transition: background .1s; }
.gene-table tbody tr:hover { background: var(--green-50); }
.gene-table tbody tr.selected { background: var(--green-100); }
.col-check { width: 40px; text-align: center; }
.col-id { font-family: "SF Mono", Menlo, Consolas, monospace; font-weight: 600; }
.col-id a { color: var(--green-700); text-decoration: none; }
.col-id a:hover { text-decoration: underline; }
.col-strand .badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: .75rem; font-weight: 600;
}
.badge-plus { background: var(--blue-50); color: var(--blue-600); }
.badge-minus { background: var(--red-50); color: var(--red-500); }

/* ── Gene Symbol / TAIR / Annotation ── */
.col-sym { font-weight: 600; color: var(--green-800); }
.col-arath { font-size: .85rem; }
.col-arath .tair-link {
  color: var(--blue-600); text-decoration: none;
  font-weight: 500; border-bottom: 1px dashed var(--blue-400);
  transition: color .15s;
}
.col-arath .tair-link:hover { color: #1e40af; border-bottom-color: #1e40af; }

.custom-name-tag {
  display: inline-block; margin-left: 6px; padding: 1px 8px;
  background: var(--green-100); color: var(--green-800);
  border-radius: 10px; font-size: .76rem; font-weight: 700;
}

/* ── Detail Modal: Annotation ── */
.gene-id-val {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.05rem; font-weight: 700; color: var(--green-800);
}
.gene-sym-val {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 1rem; font-weight: 600; color: var(--green-700);
}
.func-desc { font-size: .88rem; line-height: 1.7; color: var(--gray-700); }
.blast-info { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .8rem; color: var(--gray-500); }

.tair-link-lg {
  display: inline-flex; align-items: center; gap: 4px;
  color: #1e40af; font-weight: 600; text-decoration: none;
  padding: 3px 0; border-bottom: 2px solid transparent;
  transition: border-color .15s;
}
.tair-link-lg:hover { border-bottom-color: #1e40af; }

/* GO annotations */
.go-section {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 8px 0; border-top: 1px solid var(--gray-100);
}
.go-section:first-of-type { border-top: 1px solid var(--gray-200); margin-top: 4px; }
.go-label {
  flex-shrink: 0; min-width: 100px;
  font-size: .72rem; font-weight: 700; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .03em;
  padding-top: 1px;
}
.go-text { font-size: .84rem; line-height: 1.65; color: var(--gray-600); }

/* ── Pagination ── */
.pagination { display: flex; justify-content: center; align-items: center; gap: 4px; margin-top: 20px; }
.page-btn {
  padding: 8px 14px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
  background: var(--white); cursor: pointer; font-size: .88rem; color: var(--gray-700);
  transition: background .1s;
}
.page-btn:hover:not(:disabled) { background: var(--gray-100); }
.page-btn.active { background: var(--green-700); color: var(--white); border-color: var(--green-700); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-info { padding: 0 12px; font-size: .88rem; color: var(--gray-500); }

/* ── Loading ── */
.loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 0; color: var(--gray-500); }
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--gray-200);
  border-top-color: var(--green-600); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 64px 16px; color: var(--gray-500); }
.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.2rem; color: var(--gray-700); margin-bottom: 8px; }
.quick-links { margin-top: 20px; font-size: .9rem; }
.quick-link {
  display: inline-block; margin: 0 6px; padding: 4px 12px;
  background: var(--green-50); color: var(--green-700);
  border-radius: 20px; text-decoration: none; font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: .85rem; transition: background .15s;
}
.quick-link:hover { background: var(--green-100); }

/* ── Error State ── */
.error-state { text-align: center; padding: 64px 16px; }
.error-icon { font-size: 3rem; margin-bottom: 16px; }
.error-state h3 { color: var(--red-500); margin-bottom: 8px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
}
.modal {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); max-width: 560px; width: 100%; max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--gray-200);
}
.modal-header h2 { font-size: 1.15rem; color: var(--green-900); }
.modal-close {
  width: 32px; height: 32px; border: none; background: none;
  font-size: 1.4rem; cursor: pointer; color: var(--gray-400);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--gray-200);
  display: flex; gap: 8px; justify-content: flex-end;
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-item label { display: block; font-size: .78rem; color: var(--gray-500); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.detail-item .val { font-weight: 500; word-break: break-all; }
.detail-full { grid-column: 1 / -1; }

/* ── Toast ── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  font-size: .9rem; animation: slideIn .25s ease-out;
  max-width: 380px;
}
.toast-success { background: var(--green-700); color: var(--white); }
.toast-error { background: var(--red-500); color: var(--white); }
.toast-info { background: var(--gray-800); color: var(--white); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Footer ── */
.footer {
  text-align: center; padding: 24px 16px; color: var(--gray-400);
  font-size: .82rem; border-top: 1px solid var(--gray-200);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .hero-inner h1 { font-size: 1.4rem; }
  .search-filters { flex-direction: column; }
  .gene-table { font-size: .82rem; }
  .gene-table th, .gene-table td { padding: 8px 10px; }
  .detail-grid { grid-template-columns: 1fr; }
  .results-header { flex-direction: column; align-items: flex-start; }
}
