/* Paint — verktyg.itpris.se */
:root {
  --face: #c0c0c0;
  --hi: #ffffff;
  --lt: #dfdfdf;
  --sh: #808080;
  --dk: #0a0a0a;
  --hl: #000080;
  --hl-text: #ffffff;
  --tlbx: #ffeae8;
  --tlbx2: #ffa59e;
  --desk: #008080;
  --ui: 11px Tahoma, "MS Sans Serif", "Microsoft Sans Serif", "Segoe UI", Geneva, Verdana, "DejaVu Sans", sans-serif;
  --raised: inset -1px -1px var(--dk), inset 1px 1px var(--hi), inset -2px -2px var(--sh), inset 2px 2px var(--lt);
  --pressed: inset -1px -1px var(--hi), inset 1px 1px var(--dk), inset -2px -2px var(--lt), inset 2px 2px var(--sh);
  --field: inset -1px -1px var(--hi), inset 1px 1px var(--sh), inset -2px -2px var(--lt), inset 2px 2px var(--dk);
  --thin-in: inset 1px 1px var(--sh), inset -1px -1px var(--hi);
  --thin-out: inset -1px -1px var(--sh), inset 1px 1px var(--hi);
  --window: inset -1px -1px var(--dk), inset 1px 1px var(--lt), inset -2px -2px var(--sh), inset 2px 2px var(--hi);
  --dither: repeating-conic-gradient(var(--hi) 0 25%, var(--face) 0 50%) 0 0 / 2px 2px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--desk);
  font: var(--ui);
  color: #000;
  -webkit-font-smoothing: none;
  -webkit-text-size-adjust: 100%;
}
body {
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: var(--ui); color: #000; }
button { cursor: default; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }

/* ---------- desktop ---------- */
.desktop { position: fixed; inset: 0 0 30px 0; }
.dicon {
  position: absolute; left: 10px; width: 72px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 0; padding: 2px; color: #fff; text-decoration: none; text-align: center;
}
.dicon span { padding: 1px 2px; }
.desktop:has(> .app:not([hidden])) .dicon { visibility: hidden; }
.dicon:focus-visible span, .dicon:active span { background: var(--hl); outline: 1px dotted #fff; }

/* ---------- window ---------- */
.win {
  background: var(--face);
  padding: 3px;
  box-shadow: var(--window);
}
.app {
  position: absolute;
  inset: 10px 10px 10px 10px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
@media (min-width: 1200px) { .app { inset: 18px 22px 16px 22px; } }
.app.max { inset: 0; }
.titlebar {
  height: 18px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 2px 0 2px;
  background: linear-gradient(90deg, var(--tlbx), var(--tlbx2));
  color: #0a0a0a;
  font-weight: bold;
  touch-action: none;
}
.app.inactive > .titlebar { background: linear-gradient(90deg, #808080, #b5b5b5); color: #cbd1dc; }
.titlebar .ticon { flex: none; }
.titlebar .ttl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .1px; }
.tbtn {
  width: 16px; height: 14px; flex: none;
  border: 0; padding: 0;
  background: var(--face);
  box-shadow: var(--raised);
  display: grid; place-items: center;
}
.tbtn svg { fill: #000; display: block; }
.tbtn:active { box-shadow: var(--pressed); }
.tbtn:active svg { transform: translate(1px, 1px); }
.tbtn.close { margin-left: 2px; }

/* ---------- menus ---------- */
.menubar { display: flex; flex: none; padding: 1px 0 1px; position: relative; }
.mb-item {
  border: 0; background: none; padding: 2px 6px 3px; line-height: 14px;
}
.mb-item.open { box-shadow: var(--thin-in); padding: 3px 5px 2px 7px; }
.mb-item:focus-visible { outline: 1px dotted #000; outline-offset: -2px; }
.menu {
  position: fixed;
  z-index: 300;
  min-width: 170px;
  padding: 3px;
  background: var(--face);
  box-shadow: var(--window), 2px 2px 0 rgba(0,0,0,.25);
  display: flex; flex-direction: column;
}
.mi {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 2px;
  border: 0; background: none; text-align: left;
  padding: 3px 14px 3px 4px; line-height: 13px;
  white-space: nowrap;
}
.mi .k { padding-left: 24px; }
.mi .chk { font-size: 11px; text-align: center; }
.mi:hover, .mi:focus { background: var(--hl); color: var(--hl-text); outline: none; }
.mi[aria-disabled="true"] { color: var(--sh); text-shadow: 1px 1px var(--hi); }
.mi[aria-disabled="true"]:hover, .mi[aria-disabled="true"]:focus { color: var(--sh); text-shadow: none; }
.mi.tlbxify { font-weight: bold; }
.mi.tlbxify .lbl::after { content: " \2728"; }
.sep { height: 2px; margin: 3px 1px; border-top: 1px solid var(--sh); border-bottom: 1px solid var(--hi); flex: none; }

/* ---------- body ---------- */
.body { flex: 1; display: flex; min-height: 0; position: relative; padding-top: 1px; }
.toolbox {
  width: 58px; flex: none;
  display: flex; flex-direction: column; align-items: center;
  padding: 3px 3px 0 2px; gap: 5px;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none;
}
.toolbox::-webkit-scrollbar { display: none; }
.tools { display: grid; grid-template-columns: repeat(2, 25px); grid-auto-rows: 25px; }
.tool {
  width: 25px; height: 25px; border: 0; padding: 0;
  background: var(--face); box-shadow: var(--raised);
  display: grid; place-items: center;
}
.tool svg { width: 16px; height: 16px; display: block; pointer-events: none; }
.tool[aria-pressed="true"] { box-shadow: var(--pressed); background: var(--dither); }
.tool[aria-pressed="true"] svg { transform: translate(1px, 1px); }
.tool:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }
.tool-sep {
  grid-column: 1 / -1; height: 9px; position: relative;
}
.tool-sep::before {
  content: ""; position: absolute; left: 1px; right: 1px; top: 3px; height: 2px;
  border-top: 1px solid var(--sh); border-bottom: 1px solid var(--hi);
}
.optbox {
  width: 46px; min-height: 68px; flex: none;
  box-shadow: var(--thin-in);
  padding: 4px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.optsec { display: grid; grid-template-columns: repeat(var(--cols, 1), auto); gap: 1px; justify-content: center; }
.optsec + .optsec { padding-top: 4px; border-top: 1px solid var(--sh); box-shadow: 0 -1px 0 var(--hi) inset; }
.opt {
  border: 0; background: transparent; padding: 1px;
  display: grid; place-items: center;
  min-width: 13px; min-height: 13px; line-height: 1;
  font-size: 10px;
}
.opt canvas { display: block; image-rendering: pixelated; }
.opt.txt { width: 36px; padding: 2px 0; font-size: 11px; }
.opt.emo { font-size: 15px; width: 20px; height: 20px; padding: 0; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.opt.sel { background: var(--hl); color: var(--hl-text); }
.opt.sel canvas.inv { filter: invert(1); }
.opt:focus-visible { outline: 1px dotted #000; outline-offset: 0; }

/* ---------- workspace ---------- */
.ws-frame { flex: 1; min-width: 0; min-height: 0; padding: 2px; box-shadow: var(--field); display: flex; }
.workspace {
  flex: 1; min-width: 0; min-height: 0;
  overflow: auto;
  background: var(--sh);
  position: relative;
}
.stage { position: relative; }
.wrap {
  position: absolute; left: 3px; top: 3px;
  touch-action: none;
  background: #fff;
}
.wrap canvas {
  position: absolute; left: 0; top: 0;
  image-rendering: pixelated;
  display: block;
}
#overlay { pointer-events: none; }
.grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(128,128,128,.75) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(128,128,128,.75) 1px, transparent 1px);
}
.selbox {
  position: absolute; pointer-events: none;
  border: 1px dashed #000;
  outline: 1px solid rgba(255,255,255,.55);
  outline-offset: -2px;
}
.selbox .sh {
  position: absolute; width: 5px; height: 5px; background: var(--hl);
  pointer-events: auto; display: none; touch-action: none;
}
.selbox.handles .sh { display: block; }
.selbox .sh::before { content: ""; position: absolute; inset: -5px; }
.sh[data-dir="nw"] { left: -3px; top: -3px; cursor: nwse-resize; }
.sh[data-dir="n"] { left: calc(50% - 3px); top: -3px; cursor: ns-resize; }
.sh[data-dir="ne"] { right: -3px; top: -3px; cursor: nesw-resize; }
.sh[data-dir="w"] { left: -3px; top: calc(50% - 3px); cursor: ew-resize; }
.sh[data-dir="e"] { right: -3px; top: calc(50% - 3px); cursor: ew-resize; }
.sh[data-dir="sw"] { left: -3px; bottom: -3px; cursor: nesw-resize; }
.sh[data-dir="s"] { left: calc(50% - 3px); bottom: -3px; cursor: ns-resize; }
.sh[data-dir="se"] { right: -3px; bottom: -3px; cursor: nwse-resize; }
.ghost { position: absolute; left: 0; top: 0; border: 1px dashed #000; pointer-events: none; outline: 1px solid rgba(255,255,255,.5); outline-offset: -2px; }
.hdl {
  position: absolute; width: 4px; height: 4px; background: var(--hl);
  touch-action: none;
}
.hdl::before { content: ""; position: absolute; inset: -7px; }
.hdl.e { left: 100%; top: calc(50% - 2px); cursor: ew-resize; }
.hdl.s { top: 100%; left: calc(50% - 2px); cursor: ns-resize; }
.hdl.se { left: 100%; top: 100%; cursor: nwse-resize; }
.textbox { position: absolute; outline: 1px dashed #000; }
.textbox textarea {
  display: block; width: 100%; height: 100%;
  border: 0; margin: 0; padding: 0;
  resize: none; overflow: hidden;
  background: transparent; outline: none;
  white-space: pre-wrap; overflow-wrap: break-word;
  user-select: text; -webkit-user-select: text;
  font-kerning: normal;
}
