:root {
  --ink: #172033;
  --muted: #667085;
  --line: rgba(91, 108, 134, 0.2);
  --panel: rgba(255, 255, 255, 0.72);
  --paper: rgba(255, 255, 255, 0.82);
  --blue: #2563eb;
  --teal: #0f9f8f;
  --rose: #d9466b;
  --amber: #d99000;
  --violet: #7c3aed;
  --green: #159947;
  color: #111827;
  background: #e9eef4;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: geometricPrecision;
}

* {
  box-sizing: border-box;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(83, 103, 135, 0.42) transparent;
}

*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(83, 103, 135, 0.38);
  background-clip: content-box;
}

body {
  margin: 0;
  min-width: 320px;
  overflow: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
  display: none;
}

body::before {
  inset: auto auto 0 0;
  width: 64vw;
  height: 36vh;
  background:
    linear-gradient(136deg, rgba(255, 255, 255, 0.34), transparent 34%),
    linear-gradient(160deg, rgba(236, 72, 153, 0.5), rgba(251, 146, 60, 0.36));
  clip-path: polygon(0 12%, 78% 0, 100% 100%, 0 100%);
  opacity: 0.72;
}

body::after {
  inset: 0 0 auto auto;
  width: 58vw;
  height: 34vh;
  clip-path: polygon(26% 0, 100% 0, 100% 100%, 0 70%);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.46), transparent 28%),
    linear-gradient(145deg, rgba(37, 99, 235, 0.38), rgba(20, 184, 166, 0.25));
  opacity: 0.78;
}

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

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(300px, 344px) minmax(520px, 1fr) minmax(304px, 336px);
  gap: 12px;
  height: 100vh;
  padding: 12px;
  overflow: hidden;
}

.panel {
  position: relative;
  align-self: stretch;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 14px;
  background: var(--panel);
  backdrop-filter: blur(22px) saturate(1.12);
  -webkit-backdrop-filter: blur(22px) saturate(1.12);
  padding: 15px;
  box-shadow: 0 10px 32px rgba(52, 70, 96, 0.08);
  animation: surface-in 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.style-panel {
  animation-delay: 80ms;
}

.brand {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 13px;
  border-bottom: 1px solid rgba(91, 108, 134, 0.14);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 33% 38%, #2dd4bf 0 8%, transparent 9%),
    radial-gradient(circle at 62% 62%, #e11d48 0 8%, transparent 9%),
    linear-gradient(135deg, #111827 0%, #23324d 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.38);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.12;
  letter-spacing: 0;
  color: var(--ink);
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.brand p,
.panel-head span,
.export-note,
.status-card span,
.rec span,
.dropzone span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

.field span {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

textarea,
select,
input {
  width: 100%;
  border: 1px solid rgba(130, 148, 178, 0.32);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

textarea:focus,
select:focus,
input:focus {
  border-color: rgba(76, 141, 246, 0.78);
  box-shadow: 0 0 0 4px rgba(76, 141, 246, 0.15);
}

textarea {
  min-height: 180px;
  resize: vertical;
  padding: 11px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
}

.mini-textarea {
  min-height: 86px;
  resize: vertical;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.35;
}

input[type="file"] {
  padding: 6px 8px;
}

select,
input {
  height: 38px;
  padding: 0 10px;
}

select[multiple] {
  height: auto;
  padding: 8px;
}

select[multiple] option {
  border-radius: 8px;
  padding: 7px 8px;
}

select[multiple] option:checked {
  background: linear-gradient(135deg, #1e3558, #4c8df6);
  color: #ffffff;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.style-panel .two-col {
  grid-template-columns: 1fr;
}

.style-panel .field input {
  min-width: 0;
}

.stage {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  min-width: 0;
  min-height: 0;
  height: calc(100vh - 24px);
  position: sticky;
  top: 12px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(22px) saturate(1.12);
  -webkit-backdrop-filter: blur(22px) saturate(1.12);
  padding: 9px 11px;
  box-shadow: 0 8px 26px rgba(52, 70, 96, 0.07);
  animation: surface-in 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.toolbar-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.style-select,
.segmented,
.actions,
.export-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.style-select {
  align-items: center;
  gap: 8px;
}

.style-select span {
  color: #344054;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.style-select select {
  min-width: 180px;
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-pills span,
.canvas-meta span {
  border: 1px solid rgba(130, 148, 178, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  color: #526071;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.export-bar {
  flex-wrap: nowrap;
  margin-left: auto;
}

button {
  min-height: 34px;
  border: 1px solid rgba(130, 148, 178, 0.34);
  border-radius: 8px;
  background: var(--paper);
  color: #172033;
  padding: 0 12px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

button:hover {
  border-color: rgba(76, 141, 246, 0.78);
  box-shadow: 0 5px 16px rgba(45, 70, 105, 0.12);
  transform: translateY(-1px);
}

.toggle:hover,
.color-swatch:hover {
  box-shadow: 0 5px 14px rgba(15, 23, 42, 0.1);
}

button.active {
  border-color: #172033;
  background: #172033;
  color: #ffffff;
}

.dropzone {
  display: grid;
  gap: 8px;
  align-content: center;
  min-height: 138px;
  margin-bottom: 12px;
  border: 1px dashed rgba(37, 99, 235, 0.42);
  border-radius: 12px;
  background: rgba(247, 250, 254, 0.82);
  padding: 14px;
  cursor: pointer;
  overflow: hidden;
}

.dropzone input {
  display: none;
}

.dropzone .embedded-input {
  display: block;
}

.dropzone strong {
  color: #0f172a;
  font-size: 20px;
  line-height: 1.15;
}

.drop-eyebrow {
  position: relative;
  z-index: 1;
  justify-self: start;
  border-radius: 6px;
  background: rgba(226, 235, 248, 0.82);
  color: #2453a6;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.drop-tags {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 6px;
}

.drop-tags b {
  border: 1px solid rgba(76, 141, 246, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  color: #526071;
  padding: 4px 8px;
  font-size: 11px;
}

.dropzone em {
  color: #526071;
  font-size: 12px;
  font-style: normal;
  line-height: 1.35;
}

.dropzone .embedded-input {
  position: relative;
  z-index: 1;
  height: 36px;
  margin-top: 4px;
  border-color: rgba(76, 141, 246, 0.22);
  background: rgba(255, 255, 255, 0.64);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.64);
}

.smart-dropzone::before {
  content: "";
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background:
    radial-gradient(circle at 30% 28%, #38d0c0 0 9%, transparent 10%),
    radial-gradient(circle at 66% 34%, #ff78a2 0 9%, transparent 10%),
    radial-gradient(circle at 48% 68%, #4c8df6 0 9%, transparent 10%),
    rgba(255, 255, 255, 0.74);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.smart-dropzone {
  position: relative;
}

.dropzone.dragover {
  border-color: #0ea5e9;
  background: #eff6ff;
}

.compact-editor {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}

.compact-editor summary {
  padding: 11px 12px;
  color: #344054;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.compact-editor textarea {
  min-height: 170px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
}

.status-card {
  display: grid;
  gap: 5px;
  margin: 12px 0 14px;
  border: 1px solid rgba(56, 208, 192, 0.34);
  border-radius: 8px;
  background: rgba(240, 251, 249, 0.78);
  padding: 11px 12px;
  box-shadow: inset 3px 0 0 #21b8a8;
}

.status-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-title {
  margin-bottom: 8px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.rec-list {
  display: grid;
  gap: 8px;
}

.quick-list,
.publisher-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.rec,
.quick,
.publisher {
  position: relative;
  display: grid;
  height: auto;
  min-height: 60px;
  justify-items: start;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  padding: 9px 11px;
  text-align: left;
  overflow: hidden;
}

.rec::before,
.quick::before,
.publisher::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 4px;
  background: var(--accent, var(--blue));
}

.rec:nth-of-type(2),
.quick:nth-of-type(2),
.publisher:nth-of-type(2) {
  --accent: var(--rose);
}

.rec:nth-of-type(3),
.quick:nth-of-type(3),
.publisher:nth-of-type(3) {
  --accent: var(--amber);
}

.rec:nth-of-type(4),
.quick:nth-of-type(4),
.publisher:nth-of-type(4) {
  --accent: var(--violet);
}

.quick:nth-of-type(5) {
  --accent: var(--green);
}

.rec strong,
.quick strong,
.publisher strong {
  font-size: 14px;
}

.quick,
.publisher {
  border-color: rgba(255, 255, 255, 0.58);
  background: rgba(255, 255, 255, 0.58);
}

.rec.active,
.quick.active,
.publisher.active {
  border-color: #172033;
  background: #172033;
  color: #ffffff;
}

.rec.active span,
.quick.active span,
.publisher.active span {
  color: rgba(255, 255, 255, 0.78);
}

.export-bar select {
  min-width: 150px;
}

.export-bar button {
  min-width: 62px;
  white-space: nowrap;
}

.canvas-wrap {
  position: relative;
  display: grid;
  min-height: 520px;
  height: 100%;
  align-content: center;
  align-items: center;
  justify-items: center;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 14px;
  background: rgba(247, 249, 252, 0.78);
  backdrop-filter: blur(22px) saturate(1.08);
  -webkit-backdrop-filter: blur(22px) saturate(1.08);
  padding: 24px 20px 42px;
  box-shadow: none;
  animation: surface-in 440ms 40ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.canvas-wrap::before {
  content: "";
  position: absolute;
  inset: 16px;
  border: 1px solid rgba(130, 148, 178, 0.14);
  border-radius: 10px;
  pointer-events: none;
}

#figureSvg {
  position: relative;
  z-index: 1;
  display: block;
  width: min(100%, 980px);
  height: auto;
  max-height: calc(100vh - 210px);
  object-fit: contain;
  background: var(--figure-bg);
  box-shadow: 0 0 0 1px rgba(105, 120, 143, 0.18);
  animation: figure-enter 360ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.canvas-meta {
  position: absolute;
  inset: auto 24px 14px;
  z-index: 1;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: none;
}

@keyframes figure-enter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

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

.settings-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.56);
  border-radius: 10px;
  background: rgba(238, 242, 247, 0.7);
  padding: 5px;
}

.settings-tabs button {
  min-height: 34px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #526071;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 800;
}

.settings-tabs button.active {
  background: #172033;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(23, 32, 51, 0.18);
}

.tab-section {
  display: none;
}

.tab-section.active {
  display: block;
  animation: tab-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

.switches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0 14px;
}

.toggle {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(130, 148, 178, 0.28);
  border-radius: 10px;
  background: var(--paper);
  padding: 0 10px;
  font-size: 14px;
  font-weight: 700;
}

.style-panel .field {
  margin-bottom: 12px;
}

.style-panel input[type="number"] {
  font-weight: 800;
}

.toggle input {
  width: 16px;
  height: 16px;
}

.palette-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}

.palette-head span {
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.palette-head button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

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

.palette-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.palette-presets button {
  display: grid;
  gap: 7px;
  min-height: 54px;
  padding: 8px;
  font-size: 12px;
  text-align: left;
  overflow: hidden;
}

.palette-presets button span {
  overflow: hidden;
  color: #344054;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-presets button i {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.1);
}

.palette-presets button b {
  background: var(--swatch);
}

.color-control {
  display: grid;
  grid-template-columns: 54px 1fr;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.56);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 8px;
}

@media (hover: none) {
  button:hover {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.color-swatch {
  position: relative;
  display: block;
  min-height: 40px;
  border-radius: 7px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: var(--swatch);
  cursor: pointer;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.color-swatch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.color-swatch span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 0;
  background: transparent;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.color-meta {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.color-meta strong {
  color: #344054;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
}

.color-meta button {
  min-height: 24px;
  justify-self: start;
  padding: 0 8px;
  color: #344054;
  font-size: 11px;
}

.export-note {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

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

.ai-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ai-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.ai-status {
  border: 1px solid rgba(76, 141, 246, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.52);
  color: #526071;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.ai-result {
  min-height: 150px;
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: minmax(280px, 340px) 1fr;
  }

  .style-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    gap: 12px;
  }

  .style-panel .panel-head,
  .style-panel .settings-tabs,
  .style-panel .tab-section,
  .style-panel .switches,
  .style-panel .palette,
  .style-panel .export-note {
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .shell {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .stage {
    height: auto;
    min-height: 640px;
    position: static;
  }

  .style-panel {
    display: block;
  }
}

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

  .style-panel {
    display: block;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-left,
  .style-select {
    width: 100%;
    min-width: 0;
  }

  .style-select select {
    flex: 1;
    min-width: 0;
  }

  .export-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    width: 100%;
    min-width: 0;
    margin-left: 0;
  }

  .export-bar select {
    min-width: 0;
  }

  .canvas-wrap {
    width: 100%;
    min-width: 0;
    min-height: 420px;
    height: auto;
    padding: 14px;
  }

  #figureSvg {
    max-height: none;
  }

  textarea {
    min-height: 200px;
  }
}
