:root {
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans JP", "Segoe UI", sans-serif;
  color: #252932;
  background: #f6f7f9;
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button {
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  background: white;
  color: inherit;
  border: 1px solid #dce0e6;
  border-radius: 3px;
  min-height: 42px;
  padding: 0 16px;
  transition: background 0.12s;
}
button:hover {
  background: #edf0f6;
}
button:disabled {
  opacity: 0.35;
  cursor: default;
}
header {
  height: 48px;
  background: #fff;
  border-bottom: 1px solid #e2e5eb;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: auto;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.7px;
}
.export {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  margin-left: auto;
}
/* As wide as their confirmations (✓ コピー済み, ✓ ダウンロード済み) from the start, so confirming
   does not widen them and move the buttons beside them. */
#copy {
  min-width: 8em;
}
#download {
  min-width: 10.6em;
}
.primary {
  background: #344bc5;
  border-color: #344bc5;
  color: #fff;
  font-weight: 600;
}
.primary:hover {
  background: #263aab;
}
.primary span {
  margin-left: 14px;
}
main {
  width: 100%;
  margin: 0;
  padding: 0;
  height: calc(100dvh - 48px);
  min-height: 320px;
  display: flex;
  flex-direction: column;
}
#save-status {
  font-size: 13px;
  color: #606c80;
}
#save-status[data-state="error"] {
  color: #8a4013;
  background: #fff3e8;
  border-left: 3px solid #b76025;
  padding: 6px 8px;
  line-height: 1.5;
}
.workspace {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: #eef0f4;
  border: 0;
  border-radius: 0;
  overflow: hidden;
}
.toolbar {
  flex: 0 0 auto;
  background: white;
  padding: 3px 8px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid #e2e5eb;
}
.toolbar button {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 0;
  padding: 4px 8px;
  font-size: 13px;
  min-height: 36px;
  background: transparent;
}
.toolbar button > span {
  font-size: 22px;
  height: 24px;
  line-height: 24px;
  font-family: Arial, sans-serif;
}
.toolbar button .text-icon {
  font-size: 24px;
}
.toolbar .export .primary span {
  margin-left: 0;
  font-size: 16px;
  height: 20px;
  line-height: 20px;
}
.toolbar button:hover {
  background: #f1f3f8;
}
.toolbar button[aria-pressed="true"] {
  background: #e9edff;
  color: #3047c0;
  box-shadow: inset 0 0 0 1px #d2dafa;
}
.divider {
  width: 1px;
  height: 28px;
  background: #e8ebef;
  margin: 0 6px;
}
.toolbar-bottom {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.toolbar-bottom button {
  min-height: 36px;
}
.desk {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.paper-area {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  touch-action: none;
  background-color: #e8ebf0;
  background-image: radial-gradient(#c9ced9 1px, transparent 1px);
  background-size: 20px 20px;
  border-radius: 0;
}
.paper-footer {
  display: flex;
  justify-content: space-between;
  color: #606c80;
  font-size: 12px;
  gap: 12px;
}
.paper {
  width: 1200px;
  height: 800px;
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  background: white;
  box-shadow: none;
  aspect-ratio: 3/2;
  isolation: isolate;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}
.paper-footer {
  margin-top: 0;
  padding: 3px 8px;
  background: #fff;
  font-size: 12px;
  align-items: center;
  flex-wrap: wrap;
}
/* The bar keeps 3px around its controls, so the focus ring hugs them to stay in view. */
.paper-footer :focus-visible {
  outline-offset: 0;
}
#text-editor {
  position: absolute;
  z-index: 2;
  border: 1px solid #4d64d8;
  outline: 3px solid #4d64d81a;
  background: #fff;
  resize: none;
  padding: 0;
  margin: 0;
  border-radius: 0;
  color: #20242b;
  font-family: sans-serif;
  line-height: 1.4;
  min-width: 20px;
  min-height: 0;
  overflow: hidden;
}
#toast {
  position: fixed;
  z-index: 100;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #252c40;
  color: #fff;
  padding: 13px 22px;
  border-radius: 3px;
  font-size: 14px;
  box-shadow: none;
  opacity: 0;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
  transition: opacity 0.15s;
}
#toast.visible {
  opacity: 1;
}
@media (max-width: 700px) {
  header {
    padding: 0 14px;
    gap: 8px;
  }
  .brand {
    font-size: 20px;
  }
  .export {
    gap: 6px;
  }
  .export button {
    font-size: 12px;
    padding: 0 9px;
  }
  .primary span {
    display: none;
  }
  main {
    min-height: 320px;
  }
  #save-status {
    font-size: 12px;
  }
  .toolbar {
    padding: 3px 4px;
    gap: 2px;
  }
  .toolbar button {
    min-width: 44px;
    min-height: 36px;
    padding: 3px 5px;
  }
  .toolbar .divider {
    display: none;
  }
  .toolbar-bottom {
    gap: 2px;
  }
  .toolbar-bottom button {
    min-height: 36px;
  }
  .desk {
    padding: 0;
  }
  .paper-footer {
    font-size: 12px;
    flex-wrap: wrap;
    gap: 4px;
  }
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}
.zoom-controls button {
  min-height: 36px;
  padding: 0 10px;
}
.zoom-controls output {
  min-width: 48px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
#selection-delete {
  position: absolute;
  z-index: 3;
  min-height: 36px;
  padding: 0 10px;
  color: #b32836;
  border-color: #e4b6bc;
  box-shadow: none;
}
#selection-delete[hidden] {
  display: none;
}

.toolbar #save-status {
  margin-right: auto;
  font-size: 12px;
}
.zoom-controls button {
  min-height: 30px;
}
#paper-size {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
#paper-size label {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
#paper-size input {
  width: 72px;
  min-height: 30px;
  padding: 3px 5px;
  border: 1px solid #dce0e6;
  border-radius: 3px;
  font: inherit;
  font-size: 14px;
}
#paper-size button {
  min-height: 30px;
  padding: 0 10px;
}
#hint {
  margin-left: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The exact paper size is an occasional setting; the paper's own handles cover most resizing. */
.paper-size-menu {
  position: relative;
}
.paper-size-menu > summary {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #dce0e6;
  border-radius: 3px;
  background: #fff;
  color: #273247;
  font-size: 13px;
  cursor: pointer;
  list-style: none;
}
.paper-size-menu > summary::-webkit-details-marker {
  display: none;
}
.paper-size-menu[open] > summary {
  background: #eef1fb;
}
.paper-size-menu > form {
  flex-wrap: nowrap;
  width: max-content;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 5;
  padding: 10px;
  background: #fff;
  border: 1px solid #dce0e6;
  border-radius: 3px;
}

#paper-handles {
  position: absolute;
  border: 1px solid #4b62d5;
  pointer-events: none;
  z-index: 2;
}
#paper-handles[hidden] {
  display: none;
}
.paper-handle {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
}
.handle-n,
.handle-s {
  left: 0;
  width: 100%;
  height: 12px;
  cursor: ns-resize;
}
.handle-n {
  top: -6px;
}
.handle-s {
  bottom: -6px;
}
.handle-e,
.handle-w {
  top: 0;
  height: 100%;
  width: 12px;
  cursor: ew-resize;
}
.handle-e {
  right: -6px;
}
.handle-w {
  left: -6px;
}
.handle-n::after,
.handle-s::after,
.handle-e::after,
.handle-w::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  background: white;
  border: 1px solid #4b62d5;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.handle-nw,
.handle-ne,
.handle-se,
.handle-sw {
  width: 10px;
  height: 10px;
  background: white;
  border: 1px solid #4b62d5;
  z-index: 1;
}
.handle-nw {
  left: -5px;
  top: -5px;
  cursor: nwse-resize;
}
.handle-ne {
  right: -5px;
  top: -5px;
  cursor: nesw-resize;
}
.handle-se {
  right: -5px;
  bottom: -5px;
  cursor: nwse-resize;
}
.handle-sw {
  left: -5px;
  bottom: -5px;
  cursor: nesw-resize;
}

#new-dialog {
  width: min(600px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  border: 1px solid #dce0e6;
  border-radius: 3px;
  color: #252932;
  overflow: auto;
  line-height: 1.7;
}
#new-dialog::backdrop {
  background: #19223850;
}
#new-dialog {
  width: min(460px, calc(100vw - 24px));
  box-shadow: none;
}
#new-dialog h2 {
  margin: 0 0 12px;
  font-size: 20px;
  line-height: 1.5;
}
#new-dialog p {
  margin: 8px 0;
  font-size: 14px;
}
.new-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}
#tour {
  position: fixed;
  z-index: 5;
  right: 16px;
  top: 110px;
  width: min(340px, calc(100vw - 24px));
  padding: 18px;
  border: 1px solid #cdd5f1;
  border-radius: 3px;
  background: white;
  box-shadow: none;
}
#tour[hidden] {
  display: none;
}
#tour:focus-visible {
  outline: 2px solid #8295f1;
}
.tour-top,
.tour-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.tour-top span {
  font-size: 13px;
  color: #69748d;
}
.tour-top button {
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  font-size: 14px;
}
#tour h2 {
  font-size: 18px;
  margin: 12px 0 8px;
}
#tour p {
  font-size: 16px;
  line-height: 1.7;
  margin: 0 0 18px;
}
.tour-actions button {
  min-height: 36px;
}
.tour-highlight {
  outline: 2px solid #6178e3;
  outline-offset: -2px;
}
@media (max-width: 700px) {
  header {
    gap: 6px;
    padding: 0 8px;
  }
  .brand {
    font-size: 16px;
  }
  .export {
    gap: 4px;
  }
  .export button {
    padding: 0 7px;
  }
  #tour {
    top: auto;
    bottom: 60px;
    right: 12px;
  }
}

#tour-spotlight {
  position: fixed;
  z-index: 4;
  pointer-events: none;
  border: 2px solid #6178e3;
  border-radius: 3px;
}
#tour-shade {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: rgb(30 35 45 / 48%);
}
#tour-arrow {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px white);
}
#tour-arrow[hidden],
#tour-shade[hidden],
#tour-spotlight[hidden] {
  display: none;
}
#tour {
  max-height: calc(100dvh - 24px);
  overflow: auto;
}

#welcome-dialog {
  width: min(480px, calc(100vw - 24px));
}
#welcome-dialog h2 {
  margin: 0 0 12px;
  font-size: 22px;
  line-height: 1.5;
}
#welcome-dialog p {
  margin: 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;
}
header {
  height: auto;
  min-height: 48px;
  flex-wrap: wrap;
  padding-top: 6px;
  padding-bottom: 6px;
}
@media (max-width: 1100px) {
  .toolbar #save-status[data-state="saved"],
  .toolbar #save-status[data-state="ready"] {
    display: none;
  }
  .toolbar #save-status:is([data-state="error"], [data-state="saving"], [data-state="loading"]) {
    flex-basis: 100%;
    order: 1;
  }
}
@media (max-width: 700px) {
  header .tool-directory-link {
    margin-left: auto;
  }
}

body.has-tool-info[data-tool="roughpad"] {
  height: auto;
  min-height: 100dvh;
  display: block;
  overflow: visible;
}
body.has-tool-info[data-tool="roughpad"] > main#tool-workspace {
  height: calc(100dvh - var(--tool-header-height, 56px) - 44px);
  min-height: 360px;
  flex: none;
}

.tool-about .roughpad-shortcuts {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) 3fr;
  margin-top: 12px;
  font-size: 14px;
}
.roughpad-shortcuts dt,
.roughpad-shortcuts dd {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ui-border);
}
.roughpad-shortcuts dt {
  padding-left: 0;
  font-weight: 600;
}
.roughpad-tool-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.roughpad-tool-keys span {
  white-space: nowrap;
}
.roughpad-shortcuts kbd {
  padding: 1px 5px;
  border: 1px solid var(--ui-border);
  border-radius: 3px;
  color: var(--ui-text);
  background: var(--ui-background);
  font: inherit;
  white-space: nowrap;
}
@media (max-width: 700px) {
  .tool-about .roughpad-shortcuts {
    grid-template-columns: 1fr;
  }
  .roughpad-shortcuts dt {
    padding: 12px 0 4px;
    border-bottom: 0;
  }
  .roughpad-shortcuts dd {
    padding: 0 0 12px;
  }
}

/* The paper lies on the shared dot-grid desk. */
.paper-area {
  background-color: #f3f4f7;
  background-image: radial-gradient(#d3d9e2 1px, transparent 1.2px);
  background-position: 10px 10px;
}
/* One family of line icons for the tools and edits, as in Marklet. */
.toolbar button > span:has(> svg) {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
}
.toolbar button > span > svg {
  width: 22px;
  height: 22px;
}

#copy.is-done,
#download.is-done {
  white-space: nowrap;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Phones: the footer keeps two rows. The hint shares the first with "paper size" and has
   room for two lines, so a longer hint for another tool never adds a row. */
@media (max-width: 700px) {
  .paper-footer {
    flex-wrap: wrap;
    row-gap: 4px;
  }
  #hint {
    flex: 1 1 0;
    display: -webkit-box;
    min-height: 2.8em;
    line-height: 1.4;
    text-align: right;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .zoom-controls {
    flex-basis: 100%;
    justify-content: flex-end;
  }
}

/* After a copy or save, a light runs once around the paper that was output (as in Marklet). */
@property --sweep {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
#export-glow {
  position: absolute;
  z-index: 4;
  padding: 3px;
  border-radius: 3px;
  opacity: 0;
  pointer-events: none;
  background: conic-gradient(from -90deg, #4d64d8 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;
  }
}
/* Phones: the line icons are a little smaller so the toolbar keeps the rows it had. */
@media (max-width: 700px) {
  .toolbar button > span:has(> svg),
  .toolbar button > span > svg {
    width: 18px;
    height: 18px;
  }
  .toolbar button {
    gap: 4px;
    padding-inline: 6px;
  }
}
