:root {
  color-scheme: dark;
  --sl-color-primary-50: #e9fff6;
  --sl-color-primary-100: #c8f8e5;
  --sl-color-primary-200: #96ecc9;
  --sl-color-primary-300: #62dbaa;
  --sl-color-primary-400: #3cc990;
  --sl-color-primary-500: #24b77d;
  --sl-color-primary-600: #149866;
  --sl-color-primary-700: #0d7952;
  --sl-color-primary-800: #0a6042;
  --sl-color-primary-900: #084f37;
  --sl-color-primary-950: #052d20;
  --sl-border-radius-small: 6px;
  --sl-border-radius-medium: 8px;
  --sl-border-radius-large: 10px;
  --sl-input-height-medium: 36px;
  --sl-font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #101312;
  --bg-2: #141816;
  --panel: #191e1c;
  --panel-raised: #202623;
  --panel-soft: #151a18;
  --field: #0f1412;
  --line: #303832;
  --line-strong: #4a574f;
  --text: #eef4ec;
  --text-strong: #ffffff;
  --muted: #9aa79f;
  --muted-2: #748178;
  --accent: #4fc39a;
  --accent-dark: #28a777;
  --accent-soft: rgba(79, 195, 154, 0.14);
  --accent-line: rgba(79, 195, 154, 0.42);
  --warm: #d8a852;
  --danger: #e16f5b;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 10px 26px rgba(0, 0, 0, 0.2);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.app {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px, 28px 28px, auto;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid #252d29;
  background: rgba(16, 19, 18, 0.96);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}

.brand {
  display: grid;
  gap: 2px;
  min-width: 250px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--text-strong);
  font-size: 20px;
  font-weight: 850;
  letter-spacing: 0;
}

.brand-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

.tool-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111614;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.app:not(.tool-open) .tool-tabs {
  display: none;
}

.tool-tab {
  color: var(--muted);
  white-space: nowrap;
}

.tool-tab::part(base) {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.tool-tab.active::part(base) {
  background: var(--panel-raised);
  color: var(--text-strong);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    0 8px 18px rgba(0, 0, 0, 0.2);
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status-strip sl-tag::part(base) {
  border-color: rgba(216, 168, 82, 0.28);
  background-color: rgba(216, 168, 82, 0.08);
  color: #e6c887;
}

sl-button::part(base) {
  font-weight: 720;
}

sl-button[variant="default"]::part(base) {
  border-color: var(--line);
  background-color: #171c1a;
  color: var(--text);
}

sl-button[variant="default"]::part(base):hover {
  border-color: var(--line-strong);
  background-color: #222a26;
}

sl-button[variant="primary"]::part(base) {
  border-color: var(--accent-line);
  background: linear-gradient(180deg, #55cda3, #31aa7d);
  color: #07110d;
  box-shadow: 0 12px 22px rgba(39, 163, 116, 0.18);
}

sl-button[variant="primary"]::part(base):hover {
  border-color: rgba(114, 225, 184, 0.58);
  background: linear-gradient(180deg, #6bd9b3, #3bb889);
}

.full-button {
  width: 100%;
}

input[type="file"] {
  display: none;
}

main {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  padding: 18px;
  min-height: 0;
  overflow: hidden;
}

main[hidden] {
  display: none;
}

.home-view {
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 24px;
  overflow: auto;
  padding: 34px;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  gap: 28px;
  align-items: stretch;
  min-height: 330px;
}

.home-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(79, 195, 154, 0.14), transparent 42%),
    rgba(25, 30, 28, 0.94);
  box-shadow: var(--shadow);
}

.home-copy h2 {
  max-width: 680px;
  margin: 8px 0 0;
  color: var(--text-strong);
  font-size: 46px;
  font-weight: 880;
  line-height: 1.08;
  letter-spacing: 0;
}

.home-copy p:not(.eyebrow) {
  max-width: 560px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.studio-preview {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0e1211;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.preview-topbar {
  display: flex;
  gap: 7px;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: #151a18;
}

.preview-topbar span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--line-strong);
}

.preview-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  grid-template-rows: 1fr 1fr 0.72fr;
  gap: 12px;
  padding: 18px;
}

.preview-tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 86px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent),
    #151a18;
}

.preview-tile.large {
  grid-row: span 2;
  background:
    linear-gradient(135deg, rgba(79, 195, 154, 0.22), transparent 62%),
    #151a18;
}

.preview-tile.wide {
  grid-column: 1 / -1;
  background:
    linear-gradient(90deg, rgba(216, 168, 82, 0.14), transparent),
    #151a18;
}

.preview-tile span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.preview-tile strong {
  color: var(--text-strong);
  font-size: 18px;
  letter-spacing: 0;
}

.tool-entry-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.entry-card {
  display: grid;
  gap: 10px;
  min-height: 210px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(25, 30, 28, 0.94);
  color: var(--text);
  text-decoration: none;
  text-align: left;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.entry-card:hover {
  border-color: var(--accent-line);
  background:
    linear-gradient(135deg, rgba(79, 195, 154, 0.1), transparent 58%),
    rgba(30, 36, 33, 0.98);
}

.entry-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.entry-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.entry-card strong {
  color: var(--text-strong);
  font-size: 24px;
  line-height: 1.2;
}

.entry-card span:not(.entry-kicker) {
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.entry-card small {
  align-self: end;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.home-footnotes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.home-footnotes span {
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid rgba(216, 168, 82, 0.22);
  border-radius: 999px;
  background: rgba(216, 168, 82, 0.07);
  color: #e6c887;
  font-size: 12px;
  font-weight: 700;
}

aside,
.stage {
  min-height: 0;
}

aside {
  background: rgba(25, 30, 28, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
  overflow: auto;
}

.tool-intro {
  border-bottom: 1px solid var(--line);
  margin: 0 0 14px;
  padding-bottom: 14px;
}

.tool-intro-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.tool-intro h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 19px;
  font-weight: 850;
  letter-spacing: 0;
}

.tool-intro p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.drop-zone {
  border: 1px dashed rgba(79, 195, 154, 0.48);
  border-radius: 8px;
  background: var(--accent-soft);
  padding: 22px 16px;
  text-align: center;
  color: #cdeee0;
  font-size: 14px;
  font-weight: 720;
  line-height: 1.5;
  margin-bottom: 12px;
}

.drop-zone span,
.drop-zone small {
  display: block;
}

.drop-zone small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.drop-zone.dragging {
  border-color: rgba(114, 225, 184, 0.88);
  background: rgba(79, 195, 154, 0.22);
  color: var(--text-strong);
}

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

.section:first-of-type {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.section-title {
  margin: 0 0 10px;
  color: #d8ded8;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

sl-radio-group {
  display: block;
}

sl-radio-group::part(form-control-input) {
  display: grid;
  gap: 8px;
}

sl-radio::part(base) {
  align-items: center;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
}

sl-radio[checked]::part(base) {
  border-color: var(--accent-line);
  background: rgba(79, 195, 154, 0.12);
}

sl-checkbox {
  display: block;
  margin-bottom: 10px;
}

sl-checkbox::part(base) {
  color: var(--text);
}

.advanced-panel,
.compact-details {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 10px;
}

sl-details::part(base) {
  border: 0;
  background: transparent;
}

sl-details::part(header) {
  min-height: auto;
  padding: 0;
  color: #dce5de;
  font-size: 13px;
  font-weight: 800;
}

sl-details::part(summary) {
  color: #dce5de;
}

sl-details::part(content) {
  padding: 12px 0 0;
}

.hint,
.action-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.button-grid + .action-hint {
  margin-bottom: 2px;
}

.sample-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.swatch {
  width: 38px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #000;
}

.swatch-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  min-width: 42px;
}

.swatch-list .swatch {
  width: 24px;
}

.control {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  cursor: help;
}

.control-header,
.control label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #d8ded8;
  font-size: 13px;
}

.control sl-range {
  display: block;
}

sl-input,
sl-select,
sl-textarea {
  display: block;
  margin-bottom: 12px;
}

sl-input::part(base),
sl-select::part(combobox),
sl-textarea::part(base) {
  border-color: var(--line);
  background-color: var(--field);
  color: var(--text);
}

sl-input::part(form-control-label),
sl-select::part(form-control-label),
sl-textarea::part(form-control-label) {
  color: #d8ded8;
  font-size: 13px;
}

sl-input::part(form-control-help-text),
sl-select::part(form-control-help-text) {
  color: var(--muted);
  font-size: 12px;
}

.text-input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  background: var(--field);
}

.text-input:disabled {
  color: var(--muted-2);
  background: #111513;
}

sl-button::part(base):focus-visible,
sl-input::part(base):focus-visible,
sl-select::part(combobox):focus-visible,
sl-textarea::part(base):focus-visible {
  outline: 2px solid rgba(79, 195, 154, 0.44);
  outline-offset: 2px;
}

select.text-input {
  padding-right: 28px;
}

.textarea-input {
  height: 78px;
  padding: 8px 10px;
  resize: vertical;
}

.control output {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

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

sl-progress-bar {
  margin-top: 12px;
  --height: 10px;
}

sl-progress-bar::part(base) {
  background-color: var(--field);
}

sl-progress-bar::part(indicator) {
  background: linear-gradient(90deg, #35b889, #75dfba);
}

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

.export-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.zoom-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.zoom-buttons button {
  height: 30px;
  padding: 0;
  font-size: 12px;
}

.zoom-buttons sl-button::part(base) {
  min-height: 30px;
  font-size: 12px;
}

.native-color {
  width: 100%;
  height: 36px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
}

.stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  height: 100%;
  overflow: hidden;
}

.viewer {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: #151a18;
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 850;
}

.viewer-header span:last-child {
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.canvas-wrap {
  position: relative;
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #0d1110;
}

.canvas-wrap.can-pan {
  cursor: grab;
}

.canvas-wrap.panning {
  cursor: grabbing;
  user-select: none;
}

.checker {
  background-color: #111513;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.065) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.065) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.065) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.065) 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

canvas {
  display: block;
  image-rendering: auto;
}

video {
  display: block;
  max-width: 100%;
  max-height: 100%;
  background: #050807;
}

.sheet-canvas {
  max-width: none;
  max-height: none;
}

.pixel-preview-canvas {
  max-width: none;
  max-height: none;
  image-rendering: pixelated;
}

#sourceCanvas.pickable {
  cursor: crosshair;
}

.empty {
  position: absolute;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  text-align: center;
  pointer-events: none;
}

::selection {
  background: rgba(79, 195, 154, 0.28);
}

@media (max-width: 1100px) {
  header {
    align-items: flex-start;
  }

  .header-actions {
    align-items: flex-end;
    flex-direction: column;
  }

  .status-strip {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .home-hero {
    grid-template-columns: 1fr;
  }

  .tool-entry-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  header {
    display: grid;
    gap: 12px;
  }

  .brand {
    min-width: 0;
  }

  .header-actions {
    align-items: stretch;
  }

  .tool-tabs {
    overflow-x: auto;
  }

  .status-strip {
    justify-content: flex-start;
  }

  main {
    grid-template-columns: 1fr;
    overflow: visible;
    padding: 14px;
  }

  .home-view {
    padding: 14px;
  }

  .home-copy {
    padding: 22px;
  }

  .home-copy h2 {
    font-size: 32px;
  }

  .preview-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }

  .preview-tile.large,
  .preview-tile.wide {
    grid-column: auto;
    grid-row: auto;
  }

  aside {
    overflow: visible;
  }

  .stage {
    grid-template-columns: 1fr;
    min-height: 560px;
    height: auto;
    overflow: visible;
  }

  .viewer {
    min-height: 280px;
  }
}
