:root {
  color-scheme: dark;
  --bg: #0a1020;
  --card: rgba(18, 28, 54, 0.86);
  --card-strong: rgba(24, 37, 70, 0.95);
  --text: #f4f7fb;
  --muted: #9aa8c7;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #e94560;
  --accent-2: #4ecca3;
  --warning: #f5a623;
  --danger: #ff6b6b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  background:
    radial-gradient(circle at top left, rgba(233, 69, 96, 0.22), transparent 34rem),
    radial-gradient(circle at top right, rgba(78, 204, 163, 0.18), transparent 30rem),
    linear-gradient(135deg, #080c18 0%, #0f1832 52%, #11172b 100%);
  color: var(--text);
  overflow-x: hidden;
}

button, input, textarea, select { font: inherit; }
button { border: 0; }

.app-shell {
  width: min(1180px, calc(100vw - 28px));
  min-height: 100svh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 0 max(14px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: clamp(18px, 3vw, 26px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  font-weight: 800;
}

h1, h2 { margin: 0; }
h1 { font-size: clamp(1.8rem, 4vw, 3.25rem); line-height: 1; }
h2 { font-size: 1.05rem; }

.subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  max-width: 760px;
}

.tutorial-card {
  padding: clamp(16px, 2.4vw, 20px);
}

.tutorial-head {
  margin-bottom: 12px;
}

.tutorial-list {
  margin: 0;
  padding-left: 1.3rem;
  color: var(--muted);
  line-height: 1.55;
}

.tutorial-list li + li {
  margin-top: 6px;
}

.tutorial-list strong {
  color: var(--text);
}

.status-pill {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(78, 204, 163, 0.12);
  color: var(--accent-2);
  border: 1px solid rgba(78, 204, 163, 0.28);
  font-weight: 800;
  text-align: center;
}

.status-pill.busy {
  color: var(--warning);
  background: rgba(245, 166, 35, 0.12);
  border-color: rgba(245, 166, 35, 0.32);
}

.status-pill.error {
  color: var(--danger);
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.32);
}

.grid-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: clamp(16px, 2.4vw, 20px);
}

.input-panel,
.output-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.grow-field {
  flex: 1;
  min-height: 110px;
}

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

input[type="text"], textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(5, 10, 24, 0.72);
  color: var(--text);
  outline: none;
  padding: 12px 13px;
}

textarea {
  min-height: clamp(120px, 18svh, 230px);
  height: auto;
  resize: vertical;
  font-family: "Cascadia Code", Consolas, monospace;
  line-height: 1.45;
}

input:focus, textarea:focus {
  border-color: rgba(233, 69, 96, 0.74);
  box-shadow: 0 0 0 4px rgba(233, 69, 96, 0.12);
}

.file-drop {
  display: grid;
  place-items: center;
  gap: 6px;
  text-align: center;
  border: 1px dashed rgba(255, 255, 255, 0.26);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  padding: clamp(16px, 3vw, 22px);
  cursor: pointer;
  margin-bottom: 14px;
  transition: 0.18s ease;
}

.file-drop:hover,
.file-drop.dragover {
  border-color: var(--accent-2);
  background: rgba(78, 204, 163, 0.08);
}

.file-drop input { display: none; }
.file-icon { font-size: 2rem; }
.file-drop small { color: var(--muted); }

.disclaimer {
  margin: 0 0 16px;
  border: 1px solid rgba(245, 166, 35, 0.28);
  border-radius: 16px;
  padding: 12px;
  color: var(--warning);
  background: rgba(245, 166, 35, 0.09);
  font-size: 0.9rem;
  line-height: 1.45;
}

.actions, .button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button, .secondary-button, .ghost-button {
  cursor: pointer;
  border-radius: 13px;
  font-weight: 900;
  transition: transform 0.14s ease, opacity 0.14s ease, background 0.14s ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover { transform: translateY(-1px); }

.primary-button:disabled {
  opacity: 0.58;
  cursor: wait;
  transform: none;
}

.primary-button {
  padding: 13px 18px;
  color: white;
  background: linear-gradient(135deg, var(--accent), #ff7a59);
}

.secondary-button {
  padding: 13px 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.ghost-button {
  padding: 9px 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.075);
}

.summary {
  border: 1px solid var(--line);
  background: rgba(78, 204, 163, 0.07);
  color: var(--accent-2);
  border-radius: 15px;
  padding: 12px;
  margin-bottom: 12px;
  font-weight: 800;
}

.summary.error {
  color: var(--danger);
  background: rgba(255, 107, 107, 0.09);
}

.summary.warn {
  color: var(--warning);
  background: rgba(245, 166, 35, 0.09);
}

.output {
  flex: 1;
  min-height: clamp(180px, 28svh, 360px);
  max-height: calc(100svh - 360px);
  margin: 0;
  white-space: pre;
  overflow: auto;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(2, 6, 16, 0.78);
  color: #93ffd9;
  padding: 14px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: clamp(0.78rem, 1.8vw, 0.88rem);
  line-height: 1.45;
}

.log-box {
  margin-top: 12px;
  color: var(--muted);
}

.log-box summary {
  cursor: pointer;
  font-weight: 800;
}

.log-box pre {
  white-space: pre-wrap;
  overflow: auto;
  max-height: 180px;
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.045);
}

@media (max-width: 960px) {
  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-pill { width: 100%; }

  .grid-layout {
    grid-template-columns: 1fr;
  }

  .output {
    max-height: none;
    min-height: clamp(180px, 28svh, 360px);
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100vw - 18px, 1180px);
    gap: 10px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .hero,
  .panel {
    border-radius: 18px;
    padding: 16px;
  }

  .actions > button {
    width: 100%;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .button-row,
  .button-row button {
    width: 100%;
  }

  textarea {
    min-height: 22svh;
  }

  .output {
    min-height: 28svh;
  }
}
