:root {
  --bg: #ffffff;
  --panel: #f6f7f9;
  --panel-2: #eef0f4;
  --border: #d7dbe2;
  --text: #14161a;
  --muted: #5b6675;
  --accent: #0a84ff;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.bar__meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bar__meta strong {
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar__src {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(60vw, 520px);
}

.bar__src:hover {
  text-decoration: underline;
}

.bar__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn,
.tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover,
.tool:hover {
  border-color: #a9b2be;
}

.btn--danger {
  background: transparent;
  border-color: #e0b4b0;
  color: #c0392b;
}

.btn--danger:hover {
  background: #fdeceb;
  border-color: #c9857f;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* White text worked when the button sat on a dark panel; on a light one the
   pressed tool takes the accent as its foreground instead. */
.tool[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

/* --------------------------------------------------------------- toolbar */

/* A class-level `display` outranks the UA's `[hidden] { display: none }`, so
   the toolbar needs to opt back out explicitly or it shows before unlock. */
.toolbar[hidden] {
  display: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}

.toolbar__group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
  padding: 0;
}

.swatch[aria-pressed="true"] {
  border-color: var(--text);
}

.status {
  font-size: 12px;
  color: var(--muted);
  min-width: 90px;
}

/* ----------------------------------------------------------------- stage */

.stage {
  padding: 20px;
  display: flex;
  justify-content: center;
}

.canvas {
  position: relative;
  width: 100%;
  /* Never upscale past the capture's own pixels — a small shot blown up to
     fill the page is just blurry. `--natural` comes from the shot row. */
  max-width: min(1400px, var(--natural, 1400px));
  line-height: 0;
  border-radius: 10px;
  overflow: hidden;
  /* Most screenshots are of light UI, so on a white page the shot would bleed
     into it edgelessly. The hairline border does the work the dark backdrop
     used to; the shadow only lifts it. */
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgb(20 22 26 / 10%);
  background: var(--panel-2);
}

.canvas img,
.canvas svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* The annotation layer sits exactly over the image and only takes pointer
   events once editing is unlocked, so a plain viewer can still select text
   and drag the image out. */
.canvas svg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  touch-action: none;
}

.canvas--editing svg {
  pointer-events: auto;
  cursor: crosshair;
}

/* ----------------------------------------------------------------- prose */

.prose {
  max-width: 640px;
  margin: 0 auto;
  padding: 64px 20px;
  line-height: 1.6;
}

.prose h1 {
  font-size: 28px;
  margin: 0 0 12px;
}

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

@media (max-width: 640px) {
  .stage {
    padding: 10px;
  }

  .bar,
  .toolbar {
    padding: 10px;
  }
}

/* ---------------------------------------------------------------- unlock */

.unlock[hidden] {
  display: none;
}

.unlock {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.unlock label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.unlock input {
  flex: 1;
  min-width: 180px;
  max-width: 340px;
  min-height: 36px;
  padding: 7px 11px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.unlock__msg {
  font-size: 12px;
  color: var(--muted);
}

/* Text entry sits over the image at the point you clicked. */
.text-entry {
  position: absolute;
  z-index: 3;
  transform: translateY(-2px);
  min-width: 140px;
  padding: 2px 6px;
  font-family: inherit;
  font-weight: 700;
  line-height: 1.2;
  background: rgb(255 255 255 / 92%);
  border: 2px dashed var(--accent);
  border-radius: 6px;
  outline: none;
}

.locked {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.locked::before {
  content: "\2713";
}

.btn[hidden] { display: none; }
.tool:disabled { opacity: 0.45; cursor: default; }
.canvas--editing [data-index] { cursor: move; }
