:root {
  color-scheme: dark;
  font-family: system-ui, "Yu Gothic UI", Meiryo, sans-serif;
  color: #e9eeeb;
  background: #131619;
  --panel: #1b1f22;
  --panel-deep: #171b1e;
  --well: #242a2d;
  --border: #333a3d;
  --text: #e9eeeb;
  --subtle: #aab6b0;
  --muted: #929e99;
  --mint: #b5ebca;
  --mint-bright: #c6f5d8;
  --mint-text: #172d22;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button, select { color: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: default; opacity: .48; }
button, select, input { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--mint-bright); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
svg { width: 18px; height: 18px; flex: none; }
svg[aria-hidden="true"] { fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
fieldset { padding: 0; border: 0; margin: 0; min-inline-size: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.app-header {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  gap: 16px;
  background: #181c1f;
  border-bottom: 1px solid var(--border);
}
.brand, .header-actions { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: #2c4136;
  color: var(--mint);
  border: 1px solid #44614f;
  border-radius: 11px;
}
.brand-icon svg { width: 23px; height: 23px; }
.brand-eyebrow { display: block; color: var(--mint); font-size: 11px; font-weight: 650; letter-spacing: .10em; }
.brand h1 { margin-top: 2px; font-size: 19px; line-height: 1.25; letter-spacing: .03em; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--well);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.button:not(:disabled):hover { background: #30383b; }
.button-quiet { color: var(--subtle); background: transparent; border-color: transparent; }
.button-reset { color: var(--mint); background: #263a30; border-color: #425f4e; }
.button-reset:not(:disabled):hover { background: #365040; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 342px;
  gap: 16px;
  height: calc(100dvh - 76px);
  padding: 17px 22px 20px;
  margin: 0 auto;
  max-width: 1920px;
}
.preview, .inspector {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.preview { display: grid; grid-template-rows: 48px minmax(0, 1fr) 40px; }
.preview-header, .preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
}
.preview-header h2, .export-fields h2 { display: flex; align-items: center; gap: 8px; }
.preview-header h2, .setting-section h2, .export-fields h2 { font-size: 14px; font-weight: 700; }
.preview-header h2 svg, .export-fields h2 svg { color: var(--mint); }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #b7c6bc;
  border: 1px solid #3c4943;
  border-radius: 30px;
  padding: 4px 9px;
  font-size: 11px;
  line-height: 1.2;
}
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #e7bc76; }
.status-pill[data-state="ready"]::before { background: #a7e4bd; }
.status-pill[data-state="error"]::before { background: #f39a89; }
.stage {
  display: grid;
  place-items: center;
  position: relative;
  min-width: 0;
  min-height: 0;
  isolation: isolate;
  overflow: hidden;
  background-color: #121618;
  background-image: radial-gradient(#343e3d 0.8px, transparent 0.8px);
  background-size: 14px 14px;
  border-block: 1px solid #2b3133;
}
.shot { position: relative; display: grid; place-items: stretch; box-shadow: 0 8px 30px #0609078f; }
#preview-canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; user-select: none; }
#preview-canvas.is-dragging { cursor: grabbing; }
.shot-corner { position: absolute; pointer-events: none; width: 15px; height: 15px; border: solid #e4ffe9; filter: drop-shadow(0 0 2px #101812); }
.top-left { top: 0; left: 0; border-width: 2px 0 0 2px; }
.top-right { top: 0; right: 0; border-width: 2px 2px 0 0; }
.bottom-left { bottom: 0; left: 0; border-width: 0 0 2px 2px; }
.bottom-right { bottom: 0; right: 0; border-width: 0 2px 2px 0; }
.preview-footer { color: var(--subtle); font-size: 11px; }
.preview-footer span { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.preview-footer svg { width: 15px; height: 15px; }
.preview-footer .frame-guide { margin-right: auto; }
.frame-guide i { display: block; width: 11px; height: 8px; border: 1px solid var(--mint); }
.location-label { font-variant-numeric: tabular-nums; }
.load-message {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  color: var(--subtle);
  font-size: 13px;
}
.load-message strong { color: var(--text); font-size: 16px; }
.load-message svg { color: var(--mint); width: 35px; height: 35px; }
.file-message, .local-file #load-message { display: none; }
.local-file .file-message { display: flex; }

.plan {
  position: absolute;
  z-index: 1;
  left: 12px;
  bottom: 12px;
  width: 188px;
  max-width: calc(100% - 24px);
  background: #181e20;
  border: 1px solid #4a5951;
  border-radius: 9px;
  box-shadow: 0 4px 16px #080d0a80;
  overflow: hidden;
}
.plan.is-large { width: 302px; }
.plan.is-collapsed { width: 126px; }
.plan-header { height: 35px; display: flex; align-items: center; gap: 3px; padding: 0 6px 0 9px; }
.plan-header h3 { display: flex; align-items: center; gap: 5px; margin-right: auto; font-size: 12px; }
.plan-header h3 svg { width: 14px; height: 14px; color: var(--mint); }
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 27px;
  height: 27px;
  padding: 0;
  color: var(--subtle);
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
}
.icon-button:hover { background: #2b3330; color: var(--mint); }
.icon-button svg { width: 15px; height: 15px; }
.plan-body { padding: 0 7px 6px; }
.plan-svg { display: block; width: 100%; height: auto; aspect-ratio: 1.19; cursor: crosshair; background: #232c2c; border-radius: 4px; }
.plan-body p { display: flex; align-items: center; gap: 6px; margin: 5px 0 0 3px; font-size: 10px; color: var(--subtle); }
.plan-body i { width: 5px; height: 5px; background: var(--mint); border-radius: 50%; }

.inspector { display: grid; grid-template-rows: 47px minmax(0, 1fr) auto; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 0 13px; border-bottom: 1px solid var(--border); }
.tabs button {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  padding: 0 6px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--subtle);
  font-size: 13px;
  font-weight: 700;
}
.tabs button svg { width: 16px; height: 16px; }
.tabs button[aria-selected="true"] { border-color: var(--mint); color: var(--mint-bright); }
.tabs button:hover { color: var(--mint-bright); }
.wall-badge { border-radius: 12px; background: #344e40; padding: 2px 6px; font-size: 10px; color: var(--mint); }
.settings { overflow: auto; scrollbar-width: thin; scrollbar-color: #485750 transparent; }
.setting-section { padding: 14px 15px; border-bottom: 1px solid #2d3436; }
.setting-section:last-child { border-bottom: 0; }
.setting-section h2 { margin-bottom: 9px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.section-heading > span { font-size: 11px; color: var(--muted); }
.setting-section .section-heading > span { margin-bottom: 9px; }
.segments {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid #353f3e;
  background: #151a1c;
}
.segments button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 31px;
  padding: 4px 3px;
  color: var(--subtle);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 650;
}
.segments button:not(:disabled):hover { background: #2b3531; color: var(--text); }
.segments button[aria-pressed="true"] { background: #314639; border-color: #496553; color: var(--mint-bright); }
.motion-controls { display: grid; grid-template-columns: 3fr 1fr; align-items: stretch; gap: 12px; }
.dpad { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-areas: ". f ." "l b r"; gap: 4px; }
.dpad .forward { grid-area: f; }
.dpad .left { grid-area: l; }
.dpad .back { grid-area: b; }
.dpad .right { grid-area: r; }
.vertical-pad { display: grid; grid-template-rows: 1fr 1fr; gap: 4px; border-left: 1px solid #39413f; padding-left: 10px; }
.motion {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: #272e30;
  color: var(--text);
  border: 1px solid #414b49;
  border-radius: 7px;
  min-height: 34px;
  padding: 2px;
  font-size: 11px;
  user-select: none;
  touch-action: none;
}
.motion svg { width: 14px; height: 14px; color: var(--mint); }
.motion:not(:disabled):hover { background: #34413b; }
.motion.is-moving { background: #405747; border-color: #749b80; }
.range-control { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 8px; row-gap: 3px; margin-top: 11px; font-size: 12px; color: var(--subtle); }
.range-control output { color: var(--mint-bright); font-size: 12px; font-variant-numeric: tabular-nums; }
.range-control input { grid-column: 1 / -1; }
input[type="range"] {
  appearance: none;
  width: 100%;
  min-height: 21px;
  margin: 0;
  cursor: pointer;
  background: transparent;
  accent-color: var(--mint);
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 3px; background: linear-gradient(to right, #89c6a3 var(--fill, 0%), #45524c var(--fill, 0%)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 3px; background: linear-gradient(to right, #89c6a3 var(--fill, 0%), #45524c var(--fill, 0%)); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 14px; height: 14px; margin-top: -5px; background: var(--mint-bright); border: 2px solid #25392d; border-radius: 50%; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; background: var(--mint-bright); border: 2px solid #25392d; border-radius: 50%; }
.lens-range { margin: 0 0 6px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid #e4e8dd66; }
.color-swatch { background: conic-gradient(#f1bb73, #e68d87, #a48ee0, #82c7b1, #f1bb73); }
.mono-swatch { background: linear-gradient(140deg, #f5f5f5 48%, #515151 49%); }
.text-button { padding: 3px 0; margin-top: 4px; border: 0; background: transparent; color: var(--mint); font-size: 11px; text-underline-offset: 2px; }
.text-button:hover { text-decoration: underline; }
.wall-segments { grid-template-columns: .85fr 1.15fr; }
.setting-note { margin-top: 7px; color: var(--muted); line-height: 1.55; font-size: 11px; }
.line-heading > span { color: var(--subtle); font-size: 12px; }
details { margin-top: 9px; padding: 8px 9px; border: 1px solid var(--border); border-radius: 7px; font-size: 12px; }
summary { cursor: pointer; color: var(--subtle); }
.wall-options { display: grid; gap: 6px; margin-top: 8px; }
.wall-row, .switch-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.wall-row > span { display: grid; gap: 1px; }
.wall-row small { color: var(--muted); }
.wall-row select, .export-option select { min-height: 32px; padding: 4px 8px; background: #242c2d; border: 1px solid #43504a; border-radius: 6px; }
.switch-row { margin-top: 12px; cursor: pointer; font-size: 12px; }
.switch-row input { appearance: none; width: 33px; height: 19px; margin: 0; border: 1px solid #627068; border-radius: 12px; background: #333d39; cursor: pointer; }
.switch-row input::before { content: ""; display: block; width: 11px; height: 11px; margin: 3px; border-radius: 50%; background: #c7d3ca; }
.switch-row input:checked { background: #446c54; border-color: #8fcba5; }
.switch-row input:checked::before { transform: translateX(14px); background: var(--mint-bright); }

.export-fields { display: grid; gap: 10px; padding: 13px 15px 15px; background: var(--panel-deep); border-top: 1px solid var(--border); }
.file-badge { font-family: ui-monospace, Consolas, monospace; border: 1px solid #45504b; border-radius: 4px; padding: 2px 5px; letter-spacing: .06em; }
.export-options { display: grid; gap: 7px; }
.export-option { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 7px; color: var(--subtle); font-size: 12px; }
.export-option select { width: 100%; }
.ratios button { min-height: 26px; }
.save-button {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 43px;
  padding: 7px 10px;
  color: var(--mint-text);
  background: var(--mint);
  border: 1px solid #d0f5db;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
}
.save-button:not(:disabled):hover { background: #cef8dc; }
.dimensions { margin-left: auto; color: #21412e; font-size: 11px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.output-note { color: var(--subtle); font-size: 11px; line-height: 1.5; }
.save-message { font-size: 11px; line-height: 1.4; color: var(--mint); }
.save-message[data-error="true"] { color: #ffb4a4; }

dialog { width: min(460px, calc(100% - 30px)); max-height: calc(100dvh - 24px); padding: 20px; color: var(--text); background: var(--panel); border: 1px solid #4c6155; border-radius: 12px; box-shadow: 0 16px 48px #0009; }
dialog::backdrop { background: #080b09b0; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-header h2 { font-size: 18px; }
dialog dl { display: grid; gap: 12px; }
dialog dt { font-weight: 700; font-size: 13px; color: var(--mint); }
dialog dd { margin: 3px 0 0; font-size: 13px; line-height: 1.6; color: var(--subtle); }
.noscript { padding: 16px; color: #ffb4a4; }

@media (max-height: 770px) and (min-width: 801px) {
  .app-header { height: 64px; }
  .workspace { height: calc(100dvh - 64px); padding-top: 12px; padding-bottom: 12px; }
  .setting-section { padding-block: 10px; }
  .range-control { margin-top: 7px; }
  .lens-range { margin-top: 0; }
}
@media (max-width: 1040px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 312px; padding-inline: 12px; gap: 12px; }
}
@media (max-width: 800px) {
  .app-header { height: 66px; padding-inline: 12px; }
  .workspace { grid-template-columns: minmax(0, 1fr); height: auto; padding: 10px 10px 18px; }
  .preview { height: clamp(335px, 60dvh, 620px); grid-template-rows: 40px minmax(0, 1fr) 34px; }
  .inspector { grid-template-rows: 44px auto auto; }
  .plan { left: 7px; bottom: 7px; width: 135px; }
  .plan.is-large { width: min(255px, calc(100% - 14px)); }
  .plan-header { height: 30px; }
  .preview-header, .preview-footer { padding-inline: 9px; }
  .preview-footer { gap: 7px; font-size: 10px; }
}
@media (max-width: 475px) {
  .app-header { gap: 6px; }
  .brand, .header-actions { gap: 5px; }
  .brand-icon { width: 29px; height: 29px; border-radius: 7px; }
  .brand-icon svg { width: 18px; height: 18px; }
  .brand-eyebrow { font-size: 9px; }
  .brand h1 { font-size: 14px; }
  .header-actions .button { padding-inline: 6px; gap: 3px; min-height: 33px; font-size: 10px; }
  .header-actions .button svg { width: 13px; height: 13px; }
  .preview-footer .location-label { display: none; }
}
