:root {
  color-scheme: light;
  --ink: #19202a;
  --muted: #6b7280;
  --line: #d9dee8;
  --panel: #ffffff;
  --surface: #f5f7fb;
  --accent: #2364aa;
  --accent-2: #0f8f72;
  --rose: #c94f70;
  --gold: #b88219;
  --shadow: 0 18px 44px rgba(22, 31, 46, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    linear-gradient(90deg, rgba(35, 100, 170, 0.08), transparent 33%),
    linear-gradient(180deg, #f8fafc, #eef2f7);
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(420px, 1fr) minmax(300px, 380px);
  gap: 16px;
  min-height: 100vh;
  padding: 16px;
}

.left-rail,
.right-rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 4px 2px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 26px rgba(35, 100, 170, 0.22);
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.status-dot,
#confidence,
#filterSummary,
#stepCount {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 7px;
  min-height: 150px;
  border: 1px dashed #aeb8c8;
  border-radius: 8px;
  color: var(--muted);
  background:
    linear-gradient(135deg, rgba(15, 143, 114, 0.08), rgba(35, 100, 170, 0.08)),
    #fbfcff;
}

.drop-zone input {
  display: none;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  font-size: 24px;
  background: var(--accent);
}

.drop-zone strong {
  color: var(--ink);
  font-size: 15px;
}

.drop-zone small {
  font-size: 12px;
}

textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fbfcff;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 100, 170, 0.16);
}

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

.preset-grid button,
.ghost-btn {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

.primary-btn {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #17456f);
}

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #111827;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(330px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  min-height: 36px;
  color: var(--muted);
  background: #fff;
  border-right: 1px solid var(--line);
}

.segmented button:last-child {
  border-right: 0;
}

.segmented .active {
  color: #fff;
  background: var(--ink);
}

.actions {
  display: flex;
  gap: 8px;
}

.tool-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  background: var(--accent-2);
}

.tool-btn:first-child {
  background: #273a66;
}

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 560px;
  padding: 18px;
  background:
    linear-gradient(45deg, #151a22 25%, transparent 25%),
    linear-gradient(-45deg, #151a22 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #151a22 75%),
    linear-gradient(-45deg, transparent 75%, #151a22 75%),
    #111827;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

canvas {
  width: 100%;
  max-width: 1120px;
  max-height: calc(100vh - 110px);
  aspect-ratio: 16 / 11;
  border-radius: 8px;
  background: #d9e4ee;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
}

.empty-state {
  position: absolute;
  display: grid;
  gap: 8px;
  place-items: center;
  text-align: center;
  color: #fff;
  pointer-events: none;
}

.empty-state span {
  color: #9cc7ff;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.empty-state strong {
  max-width: 280px;
  font-size: 20px;
  line-height: 1.35;
}

.assistant-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: 86px;
  padding: 12px;
  border-radius: 8px;
  color: #263241;
  background: #f6f8fb;
}

.assistant-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
}

.assistant-orb {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--rose);
}

.sliders-panel {
  display: grid;
  gap: 10px;
}

.sliders-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.plan-list {
  display: grid;
  gap: 8px;
  max-height: 250px;
  margin: 0;
  padding-left: 22px;
  overflow: auto;
}

.plan-list li {
  padding: 8px 10px;
  border-radius: 8px;
  color: #263241;
  font-size: 13px;
  line-height: 1.35;
  background: #f6f8fb;
}

.code-panel {
  min-height: 180px;
}

pre {
  max-height: 240px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #dbeafe;
  border-radius: 8px;
  padding: 12px;
  background: #111827;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 310px minmax(360px, 1fr);
  }

  .right-rail {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .topbar {
    flex-direction: column;
  }

  .segmented {
    width: 100%;
  }

  .right-rail {
    display: flex;
  }

  .canvas-wrap {
    min-height: 390px;
    padding: 10px;
  }

  canvas {
    max-height: 62vh;
  }
}
