/* ===========================================================
   Scrape-Verse Edge Console — field-terminal theme
   =========================================================== */

@import url('https://cdnjs.cloudflare.com/ajax/libs/JetBrains-Mono/2.304/font.css');

:root {
  --bg: #0B0E0C;
  --bg-raised: #12160F;
  --bg-input: #0F130D;
  --line: #263025;
  --amber: #FFB000;
  --amber-dim: #8A6103;
  --green: #6FCF97;
  --red: #FF5C5C;
  --text: #E4E8DE;
  --text-dim: #8C9484;
  --radius: 3px;
  --mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  height: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* subtle CRT scanline overlay — signature element */
.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 176, 0, 0.015) 0px,
    rgba(255, 176, 0, 0.015) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-glyph {
  color: var(--amber);
  font-size: 22px;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(255, 176, 0, 0.4);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-size: 14px; font-weight: 700; letter-spacing: 2px; }
.brand-sub { font-size: 10px; color: var(--text-dim); letter-spacing: 0.5px; }

.status-cluster { display: flex; align-items: center; gap: 12px; }

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 10px;
  letter-spacing: 1px;
}
.status-pill .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red);
}
.status-pill[data-state="online"] .dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-pill[data-state="online"] .label { color: var(--green); }
.status-pill[data-state="offline"] .label { color: var(--red); }

.icon-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  width: 32px; height: 32px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 16px;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { border-color: var(--amber); color: var(--amber); }

/* ---------- layout ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  padding: 16px;
  min-height: 0;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.control-panel {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-self: start;
}

.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}
.field-group label .opt { color: #5A6154; letter-spacing: 0; text-transform: none; }

input[type="text"], input[type="number"], textarea, select {
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 1px rgba(255, 176, 0, 0.25);
}

/* translucent placeholder styling, required for the system prompt field */
::placeholder {
  color: rgba(228, 232, 222, 0.32);
  opacity: 1;
}
#systemPrompt::placeholder {
  color: rgba(255, 176, 0, 0.28);
  font-style: italic;
}

textarea { resize: vertical; min-height: 120px; line-height: 1.5; }

.run-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--amber);
  color: #1A1300;
  border: none;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  padding: 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease;
}
.run-btn:hover { filter: brightness(1.12); }
.run-btn:active { transform: translateY(1px); }
.run-btn:disabled { filter: grayscale(0.6) brightness(0.7); cursor: not-allowed; }
.run-btn-glyph { font-size: 11px; }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  padding: 5px 10px;
  border-radius: var(--radius);
  cursor: pointer;
}
.ghost-btn:hover { color: var(--amber); border-color: var(--amber); }

.meta-readout {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
}
.meta-row span:last-child { color: var(--text); font-weight: 700; }

/* ---------- terminal ---------- */
.terminal-wrap {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}

.terminal {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  font-size: 12.5px;
  line-height: 1.65;
  min-height: 320px;
}

.log-line { display: flex; gap: 10px; margin-bottom: 2px; animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }

.log-time { color: #5A6154; flex-shrink: 0; }
.log-tag { flex-shrink: 0; width: 66px; font-weight: 700; }
.log-tag.info { color: #7FB0FF; }
.log-tag.ok { color: var(--green); }
.log-tag.warn { color: var(--amber); }
.log-tag.err { color: var(--red); }
.log-tag.heal {
  color: #1A1300;
  background: var(--amber);
  padding: 0 4px;
  border-radius: 2px;
  animation: pulseHeal 1.1s ease-in-out;
}
@keyframes pulseHeal {
  0% { box-shadow: 0 0 0 rgba(255, 176, 0, 0); }
  30% { box-shadow: 0 0 10px rgba(255, 176, 0, 0.7); }
  100% { box-shadow: 0 0 0 rgba(255, 176, 0, 0); }
}
.log-msg { color: var(--text); word-break: break-word; }

/* ---------- settings overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 3, 0.7);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.overlay[hidden] {
  display: none !important;
}

.settings-panel {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.settings-head h2 { font-size: 14px; margin: 0; letter-spacing: 1px; }

/* ---------- tablet optimization (Galaxy Tab A9+ ~ 1340x800 css px landscape) ---------- */
@media (min-width: 900px) and (max-width: 1400px) {
  .layout { grid-template-columns: 340px 1fr; padding: 20px; gap: 20px; }
  .terminal { font-size: 13.5px; }
}
