:root {
  --bg-1: #0d1020;
  --bg-2: #161d33;
  --bg-3: #1f2742;
  --glass: rgba(255, 255, 255, 0.12);
  --glass-strong: rgba(255, 255, 255, 0.2);
  --text-main: #edf3ff;
  --text-soft: #c8d4ef;
  --text-dim: #9eb3d8;
  --accent: #6edbff;
  --accent-2: #8b7cff;
  --danger: #ff7f97;
  --ok: #67ef97;
  --warn: #ff9b78;
  --radius: 20px;
  --shadow: 0 20px 50px rgba(5, 10, 30, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 15% 20%, rgba(110, 219, 255, 0.35), transparent 35%),
    radial-gradient(circle at 90% 10%, rgba(139, 124, 255, 0.3), transparent 30%),
    radial-gradient(circle at 65% 80%, rgba(140, 102, 255, 0.25), transparent 35%),
    linear-gradient(150deg, var(--bg-1) 0%, var(--bg-2) 45%, #101827 100%);
  padding: 28px 16px 32px;
}

.app-shell {
  max-width: 1040px;
  margin: 0 auto;
}

.hero {
  margin: 0 0 16px;
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.08));
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 3.2vw, 38px);
  letter-spacing: 0.4px;
}

h3 {
  margin: 0 0 12px;
  font-size: 18px;
  color: #f5f8ff;
}

.hero-tag {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 700;
}

.row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.action-row {
  margin-bottom: 12px;
}

.mt-12 {
  margin-top: 12px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(110, 219, 255, 0.45);
  color: #d6f3ff;
  font-size: 11px;
  background: rgba(110, 219, 255, 0.15);
  text-transform: lowercase;
}

.chip-ok {
  border-color: rgba(103, 239, 151, 0.55);
  background: rgba(103, 239, 151, 0.16);
  color: #dfffea;
}

.chip-warn {
  border-color: rgba(255, 155, 120, 0.55);
  background: rgba(255, 155, 120, 0.16);
  color: #ffe9df;
}

.card {
  background: linear-gradient(140deg, var(--glass), rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  margin-bottom: 16px;
  backdrop-filter: blur(16px) saturate(130%);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  box-shadow: var(--shadow);
}

label {
  display: block;
  margin: 0 0 6px;
  color: var(--text-soft);
  font-size: 12px;
}

.field {
  min-width: 220px;
  flex: 1;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--text-dim);
}

.req {
  color: var(--warn);
  font-weight: 700;
}

.select-wrap {
  position: relative;
}

.select-wrap select {
  background: rgba(255, 255, 255, 0.09);
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid rgba(237, 243, 255, 0.85);
  border-bottom: 2px solid rgba(237, 243, 255, 0.85);
  transform: translateY(-60%) rotate(45deg);
  pointer-events: none;
}

input,
select,
button,
textarea {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  font-size: 14px;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.09);
}

input,
select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#altKeywords,
#metaNotes {
  width: 100%;
  min-height: 132px;
  padding: 12px;
  resize: vertical;
  outline: none;
  line-height: 1.45;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input::placeholder {
  color: rgba(216, 228, 252, 0.65);
}

textarea::placeholder {
  color: rgba(216, 228, 252, 0.65);
}

select {
  appearance: none;
  padding-right: 36px;
  color: var(--text-main);
}

select option {
  color: #0f172a;
  background: #ffffff;
}

select:invalid {
  color: rgba(230, 237, 252, 0.65);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110, 219, 255, 0.2);
  background: rgba(255, 255, 255, 0.12);
}

input.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 127, 151, 0.2);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.08);
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-ui {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  position: relative;
  transition: background 0.2s ease;
}

.switch-ui::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-ui {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.switch input:checked + .switch-ui::before {
  transform: translateX(20px);
}

.switch-text {
  color: var(--text-soft);
  font-size: 12px;
}

button {
  cursor: pointer;
  height: 42px;
  padding: 0 16px;
  font-weight: 600;
  border-color: rgba(255, 255, 255, 0.3);
  background: linear-gradient(120deg, rgba(110, 219, 255, 0.22), rgba(139, 124, 255, 0.2));
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(53, 113, 186, 0.35);
  background: linear-gradient(120deg, rgba(110, 219, 255, 0.3), rgba(139, 124, 255, 0.3));
}

button:active {
  transform: translateY(0);
}

button.btn-secondary {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.22);
}

button.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

button:disabled,
input:disabled,
select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.maintenance summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: #dce8ff;
  padding: 2px 0;
}

.maintenance summary::-webkit-details-marker {
  display: none;
}

.maintenance summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  transform: translateY(-1px);
  transition: transform 0.2s ease;
  color: var(--accent);
}

.maintenance[open] summary::before {
  transform: rotate(90deg) translateX(1px);
}

#log {
  width: 100%;
  height: 320px;
  resize: vertical;
  padding: 14px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  background: rgba(4, 10, 22, 0.56);
  color: #d6f5e2;
}

#jsonEditor {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  padding: 14px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  background: rgba(4, 10, 22, 0.56);
  color: #dff0ff;
}

.muted {
  color: var(--text-soft);
  font-size: 12px;
  margin: 6px 0;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 8, 24, 0.58);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.modal-overlay.is-open {
  display: flex;
}

.modal-card {
  width: min(900px, 100%);
  max-height: 88vh;
  overflow: auto;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.08));
  box-shadow: var(--shadow);
  padding: 16px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

#promptPreview {
  width: 100%;
  min-height: 380px;
  resize: vertical;
  padding: 14px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  background: rgba(4, 10, 22, 0.56);
  color: #dff0ff;
  margin-top: 8px;
  margin-bottom: 12px;
}

@media (max-width: 760px) {
  .card-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .field {
    min-width: 100%;
  }
  .switch {
    width: 100%;
  }
}
