:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #151922;
  --muted: #5f6878;
  --line: #d9dee8;
  --accent: #ba1b1d;
  --accent-dark: #8f1114;
  --shadow: 0 18px 50px rgba(21, 25, 34, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.tool-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

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

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.primary-btn {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

.primary-btn:hover:not(:disabled) {
  background: var(--accent-dark);
}

.primary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

.file-drop {
  display: grid;
  gap: 6px;
  min-height: 88px;
  align-content: center;
  border: 1px dashed #b6bfce;
  border-radius: 8px;
  padding: 14px;
  background: #fbfcff;
  cursor: pointer;
}

.file-drop:hover {
  border-color: var(--accent);
}

.file-drop span,
.settings-row label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.file-drop strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.file-drop input {
  display: none;
}

.settings-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.settings-row label {
  display: grid;
  gap: 6px;
}

.settings-row input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: white;
  color: var(--ink);
}

.noise-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px auto;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.switch-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #fff 0%, #f8fbff 100%);
  cursor: pointer;
}

.switch-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  position: relative;
  width: 54px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #c7cedb;
  pointer-events: none;
  transition:
    background 160ms ease,
    box-shadow 160ms ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(21, 25, 34, 0.25);
  transition: transform 160ms ease;
}

.switch-card input:checked + .switch {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(186, 27, 29, 0.12);
}

.switch-card input:checked + .switch::after {
  transform: translateX(24px);
}

.switch-card strong {
  display: block;
  font-size: 14px;
}

.switch-card small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.compact-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.compact-field input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: white;
  color: var(--ink);
}

.status-pill {
  justify-self: end;
  border: 1px solid #cbd4e3;
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: #fbfcff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.ready {
  border-color: rgba(36, 128, 86, 0.35);
  color: #17633f;
  background: #eefaf4;
}

.status-pill.busy {
  border-color: rgba(186, 27, 29, 0.35);
  color: var(--accent-dark);
  background: #fff4f4;
}

.preview-wrap {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background:
    linear-gradient(45deg, #d8d8d8 25%, transparent 25%) 0 0 / 24px 24px,
    linear-gradient(45deg, transparent 75%, #d8d8d8 75%) 0 0 / 24px 24px,
    linear-gradient(45deg, transparent 75%, #d8d8d8 75%) 12px 12px / 24px 24px,
    linear-gradient(45deg, #d8d8d8 25%, #f7f7f7 25%) 12px 12px / 24px 24px;
  overflow: auto;
}

canvas {
  display: block;
  width: min(100%, 820px);
  height: auto;
  margin: 0 auto;
}

@media (max-width: 760px) {
  .brand-row,
  .control-grid,
  .settings-row,
  .noise-row {
    grid-template-columns: 1fr;
  }

  .brand-row {
    display: grid;
  }

  .status-pill {
    justify-self: stretch;
    text-align: center;
  }
}
