/* Kerf: a cutting mat for images */

/* Bricolage Grotesque (SIL Open Font License 1.1), self-hosted so the page needs no
   third-party request before it can render. One variable file per subset covers every weight. */
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/bricolage-grotesque-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/bricolage-grotesque-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --mat: #1E5B4B;
  --mat-deep: #163F35;
  --mat-line: rgba(236, 244, 238, 0.055);
  --mat-line-strong: rgba(236, 244, 238, 0.12);
  --ink: #ECF4EE;
  --ink-soft: rgba(236, 244, 238, 0.74);
  --ink-faint: rgba(236, 244, 238, 0.16);
  --cut: #E63946;
  --cut-strong: #D62839;
  --focus: #F2C94C;
  --font: "Bricolage Grotesque", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  --dock-h: 72px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  background-color: var(--mat);
  background-image:
    radial-gradient(ellipse at 50% 40%, transparent 55%, rgba(10, 36, 29, 0.45) 100%),
    linear-gradient(var(--mat-line-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--mat-line-strong) 1px, transparent 1px),
    linear-gradient(var(--mat-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--mat-line) 1px, transparent 1px);
  background-size: 100% 100%, 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  background-position: 0 0, -1px -1px, -1px -1px, -1px -1px, -1px -1px;
}

button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
svg { flex: none; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: rgba(22, 63, 53, 0.92);
  border-bottom: 1px solid var(--ink-faint);
  position: relative;
  z-index: 20; /* above the work area, so the Save as menu can drop over it */
}

.brand { display: flex; align-items: baseline; gap: 14px; min-width: 0; }

/* The wordmark has a strip cut out of it. */
.wordmark {
  font-size: 30px;
  font-weight: 800;
  font-variation-settings: "opsz" 96;
  letter-spacing: -0.03em;
  line-height: 1;
  padding-right: 2px;
  color: transparent;
  background: linear-gradient(90deg,
    var(--ink) 0 47%,
    var(--cut) 47% 49%,
    transparent 49% 53%,
    var(--cut) 53% 55%,
    var(--ink) 55%);
  -webkit-background-clip: text;
  background-clip: text;
}

.tagline { color: var(--ink-soft); font-size: 14px; white-space: nowrap; }

.actions { display: flex; align-items: center; gap: 4px; }

.tool {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.tool svg, .seg svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.tool:hover:not(:disabled) { background: rgba(236, 244, 238, 0.08); }
.tool:disabled { opacity: 0.38; cursor: default; }
.tool-primary { background: var(--ink); color: var(--mat-deep); font-weight: 600; }
.tool-primary:hover:not(:disabled) { background: #fff; }
.tool-primary:disabled { background: transparent; color: var(--ink); border-color: var(--ink-faint); }

.sep { width: 1px; height: 24px; background: var(--ink-faint); margin: 0 6px; }

/* Download: the main part saves in the original format, the arrow opens "Save as". */
.split { position: relative; display: flex; }
.split .split-main { border-radius: 10px 0 0 10px; }
.split .split-caret {
  padding: 0 7px;
  border-radius: 0 10px 10px 0;
  border-left: 1px solid rgba(22, 63, 53, 0.22);
}
.split .split-caret svg { width: 16px; height: 16px; transition: transform 0.15s ease-out; }
.split .split-caret[aria-expanded="true"] svg { transform: rotate(180deg); }
.split .split-caret:disabled { border-left-color: var(--ink-faint); }
.split .split-main:disabled { border-right: 0; }

.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  width: 288px;
  padding: 6px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--mat-deep);
  box-shadow: 0 18px 40px -12px rgba(4, 20, 16, 0.75), 0 0 0 1px rgba(4, 20, 16, 0.12);
  animation: menu-in 0.14s ease-out;
}
/* Invisible bridge so the pointer can travel from the arrow to the menu without closing it. */
.menu::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }
.menu-title { margin: 4px 10px 6px; font-size: 12.5px; font-weight: 600; color: rgba(22, 63, 53, 0.7); }
.menu-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 1px 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: rgba(22, 63, 53, 0.09); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--mat-deep); }
.menu-name { font-size: 14.5px; font-weight: 600; }
.menu-ext { margin-left: 6px; font-size: 12.5px; font-weight: 500; color: rgba(22, 63, 53, 0.6); }
.menu-tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--mat-deep);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
}
.menu-note { grid-column: 1 / -1; font-size: 12.5px; color: rgba(22, 63, 53, 0.72); }

/* ---------- Stage ---------- */

.stage {
  position: relative;
  overflow: hidden;
  min-height: 0;
}

/* Scrollable work area; the sheet is centred with auto margins so it stays reachable when zoomed in. */
.viewport {
  position: absolute;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  scrollbar-width: thin;
  scrollbar-color: rgba(236, 244, 238, 0.3) transparent;
}
.viewport.can-pan { cursor: grab; }
.viewport.loupe-on { cursor: crosshair; }
.viewport.panning { cursor: grabbing; }

.canvas-area {
  display: flex;
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  padding: 46px 84px calc(var(--dock-h) + 58px) 46px;
}

/* Empty state */
.stage.is-empty { display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.empty { display: grid; place-items: center; width: 100%; height: 100%; }
.drop {
  width: min(540px, 100%);
  padding: 44px 32px 40px;
  text-align: center;
  border: 2px dashed rgba(236, 244, 238, 0.34);
  border-radius: 22px;
  background: rgba(22, 63, 53, 0.55);
  transition: border-color 0.15s, background-color 0.15s;
}
body.dragging .drop { border-style: solid; border-color: var(--ink); background: rgba(236, 244, 238, 0.08); }
.drop-art { width: 160px; height: 110px; filter: drop-shadow(0 10px 18px rgba(5, 25, 20, 0.45)); }
.drop h1 {
  margin: 22px 0 8px;
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 700;
  font-variation-settings: "opsz" 64;
  letter-spacing: -0.015em;
  line-height: 1.15;
}
.drop p { margin: 0 auto 26px; max-width: 38ch; color: var(--ink-soft); }

.btn-primary {
  min-height: 46px;
  padding: 0 24px;
  border: 0;
  border-radius: 12px;
  background: var(--ink);
  color: var(--mat-deep);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: #fff; }

/* Sheet: the image lying on the mat */
.sheet { position: relative; flex: none; margin: auto; }

.paper {
  position: absolute;
  left: 0; top: 0;
  overflow: hidden;
  background: repeating-conic-gradient(#e4e9e6 0 25%, #fff 0 50%) 0 0 / 16px 16px;
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.18),
    0 4px 10px rgba(5, 25, 20, 0.3),
    0 22px 44px -14px rgba(5, 25, 20, 0.7);
}
.paper canvas { position: absolute; display: block; }

/* Rulers hug the image, and pin to the edges of the work area once it is zoomed past them. */
.ruler { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; }

.dims {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 10px);
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  color: var(--ink-soft);
  white-space: nowrap;
}
#dimsName { overflow: hidden; text-overflow: ellipsis; }

/* Overlay: red strip, lines and grips */
.overlay { position: absolute; inset: 0; }
.overlay > svg { position: absolute; overflow: hidden; pointer-events: none; }

.band { fill: rgba(230, 57, 70, 0.3); pointer-events: visible; cursor: grab; touch-action: none; }

/* Crop: everything outside the rectangle is dimmed; corners and edges have handles. */
.crop-shade { fill: rgba(8, 26, 21, 0.6); pointer-events: visible; cursor: crosshair; touch-action: none; }
.crop-area { fill: transparent; stroke: #fff; stroke-width: 1.5; pointer-events: visible; cursor: move; touch-action: none; }
.crop-grid line { stroke: rgba(255, 255, 255, 0.4); stroke-width: 1; }
.crop-grid { opacity: 0.55; transition: opacity 0.15s; }
.overlay.crop-dragging .crop-grid { opacity: 1; }

.ch { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; touch-action: none; outline: none; }
.ch::before, .ch::after {
  content: "";
  position: absolute;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(4, 20, 16, 0.4), 0 2px 6px rgba(4, 20, 16, 0.4);
}
/* Corners: an L that wraps the corner. */
.ch[data-h="nw"]::before, .ch[data-h="ne"]::before, .ch[data-h="sw"]::before, .ch[data-h="se"]::before { top: 18px; width: 22px; height: 4px; }
.ch[data-h="nw"]::after, .ch[data-h="ne"]::after, .ch[data-h="sw"]::after, .ch[data-h="se"]::after { left: 18px; width: 4px; height: 22px; }
.ch[data-h="nw"]::before, .ch[data-h="sw"]::before { left: 18px; }
.ch[data-h="ne"]::before, .ch[data-h="se"]::before { left: 4px; }
.ch[data-h="ne"]::after, .ch[data-h="nw"]::after { top: 18px; }
.ch[data-h="sw"]::after, .ch[data-h="se"]::after { top: 4px; }
.ch[data-h="ne"]::after, .ch[data-h="se"]::after { left: 22px; }
.ch[data-h="sw"]::before, .ch[data-h="se"]::before { top: 22px; }
/* Edges: a short bar along the edge. */
.ch[data-h="n"]::before, .ch[data-h="s"]::before { left: 8px; top: 20px; width: 28px; height: 4px; }
.ch[data-h="e"]::before, .ch[data-h="w"]::before { left: 20px; top: 8px; width: 4px; height: 28px; }
.ch[data-h="n"]::after, .ch[data-h="s"]::after, .ch[data-h="e"]::after, .ch[data-h="w"]::after { display: none; }
.ch[data-h="nw"], .ch[data-h="se"] { cursor: nwse-resize; }
.ch[data-h="ne"], .ch[data-h="sw"] { cursor: nesw-resize; }
.ch[data-h="n"], .ch[data-h="s"] { cursor: ns-resize; }
.ch[data-h="e"], .ch[data-h="w"] { cursor: ew-resize; }
.ch:focus-visible::before, .ch:focus-visible::after { background: var(--focus); }
.readout.is-crop { background: rgba(22, 63, 53, 0.94); color: var(--ink); }
.band-hatch { fill: url(#hatch); pointer-events: none; }
/* Zoomed in far enough, the exact pixels are tinted on the image instead. */
.exact .band { fill: transparent; }
.exact .band-hatch { display: none; }
#hatchLine { stroke: rgba(214, 40, 57, 0.55); }
.halo { stroke: rgba(255, 255, 255, 0.9); stroke-width: 4; }
.cutline { stroke: var(--cut); stroke-width: 2; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }

.grip, .tilt {
  position: absolute;
  width: 44px; height: 44px;
  margin: -22px 0 0 -22px;
  display: grid;
  place-items: center;
  touch-action: none;
  outline: none;
  border-radius: 50%;
}
.grip { cursor: grab; }
.pill {
  position: relative;
  width: 14px; height: 40px;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 0 0 2px var(--cut), 0 3px 8px rgba(0, 0, 0, 0.38);
  transition: transform 0.12s ease-out, box-shadow 0.12s;
}
.pill::before {
  content: "";
  position: absolute;
  left: 3.5px; right: 3.5px; top: 50%;
  height: 7px; margin-top: -3.5px;
  border-top: 1.5px solid rgba(214, 40, 57, 0.6);
  border-bottom: 1.5px solid rgba(214, 40, 57, 0.6);
}
.grip:hover .pill, .grip.dragging .pill { transform: scale(1.1); }
.grip:focus-visible .pill { box-shadow: 0 0 0 2px var(--cut), 0 0 0 5px var(--focus), 0 3px 8px rgba(0, 0, 0, 0.38); }

.tilt { cursor: grab; }
.knob {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px var(--cut), 0 3px 8px rgba(0, 0, 0, 0.38);
  transition: transform 0.12s ease-out, box-shadow 0.12s;
}
.knob svg { width: 18px; height: 18px; fill: none; stroke: var(--cut-strong); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tilt:hover .knob, .tilt.dragging .knob { transform: scale(1.08); }
.tilt:focus-visible .knob { box-shadow: 0 0 0 2px var(--cut), 0 0 0 5px var(--focus), 0 3px 8px rgba(0, 0, 0, 0.38); }

.readout {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--cut-strong);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* ---------- Dock ---------- */

.dock {
  position: absolute;
  left: 50%; bottom: 20px;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 10px;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 8px;
  border: 1px solid var(--ink-faint);
  border-radius: 18px;
  background: rgba(22, 63, 53, 0.94);
  box-shadow: 0 16px 36px -12px rgba(4, 20, 16, 0.75);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.seg { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: rgba(4, 22, 17, 0.32); }
.seg button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.seg button:hover { color: var(--ink); background: rgba(236, 244, 238, 0.07); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--mat-deep); font-weight: 600; }

.divider { width: 1px; height: 30px; background: var(--ink-faint); }

.finish { display: flex; gap: 6px; }
.btn-ghost, .btn-cut {
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  font-size: 15px;
  cursor: pointer;
}
.btn-ghost { padding: 0 14px; background: transparent; color: var(--ink-soft); font-weight: 500; }
.btn-ghost:hover:not(:disabled) { color: var(--ink); background: rgba(236, 244, 238, 0.07); }
.btn-ghost:disabled { opacity: 0.4; cursor: default; }
.btn-cut { padding: 0 26px; background: var(--cut-strong); color: #fff; font-weight: 600; }
.btn-cut:hover:not(:disabled) { background: #c41f30; }
.btn-cut:disabled { background: rgba(236, 244, 238, 0.08); color: rgba(236, 244, 238, 0.42); cursor: default; }

/* ---------- Zoom bar and magnifier ---------- */

.zoombar {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px;
  border: 1px solid var(--ink-faint);
  border-radius: 14px;
  background: rgba(22, 63, 53, 0.94);
  box-shadow: 0 14px 30px -12px rgba(4, 20, 16, 0.75);
}
.zoombar button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.zoombar button svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.zoombar button:hover:not(:disabled) { background: rgba(236, 244, 238, 0.08); }
.zoombar button:disabled { opacity: 0.35; cursor: default; }
.zoombar button[aria-pressed="true"] { background: var(--ink); color: var(--mat-deep); }
.zoombar .zoom-level { height: 28px; font-size: 11.5px; font-weight: 600; letter-spacing: -0.01em; }
.zoom-rule { width: 26px; height: 1px; margin: 3px 0; background: var(--ink-faint); }

.loupe {
  position: absolute;
  left: 0; top: 0;
  z-index: 8;
  width: 176px;
  height: 176px;
  border-radius: 50%;
  pointer-events: none;
  box-shadow:
    0 0 0 3px #fff,
    0 0 0 4px rgba(4, 20, 16, 0.35),
    0 16px 34px -8px rgba(4, 20, 16, 0.75);
}

/* ---------- History ---------- */

.tool .count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(236, 244, 238, 0.14);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}
#historyBtn[aria-expanded="true"] { background: rgba(236, 244, 238, 0.12); }

.history {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  z-index: 7;
  width: 320px;
  display: flex;
  flex-direction: column;
  background: rgba(22, 63, 53, 0.97);
  border-left: 1px solid var(--ink-faint);
  box-shadow: -18px 0 40px -24px rgba(4, 20, 16, 0.85);
  animation: history-in 0.2s ease-out;
}
@keyframes history-in { from { opacity: 0; transform: translateX(24px); } }

.history-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 4px 18px; }
.history-head h2 { margin: 0; font-size: 18px; font-weight: 700; font-variation-settings: "opsz" 48; }
.history-close {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border: 0; border-radius: 10px;
  background: transparent;
  cursor: pointer;
}
.history-close:hover { background: rgba(236, 244, 238, 0.08); }
.history-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.history-hint { margin: 0 18px 8px; font-size: 13px; line-height: 1.45; color: var(--ink-soft); }

.log { flex: 1; margin: 0; padding: 4px 12px 20px 8px; overflow-y: auto; list-style: none; scrollbar-width: thin; }

/* One version: a rail with a dot (the commit graph), then a card. */
.commit { position: relative; display: grid; grid-template-columns: 24px 1fr; }
.commit::before {
  content: "";
  position: absolute;
  left: 11px; top: 0; bottom: 0;
  width: 2px;
  background: rgba(236, 244, 238, 0.2);
}
.commit:first-child::before { top: 24px; }
.commit:last-child::before { bottom: calc(100% - 24px); }
.commit:only-child::before { display: none; }
.dot {
  position: relative;
  z-index: 1;
  width: 12px; height: 12px;
  margin: 19px 0 0 6px;
  border: 2px solid var(--ink-soft);
  border-radius: 50%;
  background: var(--mat-deep);
}
.commit.kind-cut .dot { border-color: var(--cut); }
.commit.kind-crop .dot { border-color: var(--focus); }
.commit.is-head .dot { width: 14px; height: 14px; margin: 18px 0 0 5px; border-color: var(--ink); background: var(--ink); box-shadow: 0 0 0 3px rgba(236, 244, 238, 0.18); }

.card {
  margin: 4px 0;
  padding: 10px 12px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.12s;
}
.card:hover { background: rgba(236, 244, 238, 0.06); }
.card:focus-visible { outline-offset: 0; }
.is-head .card { background: rgba(236, 244, 238, 0.07); }
.is-preview .card { background: rgba(236, 244, 238, 0.12); border-color: rgba(236, 244, 238, 0.35); }
.is-undone .card { opacity: 0.6; }
.is-undone .card:hover, .is-undone.is-preview .card { opacity: 1; }

.card-title { display: flex; align-items: baseline; gap: 6px; font-size: 14.5px; font-weight: 600; line-height: 1.3; }
.card-title .num { color: var(--ink-soft); font-weight: 500; }
.tag {
  margin-left: auto;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  background: rgba(236, 244, 238, 0.12);
  color: var(--ink-soft);
}
.is-head .tag { background: var(--ink); color: var(--mat-deep); }
.card-detail { margin-top: 2px; font-size: 13px; color: var(--ink-soft); }
.thumbs { display: flex; align-items: center; gap: 6px; margin: 9px 0 8px; }
.thumbs img {
  display: block;
  max-width: 108px;
  max-height: 64px;
  border-radius: 4px;
  background: repeating-conic-gradient(#e4e9e6 0 25%, #fff 0 50%) 0 0 / 10px 10px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 4px 10px -4px rgba(0, 0, 0, 0.5);
}
.thumbs svg { width: 16px; height: 16px; fill: none; stroke: var(--ink-soft); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-soft); }
.card-foot { flex-wrap: wrap; }
.card-actions { display: flex; gap: 6px; margin-left: auto; }
.card-actions:empty { display: none; }
.card-foot .restore {
  flex: none;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid rgba(236, 244, 238, 0.3);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.card-foot .restore:hover:not(:disabled) { background: var(--ink); color: var(--mat-deep); }
.card-foot .restore:disabled { opacity: 0.45; cursor: default; }

.preview-bar {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 32px);
  padding: 6px 6px 6px 14px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--mat-deep);
  font-size: 14px;
  box-shadow: 0 12px 28px -10px rgba(4, 20, 16, 0.7);
  white-space: nowrap;
}
.preview-bar > span { overflow: hidden; text-overflow: ellipsis; }
.preview-bar button {
  flex: none;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(22, 63, 53, 0.25);
  border-radius: 8px;
  background: transparent;
  color: var(--mat-deep);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.preview-bar button:hover { background: rgba(22, 63, 53, 0.08); }
.preview-bar .primary { border-color: transparent; background: var(--mat-deep); color: var(--ink); }
.preview-bar .primary:hover { background: #0f2e26; }

.dock button:disabled { opacity: 0.4; cursor: default; }
/* Make room for the preview bar above the rulers. */
.stage.previewing .canvas-area { padding-top: 92px; }
.preview-bar { top: 10px; }

/* Wide screens: the history panel takes its own column instead of covering the image. */
@media (min-width: 900px) {
  .stage.history-open .canvas-area { padding-right: 404px; }
  .stage.history-open .zoombar { right: 336px; }
  .stage.history-open .dock,
  .stage.history-open .toast,
  .stage.history-open .preview-bar { left: calc((100% - 320px) / 2); }
}

/* Narrow screens: the history panel is a bottom sheet. */
@media (max-width: 899px) {
  .history {
    top: auto; left: 0;
    width: auto;
    height: min(64%, 540px);
    border-left: 0;
    border-top: 1px solid var(--ink-faint);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -18px 40px -20px rgba(4, 20, 16, 0.85);
    animation-name: sheet-in;
  }
  @keyframes sheet-in { from { opacity: 0; transform: translateY(32px); } }
}

/* ---------- Toast and drop hint ---------- */

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--dock-h) + 34px);
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 32px);
  padding: 9px 9px 9px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--mat-deep);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 12px 28px -10px rgba(4, 20, 16, 0.7);
  animation: toast-in 0.18s ease-out;
}
.toast:not(:has(button)) { padding-right: 16px; }
.toast button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(22, 63, 53, 0.28);
  border-radius: 8px;
  background: transparent;
  color: var(--mat-deep);
  font-weight: 600;
  cursor: pointer;
}
.toast button:hover { background: rgba(22, 63, 53, 0.08); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } }

.drop-hint {
  position: absolute;
  inset: 14px;
  z-index: 7;
  display: grid;
  place-items: center;
  border: 2px dashed var(--ink);
  border-radius: 22px;
  background: rgba(22, 63, 53, 0.78);
  font-size: 22px;
  font-weight: 600;
  pointer-events: none;
}

/* ---------- Small screens ---------- */

@media (max-width: 900px) {
  .tagline { display: none; }
}

@media (max-width: 680px) {
  .topbar { padding: 8px 12px; }
  .wordmark { font-size: 26px; }
  .tool { padding: 0 10px; }
  .tool span { display: none; }
  .actions { gap: 0; }
  .tool { padding: 0 8px; }
  .split .split-caret { padding: 0 5px; }
  .menu { width: min(288px, calc(100vw - 24px)); }
  .preview-bar { flex-wrap: wrap; justify-content: center; width: calc(100% - 32px); padding: 8px; gap: 6px; }
  .preview-bar > span { width: 100%; text-align: center; }
  .stage.previewing .canvas-area { padding-top: 120px; }
  .sep { margin: 0 2px; }
  .canvas-area { padding: 36px 58px calc(var(--dock-h) + 48px) 34px; }
  .zoombar { right: 8px; padding: 4px; }
  .zoombar button { width: 36px; height: 36px; }
  .zoombar .zoom-level { height: 26px; font-size: 10.5px; }
  .loupe { width: 148px; height: 148px; }
  .dock { bottom: 12px; gap: 6px; padding: 6px; }
  .divider { display: none; }
  .seg button { padding: 0 10px; font-size: 13.5px; gap: 6px; }
  .btn-ghost { padding: 0 10px; }
  .btn-cut { padding: 0 20px; }
  .drop { padding: 32px 20px; }
}

@media (max-width: 400px) {
  .seg button svg { display: none; }
}

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