@font-face {
  font-family: Martian;
  src: url(/fonts/martian-mono-latin-wght-normal.woff2) format('woff2');
  font-weight: 100 800;
  font-display: swap;
}
:root {
  color-scheme: light dark;
  --paper: #f2f0e9;
  --sheet: #faf9f3;
  --ink: #141412;
  --muted: #68665e;
  --rule: #cfccc0;
  --accent: #ff4d00;
  --grid: #e3e0d6;
  --tri: #e8e5db;
  --tri-grid: #cfcbbd;
  --mono: Martian, ui-monospace, Menlo, monospace;
  --jp: 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141413;
    --sheet: #1a1a18;
    --ink: #f0eee6;
    --muted: #a8a69c;
    --rule: #45443d;
    --grid: #32322c;
    --tri: #292922;
    --tri-grid: #45453c;
  }
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 var(--jp);
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 1220px;
  margin: 0 auto;
  padding: clamp(20px, 5vh, 54px) clamp(18px, 4.4vw, 64px) 18px;
}
header,
.identity,
.sheet-head,
.panel-head,
.proof,
.weight,
footer,
.messages {
  display: flex;
  align-items: center;
}
header {
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--ink);
  padding-bottom: clamp(14px, 2.5vh, 26px);
}
.identity {
  gap: clamp(12px, 2vw, 26px);
}
button,
input,
textarea {
  font: inherit;
  color: inherit;
}
button {
  border: 0;
  background: none;
  cursor: pointer;
}
button:disabled {
  cursor: wait;
  opacity: 0.55;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
a {
  color: inherit;
  text-decoration: none;
}
a:hover {
  color: var(--accent);
}
.mark {
  font: 800 clamp(32px, 4.4vw, 58px)/0.96 var(--mono);
  letter-spacing: -0.09em;
}
.mark span {
  color: var(--accent);
}
h1 {
  font-size: clamp(14px, 1.6vw, 19px);
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.04em;
}
h2,
.weight label {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-width: 1.6;
}
.export {
  display: flex;
  position: relative;
  background: var(--accent);
  color: #201508;
  border-radius: 999px;
}
.export > button {
  min-height: 42px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.export > button:hover {
  background: #0001;
}
#save {
  padding: 0 14px 0 18px;
  border-radius: 999px;
}
#save .chevron {
  width: 14px;
}
#export-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 5;
  margin: 0;
  padding: 16px 18px;
  width: min(320px, calc(100vw - 24px));
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: 0 6px 16px #0001;
}
#export-panel legend {
  float: left;
  width: 100%;
  margin-bottom: 6px;
  font-weight: 700;
}
#export-panel label {
  clear: both;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 35px;
  cursor: pointer;
}
#export-panel small {
  margin-left: auto;
  color: var(--muted);
  font: 10px var(--mono);
}
#export-panel input {
  accent-color: var(--accent);
}
.format-note {
  display: block;
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  font-size: 11px;
  color: var(--muted);
}
.desk {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(256px, 32%);
  gap: clamp(24px, 3.8vw, 54px);
  margin: clamp(20px, 5vh, 46px) 0;
}
.sheet {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.sheet-head,
.panel-head {
  justify-content: space-between;
  min-height: 36px;
  margin: 0 0 10px;
}
#edit,
#reset {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  min-height: 36px;
  font-size: 12px;
  border-radius: 6px;
}
#reset {
  min-width: 36px;
}
#edit:hover,
#reset:hover {
  color: var(--ink);
  background: var(--tri);
}
#edit svg {
  width: 14px;
}
.stage {
  position: relative;
  display: grid;
  min-height: 264px;
  flex: 1;
  isolation: isolate;
  border: 1px solid var(--rule);
  background-color: var(--sheet);
  background-image: radial-gradient(circle, var(--grid) 0.8px, transparent 1px);
  background-size: 20px 20px;
  background-position: 9px 9px;
}
.stage::before,
.stage::after {
  content: '';
  pointer-events: none;
  z-index: 1;
  position: absolute;
  inset: 11px;
  border: solid var(--muted);
  opacity: 0.55;
  width: 8px;
  height: 8px;
}
.stage::before {
  border-width: 1px 0 0 1px;
}
.stage::after {
  inset: auto 11px 11px auto;
  border-width: 0 1px 1px 0;
}
.sample {
  grid-area: 1/1;
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: 100%;
  border: 0;
  padding: clamp(15px, 2.4vw, 34px);
  margin: 0;
  text-align: left;
  background: transparent;
  font-size: var(--sample-size, 64px);
  line-height: 1.17;
  letter-spacing: normal;
  font-weight: normal;
  font-synthesis: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
  border-radius: 0;
}
.sample {
  display: flex;
  align-items: center;
  cursor: text;
  position: absolute;
  inset: 0;
  overflow: auto;
}
.sample > span {
  max-height: 100%;
  display: block;
}
.text-editor {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-top: 0;
}
#text-input {
  display: block;
  resize: vertical;
  min-height: 3.3em;
  width: 100%;
  padding: 5px 9px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.4 var(--jp);
}
.ink-tools, .ink-presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
.ink-tools { gap: 2px 6px; }
.ink-presets { gap: 2px; }
#ink-target { color: var(--muted); font-size: 11px; white-space: nowrap; }
#ink-target { min-width: 5em; }
.ink-presets button, .ink-custom {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 34px;
  padding: 0;
  border-radius: 4px;
}
.ink-presets button::before, .ink-custom span {
  content: '';
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 1px solid var(--muted);
  background: var(--swatch, var(--ink));
}
.ink-presets button[aria-pressed='true']::before {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.ink-custom span { background: var(--sheet); line-height: 1; }
.ink-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.ink-custom:focus-within { outline: 2px solid var(--accent); }
.typeface {
  font-family: var(--mix-font, var(--jp));
}
.proof {
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: 5px 2px 0;
}
.proof-label,
.format-note {
  color: var(--muted);
  font-size: 11px;
}
.proof-text {
  font-size: clamp(19px, 2vw, 27px);
  font-synthesis: none;
}
.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.pad {
  width: 100%;
  max-width: 365px;
  position: relative;
  aspect-ratio: 320/236;
  margin: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#triangle {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}
.triangle-fill {
  fill: var(--tri);
}
#grid {
  stroke: var(--tri-grid);
  stroke-width: 0.8;
}
.triangle-edge {
  stroke: var(--ink);
  stroke-width: 1.1;
  fill: none;
  stroke-linejoin: round;
}
.corners {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 1.15;
}
#guides {
  stroke: var(--accent);
  stroke-width: 1;
  stroke-dasharray: 2.5 3;
  opacity: 0.85;
}
.handle {
  fill: var(--accent);
  stroke: var(--paper);
  stroke-width: 2.3;
}
.handle-core {
  fill: #331300;
}
.vertex {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  padding: 2px 4px;
  white-space: nowrap;
  border-radius: 4px;
}
.vertex:hover {
  background: var(--tri);
}
.vertex b {
  font-weight: normal;
  font-size: clamp(16px, 1.7vw, 21px);
  line-height: 1;
}
.vertex span {
  font: 10px var(--mono);
  color: var(--muted);
}
.mincho {
  left: 50%;
  top: 1%;
  transform: translateX(-50%);
}
.kaku {
  left: 2%;
  top: 80%;
}
.maru {
  right: 2%;
  top: 80%;
}
.mix-access:not(:focus-within) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.mix-access:focus-within {
  margin: 5px 0;
}
.mix-access label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}
.weight {
  border-top: 1px solid var(--rule);
  padding: 16px 0 0;
  margin: 8px 0 15px;
  justify-content: space-between;
  flex-wrap: wrap;
}
#weight-value {
  font: 12px var(--mono);
  color: var(--muted);
}
#weight {
  width: 100%;
  height: 26px;
  margin: 4px 0 0;
  appearance: none;
  background: none;
  cursor: pointer;
  accent-color: var(--accent);
}
#weight::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(to right, var(--ink) var(--fill), var(--rule) var(--fill));
}
#weight::-moz-range-track {
  height: 2px;
  background: var(--rule);
}
#weight::-moz-range-progress {
  height: 2px;
  background: var(--ink);
}
#weight::-webkit-slider-thumb {
  appearance: none;
  border: 2px solid var(--paper);
  border-radius: 50%;
  width: 17px;
  height: 17px;
  background: var(--ink);
  margin-top: -7.5px;
}
#weight::-moz-range-thumb {
  border: 2px solid var(--paper);
  border-radius: 50%;
  width: 14px;
  height: 14px;
  background: var(--ink);
}
footer {
  border-top: 1px solid var(--rule);
  padding-top: 15px;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 11px;
  color: var(--muted);
}
footer > a:first-child {
  font: 11px var(--mono);
}
.messages {
  flex-wrap: wrap;
  gap: 4px 12px;
}
.messages:empty {
  display: none;
}
#retry {
  padding: 3px 8px;
  border: 1px solid var(--rule);
  border-radius: 4px;
}
@media (min-width: 761px) {
  .desk {
    min-height: clamp(365px, 54vh, 556px);
  }
}
@media (max-width: 760px) {
  main {
    max-width: 610px;
    padding: 16px max(14px, env(safe-area-inset-right)) 12px max(14px, env(safe-area-inset-left));
  }
  header {
    padding-bottom: 12px;
  }
  .desk {
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 11px 0 17px;
  }
  .sheet-head,
  .panel-head {
    margin-bottom: 4px;
  }
  .stage {
    min-height: clamp(156px, 27svh, 245px);
  }
  .proof {
    min-height: 40px;
  }
  .panel {
    display: grid;
    grid-template-columns: minmax(175px, 1.35fr) minmax(90px, 1fr);
    gap: 0 18px;
    align-items: center;
    border-top: 1px solid var(--rule);
    padding-top: 4px;
  }
  .panel-head {
    grid-column: 1/-1;
    width: 100%;
  }
  .pad {
    max-width: 255px;
  }
  .weight {
    margin: 0;
    border-top: 0;
    padding: 0;
  }
  .vertex b {
    font-size: 16px;
  }
  .vertex span {
    font-size: 9px;
  }
  .vertex {
    gap: 3px;
    min-height: 26px;
  }
  .mincho {
    top: -1%;
  }
  .kaku,
  .maru {
    top: 79%;
  }
  .kaku {
    left: 0;
  }
  .maru {
    right: 0;
  }
  .mix-access:focus-within {
    grid-column: 1/-1;
  }
  .messages:not(:has(span:not(:empty))) {
    display: none;
  }
  .messages:has(span:not(:empty)) {
    order: 3;
    width: 100%;
  }
}
@media (max-width: 480px) {
  .panel {
    display: flex;
    gap: 0;
    align-items: stretch;
  }
  .panel-head {
    margin: 0;
  }
  .pad {
    width: min(76vw, 285px);
    max-width: none;
    margin: 0 auto;
  }
  .vertex {
    min-height: 32px;
  }
  .mincho {
    top: 0;
  }
  .kaku,
  .maru {
    top: 78%;
  }
  .weight {
    display: grid;
    grid-template-columns: auto 1fr 3ch;
    gap: 14px;
    align-items: center;
    margin-top: 2px;
  }
  #weight {
    grid-row: 1;
    grid-column: 2;
    margin: 0;
  }
  #weight-value {
    grid-column: 3;
    text-align: right;
  }
}
@media (max-width: 355px) {
  .identity {
    gap: 8px;
  }
  .desk {
    gap: 5px;
  }
  .panel {
    column-gap: 8px;
  }
  .proof-label {
    font-size: 10px;
  }
}

.genres {
  margin-top: clamp(14px, 2.6vh, 26px);
}
.genre-heading,
.views {
  display: flex;
  align-items: center;
}
.genre-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}
.compare,
.tabular {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
}
.compare input,
.tabular input {
  margin: 0;
  accent-color: var(--accent);
}
.genre-list {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  border: 1px solid var(--rule);
}
.genre-list button {
  min-height: 52px;
  padding: 5px 2px;
  font-size: clamp(15px, 1.7vw, 24px);
  font-synthesis: none;
  border-inline-end: 1px solid var(--rule);
}
.genre-list button:last-child {
  border: 0;
}
.genre-list button[aria-pressed='true'] {
  color: var(--paper);
  background: var(--ink);
  box-shadow: inset 0 -3px var(--accent);
}
.genre-list button:hover:not([aria-pressed='true']) {
  background: var(--tri);
}
.desk {
  margin-top: clamp(12px, 2.7vh, 27px);
}
.views {
  gap: 3px;
}
.views button {
  padding: 6px 12px;
  font-weight: 700;
  font-size: 13px;
  border-radius: 5px;
  color: var(--muted);
}
.views button[aria-pressed='true'] {
  background: var(--ink);
  color: var(--paper);
}
.blend-panel {
  display: contents;
}
#shape-panel {
  grid-column: 1/-1;
}
#axis-list {
  border-block: 1px solid var(--rule);
}
.axis {
  display: grid;
  grid-template-columns: 4.4em minmax(48px, 1fr) 5.4em;
  gap: 6px;
  align-items: center;
  min-height: 35px;
  font-size: 12px;
}
.axis + .axis {
  border-top: 1px solid var(--grid);
}
.axis input {
  min-width: 0;
  width: 100%;
  margin: 0;
  height: 28px;
  accent-color: var(--accent);
  cursor: pointer;
}
.axis output {
  text-align: right;
  color: var(--muted);
  font:
    10px var(--mono),
    var(--jp);
}
.proof-text.game-ui {
  font-size: 16px;
  overflow-wrap: anywhere;
}
.proof-label {
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .genre-list {
    display: flex;
    overflow-x: auto;
  }
  .genre-list button {
    flex: 1 0 auto;
    min-width: 63px;
    min-height: 44px;
    padding-inline: 8px;
  }
  .genre-heading {
    margin-bottom: 4px;
  }
  .genres {
    margin-top: 8px;
  }
  .axis {
    min-height: 34px;
  }
}

.optics {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 2px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 12px;
}
.optics label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  cursor: pointer;
}
.optics input {
  margin: 0;
  accent-color: var(--accent);
}
#optical-strength {
  width: min(32vw, 150px);
  cursor: pointer;
}
.optics output {
  min-width: 3.6em;
  font-family: var(--mono);
  font-size: 10px;
}

.genre-variants {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.genre-variants button {
  min-height: 34px;
  padding: 4px 12px;
  font-size: 13px;
  border-radius: 4px;
  color: var(--muted);
}
.genre-variants button[aria-pressed='true'] {
  color: var(--ink);
  background: var(--tri);
  box-shadow: inset 0 -2px var(--accent);
}

.sheet-actions,
.finish {
  display: flex;
  align-items: center;
}
.sheet-actions {
  gap: clamp(5px, 1.25vw, 16px);
}
.finish {
  justify-content: space-between;
  min-height: 36px;
  gap: 8px;
  font-size: 12px;
}
.finish select {
  font: inherit;
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 3px;
}

.header-actions, .share-head, .share-actions, #share {
  display: flex;
  align-items: center;
}
.header-actions { gap: clamp(4px, 1.2vw, 14px); }
#share { min-height: 42px; gap: 5px; padding: 0 6px; font-weight: 700; }
#share-dialog {
  box-sizing: border-box;
  width: min(390px, calc(100% - 24px));
  max-height: 90vh;
  padding: 14px 18px 16px;
  border: 1px solid var(--rule);
  border-radius: 9px;
  color: var(--ink);
  background: var(--sheet);
}
#share-dialog::backdrop { background: rgb(0 0 0 / 38%); }
.share-head { justify-content: space-between; }
.share-head button { width: 40px; height: 40px; font-size: 23px; }
.share-preview { display: grid; place-items: center; }
#share-preview {
  width: 100%; height: 135px; object-fit: contain;
  padding: 10px; border: 1px solid var(--rule); background: var(--sheet);
}
#share-caption {
  width: 100%; margin: 8px 0; padding: 4px 0; border: 0;
  background: transparent; resize: none; font: 14px/1.5 var(--jp);
}
.share-actions { flex-wrap: wrap; gap: 3px 12px; }
.share-actions > *, #share-native {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; padding: 0; font: 600 13px var(--jp); cursor: pointer;
}
#share-native, .share-actions a:first-child {
  padding: 0 13px; border-radius: 5px; background: var(--ink); color: var(--sheet);
}
#share-native { width: 100%; margin-bottom: 5px; }
#share-native:not([hidden]) + .share-actions a:first-child { background: transparent; color: var(--ink); padding: 0; }
#share-note, #share-status { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
#share-status:empty { display: none; }

/* スマホの幅でもヘッダーの文字を折り返さない */
h1, #share, #save { white-space: nowrap; }
.identity { min-width: 0; }
.header-actions { flex: none; }
@media (max-width: 420px) {
  h1 { font-size: 13px; letter-spacing: 0; }
  #save { gap: 5px; padding: 0 10px 0 14px; }
}
@media (max-width: 355px) {
  h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

/* 見本の文字は入力した改行でだけ折り返す */
.sample { white-space: pre; overflow-wrap: normal; overflow: hidden; }
.sample > span { flex: none; width: max-content; max-height: none; }

/* 一部の文字の色: 文字を押して選ぶ (iPhone の文字選択メニューと競合しない) */
.ink-panel { display: grid; gap: 4px; min-width: 0; }
.ink-chars {
  display: flex; gap: 3px; min-width: 0; overflow-x: auto; scrollbar-width: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.ink-chars::-webkit-scrollbar { display: none; }
.ink-chars button {
  flex: none; min-width: 38px; height: 38px; padding: 0 4px;
  border: 1px solid var(--rule); border-radius: 5px; background: var(--paper);
  font-size: 19px; line-height: 1; white-space: nowrap;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: pan-x;
}
.ink-chars .ink-all { font-size: 12px; font-weight: 700; color: var(--muted); }
.ink-chars .line-start { margin-left: 10px; }
.ink-chars button[aria-pressed='true'] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), inset 0 -4px var(--accent); }
.ink-tools { flex-wrap: nowrap; min-width: 0; }

/* 変形のつまみは種類ごとに分ける。つまみが増えても画面の高さを変えない */
.axis-groups { display: flex; gap: 3px; margin-bottom: 6px; }
.axis-groups button { min-height: 30px; padding: 2px 12px; border-radius: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.axis-groups button[aria-pressed='true'] { color: var(--ink); background: var(--tri); box-shadow: inset 0 -2px var(--accent); }
#axis-list { min-height: 212px; align-content: start; }

/* 保存はフォントも画像も同じメニューから */
.export-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.export-choices button {
  display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 58px; padding: 6px 4px;
  border: 1px solid var(--rule); border-radius: 8px; color: var(--ink); background: var(--paper);
}
.export-choices button:hover:not(:disabled) { border-color: var(--accent); }
.export-choices b { font-size: 13px; }
#export-panel .export-choices small { margin: 0; }
#export-panel section + section { margin-top: 12px; }
#export-panel h3 { margin: 0 0 6px; font-size: 12px; font-weight: 700; }
.panel-actions { display: flex; align-items: center; gap: 2px; }
#random {
  display: flex; align-items: center; gap: 5px; min-height: 36px; padding: 0 8px;
  border-radius: 6px; color: var(--ink); font-size: 12px; font-weight: 700; white-space: nowrap;
}
#random:hover { background: var(--tri); }
#random svg circle { fill: currentColor; stroke: none; }

/* iPhone: ページをスクロールさせず、1 画面に収める */
@media (max-width: 600px) and (orientation: portrait), (max-height: 500px) and (orientation: landscape) {
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  body { position: fixed; inset: 0; width: 100%; }
  main {
    display: grid;
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: max(6px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(3px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    column-gap: 10px;
    overflow: hidden;
  }
  .desk, .sheet, .panel { display: contents; }
  header { grid-column: 1 / -1; grid-row: 1; padding-bottom: 5px; }
  .mark { font-size: 27px; }
  #share, .export > button { min-height: 36px; }
  .format-note { margin-top: 6px; padding-top: 6px; }
  #export-panel { z-index: 20; }

  .genres { grid-column: 1 / -1; grid-row: 2; display: grid; margin-top: 5px; min-width: 0; }
  .genre-heading { display: contents; }
  #genre-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .genre-list { display: flex; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .genre-list::-webkit-scrollbar { display: none; }
  .genre-list button { flex: 1 0 auto; min-width: 58px; min-height: 36px; padding: 2px 8px; font-size: 15px; }
  .compare { min-height: 28px; font-size: 11px; white-space: nowrap; }
  .genre-variants { min-width: 0; margin: 0; overflow-x: auto; scrollbar-width: none; }
  .genre-variants button { flex: none; min-height: 28px; padding: 2px 8px; font-size: 12px; white-space: nowrap; }

  .sheet-head { min-height: 32px; margin: 0; justify-content: flex-end; }
  .sheet-head > h2 { display: none; }
  .stage { min-height: 0; }
  .sample { padding: 10px; }
  main :not(textarea, dialog, dialog *, #sample, #sample *) { white-space: nowrap; }
  .text-editor { gap: 3px; padding: 5px 7px; border: 1px solid var(--rule); border-bottom: 0; }
  #text-input { min-height: 0; height: 3.2em; resize: none; }
  .ink-presets button, .ink-custom { width: 30px; height: 30px; }
  .proof { min-height: 26px; padding: 2px 1px 0; overflow: hidden; }
  .proof-label { display: none; }
  .proof-text, .proof-text.game-ui { width: 100%; font-size: 16px; line-height: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .panel-head { min-height: 34px; margin: 4px 0 0; }
  .views button { padding: 5px 10px; }
  #reset, #edit, #random { min-height: 32px; }
  .pad { width: 100%; max-width: none; margin: 4px 0 0; align-self: center; }
  .vertex { min-height: 24px; gap: 2px; padding: 0 2px; }
  .vertex b { font-size: 14px; }
  .vertex span { font-size: 9px; }
  .mincho { top: 0; }
  .kaku, .maru { top: 78%; }
  .kaku { left: 0; }
  .maru { right: 0; }
  .mix-access, .mix-access:focus-within { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); }
  .weight { display: grid; grid-template-columns: auto minmax(0, 1fr) 3ch; gap: 8px; align-items: center; min-height: 34px; margin: 0; padding: 0; border: 0; }
  #weight { grid-row: 1; grid-column: 2; margin: 0; }
  #weight-value { grid-column: 3; text-align: right; }
  .optics { flex-wrap: wrap; gap: 0 6px; padding: 0; border: 0; font-size: 11px; min-width: 0; }
  .optics label { min-height: 24px; }
  .optics output { min-width: 0; margin-left: auto; }
  #optical-strength { order: 1; flex: 1 0 100%; width: 100%; height: 22px; }

  #shape-panel { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .axis-groups { grid-column: 1 / -1; margin-bottom: 2px; }
  .axis-groups button { min-height: 28px; padding: 1px 12px; }
  #axis-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 30px; column-gap: 14px; min-height: 90px; border-top: 0; }
  .axis, .axis + .axis { grid-template-columns: 4.5em minmax(0, 1fr); min-height: 30px; gap: 4px; border: 0; font-size: 11px; white-space: nowrap; }
  .axis input { height: 26px; }
  .axis output { display: none; }
  #shape-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; align-content: start; }
  #shape-panel[hidden] { display: none; }
  #axis-list { grid-column: 1 / -1; }
  .finish, .tabular { min-height: 32px; font-size: 11px; white-space: nowrap; }

  footer { grid-column: 1 / -1; display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; min-height: 22px; margin-top: 3px; padding: 0; font-size: 10px; }
  footer > a:first-child { display: none; }
  footer > a:last-child { flex: none; margin-left: auto; }
  .messages, .messages:has(span:not(:empty)) { order: 0; flex: 1 1 auto; flex-wrap: nowrap; width: auto; min-width: 0; overflow: hidden; white-space: nowrap; }
  #missing, #status { overflow: hidden; text-overflow: ellipsis; }
  #retry { flex: none; padding: 0 6px; }
}

/* 配合と変形で、タブと見本の位置を変えない */
@media (max-width: 600px) and (orientation: portrait) {
  main {
    --controls: 214px;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto minmax(56px, 1fr) auto auto calc(var(--controls) / 2) calc(var(--controls) / 2) auto;
  }
  main:has(#shape-panel:not([hidden])) {
    grid-template-rows: auto auto auto auto minmax(56px, 1fr) auto auto calc(var(--controls) - 30px) 30px auto;
  }
  .genres { grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; }
  .genre-list { grid-column: 1 / -1; grid-row: 1; }
  .genre-variants { grid-column: 1; grid-row: 2; }
  .compare { grid-column: 2; grid-row: 2; }
  .sheet-head { grid-column: 1 / -1; grid-row: 3; }
  .text-editor { grid-column: 1 / -1; grid-row: 4; }
  .stage { grid-column: 1 / -1; grid-row: 5; }
  .proof { grid-column: 1 / -1; grid-row: 6; border-bottom: 1px solid var(--rule); }
  .panel-head { grid-column: 1 / -1; grid-row: 7; }
  .pad { grid-column: 1; grid-row: 8 / span 2; margin: 0; }
  .weight { grid-column: 2; grid-row: 8; align-self: end; }
  .optics { grid-column: 2; grid-row: 9; align-self: start; margin-top: 6px; }
  footer { grid-row: 10; }
  #shape-panel { grid-column: 1 / -1; grid-row: 8; }
  main:has(#shape-panel:not([hidden])) .optics { grid-column: 1 / -1; align-self: center; margin-top: 0; flex-wrap: nowrap; }
  main:has(#shape-panel:not([hidden])) #optical-strength { flex: 1 1 auto; width: auto; }
  main:has(#text-editor:not([hidden])) {
    grid-template-rows: auto auto auto auto minmax(56px, 1fr) auto 0 0 0 auto;
  }
  main:has(#text-editor:not([hidden])) .genres,
  main:has(#text-editor:not([hidden])) .proof,
  main:has(#text-editor:not([hidden])) .pad,
  main:has(#text-editor:not([hidden])) .panel-head,
  main:has(#text-editor:not([hidden])) .weight,
  main:has(#text-editor:not([hidden])) .optics,
  main:has(#text-editor:not([hidden])) #shape-panel { display: none; }
}
@media (max-width: 600px) and (orientation: portrait) and (max-height: 500px) {
  main { --controls: 150px; }
  main:has(#shape-panel:not([hidden])) {
    grid-template-rows: auto auto auto auto minmax(56px, 1fr) auto auto var(--controls) 0 auto;
  }
  main:has(#shape-panel:not([hidden])) .optics { display: none; }
  #axis-list { grid-auto-rows: 24px; min-height: 72px; }
  .axis-groups button { min-height: 24px; }
  .axis, .axis + .axis { min-height: 24px; }
  .axis input { height: 22px; }
  .finish, .tabular { min-height: 26px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  main {
    grid-template-columns: minmax(0, 1.25fr) minmax(150px, 190px) minmax(130px, 170px);
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto;
  }
  header { padding-bottom: 3px; }
  .genres { grid-template-columns: minmax(0, 1fr) auto auto; column-gap: 8px; align-items: center; margin-top: 3px; }
  .genre-list { grid-column: 1; grid-row: 1; }
  .genre-list button { min-height: 30px; font-size: 13px; }
  .genre-variants { grid-column: 2; grid-row: 1; max-width: 200px; }
  .compare { grid-column: 3; grid-row: 1; }
  .sheet-head { grid-column: 1; grid-row: 3; min-height: 34px; margin-top: 2px; }
  .panel-head { grid-column: 2 / -1; grid-row: 3; min-height: 34px; margin-top: 2px; }
  .stage { grid-column: 1; grid-row: 4 / span 2; }
  .proof { grid-column: 1; grid-row: 6; }
  .pad { grid-column: 2; grid-row: 4 / span 3; margin: 0; }
  .weight { grid-column: 3; grid-row: 4; align-self: end; }
  .optics { grid-column: 3; grid-row: 5 / span 2; align-self: start; }
  footer { grid-row: 7; min-height: 18px; margin-top: 1px; }
  .text-editor { grid-column: 2 / -1; grid-row: 4 / span 3; overflow-y: auto; border-bottom: 1px solid var(--rule); }
  main:has(#text-editor:not([hidden])) .pad,
  main:has(#text-editor:not([hidden])) .weight,
  main:has(#text-editor:not([hidden])) .optics { display: none; }
  #shape-panel { grid-column: 2 / -1; grid-row: 4 / span 3; }
  #axis-list { grid-auto-rows: 27px; min-height: 81px; }
  .axis-groups button { min-height: 25px; }
  .axis, .axis + .axis { min-height: 27px; }
  .finish, .tabular { min-height: 28px; }
  main:has(#shape-panel:not([hidden])) .proof { display: none; }
  main:has(#shape-panel:not([hidden])) .optics { grid-column: 1; grid-row: 6; flex-wrap: nowrap; min-height: 26px; }
  main:has(#shape-panel:not([hidden])) #optical-strength { flex: 1 1 auto; width: auto; }
}
