/* AhlPaint for the web — styled to match the desktop app (appearance.py) */
:root {
  --bg: #181a1e;
  --bar: #202226;
  --ribbon: #272a2f;
  --line: #383b42;
  --text: #f0f1f4;
  --muted: #b5bdc7;
  --hover: #373c43;
  --hover-line: #484f57;
  --on: #a4f4da;
  --on-bg: #29443f;
  --on-line: #569480;
  --accent: #7bd7ba;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
button { font: inherit; color: inherit; }
select, input { font: inherit; }

/* icons */
svg.ic { width: 20px; height: 20px; display: block; fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round; }
i.s svg.ic, svg.ic.s { width: 17px; height: 17px; }
i[data-icon] { display: inline-flex; font-style: normal; }
.statusbar i.s svg.ic { width: 16px; height: 16px; }

/* app bar */
.appbar { display: flex; align-items: center; gap: 7px; padding: 7px 12px; background: var(--bar);
  border-bottom: 1px solid var(--line); min-width: 0; }
.mark svg { width: 29px; height: 29px; display: block; }
.brand { font-size: 16px; font-weight: 700; color: #f3f5f6; margin: 0 3px; }
.sep { width: 1px; align-self: stretch; background: #3c4047; margin: 2px 5px; flex: none; }
.docname { margin-left: auto; color: #b6bec7; font-size: 12px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; min-width: 0; padding-left: 8px; }
.menus { display: flex; gap: 2px; }

button.flat { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 3px 5px;
  color: #e8ebef; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
button.flat:hover:not(:disabled) { background: var(--hover); border-color: var(--hover-line); }
button.flat.on { color: var(--on); background: var(--on-bg); border-color: var(--on-line); }
button.flat:disabled { color: #68707b; cursor: default; }
button.menu { padding: 4px 8px; }
button.menu::after { content: ""; width: 0; height: 0; border: 4px solid transparent; border-top-color: currentColor;
  margin-top: 4px; opacity: .8; }
button.flat:focus-visible, button.chip:focus-visible, button.sw:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ribbon */
.ribbon { display: flex; align-items: flex-start; padding: 8px 12px 9px; background: var(--ribbon);
  border-bottom: 1px solid #3e4249; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; flex: none; }
.group { display: flex; flex-direction: column; gap: 5px; padding: 0 9px; flex: none; }
.group:first-child { padding-left: 0; }
.vsep { width: 1px; align-self: stretch; background: #3c4047; flex: none; }
.glabel { color: var(--muted); font-size: 11px; font-weight: 600; }
.glabel.c { text-align: center; }
.grid { display: grid; gap: 3px; }
.cols2 { grid-template-columns: repeat(2, auto); }
.cols3 { grid-template-columns: repeat(3, auto); }
.cols4 { grid-template-columns: repeat(4, auto); }
.ribbon select { background: #1f2125; color: var(--text); border: 1px solid #454a52; border-radius: 6px;
  padding: 3px 6px; min-width: 128px; }
.colorrow { display: flex; gap: 9px; align-items: flex-start; }
.picks { display: grid; grid-template-columns: repeat(2, auto); gap: 3px; }
button.chip { width: 34px; height: 25px; padding: 2px; border-radius: 5px; border: 1px solid #4a4f57;
  background: #2f3338; cursor: pointer; }
button.chip:hover { border-color: var(--on); }
button.chip span { display: block; width: 100%; height: 100%; border-radius: 3px; position: relative; overflow: hidden;
  background: repeating-conic-gradient(#c9ced3 0 25%, #e6e8eb 0 50%) 0 0 / 8px 8px; }
button.chip span::after { content: ""; position: absolute; inset: 0; background: var(--c); }
.swatches { display: grid; grid-template-columns: repeat(9, 20px); gap: 3px; }
button.sw { width: 20px; height: 17px; padding: 0; border-radius: 4px; border: 1px solid transparent;
  background: transparent; cursor: pointer; }
button.sw span { display: block; width: 100%; height: 100%; border-radius: 3px; background: var(--c); }
button.sw.fg { border-color: #edf5f2; }
button.sw:hover { border-color: var(--on); }

/* canvas area */
.stage { position: relative; flex: 1; min-height: 0; background: #191b1f; }
.scroller { position: absolute; inset: 0; overflow: auto; }
#spacer { width: 1px; height: 1px; }
#view { position: absolute; left: 0; top: 0; display: block; outline: none; touch-action: none; }
#ime { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; padding: 0; border: 0;
  resize: none; overflow: hidden; pointer-events: none; z-index: -1; font-size: 16px; }

/* status bar */
.statusbar { display: flex; align-items: center; gap: 7px; padding: 3px 12px; background: var(--bar);
  border-top: 1px solid #393c44; color: #bcc3cc; font-size: 12px; white-space: nowrap; flex: none; min-width: 0; }
.statusbar .pointer { min-width: 7.5em; font-variant-numeric: tabular-nums; }
.statusbar .selstatus { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.statusbar .grow { flex: 1; }
.statusbar .sep { margin: 2px 4px; }
.zoomvalue { color: var(--text); font-weight: 700; min-width: 3.3em; text-align: right; font-variant-numeric: tabular-nums; }
#zoomSlider { width: 108px; accent-color: var(--accent); }

/* dropdown menus */
.popup { position: fixed; z-index: 50; background: #24272c; border: 1px solid #454a52; border-radius: 8px;
  padding: 5px; min-width: 190px; box-shadow: 0 14px 40px -10px rgba(0,0,0,.7); }
.popup button { display: flex; width: 100%; justify-content: space-between; gap: 24px; background: transparent;
  border: 0; border-radius: 5px; padding: 6px 10px; text-align: left; cursor: pointer; color: var(--text); }
.popup button:hover:not(:disabled), .popup button:focus-visible { background: #34515a; outline: none; }
.popup button:disabled { color: #68707b; cursor: default; }
.popup kbd { font: inherit; opacity: .65; }
.popup hr { border: 0; border-top: 1px solid #3c4047; margin: 4px 2px; }

/* color popover */
.colorpop { padding: 12px; min-width: 0; display: grid; gap: 10px; }
.colorpop label { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 8px; color: var(--muted); }
.colorpop input[type=color] { width: 100%; height: 30px; border: 1px solid #454a52; border-radius: 5px; background: none; padding: 1px; cursor: pointer; }
.colorpop input[type=range] { accent-color: var(--accent); }
.colorpop output { min-width: 3em; text-align: right; color: var(--text); }
.colorpop .row { display: flex; gap: 6px; justify-content: flex-end; }

/* dialogs */
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(8,9,12,.55); display: grid; place-items: center; padding: 16px; }
.dialog { background: #24272c; border: 1px solid #454a52; border-radius: 10px; padding: 18px 20px; width: min(420px, 100%);
  box-shadow: 0 24px 60px -18px rgba(0,0,0,.8); display: grid; gap: 12px; }
.dialog h3 { margin: 0; font-size: 15px; }
.dialog p { margin: 0; color: var(--muted); }
.dialog .fields { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 10px; align-items: center; }
.dialog input[type=number], .dialog input[type=text], .dialog select, .dialog textarea {
  background: #1a1c20; color: var(--text); border: 1px solid #4a4f57; border-radius: 6px; padding: 5px 8px; width: 100%; }
.dialog textarea { min-height: 110px; resize: vertical; line-height: 1.4; }
.dialog input:focus, .dialog select:focus, .dialog textarea:focus { outline: none; border-color: var(--on-line); }
.dialog .check { display: flex; align-items: center; gap: 8px; grid-column: 1 / -1; }
.dialog .check input { accent-color: var(--accent); }
.dialog .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dialog .fontrow { display: grid; grid-template-columns: 1fr 72px auto auto; gap: 8px; align-items: center; }
.dialog .fontrow label { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.btn { border: 1px solid #4a4f57; background: #2f3338; color: var(--text); border-radius: 6px; padding: 6px 14px; cursor: pointer; }
.btn:hover { background: #393e44; }
.btn.primary { background: #2f6e5f; border-color: #569480; }
.btn.primary:hover { background: #36806e; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.drophint { position: fixed; inset: 0; z-index: 70; display: none; place-items: center; background: rgba(20,40,36,.55);
  pointer-events: none; }
.drophint.on { display: grid; }
.drophint div { border: 2px dashed var(--on); border-radius: 14px; padding: 26px 40px; font-size: 16px; font-weight: 600;
  background: rgba(24,26,30,.85); }
.toast { position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%) translateY(20px); z-index: 80;
  background: #2b2f35; border: 1px solid #4a4f57; border-radius: 8px; padding: 8px 14px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); }
.toast.on { opacity: 1; transform: translateX(-50%); }
.toast.err { border-color: #b4545a; }

#app { width: 100%; overflow: hidden; }
@media (max-width: 640px) {
  .appbar { padding: 6px 8px; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .appbar::-webkit-scrollbar { display: none; }
  .appbar > * { flex: none; }
  .brand, .appbar > .sep:first-of-type, .docname { display: none; }
  .statusbar { gap: 5px; padding: 3px 8px; }
  .statusbar #zoomSlider, .statusbar .selstatus, .statusbar .pointer, .statusbar i[data-icon=position] { display: none; }
}
