:root {
  color-scheme:dark;
  --bg:#111515;
  --panel:#1b2221;
  --line:#47534e;
  --text:#f4f5ec;
  --muted:#b8c5bd;
  --accent:#d1f881;
  --available-height:100dvh;
  --toolbar-height:calc(48px + env(safe-area-inset-top,0px));
  --tools-height:calc(52px + env(safe-area-inset-bottom,0px));
  --sheet-height:140px;
  font-family:system-ui,sans-serif;
  background:var(--bg);
  color:var(--text)
}
* { box-sizing:border-box }
html { overflow:hidden }
body { position:fixed; top:var(--viewport-top,0px); left:0; width:100%; height:var(--available-height); margin:0; overflow:hidden }
button,select,input { font:inherit }
button { min-height:44px; padding:8px 12px; border:1px solid var(--line); border-radius:6px; background:transparent; color:var(--text); font-size:13px; font-weight:650; cursor:pointer }
button:hover:not(:disabled) { border-color:var(--accent) }
button:disabled { opacity:.4; cursor:default }
button[aria-pressed=true] { color:var(--accent); border-color:var(--accent) }
.primary { background:var(--accent); border-color:var(--accent); color:#17220c }
.toolbar { height:var(--toolbar-height); display:flex; align-items:center; justify-content:space-between; gap:8px; padding:calc(1px + env(safe-area-inset-top,0px)) 12px 1px; border-bottom:1px solid #34413a }
.brand-block { position:relative; display:flex; flex-direction:column; justify-content:center; gap:1px; min-width:0; min-height:44px }
.back { font-size:11px; line-height:1.2; color:var(--muted); text-decoration:none; white-space:nowrap }
/* The wordmark is not interactive, so the small link borrows the whole block as its tap target. */
.back::after { content:""; position:absolute; inset:0 }
.back:hover { color:var(--accent) }
.brand { margin:0; font-size:16px; line-height:1.1; letter-spacing:-.5px; font-weight:850; text-decoration:none; color:var(--text) }
.toolbar-actions { display:flex; gap:6px }
.toolbar button { padding:7px 12px; font-size:12px }
.toolbar #original { min-width:76px }
main { display:grid; grid-template-columns:minmax(0,1fr) 320px; height:calc(100% - var(--toolbar-height)); min-height:0 }
.preview-panel { min-width:0; min-height:0; padding:8px 12px; display:flex; flex-direction:column; align-items:center; overflow:hidden }
.frame { position:relative; flex:none; width:min(100%,calc((var(--available-height) - var(--toolbar-height) - 44px) * .6)); aspect-ratio:3/5; background:white; overflow:hidden }
canvas { display:block; width:100%; height:auto; aspect-ratio:3/5; touch-action:pan-y; cursor:default }
canvas.loaded { cursor:grab; touch-action:none }
canvas.dragging { cursor:grabbing }
#empty { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:24px; padding:20px; background:#e6e9de; color:#394136; text-align:center }
#empty strong { font-size:clamp(28px,5vw,48px); font-weight:750; letter-spacing:-1.5px; line-height:1.05 }
#empty button { padding:10px 18px; background:#26362a; border-color:#26362a; color:#eff6e9 }
#empty span { font-size:12px; color:#52604f }
[hidden] { display:none !important }
.preview-details { display:flex; justify-content:center; flex-wrap:wrap; gap:4px 12px; margin-top:6px; min-height:18px; max-width:100%; font-size:11px; line-height:1.5; color:var(--muted) }
.preview-details p { margin:0 }
#status { font-variant-numeric:tabular-nums }
#controls { min-height:0; min-width:0; background:var(--panel); border-left:1px solid #34413a; overflow:hidden }
.tool-nav { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:0; height:48px; border-bottom:1px solid #34413a; background:var(--panel) }
.tool-nav button { height:100%; border:0; border-bottom:2px solid transparent; border-radius:0; min-width:0; padding:6px; font-size:12px; color:var(--muted) }
.tool-nav button[aria-current=true],.tool-nav button[aria-expanded=true] { border-bottom-color:var(--accent); color:var(--accent) }
.sheet-bar { display:none }
#options-scroll { height:calc(100% - 48px); overflow:auto; overscroll-behavior:contain; scrollbar-width:thin; scrollbar-color:var(--line) transparent; scroll-padding:12px }
#controls section { padding:20px 18px; border-bottom:1px solid #34413a; scroll-margin-top:0 }
h2 { font-size:14px; letter-spacing:.1px; margin:0 0 16px }
label { display:block; font-size:12px; font-weight:600; margin:16px 0 }
label>span { display:flex; justify-content:space-between; gap:10px; margin-bottom:6px }
output { font-variant-numeric:tabular-nums; color:var(--accent); font-size:11px }
select,input[type=text] { width:100%; min-height:44px; padding:8px 10px; font-size:16px; border:1px solid var(--line); border-radius:5px; background:#111816; color:var(--text) }
input[type=range] { width:100%; min-height:44px; accent-color:var(--accent); margin:0 }
.hint,.privacy { font-size:11px; color:var(--muted); line-height:1.6 }
.hint { margin:12px 0 0 }
.privacy { padding:0 18px 16px }
a { color:var(--accent) }
#save-again { display:inline-block; font-size:13px; margin-top:12px; min-height:44px; padding-top:12px }
.notifications { position:absolute; left:12px; right:332px; bottom:12px; display:flex; flex-direction:column; align-items:center; pointer-events:none; z-index:10 }
.notifications p { max-width:100%; margin:0; padding:10px 14px; border:1px solid var(--line); border-radius:6px; background:#18201cf5; color:var(--accent); font-size:12px; line-height:1.5; box-shadow:0 4px 16px #0006 }
.notifications p:empty { display:none }
.notifications #error { color:#ffb9ac }
:focus-visible { outline:2px solid var(--accent); outline-offset:2px }
canvas:focus-visible { outline-offset:-3px }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap }
@media(max-width:760px) {
  .toolbar { padding:calc(1px + env(safe-area-inset-top,0px)) 8px 1px }
  .toolbar-actions { gap:4px }
  .toolbar button { padding:7px 9px; font-size:11px }
  .toolbar #original { min-width:66px }
  main { grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(0,1fr) 0; height:calc(100% - var(--toolbar-height) - var(--tools-height)); }
  .preview-panel { padding:8px 8px 4px }
  .frame { width:min(100%,calc((var(--available-height) - var(--toolbar-height) - var(--tools-height) - 36px) * .6)) }
  .preview-details { font-size:10px; gap:3px 8px }
  #controls { border-left:0; border-top:0; }
  .tool-nav { position:absolute; bottom:0; left:0; right:0; height:var(--tools-height); padding-bottom:env(safe-area-inset-bottom,0px); border-top:1px solid #47534e; border-bottom:0 }
  .tool-nav button { font-size:13px; border-bottom:0; border-top:2px solid transparent }
  .tool-nav button[aria-expanded=true] { border-top-color:var(--accent) }
  #options-scroll { height:calc(100% - 44px); scroll-padding:8px }
  .sheet-bar { height:44px; display:none; align-items:center; justify-content:space-between; padding:0 12px; border-bottom:1px solid #34413a; font-size:12px }
  .panel-open .sheet-bar { display:flex }
  .sheet-bar button { border:0; color:var(--accent); padding:8px }
  #controls section { padding:2px 16px 8px; border-bottom:0 }
  #controls h2,.privacy { display:none }
  #photo-section { padding:8px 16px !important }
  .panel-open main { grid-template-rows:minmax(0,1fr) var(--sheet-height) }
  .panel-open #controls { border-top:1px solid var(--line) }
  .panel-open .frame { width:min(100%,calc((var(--available-height) - var(--toolbar-height) - var(--tools-height) - 36px - var(--sheet-height)) * .6)) }
  .notifications { right:12px; bottom:calc(var(--tools-height) + 8px) }
  .panel-open .notifications { bottom:calc(var(--tools-height) + var(--sheet-height) + 8px) }
  .compact.panel-open main { grid-template-columns:minmax(0,2fr) minmax(0,3fr); grid-template-rows:minmax(0,1fr) }
  .compact.panel-open #controls { border-top:0; border-left:1px solid var(--line) }
  .compact.panel-open .frame { width:min(100%,calc((var(--available-height) - var(--toolbar-height) - var(--tools-height) - 36px) * .6)) }
  .compact.panel-open .preview-details { display:block; text-align:center; font-size:10px }
  .compact.panel-open #crop-help { display:none }
  .compact.panel-open #controls section { padding-left:10px; padding-right:10px }
  .compact.panel-open .notifications { bottom:calc(var(--tools-height) + 8px) }
}

.zoom-control { display:grid; grid-template-columns:44px minmax(0,1fr) 44px; gap:8px; align-items:end; margin:16px 0 }
.zoom-control label { margin:0 }
.zoom-control button { font-size:20px; padding:4px }
.nudge-controls { border:0; padding:0; margin:16px 0 }
.nudge-controls legend { font-size:12px; font-weight:600; padding:0; margin-bottom:8px }
.nudge-grid { display:grid; grid-template-columns:repeat(3,44px); gap:6px; width:max-content }
.nudge-grid button { font-size:20px; padding:4px }
.nudge-grid [data-nudge=up] { grid-column:2 }
.nudge-grid [data-nudge=left] { grid-column:1; grid-row:2 }
.nudge-grid [data-nudge=down] { grid-column:2; grid-row:2 }
.nudge-grid [data-nudge=right] { grid-column:3; grid-row:2 }
#text-entry-switch { display:none }
@media(max-width:760px) {
  .compact.editing-text #text-controls > label { display:none }
  .compact.editing-text #text-controls > .active-line { display:block }
  .compact.editing-text #text-entry-switch { display:flex; gap:8px; padding-top:8px }
  .compact.editing-text #text-entry-switch button { flex:1; padding:8px 4px }
  .compact.editing-text #reset-type { display:none }
}

@media(max-width:760px) {
  #tool-setting { width:auto; min-width:0; flex:1; margin-right:8px; min-height:44px; height:44px; font-size:16px; border:0; background:transparent; padding:4px 0 }
  #photo-section > [data-choose-photo],#controls .hint { display:none }
  #text-controls > label,#dither-controls > label,#reset-type { display:none }
  #text-controls > .selected-setting,#dither-controls > .selected-setting { display:block; margin:8px 0 }
  [data-setting=reset-type] #reset-type { display:block; margin-top:12px }
  #crop-controls,.nudge-controls,#reset-crop { display:none }
  [data-setting=zoom] #crop-controls,[data-setting=move] .nudge-controls,[data-setting=reset-crop] #reset-crop { display:block }
  .zoom-control { margin:0 }
  .nudge-controls { margin:0 }
  .nudge-controls legend { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%) }
  /* One row keeps four 44px arrows inside the compact sheet. */
  .nudge-grid { grid-template-columns:repeat(4,44px); gap:8px; margin:auto }
  .nudge-grid [data-nudge] { grid-row:1 }
  .nudge-grid [data-nudge=left] { grid-column:1 }
  .nudge-grid [data-nudge=up] { grid-column:2 }
  .nudge-grid [data-nudge=down] { grid-column:3 }
  .nudge-grid [data-nudge=right] { grid-column:4 }
  #export-controls label { margin:8px 0 }
  #save-again { margin:0 }
  .compact.editing-text #text-controls > .active-line { display:block }
}
