:root {
  --bg: #040913;
  --card: rgba(10, 18, 36, 0.9);
  --panel: rgba(8, 14, 30, 0.86);
  --panel-strong: rgba(12, 22, 44, 0.94);
  --accent: #3b82f6;
  --accent-strong: #60a5fa;
  --text: #eaf2ff;
  --muted: #a9bddb;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --danger: #ff6b6b;
  --radius: 14px;
  --shadow: 0 20px 60px rgba(0,0,0,0.45);
  --bg-pattern: radial-gradient(circle at 18% 16%, rgba(59,130,246,0.14), transparent 34%),
                radial-gradient(circle at 80% 12%, rgba(96,165,250,0.12), transparent 38%),
                radial-gradient(circle at 52% 70%, rgba(30,64,175,0.2), transparent 44%),
                linear-gradient(140deg, #040913, #0a1430 55%, #040913);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

body.theme-dark {
  --bg: #040913;
  --card: rgba(10, 18, 36, 0.9);
  --panel: rgba(8, 14, 30, 0.86);
  --panel-strong: rgba(12, 22, 44, 0.94);
  --accent: #3b82f6;
  --accent-strong: #60a5fa;
  --text: #eaf2ff;
  --muted: #a9bddb;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --shadow: 0 20px 60px rgba(0,0,0,0.45);
  --bg-pattern: radial-gradient(circle at 18% 16%, rgba(59,130,246,0.14), transparent 34%),
                radial-gradient(circle at 80% 12%, rgba(96,165,250,0.12), transparent 38%),
                radial-gradient(circle at 52% 70%, rgba(30,64,175,0.2), transparent 44%),
                linear-gradient(140deg, #040913, #0a1430 55%, #040913);
}

body.theme-day {
  --bg: #0b1222;
  --card: rgba(16, 30, 58, 0.94);
  --panel: rgba(12, 24, 46, 0.88);
  --panel-strong: rgba(18, 36, 70, 0.96);
  --accent: #2563eb;
  --accent-strong: #3b82f6;
  --text: #f2f7ff;
  --muted: #b8c6e6;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  --bg-pattern: linear-gradient(135deg, #0b1222, #132040 50%, #0b1222);
}

body.theme-ocean {
  --bg: #030b18;
  --card: rgba(8, 20, 40, 0.92);
  --panel: rgba(6, 16, 32, 0.9);
  --panel-strong: rgba(10, 26, 50, 0.95);
  --accent: #38bdf8;
  --accent-strong: #60a5fa;
  --text: #e8f5ff;
  --muted: #a7c8e6;
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.2);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
  --bg-pattern: radial-gradient(circle at 15% 20%, rgba(56,189,248,0.14), transparent 38%),
                radial-gradient(circle at 80% 25%, rgba(96,165,250,0.12), transparent 44%),
                linear-gradient(145deg, #030b18, #07152b 58%, #030b18);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 16px;
  background: var(--bg-pattern);
  color: var(--text);
  padding: 28px 16px 52px;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: -40px;
  pointer-events: none;
  background: radial-gradient(circle at 30% 30%, rgba(255,48,48,0.12), transparent 40%),
              radial-gradient(circle at 82% 20%, rgba(255,77,77,0.12), transparent 42%),
              radial-gradient(circle at 58% 78%, rgba(120,24,32,0.16), transparent 48%);
  filter: blur(46px);
  z-index: 0;
}

.layout {
  width: min(960px, 95vw);
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 4px;
  position: relative;
  z-index: 1;
}

.card {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.hero-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  overflow: hidden;
}
.hero-card > * { position: relative; z-index: 1; }
.hero-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255,48,48,0.12), rgba(120,24,32,0.14));
  opacity: 0.8;
  pointer-events: none;
}
.hero-card h1 {
  margin: 4px 0 6px;
  font-size: 2.6rem;
  letter-spacing: -0.015em;
  font-weight: 800;
  line-height: 1.12;
}
.hero-card .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  color: var(--accent);
  margin: 0 0 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
header .eyebrow.small {
  letter-spacing: 0.12em;
  font-size: 0.62rem;
}
.alpha-badge {
  position: relative;
  display: grid;
  place-items: center;
  padding: 18px 20px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255,48,48,0.22), rgba(120,24,32,0.18));
  border: 1px solid var(--border-strong);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
  min-width: 180px;
  text-align: center;
}
.alpha-badge span {
  display: block;
  font-size: 1.6rem;
  letter-spacing: 0.38em;
  font-weight: 900;
  text-transform: uppercase;
  color: #fff2f2;
}
.muted { color: var(--muted); }
.muted.small { font-size: 0.88rem; }

.pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  border: 1px solid var(--border-strong);
  background: rgba(255,48,48,0.12);
  color: var(--text);
}
.pill.success {
  border-color: transparent;
  background: rgba(255,48,48,0.28);
  color: #0a0304;
  font-weight: 700;
}
.pill.outline {
  background: transparent;
  color: var(--muted);
}

.theme-switcher {
  display: flex;
  gap: 8px;
  align-items: center;
}
.theme-btn {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.theme-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #0a0304;
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(0,0,0,0.2);
}
.theme-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.context-card {
  border-style: dashed;
}
.context-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.context-title {
  font-size: 1.2rem;
  font-weight: 700;
}
.context-subtitle {
  color: var(--muted);
  margin-top: 2px;
}
.context-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--panel-strong);
  border: 1px solid var(--border-strong);
  font-size: 0.9rem;
}
.badge.success { background: rgba(255,48,48,0.2); color: #0a0304; border-color: transparent; }
.badge.warning { background: rgba(255,99,99,0.22); color: #0a0304; border-color: transparent; }

form { margin-top: 18px; }

.file-box {
  display: block;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--panel);
  cursor: pointer;
  transition: border 0.2s, background 0.2s, transform 0.08s ease;
}
.file-box:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.file-box.dragover {
  border-color: var(--accent-strong);
  background: var(--panel-strong);
}
.file-box-content {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  align-items: center;
}
.icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255,48,48,0.18);
  font-size: 1.4rem;
}
#file-name {
  font-weight: 600;
}

.file-list {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 10px 12px;
  max-height: 260px;
  overflow-y: auto;
}
.file-list.empty {
  color: var(--muted);
  font-style: italic;
}
.file-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}
.file-item:last-child { border-bottom: none; }
.file-title { font-weight: 600; word-break: break-word; }
.file-meta {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span {
  font-size: 0.9rem;
  color: var(--muted);
}

.field input {
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.98rem;
}

.field input:focus {
  outline: 1px solid var(--accent);
}

.actions {
  display: flex;
  gap: 10px;
  margin: 18px 0 10px;
}
button {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.2s;
}
button#submit-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #0a0304;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(255,48,48,0.22);
}
button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border-strong);
}
button:active { transform: translateY(1px); }
button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  box-shadow: none;
}
button.active {
  background: var(--accent);
  color: #0a0304;
  border-color: transparent;
}

.status {
  min-height: 22px;
  font-size: 0.95rem;
  color: var(--muted);
}
.status.success { color: var(--accent); }
.status.error { color: var(--danger); }

.helper {
  margin: 6px 0 4px;
  padding: 12px;
  border-radius: 12px;
  border: 1px dashed var(--border-strong);
  background: rgba(255,48,48,0.08);
}
.helper small { display: block; margin-top: 4px; }

progress {
  width: 100%;
  accent-color: var(--accent);
  margin-top: 8px;
  height: 10px;
}

.preview-card {
  margin-top: 18px;
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
}
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.preview-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.preview-table {
  margin-top: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  max-height: 360px;
  overflow-y: auto;
  overflow-x: auto;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}
.preview-table table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}
.preview-table th,
.preview-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  text-align: left;
  background: var(--card);
}
.preview-table th {
  position: sticky;
  top: 0;
  background: var(--panel-strong);
  z-index: 2;
  color: var(--text);
}
.preview-table tr:nth-child(even) td {
  background: rgba(255,255,255,0.02);
}
.preview-table input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  font-size: 0.9rem;
}
.preview-table input:focus {
  outline: 1px solid var(--accent);
}
.compact th, .compact td { padding: 6px 8px; font-size: 0.88rem; }
.sticky-col {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--panel-strong);
}
.preview-table td.sticky-col { background: var(--card); }

.logs-card {
  border: 1px dashed rgba(255,255,255,0.08);
  background: linear-gradient(180deg, var(--panel), var(--panel-strong));
}
.logs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.log-list {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  padding: 10px 12px;
  max-height: 220px;
  overflow-y: auto;
  font-family: "SFMono-Regular", ui-monospace, monospace;
  font-size: 0.9rem;
}
.log-list.empty { color: var(--muted); font-style: italic; }
.log-item { padding: 6px 4px; border-bottom: 1px solid var(--border); }
.log-item:last-child { border-bottom: none; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 99;
}
.overlay.hidden { display: none; }
.overlay-content {
  width: min(1100px, 95vw);
  height: min(90vh, 900px);
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 10px;
}
.overlay-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.overlay-table {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.overlay-title { font-weight: 700; }

.hidden { display: none; }

.footer {
  margin: 8px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

@media (max-width: 620px) {
  .actions { flex-direction: column; }
  .theme-switcher { width: 100%; justify-content: space-between; }
  .preview-actions { width: 100%; flex-direction: column; }
  .preview-table table { min-width: auto; }
  .context-actions { width: 100%; justify-content: flex-start; }
}
