:root {
  --bg: #0e0f12;
  --chrome: #18191d;
  --chrome-2: #202226;
  --panel: #1e1f22;
  --panel-2: #2b2d31;
  --line: #3b4251;
  --line-soft: #30343f;
  --text: #e8eefc;
  --muted: #aab4c8;
  --blue: #4d8dff;
  --blue-2: #8fb4ff;
  --violet: #7579ff;
  --danger: #ff6f91;
  --checker-a: #111315;
  --checker-b: #16181a;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(77, 141, 255, 0.16), transparent 28rem),
    var(--bg);
  overflow: hidden;
}

button,
select,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  --zoom: 1;
  --pan-x: 0px;
  --pan-y: 0px;
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template:
    "topbar topbar topbar" 50px
    "tools workspace panel" minmax(0, 1fr)
    "status status status" 36px / 52px minmax(420px, 1fr) 280px;
  overflow: hidden;
  background: #0b0c0e;
  border: 2px solid var(--violet);
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(143, 180, 255, 0.24);
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 14px;
  background: #16171b;
  border-bottom: 1px solid #272b35;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 122px;
  color: #a9c5ff;
  font-size: 18px;
  font-weight: 800;
}

.brand-mark {
  width: 20px;
  height: 20px;
  color: #a9c5ff;
}

svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.brand-mark svg {
  stroke-width: 2.2;
}

.menu {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.menu button,
.tabs button {
  appearance: none;
  border: 0;
  background: transparent;
  color: #dce7ff;
  cursor: pointer;
}

.menu button {
  min-height: 32px;
  padding: 0 9px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 700;
}

.menu button:hover,
.icon-button:hover,
.tool-button:hover,
.tiny-button:hover,
.layer:hover,
.lock-row button:hover {
  background: rgba(143, 180, 255, 0.12);
}

.top-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.export-button,
.icon-button,
.tool-button,
.tiny-button,
.lock-row button {
  appearance: none;
  border: 0;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.export-button {
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  gap: 8px;
  height: 30px;
  padding: 0 14px;
  border-radius: 4px;
  background: var(--blue);
  color: #08111f;
  font-size: 12px;
  font-weight: 800;
}

.export-button:hover {
  background: #6ea3ff;
}

.export-button svg {
  width: 16px;
}

.separator {
  width: 1px;
  height: 24px;
  background: #596172;
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: transparent;
  color: #dce7ff;
}

.icon-button svg {
  width: 21px;
}

.tools {
  grid-area: tools;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  background: #1a1b1f;
  border-right: 1px solid #2e3340;
}

.tool-group {
  width: 100%;
  display: grid;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid #343946;
}

.tool-group:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.tool-spacer {
  flex: 1;
}

.tool-button {
  width: 34px;
  height: 34px;
  border-radius: 5px;
  background: transparent;
  color: #d6deef;
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.tool-button.active {
  background: var(--blue);
  color: #08111f;
}

.tool-button:active {
  transform: translateY(1px);
}

.tool-button svg {
  width: 20px;
}

.color-swatch {
  width: 26px;
  height: 26px;
  place-self: center;
  display: block;
  border: 1px solid #a9c5ff;
  background: #a9c5ff;
  cursor: pointer;
}

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

.workspace {
  grid-area: workspace;
  min-width: 0;
  min-height: 0;
  position: relative;
  background:
    linear-gradient(45deg, var(--checker-a) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-a) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-a) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-a) 75%),
    var(--checker-b);
  background-position:
    0 0,
    0 12px,
    12px -12px,
    -12px 0;
  background-size: 24px 24px;
  overflow: hidden;
}

.canvas-field {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 42px 56px;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.018), transparent 32rem);
  user-select: none;
  touch-action: none;
}

.canvas-field.dragover {
  outline: 2px solid var(--blue);
  outline-offset: -10px;
}

.document-shadow {
  width: min(76vw, calc((100vh - 150px) * 1.7778));
  max-width: calc(100% - 24px);
  aspect-ratio: 16 / 9;
  box-shadow: var(--shadow);
  outline: 1px solid rgba(143, 180, 255, 0.24);
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.035) 75%),
    rgba(0, 0, 0, 0.12);
  background-position:
    0 0,
    0 16px,
    16px -16px,
    -16px 0;
  background-size: 32px 32px;
  transform: translate(var(--pan-x), var(--pan-y)) scale(var(--zoom));
  transform-origin: center;
  transition: transform 120ms ease;
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.panel {
  grid-area: panel;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #202124;
  border-left: 1px solid #4b5263;
}

.tabs {
  height: 34px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: stretch;
  border-bottom: 1px solid #454b59;
}

.tabs button {
  position: relative;
  min-width: 0;
  padding: 0 6px;
  color: #d9e4f9;
  font-size: 12px;
  font-weight: 800;
}

.tabs button.selected::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: -1px;
  height: 2px;
  background: #a9c5ff;
}

.panel-section {
  padding: 8px 10px;
  border-bottom: 1px solid #383d48;
}

.panel-pane {
  display: none;
}

.panel-pane.active {
  display: block;
}

.layers-section.panel-pane.active,
.properties-section.panel-pane.active {
  display: flex;
}

.panel-pane:not(.active) {
  display: none !important;
}

.section-title {
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #d8e5ff;
  font-size: 12px;
  font-weight: 900;
}

.tiny-button {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: transparent;
  color: #bdc8df;
}

.tiny-button svg {
  width: 16px;
}

.histogram {
  height: 160px;
  margin-top: 8px;
  border: 1px solid #5c6475;
  background: #151618;
  overflow: hidden;
}

.navigator-preview {
  height: 108px;
  margin-top: 8px;
  border: 1px solid #4f596b;
  background:
    linear-gradient(45deg, #111315 25%, transparent 25%),
    linear-gradient(-45deg, #111315 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #111315 75%),
    linear-gradient(-45deg, transparent 75%, #111315 75%),
    #17191d;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.navigator-preview canvas {
  width: 100%;
  height: 100%;
}

.panel-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.panel-actions.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-actions.compact button:nth-child(3) {
  grid-column: 1 / -1;
}

.panel-actions button {
  min-width: 0;
  height: 28px;
  border: 1px solid #4a5261;
  border-radius: 4px;
  background: #11141a;
  color: #dce7ff;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
}

.panel-actions button:hover {
  background: rgba(77, 141, 255, 0.18);
  border-color: #6f8ec4;
}

.histogram svg {
  display: block;
  width: 100%;
  height: 100%;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 2;
}

.hist-area {
  stroke: none;
  mix-blend-mode: screen;
}

.hist-area.neutral {
  fill: rgba(196, 205, 215, 0.32);
}

.hist-area.blue {
  fill: rgba(77, 141, 255, 0.2);
}

.hist-area.green {
  fill: rgba(80, 214, 151, 0.2);
}

.hist-area.red {
  fill: rgba(255, 111, 145, 0.2);
}

.layers-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.layer-controls {
  display: grid;
  grid-template-columns: 1fr 122px;
  gap: 10px;
  margin-top: 10px;
}

.panel-range {
  width: 100%;
  margin: 8px 0 0;
  accent-color: var(--blue);
}

.layer-controls select,
.layer-controls label {
  height: 28px;
  border: 1px solid #4a5261;
  background: #0f1115;
  color: #f2f6ff;
  font-size: 12px;
  font-weight: 800;
}

.layer-controls select {
  width: 100%;
  padding: 0 8px;
  border-radius: 2px;
}

.layer-controls label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px;
  border-radius: 2px;
}

.lock-row {
  height: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d9e4f9;
  font-size: 11px;
  font-weight: 800;
}

.lock-row button {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  background: transparent;
  color: #c3cee4;
}

.lock-row button.active {
  background: rgba(77, 141, 255, 0.2);
  color: #a9c5ff;
}

.lock-row svg {
  width: 15px;
}

.layers {
  display: grid;
  gap: 3px;
  min-height: 0;
}

.layer {
  appearance: none;
  width: 100%;
  height: 34px;
  display: grid;
  grid-template-columns: 20px 34px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border: 1px solid transparent;
  background: transparent;
  color: #eff4ff;
  text-align: left;
  cursor: pointer;
}

.layer[aria-hidden="true"] {
  opacity: 0.5;
}

.layer.selected {
  border-color: #8d98ad;
  background: #3a3d43;
}

.layer > svg:first-child {
  width: 18px;
  color: #bdd2ff;
}

.layer .visibility-off {
  opacity: 0.45;
}

.layer strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 850;
}

.layer.locked strong {
  font-style: italic;
}

.thumb {
  width: 30px;
  height: 24px;
  display: block;
  border: 1px solid #5f6676;
  background: #111;
}

.thumb.image {
  background-position: center;
  background-size: cover;
}

.thumb.grade {
  background: radial-gradient(circle at 35% 35%, #6ed8cf, transparent 36%),
    linear-gradient(45deg, #203445, #a2597b 52%, #15202c);
}

.thumb.curves {
  background: radial-gradient(circle at 44% 45%, #c7d0df, #5e6674 35%, #111 38%);
}

.thumb.background {
  background: radial-gradient(circle at center, #aab5c7, #27303b 38%, #111 72%);
}

.lock-icon {
  width: 15px;
  color: #687385;
}

.lock-icon.active {
  color: #b9c5dc;
}

.lock-icon:hover {
  color: #a9c5ff;
}

.properties-section {
  flex-direction: column;
  gap: 10px;
}

.property-grid {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.property-grid label {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: #d9e4f9;
  font-size: 11px;
  font-weight: 850;
}

.property-grid input,
.property-grid select {
  min-width: 0;
  height: 28px;
  border: 1px solid #4a5261;
  border-radius: 3px;
  background: #0f1115;
  color: #f2f6ff;
  padding: 0 8px;
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 70px;
  bottom: 92px;
  z-index: 20;
  max-width: min(380px, calc(100vw - 120px));
  padding: 9px 12px;
  border: 1px solid rgba(143, 180, 255, 0.42);
  border-radius: 5px;
  background: rgba(18, 22, 30, 0.94);
  color: #edf4ff;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.32);
  font-size: 12px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 150ms ease,
    transform 150ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.statusbar {
  grid-area: status;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: #1b1c20;
  border-top: 1px solid #333846;
  color: #d7e3f8;
  font-size: 12px;
  font-weight: 750;
}

.status-left,
.status-center,
.status-right {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-left {
  overflow: hidden;
}

.status-left > span,
.status-center > span {
  white-space: nowrap;
}

.status-left > span:not(:last-child)::after,
.status-center > span:not(:last-child)::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 14px;
  margin-left: 10px;
  vertical-align: middle;
  background: #596172;
}

#toolStatus {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#toolStatus svg {
  width: 15px;
  color: #a9c5ff;
}

.status-center {
  justify-content: center;
}

.status-right {
  justify-content: end;
}

.floating-controls {
  position: fixed;
  left: 70px;
  bottom: 46px;
  z-index: 5;
  width: min(760px, calc(100vw - 380px));
  min-width: 640px;
  display: grid;
  grid-template-columns: 116px repeat(3, minmax(120px, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid #4a5261;
  background: rgba(24, 25, 29, 0.88);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(10px);
}

.brush-presets {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.brush-presets button {
  min-width: 0;
  height: 24px;
  border: 1px solid #3f4654;
  border-radius: 4px;
  background: #11141a;
  color: #dbe5fa;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
}

.brush-presets button.active,
.brush-presets button:hover {
  border-color: #7fa8f4;
  background: rgba(77, 141, 255, 0.22);
  color: #ffffff;
}

.brush-preview {
  grid-row: span 2;
  min-width: 0;
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #3f4654;
  background:
    linear-gradient(45deg, #111315 25%, transparent 25%),
    linear-gradient(-45deg, #111315 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #111315 75%),
    linear-gradient(-45deg, transparent 75%, #111315 75%),
    #181a1e;
  background-position:
    0 0,
    0 7px,
    7px -7px,
    -7px 0;
  background-size: 14px 14px;
}

#brushTipPreview {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #a9c5ff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.62);
}

.floating-controls label {
  min-width: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
  color: #dbe5fa;
  font-size: 11px;
  font-weight: 850;
}

.status-left > span:nth-child(n + 5) {
  display: none;
}

.floating-controls input[type="range"] {
  min-width: 44px;
  accent-color: var(--blue);
}

.floating-controls output {
  width: 24px;
  text-align: right;
  color: #a9c5ff;
}

.brush-cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 30;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(239, 246, 255, 0.94);
  border-radius: 999px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.7),
    inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition:
    opacity 80ms ease,
    width 80ms ease,
    height 80ms ease;
}

.brush-cursor.visible {
  opacity: 1;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template:
      "topbar topbar" 50px
      "tools workspace" minmax(0, 1fr)
      "panel panel" 220px
      "status status" 36px / 52px minmax(0, 1fr);
  }

  .panel {
    border-left: 0;
    border-top: 1px solid #4b5263;
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: 34px minmax(0, 1fr);
  }

  .tabs {
    grid-column: 1 / -1;
  }

  .panel-section {
    min-height: 0;
    border-bottom: 0;
    border-right: 1px solid #383d48;
  }

  .layers-section {
    border-right: 0;
  }

  .histogram {
    height: 140px;
  }

  .floating-controls {
    width: calc(100vw - 76px);
    min-width: 0;
    left: 62px;
    bottom: 258px;
    grid-template-columns: 92px repeat(3, minmax(0, 1fr));
  }

  .brush-preview {
    grid-row: span 2;
  }
}

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

  .app-shell {
    width: 100vw;
    max-width: 100vw;
    min-height: 760px;
    border-radius: 0;
    grid-template:
      "topbar" 50px
      "workspace" minmax(400px, 1fr)
      "tools" 58px
      "panel" 250px
      "status" 46px / 1fr;
  }

  .topbar {
    gap: 8px;
    padding: 0 8px;
    min-width: 0;
    overflow: hidden;
  }

  .brand {
    min-width: 104px;
    font-size: 16px;
  }

  .menu {
    flex: 1 1 auto;
    max-width: calc(100vw - 136px);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .menu button:nth-child(n + 4) {
    display: none;
  }

  .menu::-webkit-scrollbar,
  .tools::-webkit-scrollbar {
    display: none;
  }

  .top-actions {
    display: inline-flex;
    margin-left: auto;
    gap: 4px;
  }

  .top-actions .icon-button {
    display: none;
  }

  .separator {
    display: none;
  }

  .export-button {
    width: 32px;
    padding: 0;
  }

  .export-button span {
    display: none;
  }

  .icon-button {
    width: 28px;
    height: 28px;
  }

  .tools {
    width: 100vw;
    max-width: 100vw;
    border-right: 0;
    border-top: 1px solid #2e3340;
    flex-direction: row;
    overflow-x: auto;
    padding: 9px;
  }

  .tool-group {
    width: auto;
    display: flex;
    border-bottom: 0;
    border-right: 1px solid #343946;
    padding: 0 10px 0 0;
  }

  .tool-spacer {
    display: none;
  }

  .panel {
    display: flex;
    flex-direction: column;
    width: 100vw;
    max-width: 100vw;
    overflow: hidden;
  }

  .tabs button {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
  }

  .tabs,
  .panel-section,
  .layers-section,
  .layer-controls,
  .layers,
  .layer {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tabs button:not(.selected) {
    display: block;
  }

  .layer-controls {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .layer-controls select,
  .layer-controls label {
    min-width: 0;
  }

  .layer-controls label {
    padding: 0 6px;
  }

  .layer-controls output {
    min-width: 36px;
    text-align: right;
  }

  .panel-section:first-of-type {
    display: none;
  }

  .panel-pane.active {
    flex: 1;
    min-height: 0;
  }

  .layers-section {
    overflow-y: auto;
  }

  .statusbar {
    max-width: 100vw;
    overflow: hidden;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 0 10px;
    font-size: 11px;
  }

  .status-center {
    display: none;
  }

  .status-left {
    gap: 6px;
  }

  .status-left > span:nth-child(n + 3) {
    display: none;
  }

  .floating-controls {
    left: 10px;
    right: 10px;
    bottom: 318px;
    width: auto;
    min-width: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .brush-preview {
    min-height: 34px;
    grid-row: auto;
    grid-column: 1 / -1;
  }

  .brush-presets {
    grid-column: 1 / -1;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .brush-presets button {
    padding: 0 2px;
    font-size: 10px;
  }

  .toast {
    left: 10px;
    bottom: 54px;
    max-width: calc(100vw - 20px);
  }

  .canvas-field {
    padding: 20px;
    overflow: hidden;
  }

  .document-shadow {
    width: min(calc(100vw - 72px), 320px);
    max-width: 100%;
  }
}
