/* Real-time adjustment screen: laid out as docs/gui/mock_shape.png and mock_genes.png.
   Colours (tokiryo 2026-11-13): orange = touchable and important (main actions, the active state), blue = touchable
   but not the main path (as a mark: hover borders, links on dark, labels; never small text on white), red = attention (errors), black = text to read,
   gray = side information and touchable icons, light gray = rules and disabled labels, base gray = backgrounds. */
:root {
  --orange: #FFB400; --blue: #00A0E8; --red: #F4515B;
  --ink: #222222; --gray: #8E8E93; --light: #E0E0E0; --base: #F3F6F9; --paper: #fff;
  --r-s: 8px;   /* controls */
  --r-m: 12px;  /* boxes: the view, cards, notices */
  --r-l: 16px;  /* dialogs */
  --shadow: 0 6px 20px rgba(34, 34, 34, .12), 0 1px 3px rgba(34, 34, 34, .08);
  --icon-x: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M5 5l10 10M15 5L5 15" stroke="black" stroke-width="2" stroke-linecap="round"/></svg>');
  --icon-trash: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="black" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M3.5 5.5h13M8 5.5V4h4v1.5M5.5 5.5l.8 10.5h7.4l.8-10.5M8.5 8.5v5M11.5 8.5v5"/></svg>');
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink);
  font: 15px/1.5 "Hiragino Sans", "Noto Sans JP", -apple-system, sans-serif; -webkit-text-size-adjust: 100%;
  line-break: strict; word-break: auto-phrase; scrollbar-color: var(--light) transparent; }
body { display: flex; overflow: hidden; }
h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
::selection { background: rgba(0, 160, 232, .22); }
input, select { caret-color: var(--ink); color: var(--ink); }
input::placeholder { color: var(--gray); }
button { font: inherit; color: inherit; cursor: pointer; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---- left: actions and the view */
#stage { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 12px 14px 16px 16px; }
#actions { display: flex; gap: 10px; align-items: center; height: 44px; margin-bottom: 12px; }
#shape-name { flex: 0 1 180px; width: 180px; min-width: 80px; height: 40px; padding: 0 12px; border: 1px solid var(--light);
  border-radius: var(--r-s); background: var(--paper); font-size: 15px; }
#save { margin-left: auto; }   /* 保存 and 書き出し on the right (tokiryo) */
.plain, .dark { flex: none; height: 40px; min-width: 96px; padding: 0 18px; border-radius: var(--r-s); font-weight: 600; font-size: 15px;
  transition: background-color .12s ease-out, border-color .12s ease-out; }
.plain { background: var(--paper); border: 1px solid var(--light); color: var(--ink); }   /* blue as the mark, never as small text (tokiryo: hard to read) */
.plain:hover { background: var(--base); border-color: var(--blue); }
.dark { background: var(--orange); border: 1px solid var(--orange); color: var(--ink); }
.dark:hover { background: #F2AA00; border-color: #F2AA00; }
.plain:disabled, .dark:disabled, .plain:disabled:hover, .dark:disabled:hover {
  background: var(--base); border-color: var(--base); color: var(--light); cursor: default; }
#view { flex: 1; position: relative; container: view / inline-size; background: var(--base); border-radius: var(--r-m); overflow: hidden; touch-action: none; }
#view canvas { display: block; }
.seg { position: absolute; top: 12px; display: flex; background: var(--paper); border: 1px solid var(--light);
  border-radius: var(--r-s); padding: 3px; gap: 2px; box-shadow: 0 1px 3px rgba(34, 34, 34, .06); }
#cams { left: 12px; }
#look { right: 12px; }
.seg button { border: none; background: none; min-width: 48px; height: 34px; padding: 0 12px; font-weight: 600; color: var(--gray);
  border-radius: 6px; transition: background-color .12s ease-out, color .12s ease-out; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--orange); color: var(--ink); }
/* the size of the shape as built, under the look switch: clear of the notice and the toast at the bottom */
#dims { position: absolute; top: 62px; right: 14px; pointer-events: none; user-select: none; font-size: 12px; font-weight: 600;
  color: var(--gray); font-variant-numeric: tabular-nums; white-space: nowrap; }
#dims:empty { display: none; }
#notice { position: absolute; left: 12px; bottom: 12px; max-width: calc(100% - 24px); background: var(--paper);
  border: 1px solid var(--red); border-radius: var(--r-m); padding: 8px 14px 8px 30px; font-size: 14px; box-shadow: var(--shadow); }
#notice::before { content: ""; position: absolute; left: 13px; top: 15px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
#toast { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px);
  background: var(--ink); color: var(--paper); padding: 8px 14px; font-size: 14px; border-radius: var(--r-m); box-shadow: var(--shadow);
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
#toast.error { background: var(--red); color: var(--paper); font-weight: 600; }
#toast a { color: var(--blue); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: 6px 0; white-space: nowrap; }
#toast:has(.close) { padding-right: 44px; }
#toast .msg { flex-basis: 100%; }   /* the message on its own line, the downloads under it */
#toast .close { position: absolute; top: 4px; right: 4px; border: none; background: none; color: var(--gray); width: 32px; height: 32px; }   /* top right, however the links wrap */
#toast .close:hover { color: var(--paper); }
#toast[hidden] { display: none; }

/* a drawn icon in place of the × glyph the script writes */
.close, .card header .remove { font-size: 0; position: relative; }
.close::before, .card header .remove::before { content: ""; position: absolute; inset: 0; margin: auto;
  width: 18px; height: 18px; background: currentColor; -webkit-mask: var(--icon-x) center / contain no-repeat; mask: var(--icon-x) center / contain no-repeat; }

/* ---- right panel */
#panel { width: clamp(420px, 34vw, 540px); flex: none; background: var(--paper); border-left: 1px solid var(--light);
  display: flex; flex-direction: column; padding: 0 18px; overflow: hidden; }
#tabs { display: flex; flex: none; border-bottom: 1px solid var(--light); margin: 0 -2px; }
#tabs button { flex: 1; height: 60px; border: none; background: none; font-size: 19px; font-weight: 600; color: var(--gray);
  border-bottom: 3px solid transparent; margin-bottom: -1px; transition: color .12s ease-out; }
#tabs button:hover { color: var(--ink); }
#tabs button[aria-selected="true"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--orange); }
#shape-page, #genes-page { flex: 1; overflow-y: auto; margin: 0 -18px; padding: 0 18px 24px; -webkit-overflow-scrolling: touch; }
#t-row { flex: none; padding: 18px 0 16px; border-bottom: 1px solid var(--light); }

.row { display: grid; grid-template-columns: 150px 1fr 54px; align-items: center; column-gap: 14px; min-height: 50px; }
.row > .name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#t-row .name { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; grid-row: span 2; align-self: start; padding-top: 10px; }
/* 自動: on = the t slider follows the mice (its thumb drawn hollow: the value is not the user's) */
.auto { height: 28px; padding: 0 12px; border: 1px solid var(--light); background: var(--paper); color: var(--gray);
  font-size: 13px; font-weight: 600; border-radius: 999px; }
.auto[aria-pressed="true"] { background: var(--orange); border-color: var(--orange); color: var(--ink); }
#t-row:has(.auto[aria-pressed="true"]) .thumb { background: var(--paper); box-shadow: inset 0 0 0 2px var(--orange), 0 1px 3px rgba(34, 34, 34, .2); }
.value { width: 54px; height: 38px; border: 1px solid var(--light); background: var(--paper); text-align: center;
  font: inherit; font-variant-numeric: tabular-nums; padding: 0; border-radius: var(--r-s); }

/* the unitless slider: -100 .. +100 (the word axes -50 .. +50 shown as -100 .. +100) */
.slider { position: relative; height: 44px; touch-action: pan-y; cursor: pointer; }
.slider .track { position: absolute; left: 0; right: 0; top: 50%; height: 10px; transform: translateY(-50%); }
.slider .mid { position: absolute; left: 0; right: 0; top: 3px; height: 4px; background: var(--light); border-radius: 2px; }
.slider .tick { position: absolute; top: -5px; width: 2px; margin-left: -1px; height: 20px; background: var(--gray); border-radius: 1px; }
.slider .tick.minor { top: 1px; width: 1px; margin-left: 0; height: 8px; background: var(--light); }
.slider .thumb { position: absolute; top: 50%; width: 16px; height: 24px; margin-left: -8px; transform: translateY(-50%);
  background: var(--orange); border-radius: 999px; box-shadow: 0 1px 3px rgba(34, 34, 34, .25); }
.slider:focus-visible { outline: none; }
.slider:focus-visible .thumb { outline: 2px solid var(--blue); outline-offset: 2px; }
.scale { grid-column: 2; position: relative; height: 18px; font-size: 12px; color: var(--gray); margin-top: -8px; }
.scale span { position: absolute; transform: translateX(-50%); font-variant-numeric: tabular-nums; white-space: nowrap; }

.tidy { display: flex; align-items: center; gap: 10px; padding: 14px 0 10px; border-bottom: 1px solid var(--light); }
.tidy .plain { height: 36px; min-width: 0; padding: 0 16px; }
.group { border-bottom: 1px solid var(--light); padding: 6px 0 10px; }
.group > h3 { margin: 0; }
.group > h3 button { width: 100%; display: flex; align-items: center; gap: 12px; border: none; background: none;
  height: 48px; padding: 0 4px; font-size: 18px; font-weight: 700; text-align: left; border-radius: var(--r-s); }
.group > h3 button:hover { background: var(--base); }
.group > h3 .count { margin-left: auto; font-size: 14px; font-weight: 400; color: var(--gray); }
.chev { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--gray); stroke-width: 2.2; }
.group .rows { padding-left: 4px; }

/* genes */
#genes-page h2 { font-size: 18px; margin: 22px 0 10px; }
#add { display: flex; gap: 10px; margin-bottom: 16px; }
.search-wrap { flex: 1; min-width: 0; position: relative; }
.search { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px;
  border: 1px solid var(--light); background: var(--paper); border-radius: var(--r-s); }
.search:focus-within { border-color: var(--blue); }
.search svg { width: 20px; height: 20px; fill: none; stroke: var(--gray); stroke-width: 1.8; flex: none; }
.search input { flex: 1; border: none; outline: none; font: inherit; background: none; min-width: 0; }
#add .dark { min-width: 88px; height: 44px; }
#mouse-suggest { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 5; max-height: 320px; overflow-y: auto;
  margin: 0; padding: 4px; list-style: none; background: var(--paper); border: 1px solid var(--light); border-radius: var(--r-m); box-shadow: var(--shadow); }
#mouse-suggest li { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
#mouse-suggest li[aria-selected="true"], #mouse-suggest li:hover { background: var(--base); }
#mouse-suggest .added { margin-left: auto; color: var(--gray); font-size: 13px; }
#mouse-suggest .del { flex: none; margin: 0 -8px 0 auto; width: 32px; height: 32px; border: none; background: none; color: var(--gray);
  border-radius: 6px; position: relative; font-size: 0; }
#mouse-suggest .added + .del { margin-left: 0; }
#mouse-suggest .del:hover { color: var(--red); background: var(--paper); }
#mouse-suggest .del::before { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; background: currentColor;
  -webkit-mask: var(--icon-trash) center / contain no-repeat; mask: var(--icon-trash) center / contain no-repeat; }
.card { background: var(--base); border-radius: var(--r-m); padding: 8px 14px 8px; margin-bottom: 12px; }
.card.off .row { opacity: .45; }
.card header { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.card header .label { font-size: 16px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card header .badge { flex: none; background: rgba(0, 160, 232, .16); color: var(--ink); border-radius: 999px; padding: 1px 10px;
  font-size: 12px; font-weight: 700; }
.card header .remove { flex: none; margin-left: auto; border: none; background: none; width: 40px; height: 40px;
  color: var(--gray); margin-right: -10px; border-radius: var(--r-s); }
.card header .remove:hover { color: var(--red); background: var(--paper); }
.card .row { grid-template-columns: 110px 1fr 54px; }
.switch { width: 50px; height: 30px; border: none; background: var(--light); position: relative; padding: 0; flex: none;
  border-radius: 999px; transition: background-color .15s ease-out; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; background: var(--paper);
  border-radius: 50%; box-shadow: 0 1px 3px rgba(34, 34, 34, .25); transition: left .15s ease-out; }
.switch[aria-checked="true"] { background: var(--orange); }
.switch[aria-checked="true"]::after { left: calc(100% - 27px); }
.empty { color: var(--gray); font-size: 14px; padding: 6px 2px; }

/* dialogs */
dialog { border: none; border-radius: var(--r-l); padding: 0; width: min(560px, 92vw); max-height: 80vh; color: var(--ink);
  box-shadow: 0 18px 48px rgba(34, 34, 34, .22); }
dialog::backdrop { background: rgba(34, 34, 34, .32); }
dialog form { display: flex; flex-direction: column; max-height: 80vh; }
dialog h2 { margin: 0; padding: 18px 22px 14px; font-size: 18px; border-bottom: 1px solid var(--light); }
/* モデル: the saved shapes, dropped down under the button (tokiryo 2026-11-14) */
.menu-wrap { position: relative; flex: none; }
#open { display: inline-flex; align-items: center; gap: 6px; }
#open .caret { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  transition: transform .12s ease-out; }
#open[aria-expanded="true"] .caret { transform: rotate(180deg); }
#open-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; width: min(400px, 86vw); display: flex; flex-direction: column;
  max-height: min(560px, 76vh); background: var(--paper); border: 1px solid var(--light); border-radius: var(--r-m); box-shadow: var(--shadow); }
#open-menu[hidden] { display: none; }
#open-menu .search { margin: 10px 10px 4px; }
#saved-list { overflow-y: auto; padding: 4px 6px; flex: 1 1 auto; min-height: 0; }
#saved-list .empty { padding: 14px 10px; margin: 0; color: var(--gray); font-size: 14px; }
.saved-row { display: flex; align-items: center; border-radius: var(--r-s); }
.saved-row:hover, .saved-row:focus-within { background: var(--base); }
.saved-row .pick { flex: 1; min-width: 0; display: grid; grid-template-columns: 64px 1fr; grid-template-rows: auto auto; gap: 0 12px; align-items: center;
  border: none; background: none; padding: 6px 8px; text-align: left; border-radius: var(--r-s); }
.saved-row .pick:disabled { cursor: default; opacity: .55; }
.saved-row .thumb { grid-row: 1 / 3; width: 64px; height: 48px; border-radius: 6px; background: var(--base); object-fit: cover; }
.saved-row:hover .thumb { background: var(--paper); }
.saved-row .name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-row .when { color: var(--gray); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-row .trash { flex: none; width: 40px; height: 40px; margin-right: 4px; border: none; background: none; color: var(--gray); border-radius: var(--r-s);
  opacity: 0; position: relative; font-size: 0; }
.saved-row:hover .trash, .saved-row .trash:focus-visible { opacity: 1; }
@media (hover: none) { .saved-row .trash { opacity: 1; } }   /* iPad: no hover, always shown */
.saved-row .trash:hover { color: var(--red); }
.saved-row .trash::before { content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; background: currentColor;
  -webkit-mask: var(--icon-trash) center / contain no-repeat; mask: var(--icon-trash) center / contain no-repeat; }
.menu-foot { flex: none; border: none; border-top: 1px solid var(--light); background: none; padding: 12px 16px; text-align: left;
  font-size: 14px; font-weight: 600; color: var(--ink); border-radius: 0 0 var(--r-m) var(--r-m); }
.menu-foot:hover { background: var(--base); }
.dialog-actions { padding: 12px 22px 16px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--light); }
#export-dialog { width: min(440px, 92vw); }
.toggles { padding: 6px 22px 10px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 54px; cursor: pointer; }
.toggle + .toggle { border-top: 1px solid var(--light); }
.toggle.sub { padding-left: 18px; }
.toggle.sub span { color: var(--ink); font-size: 14px; }
#gene-dialog .body { padding: 16px 22px 4px; margin: 0; line-height: 1.7; display: block; white-space: pre-line; }
#gene-dialog .gene-name { font-weight: 600; padding-bottom: 14px; }
#gene-dialog input { width: 100%; height: 40px; margin-top: 6px; padding: 0 12px; border: 1px solid var(--light);
  border-radius: var(--r-s); font: inherit; font-weight: 400; }
#gene-dialog input:focus { border-color: var(--blue); outline: none; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
/* iPad landscape and smaller: give the sliders the width (labels fit in 120px) */
@media (max-width: 1280px) { .row { grid-template-columns: 120px 1fr 54px; column-gap: 10px; } .card .row { grid-template-columns: 96px 1fr 54px; } }
/* narrow windows (down to 900px wide): a narrower panel and compact buttons, so the actions stay on one line */
@media (max-width: 1100px) {
  #panel { width: 360px; padding: 0 14px; }
  #shape-page, #genes-page { margin: 0 -14px; padding: 0 14px 24px; }
  .card .row { grid-template-columns: 88px 1fr 54px; }
  #actions { gap: 8px; }
  #actions .plain, #actions .dark { min-width: 0; padding: 0 12px; }
}
/* a narrow view: compact view switches, and the look switch (and the size under it) below the cameras when both no longer fit */
@container view (max-width: 600px) { .seg button { min-width: 0; padding: 0 9px; } }
@container view (max-width: 440px) { #look { top: 58px; } #dims { top: 108px; } }

[hidden] { display: none !important; }
