*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050816;
  color: #f9fafb;
}

body {
  display: flex;
}

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
  background: radial-gradient(circle at top left, #1d4ed8 0, rgba(15, 23, 42, 0.9) 45%, #020617 100%);
}

.app-header-main h1 {
  margin: 0 0 4px 0;
  font-size: 20px;
}

.subtitle {
  margin: 0;
  font-size: 13px;
  color: #cbd5f5;
}

.app-header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.16);
  color: #4ade80;
  font-size: 11px;
}

.endpoint-hint {
  color: #cbd5f5;
}

.app-main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr);
  gap: 0;
  min-height: 0;
}

.panel {
  padding: 16px 20px 20px;
  overflow: auto;
}

.panel-left {
  border-right: 1px solid rgba(148, 163, 184, 0.25);
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.08), transparent 55%),
    radial-gradient(circle at bottom, rgba(129, 140, 248, 0.12), transparent 55%);
}

.panel-right {
  background: radial-gradient(circle at top, rgba(94, 234, 212, 0.06), transparent 50%),
    radial-gradient(circle at bottom, rgba(59, 130, 246, 0.09), transparent 55%);
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.left-block {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}
.left-block:last-of-type { border-bottom: none; }

.left-block-title {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  margin: 0 0 8px;
}
.left-block-details summary.left-block-title {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.left-block-details summary::-webkit-details-marker { display: none; }
.left-block-details summary::-moz-details-marker { display: none; }
.left-block-details[open] summary { margin-bottom: 10px; }

.actions-block .btn-analyze-generate {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
}

.generate-progress-wrap {
  margin-top: 10px;
  width: 100%;
}
.generate-progress-wrap.hidden {
  display: none;
}
.generate-progress-wrap.error .generate-progress-fill {
  background: linear-gradient(90deg, #b91c1c, #dc2626);
}
.generate-progress-wrap.error .generate-progress-text {
  color: #fca5a5;
}
.generate-progress-bar {
  height: 8px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.3);
}
.generate-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  border-radius: 3px;
  transition: width 0.25s ease;
}
.generate-progress-text {
  font-size: 12px;
  color: #e2e8f0;
  margin-top: 4px;
}
.generate-progress-eta {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}

.output-header-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.output-header-edit h2 { margin: 0; flex: 1; min-width: 180px; }
.output-actions-generate {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.generate-label {
  font-size: 12px;
  color: #94a3b8;
  margin-right: 4px;
}

.ref-list-compact {
  max-height: 100px;
  margin-bottom: 10px;
}

.field-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
}

.field-row {
  display: flex;
  gap: 10px;
}

.field-row .field-group {
  flex: 1;
}

label {
  font-size: 12px;
  margin-bottom: 4px;
  color: #e5e7eb;
}

input[type="text"],
input[type="number"],
select,
textarea {
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.8);
  color: #f9fafb;
  font-size: 13px;
  padding: 7px 9px;
  outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4);
}

textarea {
  resize: vertical;
}

.radio-row {
  display: flex;
  gap: 12px;
  font-size: 13px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
}

.ref-list {
  margin-top: 4px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.9);
  max-height: 160px;
  overflow: auto;
  padding: 6px 8px;
  font-size: 11px;
}

.ref-group-title {
  font-weight: 600;
  color: #e5e7eb;
  margin: 4px 0 2px;
}

.ref-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 3px 4px;
  border-radius: 6px;
  cursor: pointer;
  color: #d1d5db;
}

.ref-item:hover {
  background: rgba(31, 41, 55, 0.9);
}

.ref-item.selected {
  background: rgba(37, 99, 235, 0.3);
  border: 1px solid rgba(129, 140, 248, 0.9);
}

.ref-item-main {
  display: flex;
  flex-direction: column;
}

.ref-item-name {
  font-weight: 500;
}

.ref-item-meta {
  font-size: 10px;
  color: #9ca3af;
}

.canvas-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  margin-bottom: 8px;
}

.canvas-toolbar-label {
  font-weight: 600;
  color: #e5e7eb;
}

.canvas-toolbar input[type="color"] {
  width: 32px;
  height: 18px;
  padding: 0;
  border-radius: 4px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: transparent;
}

.canvas-toolbar select {
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  font-size: 11px;
  padding: 2px 6px;
}

.canvas-toolbar-hint {
  color: #9ca3af;
}

.phrase-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.phrase-header-row h3 {
  margin-bottom: 0;
}

.phrase-target-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 10px 0 6px 0;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.5);
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.phrase-target-label {
  font-size: 13px;
  font-weight: 600;
  color: #e5e7eb;
  flex-shrink: 0;
}

.phrase-target-checkboxes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.phrase-target-cb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #cbd5e1;
  cursor: pointer;
  user-select: none;
}

.phrase-target-cb input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #3b82f6;
  cursor: pointer;
}

.ref-folders-card {
  background: rgba(30, 58, 138, 0.15);
  border: 1px solid rgba(96, 165, 250, 0.4);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
}

.ref-folders-title {
  font-size: 14px;
  font-weight: 700;
  color: #e5e7eb;
  margin: 0 0 6px 0;
}

.ref-folders-row .field-group {
  flex: 1;
}

.ref-folder-summary {
  display: block;
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

.ref-list-analyzed {
  max-height: 220px;
}

/* 통합: 추가 옵션 · 분석된 항목 */
.left-block-options-analyzed {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(15, 23, 42, 0.2);
}
.left-block-options-analyzed .left-block-title {
  margin-bottom: 4px;
}
.options-details {
  margin-top: 10px;
  margin-bottom: 14px;
}
.options-details-summary {
  cursor: pointer;
  font-weight: 600;
  color: #94a3b8;
  padding: 6px 0;
}
.analyzed-section-inner {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
}
.analyzed-subtitle {
  font-size: 13px;
  font-weight: 600;
  color: #e5e7eb;
  margin: 0 0 6px 0;
}

.analyzed-section .phrase-header-row {
  flex-wrap: wrap;
  gap: 8px;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 13px;
  padding: 7px 14px;
  cursor: pointer;
  background: rgba(148, 163, 184, 0.2);
  color: #e5e7eb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn.primary {
  background: linear-gradient(135deg, #22c55e, #4ade80);
  color: #022c22;
  border-color: transparent;
  font-weight: 600;
}

.btn.ghost {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.4);
}

.btn.small {
  padding: 4px 10px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.hint {
  font-size: 11px;
  color: #cbd5f5;
  margin-top: 6px;
}

.hint code {
  background: rgba(15, 23, 42, 0.9);
  padding: 1px 4px;
  border-radius: 4px;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.output-actions {
  display: flex;
  gap: 6px;
}

.status-bar {
  min-height: 20px;
  font-size: 12px;
  margin-bottom: 6px;
  color: #9ca3af;
}

.status-bar.error {
  color: #fecaca;
}

.code-block {
  background: rgba(15, 23, 42, 0.96);
  border-radius: 10px;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
    monospace;
  font-size: 12px;
  border: 1px solid rgba(75, 85, 99, 0.9);
  max-height: calc(100vh - 210px);
  overflow: auto;
}

.output-view.hidden {
  display: none;
}

.log-panel-wrap {
  margin: 10px 0;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.4);
}
.log-panel-header {
  display: flex;
  gap: 8px;
  padding: 6px 10px;
  align-items: center;
}
.log-panel {
  max-height: 200px;
  overflow: auto;
  padding: 8px 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}
.log-panel.hidden {
  display: none;
}
.log-content {
  margin: 0;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  color: #94a3b8;
  white-space: pre-wrap;
  word-break: break-all;
}
.log-content .log-error { color: #f87171; }
.log-content .log-warn { color: #fbbf24; }

.device-preview-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: flex-start;
}

.device-preview h3 {
  margin: 0 0 6px;
  font-size: 13px;
}

.device-frame {
  border-radius: 14px;
  padding: 8px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.5);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.device-frame.pc {
  height: 260px;
}

.device-frame.mobile {
  height: 260px;
  max-width: 210px;
  margin-left: auto;
  margin-right: auto;
}

.device-header,
.device-footer {
  min-height: 40px;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.4;
  position: relative;
  overflow: hidden;
}

.device-header {
  background: rgba(37, 99, 235, 0.14);
  border: 1px solid rgba(129, 140, 248, 0.5);
}

.device-footer {
  background: rgba(15, 118, 110, 0.16);
  border: 1px solid rgba(52, 211, 153, 0.55);
}

.device-body {
  flex: 1;
  border-radius: 8px;
  background: radial-gradient(circle at top, rgba(148, 163, 184, 0.22), transparent 55%);
  border: 1px dashed rgba(75, 85, 99, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #9ca3af;
}

.save-folder-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}
.save-folder-name {
  font-size: 12px;
  color: #94a3b8;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.save-folder-row .hint {
  width: 100%;
  margin: 4px 0 0;
}

.preview-mode-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.preview-mode-label {
  font-size: 12px;
  color: #94a3b8;
}
/* 미리보기 모드: 읽기 전용 */
.preview-three.preview-only {
  border: 1px dashed rgba(148, 163, 184, 0.35);
  border-radius: 10px;
  padding: 10px;
  background: rgba(15, 23, 42, 0.25);
}
.preview-three.preview-only .preview-item-grip {
  display: none;
}
.preview-three.preview-only .canvas-text,
.preview-three.preview-only .preview-item-content {
  pointer-events: none;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  border-color: rgba(148, 163, 184, 0.35);
}
.preview-mode-current {
  font-size: 11px;
  color: #94a3b8;
  margin-left: 8px;
}
.preview-mode-current.edit { color: #4ade80; }
.preview-mode-current.preview { color: #fbbf24; }

.preview-three {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.preview-block {
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  overflow: hidden;
  background: rgba(15, 23, 42, 0.6);
}
.preview-block h3 {
  margin: 0;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
  background: rgba(30, 41, 59, 0.8);
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
}
.device-frame.frame-banner,
.device-frame.frame-header,
.device-frame.frame-footer {
  min-height: 180px;
  position: relative;
  padding: 10px;
}
.device-frame.frame-banner {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(96, 165, 250, 0.35);
}
.device-frame.frame-header {
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(129, 140, 248, 0.4);
}
.device-frame.frame-footer {
  background: rgba(15, 118, 110, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.4);
}

.canvas-text {
  position: absolute;
  min-width: 60px;
  min-height: 18px;
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.7);
  font-size: 11px;
  color: #e5e7eb;
  cursor: move;
  white-space: pre-wrap;
}

.canvas-text:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);
  cursor: text;
}

.preview-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 6px;
  position: relative;
}
.preview-item-grip {
  flex-shrink: 0;
  width: 18px;
  padding: 4px 2px;
  cursor: grab;
  color: #94a3b8;
  font-size: 10px;
  user-select: none;
  border-radius: 4px;
}
.preview-item-grip:hover {
  color: #e2e8f0;
  background: rgba(148, 163, 184, 0.2);
}
.preview-item-grip:active {
  cursor: grabbing;
}
.preview-item-image-wrap {
  flex-shrink: 0;
  width: 120px;
  min-height: 48px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.4);
}
.preview-item-image-wrap.preview-item-image-error {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 11px;
}
.preview-item-image-wrap.preview-item-image-error .preview-item-image {
  display: none;
}
.preview-item-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 80px;
  object-fit: contain;
  vertical-align: middle;
}
.preview-item-content {
  flex: 1;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.5);
  font-size: 12px;
  color: #e5e7eb;
  white-space: pre-wrap;
}
.preview-item-dragging {
  opacity: 0.7;
}
.preview-item-drop-target {
  outline: 2px dashed #38bdf8;
  outline-offset: 2px;
}

.analyzed-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.analyzed-item-row .analyzed-item-cb {
  flex-shrink: 0;
}
.analyzed-item-row .ref-item-main {
  flex: 1;
  min-width: 0;
}

.app-footer {
  padding: 8px 20px 10px;
  font-size: 11px;
  color: #9ca3af;
  border-top: 1px solid rgba(55, 65, 81, 0.95);
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.96), rgba(2, 6, 23, 0.98));
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  opacity: 0.6;
}

@media (max-width: 900px) {
  .app-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel-left {
    border-right: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  }

  .device-preview-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

