:root {
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Kaku Gothic ProN",
    "Noto Sans JP",
    sans-serif;
  color: #27332f;
  background: #f7f8f5;
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
  border: 1px solid #dbe1da;
  background: #fff;
  color: inherit;
  border-radius: 3px;
  padding: 10px 15px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
button:hover {
  background: #edf2eb;
}
button:disabled {
  opacity: 0.35;
  cursor: default;
}
.primary {
  background: #d9eac8;
  border-color: #c9dfb4;
}
.dark {
  background: #2d3b32;
  color: white;
  border-color: #2d3b32;
}
.dark:hover {
  background: #405345;
}
header {
  height: 88px;
  padding: 0 40px;
  border-bottom: 1px solid #e1e6de;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
}
.brand {
  display: flex;
  align-items: center;
  gap: 22px;
}
.brand strong {
  font-size: 28px;
  letter-spacing: -1px;
}
.brand a {
  text-decoration: none;
  color: #657465;
  font-size: 21px;
}
main {
  max-width: 1600px;
  margin: auto;
  padding: 26px 40px;
}
#filename {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #5d6858;
  font-size: 12px;
}
.workspace {
  display: flex;
  gap: 16px;
  min-height: 580px;
  height: calc(100vh - 255px);
}
.toolbar {
  width: 83px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  background: #fff;
  border: 1px solid #dfe5dc;
  border-radius: 3px;
  padding: 9px;
}
.toolbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-color: transparent;
  padding: 8px 2px;
  font-size: 12px;
}
.toolbar b {
  font-size: 23px;
  line-height: 25px;
  font-weight: 500;
}
.toolbar button[aria-pressed="true"] {
  background: #e9f1e2;
  color: #36582d;
  border-color: #d0dfc4;
}
.divider {
  border-top: 1px solid #e4e9e1;
  margin: 3px 7px;
}
.editor {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 1px solid #dfe5dc;
  border-radius: 3px;
  overflow: hidden;
  background: #fff;
}
.options {
  display: flex;
  align-items: center;
  gap: 15px;
  min-height: 60px;
  padding: 10px 18px;
  border-bottom: 1px solid #e4e9e1;
}
.options button {
  padding: 7px 8px;
  border-color: transparent;
  font-size: 12px;
}
.spacer {
  flex: 1;
}
#stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background-color: #f0f2ed;
  background-image: radial-gradient(#cfd6ca 0.7px, transparent 0.7px);
  background-size: 16px 16px;
}
#stage.dragover {
  outline: 3px dashed #739360;
  outline-offset: -8px;
}
/* One visible line for the current tool, like Roughpad's hint bar. */
.canvas-hint {
  flex-shrink: 0;
  margin: 0;
  padding: 5px 12px;
  border-top: 1px solid #e4e9e1;
  color: #5d6858;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#empty {
  text-align: center;
  padding: 25px;
}
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.16em;
  color: #7c8b72;
  font-weight: 600;
}
canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: none;
  background: repeating-conic-gradient(#e9e9e9 0 25%, white 0 50%) 0/16px 16px;
  touch-action: none;
}
dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 30px;
  border: 1px solid #dbe1da;
  border-radius: 3px;
  box-shadow: none;
  color: inherit;
}
dialog::backdrop {
  background: #24312866;
}
dialog h2,
#tour h2 {
  font-size: 21px;
}
dialog p,
#tour p {
  font-size: 13px;
  line-height: 1.9;
}
dialog a {
  color: #496e3b;
}
textarea {
  display: block;
  width: 100%;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #b6c5ad;
  border-radius: 3px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}
#spotlight {
  position: fixed;
  z-index: 20;
  border-radius: 3px;
  box-shadow: 0 0 0 9999px #29322966;
  pointer-events: none;
  border: 2px solid #a5c488;
}
#tour {
  position: fixed;
  z-index: 21;
  width: min(360px, calc(100vw - 24px));
  padding: 22px;
  background: white;
  border: 1px solid #dbe1da;
  border-radius: 3px;
  box-shadow: none;
}
[hidden] {
  display: none !important;
}
@media (max-width: 760px) {
  header {
    padding: 0 16px;
    height: 68px;
  }
  #filename {
    display: none;
  }
  main {
    padding: 16px 12px;
  }
  .workspace {
    gap: 8px;
    height: calc(100dvh - 230px);
    min-height: 550px;
  }
  .toolbar {
    width: 65px;
    padding: 5px;
  }
  .options {
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px;
  }
  .options .spacer {
    display: none;
  }
  #stage {
    padding: 12px;
  }
  #empty {
    padding: 10px;
  }
}

/* Keep the drawing workspace within the viewport; controls take only their content height. */
body.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.app header {
  height: auto;
  min-height: 52px;
  flex-shrink: 0;
  padding: 7px 12px;
  gap: 14px;
  justify-content: flex-start;
}
.app .brand {
  gap: 10px;
}
.app .brand strong {
  font-size: 22px;
}
.app .brand a {
  font-size: 17px;
}
.app header button {
  padding: 8px 11px;
  font-size: 12px;
}
.app #import-actions,
.app #export-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.app #import-actions {
  flex-shrink: 0;
}
.app #export-actions {
  flex-shrink: 0;
}
/* As wide as its confirmation (✓ コピー済み) from the start, so confirming does not move the
   buttons beside it (phones shorten both to "コピー" / "✓ コピー" instead). */
.app #copy {
  min-width: 8em;
}
.app .header-navigation {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}
.app #filename {
  max-width: 140px;
}
.app main {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 6px 8px;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.app .workspace {
  height: auto;
  min-height: 0;
  flex: 1;
  gap: 6px;
}
.app .toolbar {
  width: 72px;
  padding: 4px;
  gap: 1px;
  overflow-y: auto;
  border-radius: 3px;
}
.app .toolbar button {
  padding: 6px 1px;
  gap: 2px;
  min-height: 46px;
  flex-shrink: 0;
  font-size: 12px;
}
.app .toolbar b {
  font-size: 21px;
  line-height: 23px;
  height: 23px;
}
.app .toolbar svg {
  width: 23px;
  height: 23px;
}
.app .editor {
  min-height: 0;
  border-radius: 3px;
}
.app .options {
  flex-shrink: 0;
  flex-wrap: wrap;
}
.app #stage {
  touch-action: none;
  overscroll-behavior: contain;
  padding: 10px;
  overflow: hidden;
}
.app canvas {
  max-width: none;
  max-height: none;
  flex-shrink: 0;
  object-fit: fill;
}
.app #canvas {
  position: absolute;
  border: 0;
  outline: none;
  box-shadow: none;
}
.app #empty {
  max-height: 100%;
  overflow: auto;
  padding: 12px;
}

@media (max-width: 760px) {
  .app header {
    gap: 6px;
    flex-wrap: wrap;
    padding: 6px 8px;
    min-height: 46px;
  }
  .app .brand {
    gap: 6px;
  }
  .app .brand strong {
    font-size: 18px;
  }
  .app header button {
    font-size: 12px;
    padding: 7px 8px;
  }
  .app #filename {
    display: none;
  }
  .app #import-actions,
  .app #export-actions {
    gap: 4px;
  }
  .app .workspace {
    flex-direction: column;
    gap: 5px;
  }
  .app .toolbar {
    width: 100%;
    flex-direction: row;
    padding: 3px;
    overflow-x: auto;
    overflow-y: hidden;
    min-height: 58px;
    height: 58px;
  }
  .app .toolbar button {
    min-height: 50px;
    min-width: 48px;
    padding: 2px 4px;
  }
  .app .toolbar .divider {
    border-top: 0;
    border-left: 1px solid #e4e9e1;
    margin: 5px 3px;
  }
  .app .options {
    min-height: 40px;
    flex-wrap: wrap;
  }
  .app .options button {
    padding: 5px;
    font-size: 12px;
  }
  .app #stage {
    padding: 6px;
  }
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.app .options {
  gap: 8px;
  padding: 5px 10px;
  min-height: 44px;
}
.choice-group {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.choice-group + .choice-group {
  border-left: 1px solid #e3e7e0;
  padding-left: 10px;
  margin-left: 4px;
}
.app .choice-group button,
.app .options .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
}
.app .choice-group button[aria-pressed="true"] {
  background: #e7efdf;
  border-color: #b9caaa;
  color: #2b4930;
}
.app .choice-group button:hover,
.app .options .icon-button:hover {
  background: #eff3eb;
}
.app .choice-group svg,
.app .icon-button svg {
  width: 24px;
  height: 24px;
}
.app .palette {
  gap: 6px;
}
.app .palette .swatch {
  width: 25px;
  height: 25px;
  min-width: 25px;
  border-radius: 50%;
  background: var(--swatch);
  border: 2px solid white;
  box-shadow: 0 0 0 1px #00000015;
  padding: 0;
}
.app .palette .swatch[aria-pressed="true"] {
  background: var(--swatch);
  border-color: white;
  box-shadow: 0 0 0 2px #314435;
  color: #142818;
}
.swatch span {
  visibility: hidden;
  font-size: 15px;
}
.swatch[aria-pressed="true"] span {
  visibility: visible;
}
.mosaic-sample {
  width: 22px;
  height: 22px;
  border-radius: 2px;
  background: repeating-conic-gradient(#344634 0 25%, #c5d1bf 0 50%) 0 / var(--tile) var(--tile);
}
@media (max-width: 760px) {
  .app .options {
    gap: 5px;
    padding: 5px 7px;
  }
  .app .options .spacer {
    display: block;
  }
  .app .choice-group button,
  .app .options .icon-button {
    width: 30px;
    height: 30px;
    min-width: 30px;
  }
  .app .palette {
    gap: 5px;
  }
  .choice-group + .choice-group {
    padding-left: 7px;
    margin-left: 2px;
  }
}
@media (max-width: 760px) {
  .app .palette .swatch {
    width: 22px;
    height: 22px;
    min-width: 22px;
  }
}
.app #stage {
  position: relative;
}
#text-inline {
  position: absolute;
  z-index: 2;
  box-sizing: content-box;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 1px;
  outline-offset: 4px;
  resize: none;
  white-space: pre;
  overflow: auto;
  box-shadow: none;
  caret-color: #27332f;
  paint-order: stroke fill;
}
#text-inline::placeholder {
  color: #657365;
  -webkit-text-stroke: 0;
  font-size: 0.75em;
}
#text-inline {
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  font-weight: 900;
  line-height: 1;
  background: #00000012;
  outline: none;
  -webkit-text-stroke: 0;
}

/* Shared tool-directory navigation; keep the label visible at narrow widths. */
.tool-directory-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid #d8dfe8;
  border-radius: 3px;
  background: #fff;
  color: #40516a;
  font:
    600 12px/1.5 -apple-system,
    BlinkMacSystemFont,
    "Noto Sans JP",
    sans-serif;
  text-decoration: none;
  white-space: nowrap;
}
.tool-directory-link:hover {
  background: #f0f4fa;
  border-color: #aabbd2;
}
body.app.has-tool-info[data-tool="marklet"] {
  height: auto;
  min-height: 100dvh;
  display: block;
  overflow: visible;
}
body.has-tool-info[data-tool="marklet"] > main#tool-workspace {
  height: calc(100dvh - var(--tool-header-height, 56px) - 44px);
  min-height: 360px;
  flex: none;
}
@media (max-width: 1100px) {
  .app #filename {
    display: none;
  }
}
#copy-notice {
  position: fixed;
  z-index: 100;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 12px 20px;
  border-radius: 3px;
  background: #273247;
  color: #fff;
  font-size: 14px;
  line-height: 1.6;
  pointer-events: none;
}
#copy-notice:empty {
  padding: 0;
}

/* The download sign stands in for the words where labels are shortened (phones). */
.narrow-label {
  display: none;
}
/* Phones: keep the actions in two rows, and fade the tool row's edge to show it scrolls. */
@media (max-width: 760px) {
  .app .options {
    gap: 4px 6px;
    padding: 5px 8px;
  }
  .app .choice-group + .choice-group {
    padding-left: 6px;
    margin-left: 2px;
  }
  .wide-label {
    display: none;
  }
  /* A fixed box for the sign, so the check that replaces it while confirming takes the same
     width ("↓ PNG" → "✓ PNG"). */
  .narrow-label {
    display: inline-block;
    width: 1.25em;
    text-align: left;
  }
  .app #copy {
    min-width: 0;
  }
  .app .toolbar {
    padding-right: 28px;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
}

/* The image lies on the shared dot-grid desk. */
.app #stage {
  background-color: #f3f4f7;
  background-image: radial-gradient(#d3d9e2 1px, transparent 1.2px);
  background-size: 20px 20px;
  background-position: 10px 10px;
}
/* Before an image, a drafted note on a screenshot shows what Marklet adds. */
.empty-art {
  display: block;
  width: min(240px, 70%);
  height: auto;
  margin: 0 auto 18px;
}
.empty-art-note {
  opacity: 0.8;
}
/* The image itself is on screen, so its file name is not repeated (read aloud only). */
.app #filename {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.app .toolbar b {
  display: grid;
  place-items: center;
}

/* Before an image, settings and outputs keep their places but stay out of sight. */
.app .editor.no-image .options .choice-group,
.app .editor.no-image .options .choice-group *,
.app .editor.no-image .options .icon-button,
.app .editor.no-image #export-actions {
  visibility: hidden;
}
#copy.is-done,
#save.is-done {
  white-space: nowrap;
}

/* The bar has two parts: the document row (open, edit, output) and the current tool's
   settings. From 1000px they share one line (the widest needs about 850px); narrower ones give each its own
   fixed row (scrolling sideways if needed), so switching tools never moves the image. */
.app .options .doc-row,
.app .options .setting-row {
  display: contents;
}
.app .options {
  flex-wrap: nowrap;
}
.app .options .setting-row > * {
  order: 1;
}
.app .options .doc-row > :not(#import-actions) {
  order: 2;
}
.app .editor.no-image .canvas-hint {
  visibility: hidden;
}
@media (max-width: 999px) {
  .app .options {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  .app .options .doc-row,
  .app .options .setting-row {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .app .options .doc-row::-webkit-scrollbar,
  .app .options .setting-row::-webkit-scrollbar {
    display: none;
  }
  .app .options .doc-row > *,
  .app .options .setting-row > * {
    flex-shrink: 0;
  }
  /* The rows clip sideways scrolling, so the focus ring stays within their 36px. */
  .app .options .doc-row :focus-visible,
  .app .options .setting-row :focus-visible {
    outline-width: 2px;
    outline-offset: 0;
  }
}
/* Phones: "open" becomes "＋" and the gaps tighten so the document row fits one line. */
@media (max-width: 760px) {
  .app .options .doc-row,
  .app .options .setting-row {
    gap: 4px;
  }
  .app .options .doc-row .icon-button {
    width: 28px;
    min-width: 28px;
  }
  .app #open {
    min-width: 32px;
    font-size: 16px;
  }
}
@media (max-width: 380px) {
  .app .options .doc-row button:not(.icon-button) {
    padding-inline: 3px;
  }
}

/* After a copy or save, a light runs once around the image that was output. */
@property --sweep {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
#export-glow {
  position: absolute;
  z-index: 3;
  padding: 3px;
  border-radius: 3px;
  opacity: 0;
  pointer-events: none;
  background: conic-gradient(from -90deg, #5b8f4b var(--sweep), transparent 0);
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
}
#export-glow.is-running {
  animation: export-sweep 0.9s ease-out forwards;
}
@keyframes export-sweep {
  0% {
    --sweep: 0deg;
    opacity: 1;
  }
  75% {
    --sweep: 360deg;
    opacity: 1;
  }
  100% {
    --sweep: 360deg;
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  #export-glow.is-running {
    animation: none;
  }
}
