:root {
  color-scheme:light;
  font:14px/1.5 "Instrument Sans","Yu Gothic UI","Meiryo",system-ui,sans-serif;
  color:#243b3c;
  background:#f6f8f6;
  --ink:#243b3c;
  --muted:#647674;
  --line:#dce4df;
  --accent:#1e625d;
  --tint:#e5f1eb;
  --paper:#fcfdfb;
}

* {
  box-sizing:border-box;
}

body {
  margin:0;
}

button,input,select {
  font:inherit;
  color:inherit;
}

button,select,input[type=color],input[type=checkbox] {
  cursor:pointer;
}

button {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  border:1px solid var(--line);
  border-radius:7px;
  background:var(--paper);
  padding:7px 12px;
  font-weight:600;
}

button:hover:not(:disabled) {
  background:#eaf1ec;
}

button:disabled {
  opacity:.35;
  cursor:default;
}

button:focus-visible,select:focus-visible,input:focus-visible {
  outline:3px solid #5baca2;
  outline-offset:2px;
}

button.primary {
  background:var(--accent);
  border-color:var(--accent);
  color:white;
}

button.primary:hover {
  background:#164f4b;
}

i,[data-icon] {
  font-style:normal;
}

i[data-icon],.icon {
  display:inline-flex;
  flex:none;
  vertical-align:middle;
}

.icon {
  width:18px;
  height:18px;
}

h1,h2,h3,h4,p {
  margin:0;
}

h2 {
  font-size:16px;
  letter-spacing:.025em;
}

h3 {
  font-size:15px;
}

h4 {
  font-size:13px;
}

select {
  max-width:100%;
  border:1px solid var(--line);
  border-radius:6px;
  background:var(--paper);
  padding:6px;
}

.topbar {
  display:flex;
  align-items:center;
  gap:24px;
  padding:0 24px;
  height:68px;
  border-bottom:1px solid var(--line);
  background:var(--paper);
}

.brand {
  display:flex;
  align-items:center;
  gap:10px;
  white-space:nowrap;
}

.brand b {
  font-size:22px;
  letter-spacing:-.055em;
}

.project-picker {
  border-left:1px solid var(--line);
  padding-left:22px;
  display:flex;
  align-items:center;
  gap:10px;
}

.project-picker span,.space-meta,.muted,.section-label {
  color:var(--muted);
  font-size:12px;
}

.project-picker select {
  font-weight:650;
  background:transparent;
  border:0;
  max-width:240px;
}

.top-actions {
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:5px;
}

.top-actions .primary,.top-actions .plain {
  margin-left:6px;
}

.icon-btn,.text-btn {
  border:0;
  background:transparent;
}

.icon-btn {
  width:33px;
  height:33px;
  padding:0;
}

.text-btn {
  color:var(--accent);
  font-size:13px;
  padding:5px 6px;
}

.workbench {
  display:grid;
  grid-template-columns:minmax(200px,18vw) minmax(0,1fr) minmax(238px,21vw);
  height:calc(100dvh - 100px);
  min-height:610px;
}

.library,.inspector {
  background:var(--paper);
  min-width:0;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.library {
  border-right:1px solid var(--line);
}

.inspector {
  border-left:1px solid var(--line);
}

.panel-title {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.panel-title h2 {
  display:flex;
  align-items:center;
  gap:8px;
}

.library>.panel-title,.inspector>.panel-title {
  padding:23px 18px 15px;
}

.inspector>.panel-title {
  border-bottom:1px solid var(--line);
}

.count {
  border-radius:20px;
  background:#edf1ec;
  padding:1px 8px;
  font-size:12px;
  color:var(--muted);
}

.search {
  display:flex;
  align-items:center;
  gap:8px;
  margin:0 15px 13px;
  padding:7px 9px;
  border:1px solid var(--line);
  border-radius:6px;
  background:#f6f8f5;
  color:var(--muted);
}

.search input {
  border:0;
  background:transparent;
  min-width:0;
  width:100%;
  font-size:12px;
}

.list {
  flex:1;
  overflow:auto;
  padding:0 9px 12px;
}

.list-heading {
  display:flex;
  justify-content:space-between;
  align-items:center;
  color:#60746e;
  font-size:11px;
  font-weight:700;
  padding:14px 10px 4px;
}

.list-heading small {
  font-size:11px;
  font-weight:400;
}

.object {
  width:100%;
  text-align:left;
  justify-content:flex-start;
  gap:9px;
  border:1px solid transparent;
  background:transparent;
  min-height:35px;
  padding:5px 9px;
  font-size:13px;
  font-weight:500;
}

.object .swatch {
  width:11px;
  height:11px;
  border-radius:3px;
  border:1px solid #425c583a;
  background:var(--color);
  flex:none;
}

.object.child {
  padding-left:24px;
}

.object.active {
  background:var(--tint);
  color:#155d53;
  border-color:#c2d9cf;
  font-weight:700;
}

.object .tiny {
  margin-left:auto;
  color:#647a72;
  font-size:10px;
}

.library-foot {
  border-top:1px solid var(--line);
  padding:12px 14px;
  display:grid;
  gap:5px;
}

.wide {
  width:100%;
}

.workspace {
  min-width:0;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  background:#f4f7f3;
}

.space-head {
  padding:18px 23px 15px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.space-meta {
  display:flex;
  align-items:center;
  gap:7px;
  font-size:11px;
  letter-spacing:.04em;
}

.space-meta .icon {
  width:14px;
  height:14px;
}

.space-head h1 {
  font-size:clamp(21px,2.1vw,32px);
  font-weight:700;
  letter-spacing:-.055em;
  line-height:1.4;
}

.space-selects {
  display:flex;
  align-items:center;
  gap:3px;
}

.space-selects select {
  font-size:12px;
  max-width:150px;
}

.viewport {
  position:relative;
  flex:1;
  min-height:290px;
  margin:0 16px;
  overflow:hidden;
  border:1px solid #ccd9d1;
  border-radius:10px;
  background:#eaf0e9;
}

.viewport #stage3d,.viewport #stage2d {
  position:absolute;
  inset:0;
}

.viewport canvas,#stage2d svg {
  width:100%;
  height:100%;
  display:block;
  touch-action:none;
}

.viewport #stage2d {
  background-color:#f0f4ee;
  background-image:radial-gradient(#bbc9bf .8px,transparent .8px);
  background-size:14px 14px;
}

.canvas-bar,.canvas-bottom {
  pointer-events:none;
  position:absolute;
  left:12px;
  right:12px;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
}

.canvas-bar {
  top:12px;
}

.canvas-bottom {
  bottom:12px;
  align-items:flex-end;
}

.canvas-bar>*,.canvas-bottom>* {
  pointer-events:auto;
}

.segments,.controls {
  display:inline-flex;
  border:1px solid #c7d3ca;
  border-radius:7px;
  padding:3px;
  background:#fcfdf9f5;
  box-shadow:0 2px 6px #2149390c;
}

.segments button,.controls button {
  border:0;
  background:transparent;
  font-size:12px;
  padding:5px 10px;
}

.segments button.active,.controls button.active {
  background:#2b5551;
  color:white;
}

.canvas-bar select {
  font-size:12px;
}

.controls button {
  width:30px;
  height:29px;
  padding:0;
}

.controls .icon {
  width:16px;
  height:16px;
}

#move { width:auto; padding:0 9px; }
#dialogHelp { margin-left:auto; }
#helpDialog[open] { display:flex; flex-direction:column; }
#helpDialog .dialog-head, .help-tools { flex:none; }
.help-tools { display:grid; gap:10px; padding:14px 18px; border-bottom:1px solid var(--line); }
.help-tools .search { margin:0; }
.help-tools a { color:var(--accent); width:fit-content; }
#helpTopics { overflow:auto; overscroll-behavior:contain; padding:0 18px 16px; }
#helpTopics h3 { margin:16px 0 4px; font-size:.88rem; color:var(--muted); }
#helpTopics details { border-bottom:1px solid var(--line); padding:0 2px; }
#helpTopics summary { cursor:pointer; padding:10px 2px; font-weight:650; }
#helpTopics summary:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
#helpEmpty { margin:0; padding:14px 18px; }
.starter-list { display:grid; gap:7px; }
.starter-card { justify-content:flex-start; text-align:left; gap:12px; padding:7px; }
.starter-card small { display:block; color:var(--muted); font-weight:400; }
.starter-preview { width:78px; height:52px; object-fit:contain; background:#eff4ef; border-radius:4px; }

#minimap {
  width:clamp(96px,10vw,150px);
  padding:2px 5px;
  background:#fafcf8e8;
  border:1px solid #bdcdc2;
  border-radius:5px;
}

#minimap svg {
  width:100%;
  pointer-events:none;
}

.view-info {
  padding:8px 20px 12px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  font-size:11px;
  color:var(--muted);
}

input[type=checkbox] {
  accent-color:var(--accent);
  vertical-align:middle;
}

.validation {
  background:var(--paper);
  border-top:1px solid var(--line);
  padding:13px 20px 16px;
}

.validation h2 {
  font-size:14px;
}

.validation #validation {
  font-size:12px;
  color:var(--muted);
  padding-top:5px;
}

.flag {
  color:#9b4925;
  background:#f8eee2;
  padding:3px 6px;
  border-radius:4px;
}

.ok {
  color:var(--accent);
}

#properties {
  overflow:auto;
  padding:17px;
}

.selected-info {
  display:flex;
  align-items:center;
  gap:10px;
  padding-bottom:15px;
}

.sample-chip {
  width:42px;
  height:42px;
  border-radius:8px;
  display:grid;
  place-items:center;
  border:1px solid #425c5840;
}

.sample-chip .icon {
  width:24px;
  height:24px;
}

.selected-info small {
  color:var(--muted);
  font-size:11px;
}

.section {
  padding:14px 0;
  border-top:1px solid var(--line);
}

.section h3 {
  font-size:13px;
  margin-bottom:9px;
}

.fields {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:7px;
}

.field {
  display:flex;
  flex-direction:column;
  gap:4px;
  color:#5e706b;
  font-size:11px;
  margin-bottom:7px;
}

.field input,.field select {
  width:100%;
  min-width:0;
  padding:7px;
  border:1px solid #d3ded7;
  border-radius:5px;
  background:white;
  color:var(--ink);
  font-size:13px;
}

.field input[type=color] {
  height:35px;
  padding:3px;
}

.field input[readonly] {
  background:#f1f4f1;
}

.two {
  grid-template-columns:repeat(2,minmax(0,1fr));
}

.field-note {
  font-size:11px;
  color:var(--muted);
  overflow-wrap:anywhere;
}

.row-actions {
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}

.row-actions .primary {
  flex:1;
}

.section:last-child {
  padding-bottom:0;
}

.danger {
  color:#984427;
}

.action-list {
  display:grid;
  gap:8px;
}

.action-list button {
  justify-content:flex-start;
  text-align:left;
}

.action-list button span+small {
  margin-left:auto;
}

.action-list small {
  color:var(--muted);
  font-weight:400;
}

.action-list .active {
  border-color:#84aba1;
  background:var(--tint);
}

footer {
  min-height:32px;
  border-top:1px solid var(--line);
  background:var(--paper);
  display:flex;
  align-items:center;
  gap:16px;
  font-size:11px;
  padding:5px 18px;
  color:var(--muted);
}

footer span:last-child {
  margin-left:auto;
}

.local b {
  display:inline-block;
  width:7px;
  height:7px;
  border-radius:100%;
  background:#5c957f;
  margin-right:6px;
}

dialog {
  border:1px solid #bfcdc4;
  border-radius:12px;
  max-width:min(580px,94vw);
  width:510px;
  max-height:85dvh;
  padding:0;
  color:var(--ink);
  background:var(--paper);
  box-shadow:0 14px 70px #18362f38;
}

dialog::backdrop {
  background:#203b3559;
}

.dialog-head {
  display:flex;
  align-items:center;
  justify-content:space-between;
  position:sticky;
  top:0;
  z-index:1;
  background:var(--paper);
  border-bottom:1px solid var(--line);
  padding:13px 18px;
}

.dialog-head h2 {
  font-size:18px;
}

#dialogBody {
  padding:18px;
  display:grid;
  gap:13px;
}

#dialogBody>.section {
  padding-bottom:0;
}

#dialogBody p {
  font-size:13px;
  color:var(--muted);
}

.calibration-img {
  position:relative;
  width:100%;
  line-height:0;
  cursor:crosshair;
}

.calibration-img img {
  width:100%;
}

.cal-dot {
  position:absolute;
  transform:translate(-50%,-50%);
  border:2px solid white;
  border-radius:100%;
  background:#cc5129;
  width:12px;
  height:12px;
  pointer-events:none;
}

#notice {
  position:fixed;
  left:50%;
  bottom:40px;
  transform:translateX(-50%);
  max-width:90vw;
  padding:10px 18px;
  background:#243f3a;
  color:white;
  border-radius:7px;
  z-index:5;
  font-size:13px;
}

dialog .error {
  color:#9b4925;
  font-size:12px;
}

[hidden] {
  display:none!important;
}

@media(min-width:1550px) {
  .workbench {
    grid-template-columns:280px minmax(0,1fr) 320px;
  }
  .space-head {
    padding:22px 26px;
  }
}

@media(max-width:1000px) {
  .workbench {
    grid-template-columns:170px minmax(0,1fr) 216px;
  }
  .topbar {
    gap:10px;
    padding:0 13px;
  }
  .project-picker {
    padding-left:10px;
  }
  .project-picker span {
    display:none;
  }
  .space-head,.validation {
    padding-left:14px;
    padding-right:14px;
  }
  .viewport {
    margin:0 8px;
  }
  .space-selects select {
    max-width:100px;
  }
  .view-info {
    flex-wrap:wrap;
  }
}

@media(max-width:760px) {
  .topbar {
    height:auto;
    min-height:57px;
    flex-wrap:wrap;
    padding:8px 12px;
    gap:6px 12px;
  }
  .brand b {
    font-size:19px;
  }
  .brand img {
    width:28px;
    height:28px;
  }
  .project-picker {
    border:0;
    margin-left:auto;
  }
  .project-picker select {
    font-size:12px;
    max-width:170px;
  }
  .top-actions {
    width:100%;
    justify-content:flex-end;
    flex-wrap:wrap;
    gap:3px;
  }
  .top-actions .plain {
    margin-left:auto;
  }
  .top-actions .primary,.top-actions .plain { padding:6px 8px; }
  .workbench {
    height:auto;
    min-height:0;
    grid-template-columns:minmax(130px,.85fr) minmax(0,1.15fr);
  }
  .workspace {
    grid-column:1/-1;
    grid-row:1;
  }
  .space-head {
    padding:10px 13px;
  }
  .viewport {
    min-height:320px;
    height:47dvh;
    flex:auto;
  }
  .view-info {
    padding:7px 11px;
  }
  .library,.inspector {
    height:490px;
    border-top:1px solid var(--line);
  }
  .inspector {
    border-left:0;
  }
  .library>.panel-title,.inspector>.panel-title {
    padding:14px 11px 10px;
  }
  .search {
    margin:0 8px 8px;
  }
  .list {
    padding:0 4px;
  }
  .library-foot,#properties {
    padding:9px;
  }
  .object {
    font-size:12px;
  }
  .wide {
    font-size:12px;
  }
  .validation {
    padding:8px 12px;
  }
  .validation #validation {
    padding-top:1px;
  }
  footer {
    flex-wrap:wrap;
    gap:6px;
  }
  .fields {
    gap:4px;
  }
  .field input {
    padding:5px;
  }
  .view-info span {
    max-width:56%;
  }
}
.swing-fields {
  min-width: 0;
  margin: 12px 0;
  padding: 8px 0;
  border: 0;
}
.swing-fields legend {
  padding: 0;
  font-size: 13px;
  font-weight: 700;
}

dialog:has(#conceptPanel) { width: min(760px, 94vw); max-width: 94vw; }
#conceptPanel { display: grid; gap: 12px; }
#conceptPanel textarea { width: 100%; resize: vertical; padding: 8px; font: inherit; border: 1px solid var(--line); border-radius: 6px; }
#conceptPanel figure { margin: 0; }
#conceptPanel img { display: block; width: 100%; height: auto; object-fit: contain; border-radius: 5px; background: #f0f3ee; }
#conceptPanel img[hidden] { display:none; }
#conceptPanel .concept-input img { max-height: 180px; }
.concept-pair { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.concept-pair img { aspect-ratio: 3/2; }
.concept-pair figcaption, #conceptProvider { font-size: .87rem; color: var(--muted); }
#conceptResult > * { margin: 8px 0; }
#conceptRecord { white-space: pre-wrap; overflow-wrap: anywhere; }
#conceptStatus:empty { display:none; }
