:root {
  color-scheme: dark;
  --bg: #09111f;
  --panel: #101b2d;
  --panel-raised: #16243a;
  --line: #2a3a54;
  --line-soft: #1d2c43;
  --text: #f4f7fb;
  --muted: #9caec5;
  --amber: #f5b942;
  --orange: #ff6b57;
  --blue: #55b4ff;
  --focus: #9dd4ff;
  --radius: 14px;
  font-family: Inter, "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  height: auto;
  overflow-x: auto;
  overflow-y: scroll;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  height: auto;
  overflow: visible;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}

button, select, input { font: inherit; }

button, label[for] { -webkit-tap-highlight-color: transparent; }

.app-header {
  flex: none;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: #0d1727;
}

.conversion-intro {
  flex: none;
  min-height: 88px;
  display: grid;
  grid-template-columns: minmax(380px, 1fr) auto;
  align-items: center;
  gap: 28px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(100deg, #101f34 0%, #0d1727 58%, #17243a 100%);
}
.conversion-copy { display: grid; gap: 3px; }
.conversion-kicker { color: var(--amber); font-size: .67rem; font-weight: 900; letter-spacing: .15em; }
.conversion-copy h2 { margin: 0; font-size: 1.22rem; letter-spacing: .01em; }
.conversion-copy p { max-width: 780px; margin: 1px 0 0; color: #b6c5d8; font-size: .78rem; line-height: 1.55; }
.conversion-flow { display: flex; align-items: center; gap: 8px; }
.conversion-flow span {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 7px 10px;
  border: 1px solid #334966;
  border-radius: 9px;
  background: #111d30;
  color: #dce7f5;
  font-size: .76rem;
  font-weight: 750;
  white-space: nowrap;
}
.conversion-flow b {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #263d5c;
  color: #9dd4ff;
  font-size: .68rem;
}
.conversion-flow i { color: #71849e; font-style: normal; }
.conversion-flow .conversion-result { border-color: #9f7a24; background: #2a2416; color: #ffe090; }
.conversion-flow .conversion-result b { background: var(--amber); color: #221904; }

.svg-guide, .app-guide {
  flex: none;
  border-bottom: 1px solid var(--line);
  background: #0b1524;
}
.svg-guide > summary, .app-guide > summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 7px 20px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.svg-guide > summary::-webkit-details-marker, .app-guide > summary::-webkit-details-marker { display: none; }
.svg-guide > summary:hover, .app-guide > summary:hover { background: #101d30; }
.guide-summary-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 8px;
  background: #ff7d1a;
  color: #1b0d02;
  font-weight: 900;
  font-size: .62rem;
  letter-spacing: -.03em;
}
.svg-guide summary strong { display: block; font-size: .9rem; }
.app-guide summary strong { display: block; font-size: .9rem; }
.svg-guide summary small, .app-guide summary small { display: block; margin-top: 2px; color: var(--muted); font-size: .72rem; }
.guide-summary-icon.app-icon { background: var(--blue); color: #06111d; }
.guide-summary-action {
  margin-left: auto;
  color: var(--muted);
  font-size: .74rem;
}
.guide-summary-action::after {
  content: "＋";
  display: inline-block;
  margin-left: 8px;
  color: var(--amber);
  font-size: 1rem;
  transition: transform .2s;
}
.svg-guide[open] .guide-summary-action::after, .app-guide[open] .guide-summary-action::after { content: "−"; }
.app-guide-body {
  max-height: none;
  overflow: visible;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--line-soft);
}
.operation-flow {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(8, minmax(125px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
}
.operation-flow li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #101d30;
}
.operation-flow li > span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  background: var(--amber);
  color: #1c1403;
  font-size: .7rem;
  font-weight: 900;
}
.operation-flow strong { display: block; font-size: .76rem; }
.operation-flow small { display: block; margin-top: 4px; color: var(--muted); font-size: .67rem; line-height: 1.45; }
.settings-guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(250px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.settings-guide-grid section {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #0d1829;
}
.settings-guide-grid h3 { margin: 0 0 9px; color: #dfe9f6; font-size: .82rem; }
.settings-guide-grid dl { display: grid; gap: 6px; margin: 0; }
.settings-guide-grid dl div { display: grid; grid-template-columns: minmax(88px, .35fr) minmax(0, 1fr); gap: 9px; padding-top: 6px; border-top: 1px solid var(--line-soft); }
.settings-guide-grid dt { color: #ffd36c; font-size: .7rem; font-weight: 800; }
.settings-guide-grid dd { margin: 0; color: #b9c7d8; font-size: .7rem; line-height: 1.45; }
.guide-body {
  max-height: none;
  overflow: visible;
  padding: 4px 20px 20px;
  border-top: 1px solid var(--line-soft);
}
.guide-intro {
  display: grid;
  grid-template-columns: minmax(280px, .8fr) minmax(340px, 1.2fr);
  align-items: end;
  gap: 28px;
  padding: 18px 0 15px;
}
.guide-intro h2 { margin: 4px 0 0; font-size: 1.15rem; }
.guide-intro p { margin: 0; color: #b9c7d8; font-size: .84rem; line-height: 1.7; }
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.guide-card {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.guide-card-head { display: flex; align-items: center; gap: 9px; }
.guide-card-head > span {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  flex: none;
  border-radius: 50%;
  background: var(--amber);
  color: #191204;
  font-size: .69rem;
  font-weight: 900;
}
.guide-card h3, .guide-footer h3 { margin: 0; font-size: .83rem; }
.guide-diagram {
  width: 100%;
  height: 118px;
  display: block;
  margin: 9px 0 7px;
  border-radius: 8px;
  background: #0b1524;
}
.guide-diagram text { fill: #dce7f5; font: 12px Inter, "Noto Sans JP", sans-serif; }
.guide-diagram .diagram-ng { fill: #ff8070; font-weight: 900; }
.guide-diagram .diagram-ok { fill: #70c5ff; font-weight: 900; }
.guide-card ul {
  margin: 0;
  padding-left: 1.15em;
  color: #b9c7d8;
  font-size: .76rem;
  line-height: 1.55;
}
.guide-card li + li { margin-top: 4px; }
.guide-footer {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 10px;
  margin-top: 10px;
}
.guide-footer section {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0d1829;
}
.checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}
.checklist span {
  padding: 6px 9px;
  border-radius: 999px;
  background: #172842;
  color: #d6e2f1;
  font-size: .73rem;
}
.checklist span::before { content: "✓"; margin-right: 6px; color: var(--amber); font-weight: 900; }
.export-settings dl {
  display: grid;
  grid-template-columns: repeat(5, minmax(80px, 1fr));
  gap: 7px;
  margin: 10px 0 0;
}
.export-settings dl div { padding: 7px; border-left: 2px solid #31577c; background: #111f33; }
.export-settings dt { color: var(--muted); font-size: .65rem; }
.export-settings dd { margin: 3px 0 0; font-size: .73rem; font-weight: 700; }

.brand { display: flex; align-items: center; gap: 12px; min-width: 260px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--amber);
  color: #1d1608;
  font-size: 27px;
  font-weight: 900;
}
.brand h1 { margin: 0; font-size: 1.05rem; letter-spacing: .025em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: .78rem; }

.header-actions { display: flex; align-items: center; gap: 8px; }
.button, .icon-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--panel-raised);
  cursor: pointer;
  transition: border-color .15s, transform .15s, background .15s;
}
.button {
  min-height: 40px;
  padding: 9px 14px;
  border-radius: 9px;
  font-weight: 700;
  font-size: .88rem;
}
.button:hover, .icon-button:hover { border-color: #607493; background: #1c2e49; }
.button:active, .icon-button:active { transform: translateY(1px); }
.button.primary { background: #234970; border-color: #3479b5; }
.button.accent { background: var(--amber); border-color: var(--amber); color: #171205; }
.button:focus-visible, .icon-button:focus-visible, select:focus-visible, input:focus-visible, .layer-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 45%, transparent);
  outline-offset: 2px;
}

.workspace {
  flex: none;
  min-height: 640px;
  display: grid;
  grid-template-columns: minmax(200px, 19vw) minmax(300px, 1fr) minmax(260px, 23vw);
  height: max(640px, 75vh);
}

.panel { min-width: 0; overflow: auto; background: var(--panel); }
.layers-panel { border-right: 1px solid var(--line); padding: 20px 14px 14px; }
.settings-panel { border-left: 1px solid var(--line); padding: 20px 16px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-heading h2 { margin: 3px 0 0; font-size: 1.12rem; }
.eyebrow { color: var(--amber); font-size: .68rem; font-weight: 800; letter-spacing: .12em; }
.count-badge { min-width: 30px; padding: 4px 8px; border-radius: 999px; background: var(--panel-raised); color: var(--muted); text-align: center; font-size: .8rem; }
.hint { margin: 12px 0 14px; color: var(--muted); font-size: .78rem; line-height: 1.5; }

.layer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.layer-item { position: relative; }
.layer-button {
  width: 100%;
  display: grid;
  grid-template-columns: 27px 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  background: #0d1727;
  text-align: left;
  cursor: pointer;
}
.layer-button:hover { border-color: #344966; }
.layer-button.selected { border-color: var(--amber); background: #1b283c; box-shadow: inset 3px 0 var(--amber); }
.layer-order { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .75rem; }
.layer-swatch { width: 10px; height: 28px; border-radius: 4px; background: var(--swatch, #fff); }
.layer-copy { min-width: 0; }
.layer-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 750; font-size: .88rem; }
.layer-meta { display: block; margin-top: 3px; color: var(--muted); font-size: .7rem; }
.needle-badge { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #263956; color: #dce8f7; font-size: .75rem; font-weight: 800; }
.layer-item.disabled { opacity: .43; }

.legend { display: flex; gap: 14px; margin-top: 16px; padding: 12px 4px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: .72rem; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend-line { width: 18px; border-top: 2px solid var(--amber); }
.legend-line.jump { border-top-style: dashed; border-color: #65778f; }

.preview-panel { min-width: 0; display: grid; grid-template-rows: auto 52px minmax(0, 1fr) 34px; background: #07101d; }
.preview-toolbar, .status-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 14px; background: #0d1727; }
.preview-toolbar { border-bottom: 1px solid var(--line); }
.status-bar { border-top: 1px solid var(--line); color: var(--muted); font-size: .75rem; }
.document-name { font-weight: 750; }
.document-size { margin-left: 8px; color: var(--muted); font-size: .76rem; }
.preview-actions { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .76rem; }
.icon-button { min-width: 32px; height: 32px; border-radius: 7px; }
.text-button { width: auto; padding: 0 9px; font-size: .75rem; }
.icon-button.active { border-color: var(--amber); color: #ffd66b; background: #202b3d; }
.canvas-wrap { position: relative; overflow: hidden; min-width: 0; min-height: 0; background-color: #e7e9ec; background-image: linear-gradient(#d7dade 1px, transparent 1px), linear-gradient(90deg, #d7dade 1px, transparent 1px); background-size: 20px 20px; }
#preview-canvas { display: block; width: 100%; height: 100%; cursor: grab; }
#preview-canvas.dragging { cursor: grabbing; }

.switch-label { display: inline-flex; cursor: pointer; }
.switch-label input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 42px; height: 24px; border-radius: 999px; background: #34445c; position: relative; transition: .2s; }
.switch::after { content: ""; position: absolute; width: 18px; height: 18px; top: 3px; left: 3px; border-radius: 50%; background: white; transition: .2s; }
.switch-label input:checked + .switch { background: var(--amber); }
.switch-label input:checked + .switch::after { transform: translateX(18px); background: #211902; }

.settings-section { padding: 17px 0; border-bottom: 1px solid var(--line-soft); }
.settings-section h3 { margin: 0 0 13px; color: #d6e1ef; font-size: .82rem; letter-spacing: .025em; }
.field-grid { display: grid; gap: 12px; }
.field-grid.two { grid-template-columns: 88px minmax(0, 1fr); }
.field { display: grid; gap: 6px; color: var(--muted); font-size: .75rem; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) 104px; align-items: center; gap: 10px; }
.field-row label { color: var(--muted); font-size: .76rem; }
.stitch-description { margin: 10px 0 0; color: #9fb2c8; font-size: .76rem; line-height: 1.55; }
select, input[type="number"] {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 9px;
  background: #0c1626;
  color: var(--text);
}
.color-note { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--muted); font-size: .73rem; }
.source-color { width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(255,255,255,.35); background: var(--source, white); }
.check-grid { display: grid; gap: 10px; color: #cad6e6; font-size: .82rem; }
.check-grid label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check-grid input { accent-color: var(--amber); width: 17px; height: 17px; }
.facts { display: grid; gap: 9px; }
.facts div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.facts span { color: var(--muted); font-size: .75rem; }
.facts strong { font-size: .85rem; }

.toast { position: fixed; left: 50%; bottom: 48px; z-index: 20; transform: translate(-50%, 16px); padding: 11px 16px; border: 1px solid #3b526f; border-radius: 10px; background: #15243a; color: white; box-shadow: 0 12px 32px rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#svg-stage { position: fixed; left: -100000px; top: -100000px; width: 1000px; height: 1000px; overflow: hidden; visibility: hidden; }

@media (max-width: 980px) {
  .app-header {
    height: 118px;
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 12px 14px;
  }
  .brand { min-width: 230px; }
  .header-actions { width: 100%; }
  .button { flex: 1; text-align: center; padding-inline: 8px; }
  .workspace {
    grid-template-columns: minmax(200px, 26%) minmax(300px, 1fr) minmax(260px, 34%);
  }
  .conversion-intro { grid-template-columns: 1fr; gap: 9px; }
  .conversion-flow { justify-content: flex-start; }
  .operation-flow { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
  .settings-guide-grid { grid-template-columns: 1fr; }
  .guide-grid { grid-template-columns: repeat(2, minmax(240px, 1fr)); }
  .guide-footer { grid-template-columns: 1fr; }
  .layers-panel { padding-inline: 10px; }
  .settings-panel { padding-inline: 12px; }
  .field-grid.two { grid-template-columns: 74px minmax(0, 1fr); }
}

@media (max-width: 719px) {
  .app-header { height: auto; min-height: 118px; }
  .header-actions { flex-wrap: wrap; }
  .workspace {
    grid-template-columns: 210px minmax(360px, 1fr);
    grid-template-rows: minmax(560px, calc(100vh - 145px)) auto;
    height: auto;
    min-width: 570px;
  }
  .conversion-intro { min-width: 570px; padding-inline: 14px; }
  .conversion-flow { flex-wrap: wrap; }
  .svg-guide > summary, .app-guide > summary { padding-inline: 14px; }
  .app-guide-body { min-width: 570px; padding-inline: 14px; }
  .operation-flow { grid-template-columns: repeat(2, minmax(250px, 1fr)); }
  .guide-body { min-width: 570px; padding-inline: 14px; }
  .guide-intro { grid-template-columns: 1fr; gap: 8px; }
  .guide-grid { grid-template-columns: repeat(2, minmax(250px, 1fr)); }
  .export-settings dl { grid-template-columns: repeat(3, minmax(110px, 1fr)); }
  .settings-panel {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .settings-panel #settings-content {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
  }
}

.stitch-setting-sample { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 8px; background: #0c1728; font-size: .8rem; }
.stitch-setting-sample:empty { display: none; }
.stitch-setting-sample .stitch-sample { width: 120px; height: 48px; flex: 0 0 120px; color: #73bdff; }
.stitch-setting-sample small { width: 100%; color: var(--muted); font-size: .67rem; }
