/* Docufen Photo Repair. Tokens follow the Docufen app (neutral theme, brand green #0E7C3F).
   No external fonts: the CSP allows only this site, so a system font stack is used. */
:root {
  color-scheme: light;
  --bg: #efece6;
  --side: #efece6;
  --side-hover: #e7e3dc;
  --surface: #f9f8f5;
  --fg: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --accent: #0e7c3f;
  --accent-soft: #eef6f1;
  --on-accent: #ffffff;
  --ok: #0e7c3f;
  --ok-soft: #eef6f1;
  --warn: #92400e;
  --warn-soft: #fef3c7;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #1b1916; --side: #1b1916; --side-hover: #26231f; --surface: #1f1c19; --fg: #f5f3ef; --muted: #a8a29e; --line: #2f2b27;
  --accent: #34b26c; --accent-soft: #10291b; --on-accent: #04130a; --ok: #34b26c; --ok-soft: #10291b;
  --warn: #fbbf24; --warn-soft: #3a2a0c; --bad: #f87171; --bad-soft: #3b1414; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #1b1916; --side: #1b1916; --side-hover: #26231f; --surface: #1f1c19; --fg: #f5f3ef; --muted: #a8a29e; --line: #2f2b27;
  --accent: #34b26c; --accent-soft: #10291b; --on-accent: #04130a; --ok: #34b26c; --ok-soft: #10291b;
  --warn: #fbbf24; --warn-soft: #3a2a0c; --bad: #f87171; --bad-soft: #3b1414; color-scheme: dark }

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 14px; line-height: 1.5; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--side-hover); padding-block: 16px; padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: 12px; display: flex; flex-direction: column; gap: 18px; }
.tenant { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 14px; padding: 6px 10px; }
.logo { display: flex; align-items: center; gap: 8px; }
.logo i { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-block; }
.side .label { font-size: 13px; color: var(--muted); padding: 0 10px; }
.side .foot { margin-top: auto; font-size: 13px; color: var(--muted); padding: 6px 10px; }
.mainpane { min-width: 0; padding-block: 18px 64px; padding-left: 28px; padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 18px; align-content: start; }
.crumbs { display: flex; align-items: center; gap: 10px; font-size: 17px; flex-wrap: wrap; }
.crumbs .c1 { color: var(--muted); }
.crumbs .sep { color: var(--muted); font-size: 14px; }
.crumbs .c2 { font-weight: 500; }
.content { max-width: 880px; display: grid; gap: 14px; }
.mobsteps { display: none; font-size: 13px; color: var(--muted); margin: 0; }
@media (max-width: 760px) { .app { grid-template-columns: 1fr; } .side { display: none; } .mainpane { padding-left: max(16px, env(safe-area-inset-left, 0px)); } .mobsteps { display: block; } }
h1, h2 { font-size: 17px; font-weight: 600; margin: 0; text-wrap: balance; }
h2:focus { outline: none; }
p { margin: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.mt8 { margin-top: 8px; }
.pad { padding: 12px; }
.tag { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--warn); background: var(--warn-soft); border-radius: 999px; padding: 2px 10px; }
.rail { display: grid; gap: 2px; list-style: none; margin: 0; padding: 0; }
.rail li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--fg); padding: 8px 10px; border-radius: 8px; }
.rail li .tick { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface); display: inline-grid; place-items: center; font-size: 13px; font-weight: 600; color: var(--muted); flex: none; }
.rail li.done .tick { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.rail li.now { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.rail li.now .tick { background: var(--on-accent); border-color: var(--on-accent); color: var(--accent); }
.rail li:not(.now):not(.done) { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.05); padding: 24px; display: grid; gap: 16px; min-width: 0; }
@media (max-width: 480px) { .card { padding: 16px; } }
.lead { font-size: 14px; max-width: 62ch; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.nav { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
button, .filebtn { font: inherit; font-size: 14px; font-weight: 500; border: 1px solid var(--line); background: var(--surface); color: var(--fg); min-height: 36px; padding: 7px 16px; border-radius: 6px; cursor: pointer; position: relative; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
button:hover:not(:disabled), .filebtn:hover { background: var(--bg); }
button.primary, a.filebtn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
button.primary:hover:not(:disabled), a.filebtn.primary:hover { background: var(--accent); filter: brightness(.92); }
button.big { padding: 12px 22px; }
button:focus-visible, .filebtn:focus-within, .filebtn:focus-visible, input:focus-visible, select:focus-visible, pre:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: default; }
.filebtn input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop { border: 2px dashed var(--line); border-radius: 8px; padding: 22px; text-align: center; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--fg); }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 14px; margin: 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 300px); gap: 24px; align-items: start; }
.introtext { display: grid; gap: 10px; align-content: start; }
@media (max-width: 720px) { .intro { grid-template-columns: 1fr; } }
.start { display: grid; gap: 10px; justify-items: start; }
.steps { display: grid; gap: 12px; margin: 0; padding-left: 20px; }
.stagecol { display: grid; gap: 6px; min-width: 0; }

/* Intro animation */
.anim { margin: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.anim svg { display: block; width: 100%; height: auto; }
.a-zone { fill: var(--surface); stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 6 5; }
.a-step { fill: var(--fg); font: 600 13px var(--font-body); opacity: 0; }
.a-s1 { animation: a-s1 12s infinite; } .a-s2 { animation: a-s2 12s infinite; } .a-s3 { animation: a-s3 12s infinite; }
@keyframes a-s1 { 0%, 24% { opacity: 1; } 26%, 100% { opacity: 0; } }
@keyframes a-s2 { 0%, 25% { opacity: 0; } 27%, 68% { opacity: 1; } 70%, 100% { opacity: 0; } }
@keyframes a-s3 { 0%, 69% { opacity: 0; } 71%, 100% { opacity: 1; } }
.a-ph { fill: #cfe3f1; } .a-sun { fill: #f2b53a; } .a-hill { fill: #4f7d5c; } .a-hill2 { fill: #77a083; }
.a-photo { animation: a-photo 12s infinite; }
@keyframes a-photo { 0% { transform: translate(150px, -60px); opacity: 1; } 10% { transform: translate(150px, 72px); } 25% { transform: translate(150px, 72px); } 32% { transform: translate(110px, 44px) scale(2.334, 2.273); } 68% { transform: translate(110px, 44px) scale(2.334, 2.273); opacity: 1; } 72%, 100% { transform: translate(110px, 44px) scale(2.334, 2.273); opacity: 0; } }
.a-cropg { opacity: 0; animation: a-cropg 12s infinite; transform-origin: 0 0; }
@keyframes a-cropg { 0%, 32% { opacity: 0; transform: translate(110px, 44px) scale(1, 1); } 34% { opacity: 1; transform: translate(110px, 44px) scale(1, 1); } 46% { transform: translate(138px, 62px) scale(.8, .82); } 49% { transform: translate(138px, 62px) scale(.8, .82); } 60% { transform: translate(138px, 62px) scale(.643, .66); } 68% { opacity: 1; transform: translate(138px, 62px) scale(.643, .66); } 72%, 100% { opacity: 0; transform: translate(138px, 62px) scale(.643, .66); } }
.a-dimz { fill: rgba(0,0,0,.5); opacity: 0; animation: a-dimz 12s infinite; }
@keyframes a-dimz { 0%, 34% { opacity: 0; } 38%, 68% { opacity: 1; } 72%, 100% { opacity: 0; } }
.a-hole { transform-origin: 0 0; animation: a-hole 12s infinite; }
@keyframes a-hole { 0%, 34% { transform: translate(110px, 44px) scale(1, 1); } 46%, 49% { transform: translate(138px, 62px) scale(.8, .82); } 60%, 100% { transform: translate(138px, 62px) scale(.643, .66); } }
.a-frame { fill: none; stroke: #ffffff; stroke-width: 1.5; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }
.a-h { fill: #ffffff; stroke: var(--accent); stroke-width: 1.5; opacity: 0; }
.a-htl { animation: a-htl 12s infinite; } .a-hbr { animation: a-hbr 12s infinite; }
@keyframes a-htl { 0%, 32% { opacity: 0; transform: translate(110px, 44px); } 34% { opacity: 1; transform: translate(110px, 44px); } 46% { transform: translate(138px, 62px); } 68% { opacity: 1; transform: translate(138px, 62px); } 70%, 100% { opacity: 0; transform: translate(138px, 62px); } }
@keyframes a-hbr { 0%, 32% { opacity: 0; transform: translate(250px, 144px); } 34% { opacity: 1; transform: translate(250px, 144px); } 49% { transform: translate(250px, 144px); } 60% { transform: translate(228px, 128px); } 68% { opacity: 1; transform: translate(228px, 128px); } 70%, 100% { opacity: 0; transform: translate(228px, 128px); } }
.a-badge { opacity: 0; animation: a-badge 12s infinite; }
.a-badge rect { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1; }
.a-badge text { fill: var(--accent); font: 600 11px var(--font-body); }
@keyframes a-badge { 0%, 12% { opacity: 0; } 15%, 26% { opacity: 1; } 29%, 100% { opacity: 0; } }
.a-cursor { fill: var(--fg); stroke: var(--surface); stroke-width: 1; opacity: 0; animation: a-cursor 12s infinite; }
@keyframes a-cursor { 0%, 30% { opacity: 0; transform: translate(170px, 110px); } 31% { opacity: 1; transform: translate(170px, 110px); } 34% { transform: translate(110px, 44px); } 46% { transform: translate(138px, 62px); } 49% { transform: translate(250px, 144px); } 60% { opacity: 1; transform: translate(228px, 128px); } 64%, 100% { opacity: 0; transform: translate(228px, 128px); } }
.a-doc { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; }
.a-code { fill: var(--accent); font: 600 11px var(--font-mono); }
.a-file { opacity: 0; animation: a-file 12s infinite; }
@keyframes a-file { 0%, 71% { opacity: 0; transform: translate(165px, 75px) scale(.6); } 76% { opacity: 1; transform: translate(165px, 75px) scale(1); } 80% { opacity: 1; transform: translate(165px, 75px) scale(1); } 90% { opacity: 1; transform: translate(170px, 205px) scale(.7); } 92%, 100% { opacity: 0; transform: translate(170px, 205px) scale(.7); } }
.a-envbody { fill: var(--surface); stroke: var(--fg); stroke-width: 1.5; }
.a-envv { fill: none; stroke: var(--fg); stroke-width: 1.2; }
.a-flap { fill: var(--side); stroke: var(--fg); stroke-width: 1.5; transform-box: fill-box; transform-origin: 50% 100%; animation: a-flap 12s infinite; }
@keyframes a-flap { 0%, 91% { transform: scaleY(1); } 95%, 100% { transform: scaleY(-1); } }
@media (prefers-reduced-motion: reduce) { .a-photo, .a-cropg, .a-htl, .a-hbr, .a-badge, .a-cursor, .a-file, .a-flap, .a-s1, .a-s2, .a-s3 { animation: none; } .a-s2 { opacity: 1; } .a-photo { transform: translate(110px, 44px) scale(2.334, 2.273); } .a-cropg { opacity: 1; transform: translate(138px, 62px) scale(.643, .66); } .a-dimz { animation: none; opacity: 1; } .a-hole { animation: none; transform: translate(138px, 62px) scale(.643, .66); } }

/* Size bar, lists, photo editor */
.size { display: grid; gap: 6px; }
.bar { height: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; position: relative; overflow: hidden; }
.bar .fill { position: absolute; inset: 0 auto 0 0; background: var(--ok); }
.bar .fill.over { background: var(--bad); }
.bar .limit { position: absolute; top: -1px; bottom: -1px; width: 2px; background: var(--fg); }
.pill { display: inline-block; font-size: 13px; font-weight: 600; letter-spacing: .02em; padding: 2px 8px; border-radius: 999px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.lock { background: var(--accent-soft); color: var(--accent); }
.pill.plain { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.list li { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; }
.photo { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 720px) { .photo { grid-template-columns: 1fr; } }
.stage { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; touch-action: none; user-select: none; }
.stage canvas { display: block; width: 100%; height: auto; cursor: crosshair; }
.stage.locked canvas { cursor: default; }
.controls { display: grid; gap: 12px; align-content: start; min-width: 0; }
.ctl { display: grid; gap: 4px; font-size: 14px; }
.ctl label { color: var(--muted); }
.ctl select, .ctl input[type=range] { width: 100%; accent-color: var(--accent); }
select { font: inherit; font-size: 14px; padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); }
.loupe { border: 1px solid var(--line); border-radius: 6px; overflow: auto; max-height: 340px; background: var(--bg); }
.loupe img { max-width: none; display: block; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; }
pre { margin: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 12px; overflow: auto; max-height: 260px; font-family: var(--font-mono); font-size: 13px; }
details summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.err { color: var(--bad); font-size: 14px; }
.err:empty { display: none; }
.hint { font-size: 13px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
