
:root {
  --ink: #142235;
  --muted: #607080;
  --line: rgba(20, 34, 53, 0.12);
  --paper: rgba(255, 251, 246, 0.95);
  --paper-strong: rgba(255, 253, 249, 0.98);
  --accent: #c95f32;
  --accent-dark: #17324d;
  --accent-soft: #f6c65b;
  --danger: #9c3c2f;
  --shadow: 0 22px 56px rgba(28, 34, 45, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(249, 190, 92, 0.18), transparent 24%),
    radial-gradient(circle at bottom right, rgba(43, 114, 135, 0.1), transparent 26%),
    linear-gradient(180deg, #f7f0e8 0%, #ebdfd2 100%);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  appearance: none;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.5;
  transform: none !important;
  box-shadow: none !important;
}

.app-shell {
  width: min(1540px, calc(100% - 1rem));
  margin: 0 auto;
  padding: 0.7rem 0 1rem;
  display: grid;
  gap: 0.8rem;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.topbar {
  padding: 0.75rem 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.brand-block {
  min-width: 0;
  display: grid;
  gap: 0.14rem;
}

.incoprea-link {
  width: fit-content;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  opacity: 0.9;
}

.incoprea-link:hover {
  color: var(--accent-dark);
}

body[data-theme="dark"] .incoprea-link {
  color: #aabbd2;
}

body[data-theme="dark"] .incoprea-link:hover {
  color: #d9e6fb;
}

h1,
h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
}

h1 {
  font-size: clamp(1.55rem, 2.3vw, 2rem);
  line-height: 1;
}

h2 {
  font-size: 1.2rem;
}

.topbar-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(242px, 270px) minmax(0, 1fr) minmax(220px, 248px);
  gap: 0.8rem;
  align-items: start;
}

.controls-panel,
.canvas-panel,
.layers-panel {
  padding: 0.9rem;
}

.controls-panel {
  grid-column: 1;
}

.canvas-panel {
  grid-column: 2;
}

.layers-panel {
  grid-column: 3;
}

.controls-panel {
  display: grid;
  gap: 0.72rem;
}

.control-section {
  display: grid;
  gap: 0.55rem;
}

.tool-grid,
.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.swatch-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
}

.swatch-control {
  display: grid;
  justify-items: center;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.73rem;
  letter-spacing: 0.04em;
}

.swatch-control input[type="color"] {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 52px;
  padding: 0;
  border: 1px solid rgba(20, 34, 53, 0.12);
  border-radius: 14px;
  background: white;
  cursor: pointer;
}

.slider-stack {
  display: grid;
  gap: 0.55rem;
}

.slider-card {
  display: grid;
  gap: 0.45rem;
  padding: 0.72rem 0.78rem;
  border: 1px solid rgba(20, 34, 53, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.slider-title {
  font-size: 0.84rem;
  font-weight: 700;
}

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

.value-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 0.7rem;
  border-radius: 999px;
  background: rgba(23, 50, 77, 0.08);
  color: var(--accent-dark);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.tool-button,
.primary-button,
.secondary-button,
.danger-button,
.layer-button,
.compact-button,
.file-button,
.zoom-button,
.zoom-readout {
  min-height: 42px;
  border-radius: 14px;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.tool-button,
.secondary-button,
.file-button,
.zoom-button,
.zoom-readout {
  border: 1px solid rgba(20, 34, 53, 0.12);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
}

.tool-button.active,
.layer-button.active,
.compact-button.active {
  background: var(--accent-dark);
  color: white;
  box-shadow: 0 10px 22px rgba(23, 50, 77, 0.18);
}

.primary-button {
  padding: 0 0.9rem;
  background: var(--accent);
  color: white;
}

.secondary-button,
.file-button,
.tool-button,
.zoom-button,
.zoom-readout {
  padding: 0 0.8rem;
}

.danger-button {
  padding: 0 0.8rem;
  background: rgba(156, 60, 47, 0.12);
  color: var(--danger);
}

.tool-button:hover,
.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.layer-button:hover,
.zoom-button:hover,
.zoom-readout:hover {
  transform: translateY(-1px);
}

.wide-button {
  grid-column: 1 / -1;
}

.canvas-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.65rem;
  min-height: 0;
  background: var(--paper-strong);
}

.canvas-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.status-text {
  margin: 0;
  min-width: 0;
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.zoom-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
}

.zoom-readout {
  min-width: 68px;
  min-height: 36px;
  padding: 0 0.7rem;
}

.canvas-frame {
  min-height: 0;
  height: clamp(520px, calc(100vh - 190px), 900px);
  border-radius: 20px;
  overflow: auto;
  overscroll-behavior: contain;
  cursor: default;
  border: 1px solid rgba(20, 34, 53, 0.09);
  background:
    linear-gradient(45deg, rgba(20, 34, 53, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(20, 34, 53, 0.05) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(20, 34, 53, 0.05) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(20, 34, 53, 0.05) 75%);
  background-size: 32px 32px;
  background-position: 0 0, 0 16px, 16px -16px, -16px 0;
}

.canvas-frame.is-space-pan,
.canvas-frame.is-space-pan .drawing-surface {
  cursor: grab;
}

.canvas-frame.is-panning,
.canvas-frame.is-panning .drawing-surface {
  cursor: grabbing;
}

.drawing-surface {
  display: block;
  width: 1400px;
  height: 900px;
  min-width: 0;
  background: transparent;
  transform-origin: top left;
  transition: width 120ms ease, height 120ms ease;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.65rem;
}

.panel-heading-tight {
  margin-bottom: 0.35rem;
}

.layers-panel {
  display: grid;
  gap: 0.55rem;
}

.layer-list {
  display: grid;
  gap: 0.42rem;
}

.layer-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 0.38rem;
  align-items: stretch;
}

.canvas-bottom-actions {
  display: grid;
  gap: 0.45rem;
}

.canvas-action-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.45rem;
}

.hidden-control {
  display: none !important;
}

.layer-item.drag-over .layer-button {
  border-color: rgba(201, 95, 50, 0.55);
  box-shadow: inset 0 0 0 1px rgba(201, 95, 50, 0.25);
}

.layer-item.dragging {
  opacity: 0.55;
}

.layer-button {
  width: 100%;
  padding: 0.48rem 0.56rem;
  border: 1px solid rgba(20, 34, 53, 0.1);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  text-align: left;
  min-height: 0;
  display: grid;
  gap: 0.22rem;
}

.layer-type-badge {
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.layer-name-input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.15;
  outline: none;
}

.layer-name-input::placeholder {
  color: var(--muted);
}

.layer-reorder {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 0.28rem;
}

.layer-arrow {
  min-height: 0;
  height: 100%;
  border: 1px solid rgba(20, 34, 53, 0.12);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  padding: 0;
  font-size: 0.8rem;
  line-height: 1;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.layer-arrow:hover {
  transform: translateY(-1px);
}

.drawing-shape {
  vector-effect: non-scaling-stroke;
  cursor: pointer;
}

.drawing-shape.selected {
  opacity: 1;
}

.selection-outline {
  fill: none;
  stroke: rgba(201, 95, 50, 0.6);
  stroke-width: 1.5;
  stroke-dasharray: 10 8;
  vector-effect: non-scaling-stroke;
}

.handle-guide {
  stroke: rgba(23, 50, 77, 0.35);
  stroke-width: 1.4;
  stroke-dasharray: 5 5;
  vector-effect: non-scaling-stroke;
}

.handle-point {
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  pointer-events: all;
}

.anchor-point {
  fill: white;
  stroke: var(--accent-dark);
}

.anchor-point.active {
  fill: var(--accent);
  stroke: white;
}

.curve-handle {
  fill: var(--accent-soft);
  stroke: var(--accent-dark);
}

.transform-scale-handle {
  fill: rgba(23, 50, 77, 0.98);
  stroke: white;
  stroke-width: 2.5;
}

.transform-rotate-handle {
  fill: var(--accent);
  stroke: white;
  stroke-width: 2.5;
}

.pen-preview {
  fill: none;
  stroke: rgba(201, 95, 50, 0.7);
  stroke-width: 1.4;
  stroke-dasharray: 8 6;
  vector-effect: non-scaling-stroke;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: minmax(220px, 248px) minmax(0, 1fr);
  }

  .layers-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100%, calc(100% - 0.8rem));
  }

  .topbar,
  .canvas-topline {
    flex-direction: column;
    align-items: stretch;
  }

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

  .drawing-surface {
    min-width: 760px;
  }

  .canvas-action-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}
.gradient-swatch-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.compact-chip-button {
  min-height: 52px;
  padding: 0 0.8rem;
  border-radius: 14px;
}

.gradient-preset-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.gradient-preset-button {
  min-height: 32px;
}

.extrude-stack {
  isolation: isolate;
}


.preset-button,
.mini-pill-button {
  min-height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(20, 34, 53, 0.12);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.preset-button {
  padding: 0 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.stroke-preset-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.mini-pill-button {
  padding: 0 0.55rem;
  min-width: 2.15rem;
  font-size: 0.74rem;
  font-weight: 700;
}

.preset-button:hover,
.mini-pill-button:hover {
  transform: translateY(-1px);
}

.preset-button.active,
.mini-pill-button.active {
  background: var(--accent-dark);
  color: white;
  box-shadow: 0 8px 18px rgba(23, 50, 77, 0.16);
}

:root {
  color-scheme: light;
}

body[data-theme="light"] {
  color-scheme: light;
}

body[data-theme="dark"] {
  --ink: #eef4ff;
  --muted: #9aa9bc;
  --line: rgba(222, 234, 255, 0.14);
  --paper: rgba(14, 22, 34, 0.95);
  --paper-strong: rgba(11, 18, 29, 0.98);
  --accent: #de7549;
  --accent-dark: #90b9ff;
  --accent-soft: #f6c65b;
  --danger: #ff9c88;
  --shadow: 0 24px 60px rgba(2, 7, 16, 0.45);
  color-scheme: dark;
  background:
    radial-gradient(circle at top left, rgba(82, 126, 219, 0.18), transparent 26%),
    radial-gradient(circle at bottom right, rgba(210, 116, 88, 0.16), transparent 28%),
    linear-gradient(180deg, #0f1725 0%, #131f31 100%);
}

.topbar-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.theme-toggle,
.segmented-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.theme-button,
.segment-button {
  min-height: 34px;
  padding: 0 0.7rem;
  border-radius: 12px;
  border: 1px solid rgba(20, 34, 53, 0.12);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.theme-button:hover,
.segment-button:hover {
  transform: translateY(-1px);
}

.theme-button.active,
.segment-button.active {
  background: var(--accent-dark);
  color: white;
  box-shadow: 0 8px 18px rgba(23, 50, 77, 0.16);
}

.control-caption {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.swatch-row-2 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

.compact-swatch {
  justify-items: start;
}

.compact-swatch input[type="color"] {
  max-width: 88px;
}

.slim-card {
  padding: 0.58rem 0.68rem;
}

.select-card {
  display: grid;
  gap: 0.35rem;
}

.select-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.compact-select {
  width: 100%;
  min-height: 40px;
  padding: 0 0.82rem;
  border: 1px solid rgba(20, 34, 53, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  appearance: none;
}

.compact-select:focus {
  outline: 2px solid rgba(201, 95, 50, 0.2);
  outline-offset: 2px;
}

.effects-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.32rem;
}

.effects-row .segment-button {
  min-height: 32px;
  padding: 0 0.42rem;
  font-size: 0.76rem;
}

.compact-chip-button {
  min-height: 36px;
  padding: 0 0.8rem;
}

.slider-card.is-disabled {
  opacity: 0.55;
}

.extrude-face {
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

body[data-theme="dark"] .tool-button,
body[data-theme="dark"] .secondary-button,
body[data-theme="dark"] .file-button,
body[data-theme="dark"] .zoom-button,
body[data-theme="dark"] .zoom-readout,
body[data-theme="dark"] .theme-button,
body[data-theme="dark"] .segment-button,
body[data-theme="dark"] .preset-button,
body[data-theme="dark"] .mini-pill-button,
body[data-theme="dark"] .layer-arrow,
body[data-theme="dark"] .layer-button {
  background: rgba(20, 29, 43, 0.92);
  border-color: rgba(150, 177, 223, 0.16);
  color: var(--ink);
}

body[data-theme="dark"] .slider-card,
body[data-theme="dark"] .swatch-control input[type="color"],
body[data-theme="dark"] .compact-select {
  background: rgba(16, 24, 38, 0.88);
  border-color: rgba(150, 177, 223, 0.14);
  color: var(--ink);
}

body[data-theme="dark"] .gradient-card {
  background: rgba(16, 24, 38, 0.92);
  border-color: rgba(150, 177, 223, 0.14);
}

body[data-theme="dark"] .select-label,
body[data-theme="dark"] .mini-hint,
body[data-theme="dark"] .inline-swatch span,
body[data-theme="dark"] .swatch-control,
body[data-theme="dark"] .control-caption {
  color: #b7c7dd;
}

body[data-theme="dark"] .gradient-inline-actions .secondary-button {
  background: rgba(24, 36, 54, 0.95);
  border-color: rgba(150, 177, 223, 0.16);
}

body[data-theme="dark"] .canvas-frame {
  border-color: rgba(150, 177, 223, 0.14);
  background:
    linear-gradient(45deg, rgba(222, 234, 255, 0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(222, 234, 255, 0.04) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(222, 234, 255, 0.04) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(222, 234, 255, 0.04) 75%);
  background-size: 32px 32px;
  background-position: 0 0, 0 16px, 16px -16px, -16px 0;
}

@media (max-width: 960px) {
  .topbar-meta {
    justify-content: stretch;
  }

  .theme-toggle,
  .segmented-row {
    width: 100%;
  }

  .theme-button,
  .segment-button {
    flex: 1 1 auto;
  }
}


.style-clipboard-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.gradient-card {
  display: grid;
  gap: 0.45rem;
  padding: 0.68rem 0.72rem;
  border: 1px solid rgba(20, 34, 53, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
}

.gradient-color-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.inline-swatch {
  justify-items: stretch;
}

.inline-swatch span {
  text-align: center;
}

.inline-swatch input[type="color"] {
  max-width: none;
  min-height: 44px;
}

.gradient-inline-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.45rem;
}

.mini-hint {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.32;
  color: var(--muted);
}

.hidden-panel {
  display: none !important;
}

.gradient-handle {
  fill: rgba(114, 167, 158, 0.96);
  stroke: white;
  stroke-width: 2.4;
}

.gradient-center-handle {
  fill: rgba(201, 95, 50, 0.96);
  stroke: white;
  stroke-width: 2.4;
}


.layers-panel {
  grid-template-rows: auto auto minmax(0, 1fr);
  align-content: start;
  min-height: 0;
}

.layers-gradient-section {
  gap: 0.48rem;
  padding-bottom: 0.18rem;
  border-bottom: 1px solid rgba(20, 34, 53, 0.08);
}

.layers-gradient-section .segmented-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.32rem;
}

.layers-gradient-section .segment-button {
  min-height: 32px;
  padding: 0 0.45rem;
  font-size: 0.75rem;
}

.layers-gradient-section .gradient-card {
  padding: 0.58rem 0.62rem;
  gap: 0.38rem;
}

.layers-gradient-section .inline-swatch input[type="color"] {
  min-height: 40px;
}

.layers-gradient-section .compact-chip-button {
  min-height: 34px;
}

.layers-gradient-section .mini-hint {
  font-size: 0.68rem;
}

.layers-heading-spacer {
  margin-bottom: 0.1rem;
  padding-top: 0.08rem;
}

.layer-list {
  overflow: auto;
  padding-right: 0.1rem;
}

body[data-theme="dark"] .layers-gradient-section {
  border-bottom-color: rgba(150, 177, 223, 0.14);
}

@media (max-width: 1080px) {
  .layers-panel {
    grid-template-rows: auto auto auto;
  }

  .layer-list {
    overflow: visible;
  }
}


/* Tight cleanup */
.control-section > .compact-select {
  width: 100%;
}


.export-compact-select {
  min-width: 104px;
  width: auto;
  max-width: 118px;
}

.swatch-meta {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.swatch-clear-button {
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(20, 34, 53, 0.14);
  background: rgba(255, 255, 255, 0.84);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease, opacity 140ms ease;
}

.swatch-clear-button:hover {
  transform: translateY(-1px);
}

.swatch-clear-button.is-active {
  background: rgba(210, 118, 89, 0.14);
  border-color: rgba(210, 118, 89, 0.42);
  color: var(--accent);
}

.swatch-clear-button:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

body[data-theme="dark"] .swatch-clear-button.is-active {
  background: rgba(242, 143, 111, 0.18);
  border-color: rgba(242, 143, 111, 0.48);
  color: #ffc1ad;
}

body[data-theme="dark"] .swatch-clear-button {
  background: rgba(16, 24, 38, 0.92);
  border-color: rgba(150, 177, 223, 0.16);
  color: #c6d6ee;
}
