:root {
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  overscroll-behavior: none;
}
body > main {
  max-width: none;
  margin: 0;
  padding: 0;
}
.app-header {
  height: 68px;
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 8px clamp(12px, 3vw, 30px);
  background: #fff;
  border-bottom: 1px solid #e4e5ea;
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-header .brand img {
  width: var(--logo-width);
  max-height: 50px;
  object-fit: contain;
}
.header-project {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.header-project strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-project span {
  font-size: 0.72rem;
  color: #727582;
}
.icon-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: #eef0f6;
  color: var(--ink);
  font-size: 1.5rem;
  cursor: pointer;
}
.icon-btn.danger {
  color: #b22636;
}
.project-home {
  min-height: calc(100vh - 68px);
}
.hero {
  padding: clamp(36px, 8vw, 90px) max(20px, 8vw);
  background: linear-gradient(
    135deg,
    #fff 35%,
    color-mix(in srgb, var(--purple) 12%, #fff)
  );
  border-bottom: 1px solid #e4e5ea;
}
.hero h1 {
  font-size: clamp(2.3rem, 7vw, 5.5rem);
  line-height: 0.96;
  margin: 0.16em 0;
}
.hero p:not(.eyebrow) {
  max-width: 630px;
  font-size: 1.12rem;
}
.project-section {
  padding: 32px max(20px, 8vw);
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.section-head h2 {
  margin: 0.2rem 0;
}
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 20px;
}
.project-card {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 12px;
  align-items: center;
  background: #fff;
  border: 1px solid #e0e2e9;
  border-radius: 18px;
  padding: 10px;
  box-shadow: 0 8px 28px #1b23500b;
}
.project-thumb {
  height: 82px;
  border-radius: 12px;
  background: #e8eaf0 center/cover no-repeat;
}
.project-card > div:nth-child(2) {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
}
.project-card span {
  font-size: 0.78rem;
  color: #727582;
}
.project-shell {
  height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 330px;
  grid-template-rows: minmax(0, 1fr) 72px;
  background: #e9ebf1;
}
.image-rail {
  grid-row: 1/3;
  background: #fff;
  border-right: 1px solid #dfe1e8;
  padding: 14px;
  overflow: auto;
}
.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.image-list {
  display: grid;
  gap: 10px;
}
.image-card {
  display: block;
  align-items: center;
  text-align: left;
  border: 2px solid transparent;
  background: #f3f4f7;
  border-radius: 13px;
  padding: 7px;
  cursor: pointer;
}
.image-card-main {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 9px;
  align-items: center;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0;
  min-width: 0;
  width: 100%;
}
.image-card-actions {
  display: flex;
  grid-column: 1/-1;
  justify-content: flex-end;
}
.image-card-actions button {
  border: 0;
  background: transparent;
  padding: 2px 8px;
  color: #626777;
  font-size: 1rem;
}
.image-card.active {
  border-color: var(--purple);
  background: #fff;
}
.image-thumb {
  height: 48px;
  border-radius: 8px;
  background: center/cover;
}
.image-card span:last-child {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.image-card strong {
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.image-card small {
  color: #777;
}
.editor-column {
  min-width: 0;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr) auto auto;
  background: #272a33;
}
.editor-top {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  border-bottom: 1px solid #ddd;
}
.view-switch {
  display: flex;
  background: #eef0f5;
  border-radius: 10px;
  padding: 3px;
}
.view-switch button,
.panel-tabs button {
  border: 0;
  background: transparent;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.view-switch button.active,
.panel-tabs button.active {
  background: #fff;
  color: var(--purple);
  box-shadow: 0 1px 6px #10152b1c;
}
.stage {
  position: relative;
  height: auto;
  aspect-ratio: auto;
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 0;
  touch-action: none;
}
.empty {
  text-align: center;
  color: #fff;
}
.empty-symbol {
  font-size: 3rem;
}
.canvas-wrap {
  position: relative;
  width: max-content;
  height: max-content;
  max-width: 100%;
  max-height: 100%;
  transform: translate(var(--pan-x), var(--pan-y)) scale(var(--zoom));
  transform-origin: center;
  touch-action: none;
}
.canvas-wrap canvas {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 290px);
  width: auto;
  height: auto;
}
.canvas-wrap.pan-mode {
  cursor: grab;
}
.brush-cursor {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #111;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 4;
}
.brush-hud {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(20, 23, 32, 0.84);
  color: #fff;
  font-size: 0.78rem;
  pointer-events: none;
}
.brush-hud i {
  width: 28px;
  height: 28px;
  border: 2px solid #fff;
  border-radius: 50%;
  display: block;
}
.busy {
  position: absolute;
  inset: 0;
  background: #111b;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: #fff;
  z-index: 10;
}
.mobile-area-strip {
  display: none;
}
.tool-dock {
  background: #fff;
  border-top: 1px solid #ddd;
}
.tool-scroll {
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  padding: 5px 8px;
}
.tool-scroll button {
  min-width: 68px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 5px;
  color: #505361;
  cursor: pointer;
}
.tool-scroll button span {
  display: block;
  font-size: 0.7rem;
}
.tool-scroll button.active {
  background: color-mix(in srgb, var(--purple) 14%, white);
  color: var(--purple);
}
.tool-options {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 12px 9px;
  min-height: 42px;
}
.tool-options label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tool-options input {
  width: 180px;
}
.zoom-buttons {
  display: flex;
  gap: 3px;
}
.zoom-buttons button {
  border: 1px solid #d4d7df;
  background: #fff;
  border-radius: 7px;
  padding: 5px 8px;
}
.right-panel {
  background: #fff;
  border-left: 1px solid #dfe1e8;
  overflow: auto;
}
.panel-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #eef0f5;
  padding: 4px;
  position: sticky;
  top: 0;
  z-index: 3;
}
.panel-content {
  padding: 16px;
}
.layer-list {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}
.area-row {
  display: grid;
  grid-template-columns: 1fr auto;
  border: 1px solid #e0e2e8;
  border-radius: 13px;
  padding: 6px;
}
.area-row.active {
  border-color: var(--purple);
  background: color-mix(in srgb, var(--purple) 5%, white);
}
.area-main {
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  border: 0;
  background: transparent;
  min-width: 0;
}
.area-main i,
.result-line i {
  width: 25px;
  height: 25px;
  border-radius: 8px;
  border: 1px solid #aaa;
  flex: none;
}
.area-main span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.area-main small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.area-actions {
  display: flex;
}
.area-actions .icon-btn {
  width: 29px;
  height: 29px;
  font-size: 0.9rem;
  background: transparent;
}
.wide {
  width: 100%;
  justify-content: center;
}
.commercial-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.commercial-fields label {
  font-size: 0.72rem;
  color: #656977;
}
.commercial-fields select {
  display: block;
  width: 100%;
  margin-top: 4px;
}
.search {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 15px 0;
}
.search input {
  width: 100%;
}
.swatches {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-height: 340px;
  overflow: auto;
}
.swatch {
  border: 1px solid #dfe1e7;
  background: #fff;
  border-radius: 11px;
  padding: 7px;
  text-align: left;
  min-width: 0;
}
.swatch.selected {
  outline: 3px solid color-mix(in srgb, var(--purple) 35%, transparent);
  border-color: var(--purple);
}
.swatch i {
  display: block;
  height: 42px;
  border-radius: 7px;
  border: 1px solid #bbb;
}
.swatch strong,
.swatch small {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.swatch strong {
  font-size: 0.72rem;
  margin-top: 5px;
}
.swatch small {
  font-size: 0.66rem;
  color: #777;
}
.presentation-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.presentation-grid h3 {
  flex-basis: 100%;
  margin: 0;
}
.presentation-grid button {
  border: 1px solid #d8dae2;
  background: #fff;
  border-radius: 10px;
  padding: 10px 13px;
}
.presentation-grid button.active {
  background: var(--purple);
  color: var(--on-primary);
}
.result-bar {
  grid-column: 2/4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #fff;
  border-top: 1px solid #ddd;
}
.result-bar div {
  display: flex;
  flex-direction: column;
}
.result-bar span {
  font-size: 0.75rem;
  color: #777;
}
dialog {
  border: 0;
  border-radius: 20px;
  padding: 0;
  box-shadow: 0 30px 80px #0d112c44;
  max-width: min(94vw, 760px);
}
dialog::backdrop {
  background: #10152b99;
  backdrop-filter: blur(3px);
}
dialog > form,
.camera-dialog,
.result-dialog {
  padding: 22px;
}
.dialog-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.dialog-top h2 {
  margin: 0.1rem 0 1rem;
}
.sheet label {
  display: block;
  margin: 12px 0;
}
.sheet input,
.sheet select {
  display: block;
  width: 100%;
  margin-top: 5px;
}
.source-actions,
.camera-controls,
.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.example-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  max-height: 320px;
  overflow: auto;
}
.example-card {
  border: 2px solid transparent;
  background: #f1f2f6;
  border-radius: 12px;
  padding: 6px;
}
.example-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 8px;
}
.example-card span {
  display: block;
  padding: 6px;
  font-size: 0.75rem;
}
.camera-dialog video {
  width: min(85vw, 680px);
  background: #111;
  border-radius: 14px;
}
.result-dialog {
  width: min(94vw, 940px);
  max-width: 940px;
  max-height: 92vh;
}
.result-dialog #result-content {
  max-height: 65vh;
  overflow: auto;
}
.result-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 1fr;
  gap: 12px;
  border-top: 1px solid #ddd;
  padding: 16px 0;
}
.result-card h3 {
  grid-column: 1/-1;
}
.result-card img {
  width: 100%;
  border-radius: 12px;
}
.result-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid #eee;
  font-size: 0.8rem;
}
#chart-content iframe {
  width: min(84vw, 900px);
  height: 75vh;
  border: 0;
}
#chart-content img {
  max-width: min(84vw, 900px);
  max-height: 75vh;
}
#notice {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #161923;
  color: #fff;
  padding: 11px 17px;
  border-radius: 12px;
  z-index: 200;
  max-width: 88vw;
  text-align: center;
}
#notice:empty {
  display: none;
}
@media (max-width: 900px) {
  .app-header {
    height: 60px;
    grid-template-columns: auto auto 1fr auto;
    padding: 6px 10px;
  }
  .app-header .brand img {
    width: 80px;
  }
  .project-shell {
    height: calc(100dvh - 60px);
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .image-rail {
    display: none;
  }
  .editor-column {
    grid-row: 1;
    grid-template-rows: 42px minmax(0, 1fr) auto auto;
  }
  .right-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 72dvh;
    border: 0;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -15px 40px #1114;
    z-index: 40;
    transform: translateY(calc(100% - 52px));
    transition: 0.22s;
  }
  .right-panel:has(.panel-content:not([hidden])):focus-within,
  .right-panel.open {
    transform: translateY(0);
  }
  .panel-tabs {
    height: 52px;
  }
  .result-bar {
    grid-column: 1;
    grid-row: 2;
    height: 64px;
    padding: 8px 12px;
    padding-bottom: calc(8px + var(--safe-bottom));
  }
  .result-bar span {
    display: none;
  }
  .canvas-wrap canvas {
    max-height: calc(100dvh - 250px);
    max-width: 100vw;
  }
  .mobile-area-strip {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    background: #fff;
    padding: 6px;
  }
  .mobile-area-strip button {
    white-space: nowrap;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: #fff;
    padding: 7px 11px;
  }
  .mobile-area-strip button.active {
    background: var(--purple);
    color: var(--on-primary);
  }
  .tool-dock {
    padding-bottom: 0;
  }
  .tool-scroll button {
    min-width: 62px;
  }
  .tool-options {
    overflow-x: auto;
  }
  .tool-options input {
    width: 130px;
  }
  .commercial-fields {
    grid-template-columns: 1fr 1fr;
  }
  .swatches {
    grid-template-columns: repeat(3, minmax(82px, 1fr));
    max-height: 30vh;
  }
  .result-card {
    grid-template-columns: 1fr;
  }
  .example-list {
    grid-template-columns: repeat(2, 1fr);
  }
  .project-grid {
    grid-template-columns: 1fr;
  }
  .hero {
    padding: 34px 20px;
  }
  .project-section {
    padding: 24px 20px;
  }
}
@media (max-width: 480px) {
  .header-project strong {
    font-size: 0.82rem;
  }
  .commercial-fields {
    grid-template-columns: 1fr;
  }
  .app-header .brand {
    display: none;
  }
  .app-header {
    grid-template-columns: auto 1fr auto;
  }
  .swatches {
    grid-template-columns: repeat(2, 1fr);
  }
  .tool-options {
    font-size: 0.75rem;
  }
  .result-actions .button {
    flex: 1;
  }
  .project-card {
    grid-template-columns: 78px 1fr auto;
  }
  .project-thumb {
    height: 70px;
  }
}
