:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #f5f5f7;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.18);
  --brand: #0a6c63;
  --brand-strong: #07524b;
  --brand-soft: #e8f3f1;
  --blue: #315f9f;
  --amber: #9a6419;
  --rose: #a33b58;
  --danger: #a33b58;
  --surface-hover: #f7f7f9;
  --heading: #1d1d1f;
  --brand-line: #cfe5e0;
  --danger-line: #efc8d3;
  --danger-soft: #fff0f4;
  --brand-gradient-end: #f0f7f5;
  --muted-strong: #515154;
  --tag-ink: #3a3a3c;
  --row-hover: #f7f7f9;
  --row-selected: #eef7f4;
  --type-general-bg: #eef3fb;
  --type-artist-bg: #fdf3e3;
  --type-character-bg: #fdf0f4;
  --tag-desc: #48484a;
  --summary-hover: #f0f0f2;
  --help-line: rgba(0, 0, 0, 0.08);
  --help-bg: #f5f5f7;
  --help-ink: #515154;
  --toast-bg: rgba(29, 29, 31, 0.92);
  --on-brand: #ffffff;
  --page-glow: transparent;
  --brand-alpha-soft: rgba(10, 108, 99, 0.07);
  --brand-alpha: rgba(10, 108, 99, 0.12);
  --brand-alpha-strong: rgba(10, 108, 99, 0.4);
  --keyword-line: rgba(0, 0, 0, 0.2);
  --tooltip-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
  --toast-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
  --sheet-backdrop: rgba(0, 0, 0, 0.4);
  --glass: rgba(255, 255, 255, 0.78);
  --accent-nl: #6c5fce;
  --accent-nl-soft: #efecfb;
  --accent-nl-line: #d9d3f3;
  --coral: #b3573c;
  --coral-soft: #faefe9;
  --coral-line: #eccfc0;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 10px 30px rgba(0, 0, 0, 0.05);
  --focus-ring: 0 0 0 4px rgba(10, 108, 99, 0.16);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0e;
  --surface: #1c1c1e;
  --surface-soft: #232326;
  --ink: #f5f5f7;
  --muted: #98989d;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.24);
  --brand: #54c6b7;
  --brand-strong: #82e0d3;
  --brand-soft: #16332e;
  --blue: #a7c7ff;
  --amber: #f0c071;
  --rose: #f2a6bc;
  --danger: #f2a6bc;
  --surface-hover: #242427;
  --heading: #f5f5f7;
  --brand-line: #2c554e;
  --danger-line: #6d3b4b;
  --danger-soft: #3a1f29;
  --brand-gradient-end: #1b2f2a;
  --muted-strong: #b0b0b5;
  --tag-ink: #d1d1d6;
  --row-hover: #232326;
  --row-selected: #1a332d;
  --type-general-bg: #243754;
  --type-artist-bg: #48361d;
  --type-character-bg: #482735;
  --tag-desc: #c7c7cc;
  --summary-hover: #242427;
  --help-line: rgba(255, 255, 255, 0.1);
  --help-bg: #232326;
  --help-ink: #b0b0b5;
  --toast-bg: rgba(44, 44, 46, 0.95);
  --on-brand: #06201c;
  --page-glow: transparent;
  --brand-alpha-soft: rgba(84, 198, 183, 0.09);
  --brand-alpha: rgba(84, 198, 183, 0.15);
  --brand-alpha-strong: rgba(84, 198, 183, 0.5);
  --keyword-line: rgba(255, 255, 255, 0.28);
  --tooltip-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  --toast-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --sheet-backdrop: rgba(0, 0, 0, 0.65);
  --glass: rgba(28, 28, 30, 0.78);
  --accent-nl: #a89bff;
  --accent-nl-soft: #292440;
  --accent-nl-line: #48406f;
  --coral: #e2947b;
  --coral-soft: #392721;
  --coral-line: #5e3d30;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
  --focus-ring: 0 0 0 4px rgba(84, 198, 183, 0.28);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, var(--page-glow), transparent 180px),
    var(--bg);
  font-family:
    "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface);
}

button,
select {
  min-height: 36px;
}

button {
  cursor: pointer;
  padding: 0 14px;
  border-radius: 999px;
  font-weight: 700;
  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    color 0.18s ease,
    transform 0.15s ease,
    box-shadow 0.18s ease;
}

button:hover,
select:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

button:active {
  transform: scale(0.96);
}

input,
select,
textarea {
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

button:focus-visible {
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

h1,
h2,
h3,
p {
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

h2,
h3 {
  color: var(--heading);
  font-size: 0.85rem;
  font-weight: 800;
}

.app-shell {
  width: min(1760px, 100%);
  margin: 0 auto;
  padding: 18px 20px 40px;
}

/* ---------- 리뷰 모드 배너 ---------- */

.review-banner {
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--coral-line);
  background: var(--coral-soft);
  color: var(--coral);
  font-size: 0.85rem;
  font-weight: 600;
}

.review-banner strong {
  padding: 2px 10px;
  border: 1px solid var(--coral-line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.tool {
  min-height: calc(100vh - 36px);
}

.topbar,
.search-band,
.workspace-grid {
  width: 100%;
}

/* ---------- 상단 브랜드 ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 2px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: min(232px, 56vw);
  height: auto;
  flex: none;
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: lowercase;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-color: var(--line);
  border-radius: 50%;
  color: var(--muted-strong);
}

.theme-toggle:hover {
  color: var(--ink);
}

.status-pill,
.status-muted,
.panel-subtext {
  color: var(--muted);
  font-size: 0.82rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 0 11px;
  border: 1px solid var(--brand-line);
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 700;
}

.status-pill.error {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--rose);
}

/* ---------- 시작 안내 배너 ---------- */

.onboarding {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px 18px;
  align-items: center;
  margin-bottom: 14px;
  padding: 16px 44px 16px 18px;
  border: 1px solid var(--brand-line);
  border-radius: var(--radius);
  background: var(--brand-soft);
  box-shadow: var(--shadow);
}

.onboarding-lead {
  color: var(--brand-strong);
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.45;
}

.onboarding-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 8px 0 0;
  padding: 0 0 0 18px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.onboarding-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.onboarding-actions button {
  min-height: 42px;
  padding: 0 16px;
}

.onboarding-close {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
}

.advanced-toggles {
  display: inline-block;
}

.advanced-toggles > summary {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.advanced-toggles > summary::-webkit-details-marker {
  display: none;
}

.advanced-toggles[open] > summary {
  border-color: var(--brand);
  color: var(--brand-strong);
  background: var(--brand-soft);
}

.advanced-toggles-body {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 8px 2px 0;
}

/* ---------- 검색 밴드 ---------- */

.search-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-box label,
.settings-block label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.search-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

#searchInput {
  min-height: 44px;
  padding: 0 14px;
  font-size: 0.98rem;
}

.search-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.search-actions select {
  min-height: 44px;
  padding: 0 10px;
}

.search-actions button {
  min-height: 44px;
}

.primary-button {
  border-color: transparent;
  background: var(--brand);
  color: var(--on-brand);
}

.primary-button:hover {
  border-color: transparent;
  background: var(--brand-strong);
}

.primary-button.is-loading {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-button.is-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes loading-slide {
  0% {
    transform: translateX(-110%);
  }
  55% {
    transform: translateX(90%);
  }
  100% {
    transform: translateX(245%);
  }
}

/* ---------- LLM 보조 밴드 ---------- */

.assist-band {
  display: grid;
  grid-template-columns: minmax(300px, 38fr) minmax(380px, 62fr);
  gap: 18px;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.assist-input,
.assist-output {
  display: grid;
  gap: 10px;
  min-width: 0;
  align-content: start;
}

/* 문장/이미지 입력 모드 탭 */

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
}

.mode-tab {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.mode-tab:hover {
  border-color: transparent;
  background: var(--surface-hover);
  color: var(--ink);
}

.mode-tab.is-active,
.mode-tab.is-active:hover {
  border-color: transparent;
  background: var(--brand);
  color: var(--on-brand);
}

.mode-panel {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.mode-panel[hidden] {
  display: none;
}

.mode-panel-actions {
  display: flex;
  justify-content: flex-end;
}

.example-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.example-chips[hidden] {
  display: none;
}

.example-chips-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.example-chip {
  min-height: 30px;
  padding: 0 12px;
  color: var(--muted-strong);
  background: var(--surface-soft);
  font-size: 0.82rem;
  font-weight: 600;
}

.example-chip:hover {
  border-color: var(--brand);
  background: var(--brand-alpha);
  color: var(--brand-strong);
}

.mode-panel-actions .primary-button {
  min-height: 42px;
  padding: 0 20px;
}

#descriptionInput {
  min-height: 132px;
  resize: vertical;
  padding: 11px 13px;
  line-height: 1.55;
}

.image-assist {
  display: grid;
  gap: 9px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.beta-badge {
  display: inline-flex;
  align-items: center;
  min-height: 19px;
  margin-left: 4px;
  padding: 0 7px;
  border-radius: 999px;
  color: var(--brand-strong);
  background: var(--brand-soft);
  font-size: 0.66rem;
  vertical-align: middle;
}

.image-dropzone {
  display: grid;
  place-items: center;
  min-height: 112px;
  padding: 10px;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.image-dropzone:hover,
.image-dropzone.is-dragging {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.image-dropzone:focus-within {
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.image-dropzone.has-image {
  min-height: 160px;
  padding: 0;
  border-style: solid;
  background: var(--surface);
}

.image-dropzone img {
  display: block;
  width: 100%;
  max-height: 230px;
  object-fit: contain;
}

.image-dropzone img[hidden],
.image-placeholder[hidden] {
  display: none;
}

.image-placeholder {
  display: grid;
  gap: 4px;
  font-size: 0.78rem;
  line-height: 1.4;
}

.image-placeholder strong {
  color: var(--heading);
  font-size: 0.86rem;
}

.image-assist-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.image-select-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
}

.image-select-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.image-select-button:focus-within {
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.image-assist-actions .primary-button {
  margin-left: auto;
}

.image-meta {
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.35;
}

.assist-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}

.ghost-button,
.ghost-button:hover {
  border-color: transparent;
}

.ghost-button {
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.ghost-button:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.checkbox-label.inline {
  display: inline-flex;
  gap: 7px;
  min-height: 36px;
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.checkbox-label.nsfw-toggle:has(input:checked) {
  color: var(--rose);
  font-weight: 700;
}

.suggested-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 82px;
  align-content: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.suggested-tags.is-loading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.suggestion-loading {
  display: contents;
}

.suggestion-loading-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.suggestion-loading-copy strong {
  color: var(--brand-strong);
  font-size: 0.86rem;
}

.suggestion-loading-copy span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.suggestion-loading-bar {
  grid-column: 1 / -1;
  overflow: hidden;
  height: 4px;
  border-radius: 999px;
  background: var(--brand-alpha);
}

.suggestion-loading-bar span {
  display: block;
  width: 44%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--accent-nl));
  animation: loading-slide 1.05s ease-in-out infinite;
}

.suggestion-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  min-height: 32px;
  max-width: 100%;
  padding: 4px 11px;
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere;
  font-size: 0.84rem;
  text-align: left;
}

.chip-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.chip-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.chip-dot[data-major="인물"] {
  background: #d99a2b;
}

.chip-dot[data-major="복장 및 액세서리"] {
  background: #5b8fd9;
}

.chip-dot[data-major="포즈"] {
  background: #b57edc;
}

.chip-dot[data-major="행동"] {
  background: #e2745c;
}

.chip-dot[data-major="배경"] {
  background: #63a860;
}

.chip-dot[data-major="사물"] {
  background: #a98a5a;
}

.chip-dot[data-major="구성 및 연출"] {
  background: #52a8b8;
}

.chip-dot[data-major="작품/캐릭터/작가"] {
  background: #d873a8;
}

.chip-dot[data-major="개념 및 테마"] {
  background: #8f7fe8;
}

.chip-dot[data-major="성인용"] {
  background: #d95f7f;
}

.suggestion-chip .chip-reason {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
}

.suggestion-chip.is-selected {
  border-color: var(--brand-alpha-strong);
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.suggestion-chip.is-selected .chip-reason {
  color: inherit;
  opacity: 0.72;
}

.suggestion-chip.is-review:not(.is-selected) {
  border-color: color-mix(in srgb, var(--amber) 45%, var(--line));
  background: color-mix(in srgb, var(--amber) 9%, var(--surface));
}

.chip-status {
  display: inline-flex;
  align-items: center;
  min-height: 16px;
  margin-top: 2px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

.chip-status.verified {
  color: var(--brand-strong);
  background: var(--brand-soft);
}

.chip-status.review {
  color: var(--amber);
  background: color-mix(in srgb, var(--amber) 13%, transparent);
}

.suggestion-issues {
  display: grid;
  gap: 6px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--coral);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.suggestion-issues[hidden] {
  display: none;
}

.suggestion-issue {
  display: grid;
  grid-template-columns: auto minmax(0, auto) minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.suggestion-issue strong {
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.issue-kind {
  padding: 3px 6px;
  border-radius: 999px;
  color: var(--coral);
  background: var(--coral-soft);
  font-size: 0.65rem;
  font-weight: 800;
}

.issue-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.keyword-panel {
  display: grid;
  gap: 9px;
}

.keyword-groups {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.keyword-group {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.keyword-group + .keyword-group {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.keyword-group-title {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0;
}

.keyword-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 32px;
  align-content: start;
}

.keyword-chip {
  max-width: 100%;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid var(--keyword-line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  overflow-wrap: anywhere;
  font-size: 0.81rem;
  font-weight: 650;
  text-align: left;
}

.keyword-chip.has-tags {
  border-color: var(--brand-alpha-strong);
  background: var(--brand-alpha-soft);
  color: var(--brand-strong);
}

.keyword-chip:hover {
  border-color: var(--brand);
  background: var(--brand-alpha);
}

.analysis-loading {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  overflow: hidden;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--accent-nl-line);
  border-radius: var(--radius-sm);
  background: var(--accent-nl-soft);
  color: var(--accent-nl);
}

.analysis-loading[hidden] {
  display: none;
}

.analysis-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid color-mix(in srgb, var(--accent-nl) 24%, transparent);
  border-top-color: var(--accent-nl);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.analysis-loading-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.analysis-loading-copy strong {
  font-size: 0.88rem;
}

.analysis-steps {
  display: grid;
  gap: 3px;
  margin: 3px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.analysis-steps li {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.analysis-steps li::before {
  content: "○";
  flex: none;
  width: 14px;
  font-size: 0.72rem;
  text-align: center;
}

.analysis-steps li.is-done {
  color: var(--muted-strong);
}

.analysis-steps li.is-done::before {
  content: "✓";
  color: var(--brand);
  font-weight: 800;
}

.analysis-steps li.is-active {
  color: var(--accent-nl);
  font-weight: 700;
}

.analysis-steps li.is-active::before {
  content: "●";
  animation: step-pulse 1.1s ease-in-out infinite;
}

@keyframes step-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.analysis-loading-copy span {
  color: var(--muted-strong);
  font-size: 0.79rem;
  line-height: 1.35;
}

.analysis-progress {
  grid-column: 1 / -1;
  overflow: hidden;
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-nl) 16%, transparent);
}

.analysis-progress span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--accent-nl));
  animation: loading-slide 1.05s ease-in-out infinite;
}

.natural-heading {
  margin-top: 2px;
}

/* ---------- 연출 프리셋 밴드 ---------- */

.scene-band {
  display: block;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.scene-band summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  border-radius: var(--radius);
}

.scene-band summary::-webkit-details-marker {
  display: none;
}

.scene-band summary:hover {
  background: var(--surface-soft);
}

.scene-band summary .panel-subtext {
  overflow: hidden;
  margin-left: auto;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.scene-band[open] .summary-chevron {
  transform: rotate(-135deg);
}

.scene-groups {
  display: grid;
  grid-template-columns: 0.8fr 0.8fr 1.4fr;
  gap: 16px;
  padding: 4px 16px 16px;
}

.scene-group {
  display: grid;
  gap: 9px;
  align-content: start;
  min-width: 0;
}

.scene-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.scene-group-label {
  width: 100%;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
}

.scene-chip {
  min-height: 30px;
  font-size: 0.82rem;
}

/* ---------- 3단 작업 영역 ---------- */

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(420px, 1.55fr) minmax(330px, 1fr);
  gap: 14px;
  align-items: start;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.filter-panel,
.builder-panel {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.filter-panel::-webkit-scrollbar,
.builder-panel::-webkit-scrollbar {
  width: 8px;
}

.filter-panel::-webkit-scrollbar-thumb,
.builder-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--line-strong);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 50px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.sub-heading {
  margin-top: 8px;
  border-top: 1px solid var(--line);
}

.results-heading {
  align-items: center;
}

.results-heading > div {
  display: grid;
  gap: 2px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 12px 14px;
}

.chip-list.compact {
  gap: 6px;
}

.filter-chip {
  min-height: 31px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--tag-ink);
  font-size: 0.84rem;
  font-weight: 600;
}

.filter-chip.is-active {
  border-color: transparent;
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 700;
}

/* ---------- 결과 목록 ---------- */

.results-list {
  min-height: 500px;
}

.result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.1s ease;
}

.result-row:hover {
  background: var(--row-hover);
}

.result-row.is-selected {
  background: var(--row-selected);
  box-shadow: inset 3px 0 0 var(--brand);
}

.result-main {
  min-width: 0;
}

.result-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}

.tag-name {
  font-weight: 800;
  word-break: break-word;
}

.tag-count {
  color: var(--muted);
  font-size: 0.8rem;
}

.tag-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 6px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--type-general-bg);
  color: var(--blue);
  font-size: 0.73rem;
  font-weight: 700;
}

.meta-pill.type-artist {
  background: var(--type-artist-bg);
  color: var(--amber);
}

.meta-pill.type-character {
  background: var(--type-character-bg);
  color: var(--rose);
}

.tag-desc {
  margin: 0;
  color: var(--tag-desc);
  font-size: 0.89rem;
  line-height: 1.5;
}

.tag-keywords {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.add-button {
  align-self: start;
  min-width: 72px;
}

.result-actions {
  display: grid;
  align-self: start;
  gap: 6px;
  min-width: 82px;
}

.detail-button {
  min-height: 32px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 0.76rem;
}

.result-row.is-selected .add-button {
  border-color: transparent;
  background: var(--brand);
  color: var(--on-brand);
}

.empty-state {
  padding: 44px 16px;
  color: var(--muted);
  text-align: center;
}

.load-more {
  display: none;
  width: calc(100% - 28px);
  margin: 14px;
  min-height: 40px;
}

.load-more.is-visible {
  display: block;
}

/* ---------- 빌더 패널 ---------- */

.selected-tags {
  display: grid;
  gap: 7px;
  min-height: 110px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.selected-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  gap: 5px;
  align-items: center;
  min-height: 38px;
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.selected-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding-left: 6px;
  font-size: 0.9rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.weight-value {
  min-width: 38px;
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.small-square {
  width: 32px;
  min-height: 32px;
  padding: 0;
  color: var(--muted);
}

.small-square:hover {
  color: var(--ink);
}

.settings-block,
.output-block,
.booster-block {
  display: grid;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.settings-block input,
.settings-block select {
  min-height: 38px;
  padding: 0 10px;
}

.settings-block.split {
  grid-template-columns: 1fr 1fr;
}

.checkbox-label {
  align-content: end;
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 38px;
}

.checkbox-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.settings-block.embedded {
  padding: 0;
  border-bottom: 0;
}

/* ---------- NAI 부스터 (접이식) ---------- */

details.booster-block {
  display: block;
  padding: 0;
  background: var(--surface-soft);
}

details.booster-block summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

details.booster-block summary::-webkit-details-marker {
  display: none;
}

details.booster-block summary:hover {
  background: var(--summary-hover);
}

.summary-title {
  color: var(--heading);
  font-size: 0.85rem;
  font-weight: 800;
}

.summary-chevron {
  width: 9px;
  height: 9px;
  margin-right: 3px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

details.booster-block[open] .summary-chevron {
  transform: rotate(-135deg);
}

details.booster-block > :not(summary) {
  margin: 0 14px 12px;
}

details.booster-block > .settings-block.embedded {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.negative-help {
  padding: 10px 12px;
  border: 1px solid var(--help-line);
  border-radius: var(--radius-sm);
  background: var(--help-bg);
  color: var(--help-ink);
  font-size: 0.8rem;
  line-height: 1.55;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.preview-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.booster-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.booster-actions button {
  font-size: 0.85rem;
}

/* ---------- 출력 ---------- */

.output-route {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--accent-nl-line);
  border-radius: var(--radius-sm);
  background: var(--accent-nl-soft);
}

.output-route h2 {
  color: var(--accent-nl);
}

.output-route > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.output-route p {
  color: var(--muted-strong);
  font-size: 0.78rem;
  line-height: 1.4;
}

.output-route button {
  flex: none;
  border-color: var(--accent-nl-line);
  color: var(--accent-nl);
  background: var(--surface);
}

.output-center {
  display: grid;
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.output-center-heading {
  padding: 13px 14px 8px;
}

.output-center-heading > div {
  display: grid;
  gap: 3px;
}

.output-tabs {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 0 14px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.output-tab {
  flex: none;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--muted-strong);
  font-size: 0.76rem;
  white-space: nowrap;
}

.output-tab.is-active {
  border-color: var(--brand-alpha-strong);
  color: var(--brand-strong);
  background: var(--brand-soft);
}

/* 자연어 계열은 보라, 부정은 코랄로 결과 구역을 구분 */
.output-tab.is-active[data-output-view="natural"],
.output-tab.is-active[data-output-view="positive-natural"] {
  border-color: var(--accent-nl-line);
  color: var(--accent-nl);
  background: var(--accent-nl-soft);
}

.output-tab.is-active[data-output-view="negative"] {
  border-color: var(--coral-line);
  color: var(--coral);
  background: var(--coral-soft);
}

.output-panel[data-output-panel="positive"],
.output-panel[data-output-panel="danbooru"] {
  box-shadow: inset 3px 0 0 var(--brand);
}

.output-panel[data-output-panel="natural"],
.output-panel[data-output-panel="positive-natural"] {
  box-shadow: inset 3px 0 0 var(--accent-nl);
}

.output-panel[data-output-panel="negative"] {
  box-shadow: inset 3px 0 0 var(--coral);
}

.output-panel {
  display: grid;
  gap: 10px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
}

.output-panel[hidden] {
  display: none;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.section-title-row > h2,
.section-title-row > h3 {
  flex: none;
}

.section-title-row > .panel-subtext {
  min-width: 0;
  max-width: 68%;
  overflow: hidden;
  text-align: right;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.section-title-row select {
  min-height: 30px;
  max-width: 46%;
  margin-left: auto;
  padding: 0 8px;
  font-size: 0.79rem;
}

.output-block[hidden] {
  display: none;
}

.copy-small {
  min-height: 29px;
  padding: 0 11px;
  font-size: 0.8rem;
}

.output-text {
  width: 100%;
  min-height: 116px;
  resize: vertical;
  padding: 10px 11px;
  background: var(--surface-soft);
  font-size: 0.88rem;
  line-height: 1.5;
}

.output-text:focus {
  background: var(--surface);
}

.output-text.compact {
  min-height: 72px;
}

/* ---------- 태그 툴팁 ---------- */

.tag-tooltip {
  position: fixed;
  z-index: 40;
  display: grid;
  gap: 6px;
  max-width: 330px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--tooltip-shadow);
  pointer-events: none;
  font-size: 0.84rem;
  line-height: 1.5;
}

.tag-tooltip[hidden] {
  display: none;
}

.tip-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.tip-title strong {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.tip-count {
  color: var(--muted);
  font-size: 0.78rem;
}

.tip-meta {
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 700;
}

.tip-desc {
  margin: 0;
  color: var(--tag-desc);
}

.tip-keywords {
  color: var(--muted);
  font-size: 0.78rem;
}

.tip-footer {
  padding-top: 6px;
  border-top: 1px dashed var(--line);
  color: var(--brand-strong);
  font-size: 0.78rem;
  font-weight: 600;
}

.quality-toggle.is-active {
  border-color: transparent;
  background: var(--brand);
  color: var(--on-brand);
}

/* ---------- 토스트 ---------- */

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  padding: 11px 16px;
  border: 0;
  border-radius: 14px;
  background: var(--toast-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  color: #fff;
  font-size: 0.9rem;
  box-shadow: var(--toast-shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 0.22s ease,
    transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- 모바일 하단 바 / 바텀시트 ---------- */

.mobile-bar {
  display: none;
}

.builder-sheet-backdrop,
.sheet-close-button {
  display: none;
}

.builder-heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- 반응형 ---------- */

@media (max-width: 1180px) {
  .app-shell {
    padding-bottom: 88px;
  }

  .workspace-grid {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .mobile-bar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line);
    background: var(--glass);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.08);
    font-weight: 700;
  }

  .mobile-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .mobile-bar-actions button {
    min-height: 44px;
    padding: 10px 16px;
  }

  .builder-panel {
    display: none;
  }

  .builder-panel.sheet-open {
    display: block;
    position: fixed;
    top: auto;
    left: 50%;
    right: auto;
    bottom: 0;
    z-index: 55;
    width: min(720px, calc(100vw - 32px));
    max-height: min(84vh, 850px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    overflow-y: auto;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -16px 44px rgba(0, 0, 0, 0.28);
    transform: translateX(-50%);
  }

  .builder-sheet-backdrop:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: block;
    background: var(--sheet-backdrop);
    -webkit-backdrop-filter: saturate(140%) blur(8px);
    backdrop-filter: saturate(140%) blur(8px);
  }

  .sheet-close-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
  }

  body.builder-sheet-open {
    overflow: hidden;
  }

  body.builder-sheet-open .mobile-bar {
    display: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    /* leave room for the fixed mobile bar */
    padding: 12px 12px 88px;
  }

  .builder-panel.sheet-open {
    left: 0;
    right: 0;
    width: 100%;
    max-height: 82vh;
    border-radius: 16px 16px 0 0;
    transform: none;
  }

  /* 긴 설명은 2줄로 접기 */
  .tag-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* 터치 타깃 최소 40px, 입력 16px(iOS 자동 확대 방지) */
  .filter-chip,
  .copy-small,
  .add-button,
  .image-select-button,
  .output-tab,
  .scene-chip,
  .suggestion-chip,
  .load-more {
    min-height: 40px;
  }

  .small-square {
    min-width: 40px;
    min-height: 40px;
  }

  input[type="search"],
  input[type="text"],
  select,
  textarea {
    font-size: 16px !important;
  }

  h1 {
    font-size: 1.15rem;
  }

  .brand-logo {
    width: min(176px, 50vw);
    height: auto;
  }

  .topbar,
  .search-band,
  .assist-band,
  .search-actions,
  .onboarding {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .onboarding-steps {
    display: none;
  }

  .onboarding-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .onboarding-actions button {
    min-width: 0;
    padding-inline: 10px;
  }

  .suggestion-issue {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .issue-detail {
    grid-column: 2;
  }

  .output-route {
    flex-direction: column;
    align-items: stretch;
  }

  .output-route button {
    min-height: 40px;
  }

  .mode-panel-actions {
    display: grid;
  }

  .mode-panel-actions .primary-button {
    width: 100%;
  }

  .image-assist-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .image-assist-actions .primary-button {
    grid-column: 1 / -1;
    width: 100%;
    margin-left: 0;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .filter-panel {
    position: static;
    max-height: none;
  }

  .result-row {
    grid-template-columns: 1fr;
  }

  .add-button {
    width: 100%;
  }

  .result-actions {
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .detail-button {
    width: 100%;
  }

  .settings-block.split,
  details.booster-block > .settings-block.embedded,
  .preview-grid,
  .scene-groups {
    grid-template-columns: 1fr;
  }
}

/* ---------- 모션 ---------- */

.builder-panel.sheet-open {
  animation: sheet-rise 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes sheet-rise {
  from {
    translate: 0 28px;
    opacity: 0.4;
  }
  to {
    translate: 0 0;
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}
