:root {
  color-scheme: light;
  --ink: #0b1420;
  --muted-ink: #445366;
  --sand: #f4f5f7;
  --paper: #ffffff;
  --teal: #004b87;
  --teal-dark: #00325c;
  --coral: #ffcd00;
  --coral-soft: #ffe58a;
  --mint: #d7e7f6;
  --danger: #c4482f;
  --danger-soft: rgba(196, 72, 47, 0.12);
  --border: #d7dee7;
  --shadow: 0 20px 40px rgba(0, 33, 73, 0.16);
  --radius: 18px;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --display: "Space Grotesk", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--display);
  background: radial-gradient(circle at top left, #fff4c2 0%, #f6f6f2 35%, #e6f0f8 70%, #eef3f7 100%);
  color: var(--ink);
  min-height: 100vh;
}

.ambient {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 205, 0, 0.2), transparent 40%),
    radial-gradient(circle at 88% 18%, rgba(0, 75, 135, 0.18), transparent 38%),
    repeating-linear-gradient(120deg, rgba(0, 33, 73, 0.04) 0 1px, transparent 1px 14px);
  pointer-events: none;
  z-index: -1;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100vh;
  animation: float-in 600ms ease-out;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(320px, 2fr) minmax(200px, 1fr);
  gap: 18px;
  align-items: center;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 18px 22px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.topbar-privacy {
  grid-template-columns: 1fr;
}

.privacy-title {
  line-height: 1.2;
}

@media (min-width: 960px) {
  .privacy-title {
    white-space: nowrap;
  }
}

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

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--teal);
  color: white;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 999px;
  width: max-content;
}

.brand-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.brand-logo.lg {
  width: 64px;
  height: 64px;
}

.brand-logo.xl {
  width: 80px;
  height: 80px;
}

.title {
  font-size: 22px;
  font-weight: 600;
}

.subtitle {
  font-size: 13px;
  color: var(--muted-ink);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.controls label {
  font-size: 13px;
  color: var(--muted-ink);
}

.control-row {
  display: flex;
  gap: 10px;
}

input,
textarea,
select {
  font-family: var(--display);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 14px;
  background: white;
  color: var(--ink);
  width: 100%;
}

textarea {
  resize: vertical;
  min-height: 220px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  flex: 1;
}

button,
.file-btn {
  font-family: var(--display);
  border: 1px solid transparent;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border 160ms ease;
  font-weight: 600;
}

button:hover,
.file-btn:hover {
  transform: translateY(-1px);
}

.primary {
  background: var(--coral);
  color: var(--teal-dark);
  box-shadow: none;
}

.ghost {
  background: rgba(0, 75, 135, 0.06);
  color: var(--ink);
  border: 1px solid rgba(0, 75, 135, 0.14);
}

.compact {
  padding: 8px 12px;
  font-size: 12px;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.panes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  flex: 1;
}

.pane {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

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

.pane-head h2 {
  margin: 0;
  font-size: 18px;
}

.pane-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pane-actions .ghost {
  padding: 6px 12px;
  font-size: 12px;
}

.meta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted-ink);
}

.status {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 75, 135, 0.12);
  color: var(--teal-dark);
  font-weight: 600;
}

.status.warning {
  background: rgba(255, 205, 0, 0.2);
  color: #5a4300;
  border: 1px solid rgba(255, 205, 0, 0.6);
}

.status.idle {
  background: rgba(18, 22, 29, 0.08);
  color: var(--muted-ink);
}

.footer {
  display: flex;
  justify-content: center;
  margin-top: auto;
}

.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(900px, 100%);
  flex-wrap: wrap;
}

.footer-note {
  font-size: 12px;
  color: var(--muted-ink);
  max-width: 520px;
}

.footer-copy {
  font-size: 12px;
  color: var(--muted-ink);
}

.footer-link {
  font-size: 12px;
  color: var(--muted-ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.footer-link:hover {
  border-bottom-color: currentColor;
}

.error-banner {
  background: var(--danger-soft);
  border: 1px solid rgba(196, 72, 47, 0.45);
  color: #7a2b1d;
  padding: 12px 16px;
  border-radius: 12px;
  max-width: 900px;
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.4;
}

.warning-banner {
  background: rgba(255, 205, 0, 0.2);
  border-color: rgba(255, 205, 0, 0.6);
  color: #5a4300;
}

.banner-icon {
  color: #c88a00;
  font-weight: 700;
  line-height: 1;
  padding-top: 2px;
}

.cookie-banner {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(900px, 92vw);
  background: var(--paper);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 20;
}

.cookie-banner p {
  margin: 0;
  font-size: 13px;
  color: var(--muted-ink);
}

.cookie-banner a {
  color: var(--teal-dark);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.cookie-banner a:hover {
  border-bottom-color: currentColor;
}

.cookie-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.privacy-note {
  background: rgba(0, 75, 135, 0.08);
  border: 1px solid rgba(0, 75, 135, 0.25);
  color: var(--teal-dark);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12px;
}

@media (max-width: 720px) {
  .cookie-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .cookie-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 22, 29, 0.4);
  padding: 24px;
  z-index: 10;
}

.modal-card {
  background: var(--paper);
  border-radius: 20px;
  padding: 20px;
  width: min(520px, 90vw);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-card.wide {
  width: min(720px, 92vw);
}

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

.modal-head h3 {
  margin: 0;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted-ink);
}

.param-builder {
  background: rgba(15, 124, 127, 0.06);
  padding: 12px;
  border-radius: 14px;
  border: 1px dashed rgba(15, 124, 127, 0.3);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: auto;
  margin: 12px 0;
}

.param-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
}

.param-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(220px, 26vh);
  overflow-y: auto;
  padding-right: 4px;
}

.param-list:empty {
  display: none;
}

.param-builder:has(.param-list:empty) {
  padding-bottom: 10px;
}

.param-row {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 1.2fr 0.9fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.param-row input,
.param-row select {
  font-size: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.warnings-list {
  margin: 0;
  padding-left: 18px;
  max-height: min(280px, 40vh);
  overflow-y: auto;
  color: var(--muted-ink);
  font-size: 12px;
  line-height: 1.5;
}

@keyframes float-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

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

  .param-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
