:root {
  font-family: var(--app-font);
  color: var(--app-ink);
  background: var(--app-page);
  --green: var(--app-accent);
  --ink: var(--app-ink);
  --muted: var(--app-muted);
  --line: var(--app-line);
  --soft: var(--app-tint);
  --white: var(--app-paper);
  --bar-height: 64px;
}
:focus-visible { outline-color: var(--app-accent); }
.topbar {
  height: var(--bar-height);
  padding-inline: 22px;
  gap: 22px;
  position: relative;
}
.brand {
  font-size: 24px;
  letter-spacing: -.045em;
  gap: 8px;
}
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.document {
  padding-left: 22px;
  gap: 3px;
  min-width: 0;
}
.document input { font-size: 14px; font-weight: 650; }
#save-state { font-size: 11px; line-height: 1.25; }
.header-actions { gap: 6px; }
.quiet, .primary, .danger, .icon-button { border-radius: 8px; }
.primary { box-shadow: none; }
.primary:not(:disabled):hover { background: var(--app-accent-hover); }
.header-actions #download { background: var(--ink); }
.header-actions #download:hover { background: #324d59; }
.header-actions #share { color: var(--green); background: var(--soft); }
.header-actions #share:hover { background: #d7edd1; }
.studio {
  height: calc(100% - var(--bar-height));
  padding: 0;
  gap: 0;
}
.tools {
  width: 82px;
  background: var(--white);
  border-right: 1px solid var(--line);
  padding: 12px 7px;
  gap: 3px;
  overflow: auto;
}
.tool {
  flex: none;
  width: 100%;
  height: 57px;
  min-height: 44px;
  border-radius: 9px;
  gap: 5px;
  font-size: 10px;
  font-weight: 620;
}
.tool svg { width: 22px; height: 22px; }
.tool[aria-pressed=true], .tool[aria-pressed=true]:hover {
  background: var(--soft);
  color: var(--green);
  box-shadow: inset 0 0 0 1px #c9e2ee;
}
.tool-divider { margin: 6px 10px; }
.desk { gap: 0; min-height: 0; }
.workspace-bar {
  background: var(--app-page);
  padding: 4px 14px;
  min-height: 47px;
}
.workspace-bar .icon-button { width: 36px; height: 36px; }
.workspace-bar button svg { width: 18px; height: 18px; }
.history .quiet { min-height: 36px; padding-inline: 10px; }
.zoom { border-radius: 9px; }
.zoom .icon-button, #fit { height: 34px; }
.canvas-wrap {
  margin: 0;
  border-radius: 0;
  border: 0;
  border-block: 1px solid var(--line);
  background: #eaf0ef;
}
#loading { background: #eaf0ef; }
.palette-bar {
  align-self: stretch;
  min-width: 0;
  min-height: 60px;
  padding: 8px 14px;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: flex-start;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.palette {
  gap: 2px;
  min-width: 0;
  overflow: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  justify-content: flex-start;
}
.swatch {
  width: 29px;
  height: 37px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
}
.swatch span { width: 20px; height: 20px; border-radius: 5px; }
.swatch[aria-pressed=true] { background: var(--soft); }
.size-control {
  flex: none;
  width: auto;
  margin: 0 0 0 auto;
  padding-left: 12px;
  gap: 8px;
  border-left: 1px solid var(--line);
}
#size { width: clamp(66px, 9vw, 130px); accent-color: var(--green); }
.workspace-footer { padding-inline: 14px; min-height: 28px; }
#dimensions, #size-value { font-variant-numeric: tabular-nums; }
.share-card {
  width: 212px;
  height: 100%;
  padding: 22px 18px;
  margin: 0;
  overflow: auto;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: var(--white);
}
.share-card h2 { margin: 0 0 16px; font-size: 15px; font-weight: 680; }
.share-card > button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 160px;
  background: white;
}
.share-card > button:hover { border-color: var(--green); }
.share-card p { margin-bottom: 14px; font-size: 12px; }
.share-card a { font-size: 12px; }
.share-card input, .student-label input { border-radius: 8px; }
.options { left: 89px; top: 12px; border-radius: var(--app-radius); box-shadow: var(--app-shadow); }
.options .option-row button[aria-pressed=true] { background: var(--soft); }
dialog { border-radius: 16px; box-shadow: var(--app-shadow); }
dialog::backdrop { background: #1c2c3470; backdrop-filter: blur(3px); }
.dialog-head h1 { margin: 0; font-size: 23px; letter-spacing: -.035em; }
.formats button, .picture-card { border-radius: 10px; }
.toast { background: var(--ink); }
@media (max-width: 800px) {
  .size-control label { display: none; }
  .topbar { padding-inline: 14px; gap: 14px; }
  .document { padding-left: 14px; }
  .header-actions .quiet { width: 44px; }
}
@media (max-width: 580px) {
  :root { --bar-height: 59px; }
  .topbar { padding-inline: 10px; gap: 8px; }
  .brand { font-size: 0; gap: 0; }
  .brand img { width: 32px; height: 32px; }
  .document { padding: 0; }
  .document input { font-size: 13px; }
  .header-actions { gap: 3px; }
  .studio { padding-bottom: env(safe-area-inset-bottom); }
  .tools {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
    overflow: auto;
    padding: 4px 6px;
    border-right: 0;
    gap: 3px;
  }
  .tool { width: 100%; height: 44px; font-size: 9px; }
  .workspace-bar { padding-inline: 7px; gap: 4px; }
  .workspace-bar .zoom .icon-button { width: 30px; }
  .palette-bar { min-height: 58px; padding: 6px 8px; gap: 4px; }
  .swatch { width: 32px; height: 41px; }
  .size-control { padding-left: 6px; gap: 4px; }
  .size-control #size-preview { display: none; }
  #size { width: 64px; }
  .options { left: 8px; top: auto; bottom: 62px; max-height: calc(100dvh - 135px); }
}
@media (max-height: 470px) and (min-width: 581px) {
  :root { --bar-height: 52px; }
  .tools { padding-block: 4px; }
  .tool { height: 43px; min-height: 43px; }
}
.palette-trigger {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 620;
}
.current-color {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--selected-color, #171717);
  box-shadow: inset 0 0 0 1px #0002;
}
.stroke-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  margin-left: auto;
}
#opacity-control {
  display: flex;
  align-items: center;
  gap: 6px;
  border-left: 1px solid var(--line);
  padding-left: 10px;
}
#opacity-control label { color: var(--muted); font-size: 11px; }
#opacity { width: clamp(55px, 7vw, 100px); margin: 0; accent-color: var(--green); }
#opacity-value { min-width: 3.5ch; text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; }
#color-dialog { width: min(660px, calc(100vw - 24px)); padding: clamp(12px, 3vw, 24px); }
.color-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0,1fr));
  gap: 2px;
  margin-top: 12px;
}
.color-grid button {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border-radius: 3px;
  background: var(--color);
  box-shadow: inset 0 0 0 1px #0001;
}
.color-grid button:not(:disabled):hover,
.color-grid button[aria-pressed=true] {
  background: var(--color);
  box-shadow: inset 0 0 0 2px white, inset 0 0 0 4px #1c2c34;
}
.color-grid button:focus-visible { position: relative; z-index: 1; outline-offset: 0; }
@media (max-width: 920px) {
  .palette-trigger > span:last-child { display: none; }
}
@media (max-width: 730px) {
  .palette-bar { flex-wrap: wrap; }
  .palette { flex: 1; }
  .stroke-controls { flex-basis: 100%; justify-content: flex-end; min-height: 29px; }
  .stroke-controls:has(> :not([hidden])) .size-control { margin-left: 0; padding-left: 0; border: 0; }
  #size, #opacity { width: clamp(55px, 15vw, 102px); }
  .size-control label { display: inline; }
  .stroke-controls:not(:has(> :not([hidden]))) { display: none; }
}

/* Keep the entire quick palette in view while drawing. */
.palette {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 30px));
  flex: 0 1 371px;
  gap: 1px;
  overflow: visible;
}
.swatch { width: 100%; height: 29px; }
@media (max-width: 730px) {
  .palette-bar { column-gap: 8px; }
  .palette-bar > .separator { display: none; }
  .palette {
    order: -1;
    flex: 0 0 100%;
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }
  .stroke-controls { flex-basis: auto; min-width: 0; gap: 6px; }
  .swatch span { width: min(20px, 100%); }
}

.header-actions #share { color: #294923; background: #e8f2d7; }
.header-actions #share:hover { background: #dcecc3; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline-color: var(--app-accent);
}
@media (max-width: 600px) {
  :root { --bar-height: 93px; }
  .topbar { padding-bottom: 34px; }
}
