:root {
  --ink: #17211b;
  --paper: #f3f0e7;
  --paper-2: #f7f3ea;
  --mat: #e4dccb;
  --acid: #dfff45;
  --orange: #ff6b3d;
  --line: rgba(23, 33, 27, 0.18);
  --card: #fffdf8;
  --muted: rgba(23, 33, 27, 0.62);
  --shadow: 0 22px 50px rgba(23, 33, 27, 0.16);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Arial, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.045;
  background-image: var(--grain-url);
  background-size: 220px;
  mix-blend-mode: multiply;
}

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

a { color: inherit; }

::selection { background: var(--acid); }

[hidden] { display: none !important; }

.app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  background: var(--ink);
  color: var(--paper);
  border-radius: 50%;
  font-size: 12px;
}

.top-title {
  position: absolute;
  left: 50%;
  margin: 0;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.back {
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.back:hover { text-decoration: underline; text-underline-offset: 5px; }

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
}

.stage-wrap {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 240, 231, 0.92);
}

.file-meta { min-width: 0; }

.file-meta strong {
  display: block;
  max-width: 280px;
  overflow: hidden;
  font-size: 14px;
  letter-spacing: -0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.toolgroup { display: flex; gap: 6px; }

.toolbtn, .textbtn, .primary, .xform button, .preset, .sample, .thumb-main, .thumb-x {
  border: 1px solid transparent;
}

.toolbtn, .textbtn {
  border-color: var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
}

.toolbtn:hover, .textbtn:hover { background: var(--card); }

.toolbtn.solid {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.toolbtn.solid:hover:not(:disabled) {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--paper);
}

.toolbtn.solid:disabled {
  background: transparent;
  color: inherit;
}

.toolbtn.is-on {
  background: var(--acid);
  border-color: var(--ink);
  color: var(--ink);
}

.toolbtn:disabled, .textbtn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.textbtn { padding: 6px 10px; }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse at center, transparent 40%, rgba(23, 33, 27, 0.06) 100%),
    var(--mat);
}

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px 48px 28px;
}

.eyebrow, .sample-label, .group header span, .keys {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.eyebrow::before {
  width: 9px;
  height: 9px;
  background: var(--orange);
  border-radius: 50%;
  content: "";
}

.empty h1 {
  margin: 0;
  font-size: clamp(56px, 7vw, 104px);
  font-weight: 900;
  line-height: 0.84;
  letter-spacing: -0.07em;
}

.empty h1 em {
  display: inline-block;
  padding: 0 0.08em 0.02em;
  font-style: normal;
  background: var(--acid);
  transform: rotate(-2.4deg);
}

.lede {
  max-width: 480px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-top: 26px;
}

.primary {
  border: 0;
  border-radius: 999px;
  padding: 13px 20px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 800;
}

.primary:hover { background: var(--orange); }

.hint { color: var(--muted); font-size: 13px; }

.sample-block { margin-top: 28px; }

.sample-label { margin-bottom: 10px; }

.samples {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.sample {
  padding: 0;
  background: transparent;
  text-align: left;
}

.sample img, .swatch .fx {
  display: block;
  width: 100%;
  object-fit: cover;
}

.sample img {
  aspect-ratio: 16 / 10;
  border-radius: 4px;
  box-shadow: 0 8px 20px rgba(23, 33, 27, 0.08);
  transition: transform 0.2s ease;
}

.sample span {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 800;
}

.sample:hover img { transform: translateY(-3px); }

.viewer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px;
}

.loading {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.print {
  position: relative;
  flex: none;
  background: #141816;
  box-shadow: 0 0 0 12px var(--card), var(--shadow);
}

.photo {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}

.clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #cfc6b8;
}

.clip.show-checker {
  background-color: #d5ccbe;
  background-image:
    linear-gradient(45deg, rgba(23, 33, 27, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(23, 33, 27, 0.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(23, 33, 27, 0.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(23, 33, 27, 0.08) 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.look { isolation: isolate; }

#look {
  position: absolute;
  inset: 0;
}

.layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.temp {
  background: var(--temp-color);
  opacity: var(--temp-alpha);
  mix-blend-mode: soft-light;
}

.tint {
  background: var(--tint-color);
  opacity: var(--tint-alpha);
  mix-blend-mode: soft-light;
}

.fade {
  background: rgb(255, 248, 240);
  opacity: var(--fade-alpha);
  mix-blend-mode: screen;
}

.vignette { background: var(--vignette); }

.grain {
  background-image: var(--grain-url);
  background-repeat: repeat;
  background-size: 18% auto;
  opacity: var(--grain-alpha);
  mix-blend-mode: overlay;
}

.look .fx { filter: var(--filter); }

.print.is-comparing { cursor: ew-resize; touch-action: none; }

.handle {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 3;
  width: 0;
  pointer-events: none;
}

.handle .line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 2px;
  background: #fffdf8;
  box-shadow: 0 0 0 1px rgba(23, 33, 27, 0.35);
}

.handle .tag {
  position: absolute;
  top: 14px;
  padding: 4px 7px;
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.handle .before { right: 14px; }

.handle .after { left: 14px; }

.handle .knob {
  position: absolute;
  top: 50%;
  left: 0;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--acid);
  color: var(--ink);
  transform: translate(-50%, -50%);
}

.dropveil {
  position: absolute;
  inset: 14px;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 20px;
  border: 2px dashed var(--ink);
  background: rgba(223, 255, 69, 0.9);
  font-size: clamp(32px, 5vw, 68px);
  font-weight: 900;
  letter-spacing: -0.05em;
  text-align: center;
}

.filmdock {
  border-top: 1px solid var(--line);
  background: var(--paper);
  padding: 10px 16px 12px;
}

.filmbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 800;
}

.filmstrip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.thumb { position: relative; flex: none; }

.thumb-main {
  display: block;
  padding: 0;
  background: transparent;
  text-align: left;
}

.thumb .swatch { width: 92px; height: 68px; }

.thumb .swatch .fx { height: 68px; }

.tname {
  display: block;
  width: 92px;
  margin-top: 5px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb.is-active .swatch {
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);
}

.thumb-x {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  line-height: 18px;
  opacity: 0;
}

.thumb:hover .thumb-x,
.thumb:focus-within .thumb-x { opacity: 1; }

.panel {
  min-height: 0;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--paper-2);
}

.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 0;
}

.panel-head h2 {
  margin: 0;
  font-size: 32px;
  letter-spacing: -0.05em;
}

.panel-note {
  margin: 8px 18px 14px;
  color: var(--muted);
  font-size: 13px;
}

.preset-wrap {
  padding: 0 18px;
}

.presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 8px;
  padding: 2px 0 8px;
}

.preset {
  min-width: 0;
  padding: 0;
  background: transparent;
  text-align: left;
}

.preset .swatch,
.preset .swatch .fx { height: 56px; }

.swatch {
  position: relative;
  display: block;
  height: 72px;
  overflow: hidden;
  border: 1px solid rgba(23, 33, 27, 0.18);
  border-radius: 6px;
  background: #d9d0c0;
  isolation: isolate;
}

.swatch .fx { height: 72px; }

.preset.is-active .swatch {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--acid);
}

.pname {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 800;
}

.pname small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.controls { padding: 0 18px 8px; }

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

.group header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}

.group h3 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -0.03em;
}

.slider { display: block; padding: 7px 0 2px; }

.slider-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.slider-name {
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.slider.is-changed .slider-name::before {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--orange);
  content: "";
  transform: translateY(-1px);
}

.slider-val {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}

.num {
  width: 54px;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  text-align: right;
}

.unit {
  min-width: 1em;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.slider-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

input[type="range"] {
  --a: 0%;
  --b: 50%;
  width: 100%;
  height: 22px;
  margin: 2px 0 0;
  appearance: none;
  background: transparent;
}

input[type="range"]:disabled { opacity: 0.4; }

input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 999px;
  background-image:
    linear-gradient(var(--ink), var(--ink)),
    linear-gradient(rgba(23, 33, 27, 0.16), rgba(23, 33, 27, 0.16));
  background-repeat: no-repeat;
  background-position: var(--a) 0, 0 0;
  background-size: calc(var(--b) - var(--a)) 100%, 100% 100%;
}

input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -7px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--acid);
  appearance: none;
  cursor: grab;
}

input[type="range"]::-moz-range-track {
  height: 2px;
  border: 0;
  border-radius: 999px;
  background-image:
    linear-gradient(#17211b, #17211b),
    linear-gradient(rgba(23, 33, 27, 0.16), rgba(23, 33, 27, 0.16));
  background-repeat: no-repeat;
  background-position: var(--a) 0, 0 0;
  background-size: calc(var(--b) - var(--a)) 100%, 100% 100%;
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid #17211b;
  border-radius: 50%;
  background: #dfff45;
  cursor: grab;
}

.xform {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.xform button {
  display: grid;
  gap: 3px;
  place-items: center;
  padding: 10px 0 8px;
  border-color: var(--line);
  border-radius: 8px;
  background: var(--card);
  font-size: 18px;
  font-weight: 800;
}

.xform button span {
  font-size: 11px;
  font-weight: 800;
}

.xform button:hover { border-color: var(--ink); }

.xform button.is-on {
  border-color: var(--ink);
  background: var(--acid);
}

.xform button:disabled { opacity: 0.4; cursor: not-allowed; }

.keys {
  margin: 8px 18px 22px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: none;
}

.toast {
  position: fixed;
  top: 84px;
  left: 50%;
  z-index: 30;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.noscript {
  padding: 24px;
  font-weight: 800;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

@media (max-width: 980px) {
  body { height: auto; overflow: auto; }
  .app { height: auto; min-height: 100%; }
  .workspace { grid-template-columns: 1fr; }
  .stage { height: 72vh; flex: none; }
  .panel {
    overflow: visible;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
  .top-title { display: none; }
  .empty { padding: 28px 18px 18px; }
  .samples { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .file-meta strong { max-width: 46vw; }
  .presets { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .topbar { height: 64px; padding: 0 14px; }
  .stage-toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar-actions { justify-content: flex-start; }
  .empty h1 { font-size: 64px; }
  .viewer { padding: 22px; }
  .print { box-shadow: 0 0 0 8px var(--card), var(--shadow); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
