@import url('/design/tokens.css');
body {
  min-width: 360px;
}
.app-header {
  background: white;
  border-bottom: 1px solid var(--line);
  padding: 24px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand {
  display: flex;
  gap: 15px;
  align-items: center;
}
.brand-mark {
  background: var(--ink);
  color: white;
  font-size: 18px;
  font-weight: 750;
  padding: 13px;
  border-radius: 10px;
}
.brand h1 {
  font-size: 22px;
  letter-spacing: -0.02em;
  margin: 0 0 5px;
}
.brand p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}
.save-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}
.save-actions span {
  font-size: 12px;
  margin-right: 12px;
  color: var(--muted);
}
.editor-tabs {
  display: flex;
  gap: 8px;
  padding: 15px 32px;
  background: white;
}
.editor-tabs button {
  border: 0;
  font-weight: 600;
  padding: 10px 16px;
}
.notice {
  min-height: 28px;
  padding: 4px 32px;
  font-size: 12px;
}
.workspace {
  display: grid;
  grid-template-columns: 210px 310px minmax(340px, 1fr);
  margin: 0 24px 24px;
  min-height: 680px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: white;
}
.tree-panel {
  padding: 24px 18px;
  background: #fafbfc;
  border-right: 1px solid var(--line);
}
.settings-panel {
  padding: 24px;
  border-right: 1px solid var(--line);
}
.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.panel-heading small {
  font-size: 10px;
  overflow-wrap: anywhere;
}
.workspace h2 {
  font-size: 16px;
  margin: 0 0 22px;
}
.workspace h3 {
  font-size: 13px;
  margin: 25px 0 12px;
}
.menu-tree button {
  display: block;
  width: 100%;
  text-align: left;
  margin: 3px 0;
  border: 0;
  background: none;
  font-size: 13px;
  padding: 11px 12px;
}
.menu-tree button[aria-current='true'] {
  background: var(--tint);
  color: var(--accent);
  font-weight: 700;
}
.menu-tree .group {
  font-weight: 700;
  margin-top: 14px;
}
.tree-children {
  padding-left: 15px;
  margin-left: 12px;
  border-left: 1px solid var(--line);
}
.tree-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 28px;
}
.tree-actions button,
.tree-order button {
  font-size: 11px;
  padding: 8px;
}
.tree-order {
  display: flex;
  gap: 5px;
  margin: 12px 0;
}
.hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  margin: 15px 0;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
  font-size: 12px;
  font-weight: 600;
}
.field input,
.field select {
  width: 100%;
  min-width: 0;
  font-size: 13px;
  font-weight: 400;
}
.check {
  display: flex;
  gap: 9px;
  align-items: center;
  font-size: 13px;
  margin: 12px 0;
}
.check input {
  width: 16px;
  height: 16px;
}
.source-details {
  font-size: 12px;
  margin: 20px 0;
}
.source-details summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 14px;
}
.source-details small {
  line-height: 1.6;
  display: block;
}
.layout-choices {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}
.layout-option {
  display: flex;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.layout-option.selected {
  border-color: var(--accent);
  background: var(--tint);
}
.layout-option strong {
  display: block;
  font-size: 13px;
}
.layout-option small {
  display: block;
  font-size: 11px;
  margin-top: 4px;
}
.part-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 8px;
  margin-bottom: 20px;
}
.part-choices .check {
  font-size: 12px;
}
.text-button {
  font-size: 12px;
  border: 0;
  padding: 6px 0;
}
.danger {
  color: var(--danger);
}
.preview-panel {
  background: #edf1f3;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px;
  gap: 10px;
}
.preview-heading h2 {
  margin: 0 0 5px;
}
.preview-heading small {
  font-size: 11px;
}
.preview-heading button {
  font-size: 12px;
}
.preview-stage {
  padding: 0 20px 20px;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-width: 0;
}
.preview-frame {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 100%;
  min-height: 850px;
  max-width: 100%;
}
.preview-frame.mobile {
  width: 390px;
}
.export-bar {
  padding: 18px 32px;
  background: white;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.export-bar strong {
  font-size: 14px;
}
.export-bar small {
  display: block;
  font-size: 12px;
  margin-top: 5px;
}
.export-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.export-actions button {
  font-size: 12px;
}
.download-notice {
  flex: 0 0 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--accent);
  font-size: 12px;
}
.download-notice.error {
  color: var(--danger);
}
hr {
  margin: 24px 0;
}
@media (min-width: 1700px) {
  .workspace {
    grid-template-columns: 240px 340px minmax(340px, 1fr);
  }
}
@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 180px 280px minmax(0, 1fr);
    margin: 0 12px 16px;
  }
  .settings-panel {
    padding: 18px;
  }
  .preview-stage {
    padding: 0 8px 8px;
  }
  .preview-heading {
    padding: 18px 12px;
    flex-wrap: wrap;
  }
  .app-header {
    padding: 20px;
  }
  .brand p {
    display: none;
  }
}
@media (max-width: 800px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .tree-panel,
  .settings-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .menu-tree {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
  }
  .menu-tree > button {
    width: auto;
  }
  .tree-children {
    display: flex;
    padding: 0;
    border: 0;
    margin: 0;
  }
  .tree-children button {
    width: auto;
  }
  .tree-actions {
    margin-top: 12px;
  }
  .tree-panel .hint {
    display: none;
  }
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .save-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .brand h1 {
    font-size: 20px;
  }
  .editor-tabs {
    padding: 10px;
    gap: 0;
  }
  .editor-tabs button {
    font-size: 12px;
  }
  .notice {
    padding: 5px 16px;
  }
  .export-bar {
    align-items: flex-start;
    flex-direction: column;
    padding: 20px;
  }
  .preview-frame {
    min-height: 700px;
  }
  .preview-heading {
    padding: 20px;
  }
}

@media (max-width: 800px) {
  .menu-tree {
    display: block;
  }
  .menu-tree > button {
    width: 100%;
  }
  .tree-children {
    display: block;
    padding-left: 16px;
    margin-left: 10px;
    border-left: 1px solid var(--line);
  }
  .tree-children button {
    width: 100%;
  }
}

.preview-heading {
  flex-wrap: wrap;
  gap: 8px;
}

.addon-setting {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.addon-order {
  display: flex;
  gap: 5px;
}
.addon-order button {
  min-width: 34px;
  padding: 6px;
}
.addon-setting > .addon-order {
  justify-content: flex-end;
  margin: -38px 0 18px;
}
.addon-result-order {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  font-size: 13px;
}

.preview-channel-bar {
  padding: 0 24px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.preview-channel-bar .field {
  margin: 0;
  min-width: 210px;
}
.preview-channel-bar .hint {
  flex: 1;
  min-width: 180px;
  margin: 0;
}
.preview-channel-bar select {
  background: #fff;
}

.channel-edit-hint {
  padding: 0 24px;
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

/* Editor polish within the existing three-column workspace. */
:root {
  --editor-accent: #086a65;
}
.settings-panel {
  background: #fff;
}
.settings-panel h2 {
  letter-spacing: -0.03em;
}
.settings-panel h3 {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e3eae9;
  font-size: 14px;
}
.settings-panel .field {
  gap: 7px;
  margin-bottom: 14px;
}
.settings-panel .field > span {
  color: #334f4d;
  font-size: 12px;
  font-weight: 600;
}
.settings-panel :is(select, input[type='text'], input[type='number']) {
  border-color: #cedbd9;
  border-radius: 7px;
  min-height: 36px;
  background: #fff;
}
.settings-panel :is(input, select, button):focus-visible {
  outline: 2px solid #16827b;
  outline-offset: 2px;
}
.settings-panel .hint {
  line-height: 1.7;
  color: #627573;
}
.result-presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}
.preset-button {
  border: 1px solid #b9d5d1;
  background: #f3faf8;
  color: #086a65;
  border-radius: 7px;
  padding: 10px 6px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}
.preset-button:hover:not(:disabled) {
  background: #e3f3ef;
  border-color: #086a65;
}
.appearance-section {
  border: 1px solid #dfe8e6;
  border-radius: 9px;
  margin: 9px 0;
  overflow: hidden;
}
.appearance-section > summary {
  padding: 12px;
  color: #244d49;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #f7faf9;
}
.appearance-section[open] > summary {
  border-bottom: 1px solid #e5eeeb;
}
.appearance-controls {
  padding: 14px 12px 2px;
}
.appearance-controls select {
  width: 100%;
  min-width: 0;
}
.result-appearance-settings > .text-button {
  margin-top: 10px;
}
@media (min-width: 801px) {
  .workspace {
    height: calc(100vh - 240px);
    min-height: 680px;
  }
  .tree-panel,
  .settings-panel {
    overflow-y: auto;
    scrollbar-gutter: stable;
  }
  .preview-panel,
  .preview-stage {
    min-height: 0;
  }
  .preview-stage {
    align-items: stretch;
  }
  .preview-frame {
    min-height: 0;
    height: 100%;
  }
}
@media (max-width: 800px) {
  .settings-panel {
    max-height: 680px;
    overflow-y: auto;
  }
}
.menu-tree button {
  position: relative;
  border-radius: 7px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.menu-tree button[aria-current='true'] {
  box-shadow: inset 3px 0 #086a65;
}
.menu-tree .group.has-selected-child {
  color: #086a65;
  background: #f0f7f5;
}
.menu-tree .group::before {
  content: '';
  display: inline-block;
  width: 11px;
  height: 9px;
  margin-right: 8px;
  border: 1.5px solid currentColor;
  border-top-width: 3px;
  border-radius: 2px;
  opacity: 0.7;
}
.tree-children {
  border-left-color: #cdded9;
  margin-left: 16px;
  padding-left: 10px;
}
.tree-children button {
  padding-left: 13px;
}

/* 편집 영역을 넓히고 각 패널의 끝까지 스크롤합니다. */
@media (min-width: 801px) {
  .workspace {
    height: var(--editor-height, 1600px);
    min-height: 1600px;
    grid-template-columns: 210px minmax(310px, 360px) minmax(340px, 1fr);
  }
  .tree-panel,
  .settings-panel {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding-bottom: 64px;
    scrollbar-width: auto;
  }
  .preview-heading .field {
    margin: 0;
    min-width: 140px;
  }
  .preview-stage {
    overflow: auto;
  }
}
@media (max-width: 800px) {
  .settings-panel {
    max-height: none;
    overflow: visible;
  }
  .preview-frame {
    min-height: 1600px;
  }
}

.design-color-control,
.design-size-control {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.design-color-control input[type='color'] {
  width: 38px;
  min-width: 38px;
  height: 34px;
  padding: 2px;
  cursor: pointer;
}
.design-color-control input[type='text'] {
  width: 88px;
  min-width: 0;
  flex: 1;
  font-family: monospace;
}
.design-size-control input {
  width: 70px;
  min-width: 0;
  flex: 1;
}
.design-color-control .text-button,
.design-size-control .text-button {
  flex: none;
  padding: 5px;
  font-size: 12px;
}

.design-color-control {
  flex-wrap: wrap;
}
.design-color-palette {
  width: 100%;
  margin: 2px 0 8px;
  border: 1px solid #d7e0e9;
  border-radius: 7px;
  background: #fff;
}
.design-color-palette > summary {
  font-size: 12px;
  padding: 6px 9px;
  cursor: pointer;
  color: #334354;
}
.design-color-options {
  padding: 0 9px 9px;
}
.design-color-swatches {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  margin: 6px 0 10px;
}
.design-color-swatch {
  width: 100%;
  aspect-ratio: 1;
  min-height: 20px;
  padding: 0;
  border: 1px solid #172d3b33;
  border-radius: 4px;
}
.design-color-swatch:hover {
  box-shadow: 0 0 0 2px #004b87;
}

/* 긴 미리보기 높이를 유지하면서 두 편집 패널만 화면 안에서 스크롤합니다. */
@media (min-width: 801px) {
  .workspace {
    overflow: clip;
  }
  .tree-panel,
  .settings-panel {
    position: sticky;
    top: 16px;
    align-self: start;
    height: var(--panel-height, calc(100dvh - 240px));
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    min-height: 0;
  }
}

/* 제작 화면에서도 좁은 미리보기와 가로 넘침을 방지합니다. */
body {
  min-width: 0;
}
.workspace > *,
.brand,
.save-actions,
.preview-heading > * {
  min-width: 0;
}
.editor-tabs,
.save-actions {
  flex-wrap: wrap;
}
.package-identity {
  padding: 24px;
  overflow-wrap: anywhere;
}
.package-identity input,
.package-identity select {
  min-width: 0;
  max-width: 100%;
}
@media (min-width: 801px) and (max-width: 1199px) {
  .workspace {
    grid-template-columns: 180px minmax(0, 1fr);
    height: auto;
    min-height: 0;
    overflow: hidden;
  }
  .tree-panel,
  .settings-panel {
    position: static;
    height: 680px;
    max-height: none;
  }
  .settings-panel {
    border-right: 0;
  }
  .preview-panel {
    grid-column: 1 / -1;
    height: var(--editor-height, 1600px);
    border-top: 1px solid var(--line);
  }
}
@media (max-width: 800px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }
  .preview-channel-bar {
    padding-inline: 16px;
  }
  .preview-channel-bar .field,
  .preview-channel-bar .hint {
    min-width: 0;
    width: 100%;
  }
  .preview-heading .field {
    min-width: 0;
    max-width: 100%;
  }
  .export-actions > button {
    max-width: 100%;
    white-space: normal;
  }
}
.table-column-setting {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcfe;
}
.table-column-setting .field {
  margin-bottom: 12px;
}
.table-column-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.table-column-actions button {
  font-size: 12px;
  padding: 6px 8px;
}

/* 작업 범위, 입력 오류, 미리보기 전환을 명확하게 표시합니다. */
.save-scope {
  margin: 0;
  padding: 8px 32px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}
.save-actions {
  flex-wrap: wrap;
}
.save-actions button {
  min-height: 40px;
}
.input-error {
  display: block;
  color: #a62323;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
}
.input-error[hidden] {
  display: none;
}
.settings-panel [aria-invalid='true'] {
  border-color: #a62323;
  outline: 1px solid #a62323;
}
.mobile-pane-switch {
  display: none;
}
.preview-heading {
  padding-bottom: 12px;
}
.preview-heading h2 {
  margin-bottom: 6px;
}
.preview-channel-bar {
  padding-bottom: 12px;
}
.preview-options {
  margin: 0 24px 14px;
  font-size: 12px;
  color: var(--muted);
}
.preview-options > summary {
  cursor: pointer;
  padding: 10px 0;
}
.preview-options .field {
  margin: 10px 0;
  max-width: 240px;
}
.preview-options .hint {
  margin: 12px 0;
}
.preview-options .channel-edit-hint {
  padding: 0;
  margin: 12px 0;
}
.table-column-setting > summary {
  cursor: pointer;
  font-weight: 600;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.table-column-setting[open] > summary {
  margin-bottom: 14px;
}
.settings-panel .table-column-actions button,
.settings-panel .text-button {
  min-height: 36px;
  min-width: 36px;
}
@media (max-width: 800px) {
  .save-scope {
    padding: 8px 20px;
  }
  .mobile-pane-switch {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 20;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    scroll-margin-top: 0;
  }
  .mobile-pane-switch button {
    flex: 1;
    min-height: 44px;
  }
  .mobile-pane-switch button[aria-pressed='true'] {
    background: #086a65;
    color: #fff;
    border-color: #086a65;
  }
  #app[data-mobile-pane='settings'] .preview-panel {
    display: none;
  }
  #app[data-mobile-pane='preview'] :is(.tree-panel, .settings-panel) {
    display: none;
  }
  #app[data-mobile-pane='preview'] .workspace {
    min-height: 0;
  }
  .preview-channel-bar {
    gap: 10px;
  }
  .preview-heading {
    padding: 16px;
  }
  .preview-options {
    margin-inline: 16px;
  }
  .settings-panel :is(input[type='text'], input[type='number'], select, button) {
    min-height: 44px;
  }
  .settings-panel .design-color-control .text-button {
    min-width: 44px;
  }
}

.reference-compare {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.reference-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.reference-color {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.reference-color i {
  width: 18px;
  height: 18px;
  border: 1px solid #d4dddd;
  border-radius: 4px;
}

.reference-match {
  border: 1px solid var(--line, #d8e1e6);
  border-radius: 8px;
  margin: 12px 0;
  padding: 12px;
}
.reference-candidate {
  background: #f4f7f8;
  border-radius: 6px;
  padding: 10px;
  margin: 8px 0;
  overflow-wrap: anywhere;
}
.reference-candidate button {
  margin: 4px 6px 4px 0;
}
.reference-inspector {
  width: min(1500px, 95vw);
  max-width: 95vw;
  max-height: 95vh;
  border: 1px solid #cbd5da;
  border-radius: 12px;
  padding: 16px;
}
.reference-inspector::backdrop {
  background: #102c3b99;
}
.reference-inspector-scroll {
  overflow: auto;
  max-height: 75vh;
  margin-top: 12px;
}
