:root {
  color-scheme: dark;
  --bg: #12151b;
  --panel: #f4f7fb;
  --panel-soft: #e8edf4;
  --text: #17202c;
  --muted: #5c6877;
  --accent: #2f8f83;
  --accent-dark: #24766c;
  --danger: #b3261e;
  --warning: #8a5a00;
  --success: #176b45;
  --border: #d5dde8;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Noto Sans KR", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px clamp(16px, 4vw, 48px);
  color: var(--white);
}

.eyebrow {
  margin: 0 0 4px;
  color: #9fb3c8;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow.dark {
  color: var(--muted);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 16px;
  font-size: 1.25rem;
}

.page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 8px 0 48px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 18px;
}

.project-grid {
  margin-top: 18px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: clamp(18px, 3vw, 28px);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.2);
}

.card.narrow {
  max-width: 460px;
  margin: 8vh auto 0;
}

.roadmap {
  margin-top: 18px;
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  font-weight: 700;
}

input[type="password"],
input[type="file"] {
  width: 100%;
  min-height: 46px;
  border: 1px solid #b8c2d0;
  border-radius: 6px;
  background: var(--white);
  color: var(--text);
  font-size: 1rem;
  padding: 10px 12px;
}

.button {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--white);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  padding: 10px 16px;
  text-decoration: none;
}

.button:hover,
.button:focus-visible {
  background: var(--accent-dark);
}

.button.secondary {
  background: transparent;
  border: 1px solid #90a3ba;
}

.button.secondary.light {
  color: var(--text);
}

.button.secondary:hover,
.button.secondary:focus-visible {
  background: rgba(255, 255, 255, 0.12);
}

.button.disabled,
.button:disabled {
  background: #a8b3c1;
  color: #eef2f6;
  cursor: not-allowed;
}

.small-button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.9rem;
}

.notice {
  border-radius: 6px;
  margin-bottom: 14px;
  padding: 12px 14px;
  font-weight: 700;
}

.notice.warning {
  background: #fff3d6;
  color: var(--warning);
}

.notice.error,
.error-card {
  background: #fde7e4;
  color: var(--danger);
}

.notice.success {
  background: #ddf4e9;
  color: var(--success);
}

.muted {
  color: var(--muted);
  line-height: 1.6;
}

.small {
  font-size: 0.92rem;
}

.file-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.file-list li {
  background: var(--panel-soft);
  border-radius: 6px;
  display: grid;
  gap: 4px;
  padding: 12px;
}

.file-name,
.breakable {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.file-name {
  font-weight: 700;
}

.file-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.section-head {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-head h2 {
  margin-bottom: 0;
}

.section-head.compact {
  margin-bottom: 12px;
}

.link-row,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.link-row a {
  color: var(--accent-dark);
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 5px 9px;
}

.status-uploaded {
  background: #e7eef8;
  color: #31567d;
}

.status-analyzed,
.kind-image {
  background: #ddf4e9;
  color: var(--success);
}

.status-error {
  background: #fde7e4;
  color: var(--danger);
}

.kind-sound {
  background: #fff3d6;
  color: var(--warning);
}

.kind-other {
  background: #e7eef8;
  color: #3b4b5f;
}

.meta-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.meta-grid div,
.count-card {
  background: var(--panel-soft);
  border-radius: 6px;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.meta-grid span,
.count-card span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.meta-grid strong,
.count-card strong {
  font-size: 1rem;
}

.info-list {
  display: grid;
  gap: 10px;
  grid-template-columns: 130px minmax(0, 1fr);
  margin: 0;
}

.info-list dt {
  color: var(--muted);
  font-weight: 700;
}

.info-list dd {
  margin: 0;
}

.count-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.count-card {
  color: var(--text);
  text-decoration: none;
}

.count-card strong {
  font-size: 1.8rem;
}

.thumb-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.thumb {
  background: var(--panel-soft);
  border-radius: 6px;
  color: var(--text);
  display: grid;
  gap: 8px;
  padding: 8px;
  text-decoration: none;
}

.thumb img,
.table-thumb {
  background: #dce4ed;
  border-radius: 4px;
  object-fit: contain;
}

.thumb img {
  aspect-ratio: 1 / 1;
  height: auto;
  width: 100%;
}

.thumb span {
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.table-thumb {
  height: 54px;
  width: 72px;
}

audio {
  max-width: 220px;
  width: 100%;
}

@media (max-width: 760px) {
  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid,
  .meta-grid,
  .count-row {
    grid-template-columns: 1fr;
  }

  .card.narrow {
    margin-top: 24px;
  }
}

.page-notice {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto 14px;
}

.editor-card {
  margin-top: 18px;
}

.editor-tools {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.search-input {
  min-height: 36px;
  border: 1px solid #b8c2d0;
  border-radius: 6px;
  padding: 8px 10px;
}

.json-editor {
  width: 100%;
  min-height: 62vh;
  resize: vertical;
  border: 1px solid #b8c2d0;
  border-radius: 6px;
  background: #0f1722;
  color: #edf4ff;
  font-family: Consolas, "SFMono-Regular", "Liberation Mono", monospace;
  font-size: 0.94rem;
  line-height: 1.55;
  padding: 16px;
  tab-size: 2;
  white-space: pre;
}

.editor-actions {
  margin-top: 12px;
}

.client-result {
  min-height: 24px;
  margin-bottom: 10px;
  font-weight: 700;
}

.client-result.success {
  color: var(--success);
}

.client-result.error {
  color: var(--danger);
}

.client-result.warning {
  color: var(--warning);
}

.button.danger {
  background: var(--danger);
}

.button.danger:hover,
.button.danger:focus-visible {
  background: #8f1f19;
}

.backup-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.backup-list li {
  align-items: center;
  background: var(--panel-soft);
  border-radius: 6px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px;
}

.compact-table {
  min-width: 620px;
}

.diff-block {
  background: #0f1722;
  border-radius: 6px;
  color: #e8eef7;
  font-family: Consolas, "SFMono-Regular", "Liberation Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  white-space: pre;
}

.full-diff {
  max-height: 75vh;
}

.diff-line {
  display: block;
  min-height: 1.5em;
  padding: 0 6px;
}

.diff-added {
  background: #123524;
  color: #b8f2ce;
}

.diff-deleted {
  background: #3b1718;
  color: #ffb8b8;
}

.diff-header,
.diff-hunk {
  background: #1d2a3d;
  color: #b9d5ff;
  font-weight: 700;
}

.diff-context {
  color: #d7e1ee;
}

.monospace-block {
  background: #0f1722;
  border-radius: 6px;
  color: #edf4ff;
  font-family: Consolas, "SFMono-Regular", "Liberation Mono", monospace;
  padding: 12px;
}

@media (max-width: 760px) {
  .backup-list li,
  .editor-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .search-input {
    width: 100%;
  }
}

.asset-actions {
  display: grid;
  gap: 8px;
  min-width: 220px;
}

.replace-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-file {
  max-width: 180px;
  min-height: 34px;
  font-size: 0.82rem;
  padding: 4px;
}

.small-path {
  max-width: 320px;
  font-size: 0.9rem;
}

.filter-row {
  justify-content: flex-end;
}

.asset-thumb-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
}

.canvas-card {
  margin-top: 18px;
}

.canvas-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 280px;
}

.canvas-stage {
  align-items: center;
  background: #0f1722;
  background-image:
    linear-gradient(45deg, #1e2a38 25%, transparent 25%),
    linear-gradient(-45deg, #1e2a38 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1e2a38 75%),
    linear-gradient(-45deg, transparent 75%, #1e2a38 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  min-height: 420px;
  overflow: auto;
  padding: 16px;
}

#assetCanvas {
  max-width: 100%;
  height: auto;
  image-rendering: auto;
  touch-action: none;
}

.canvas-toolbar {
  align-self: start;
  background: var(--panel-soft);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 16px;
}

.canvas-toolbar h2 {
  margin-bottom: 0;
}

.canvas-toolbar label {
  color: var(--muted);
  font-size: 0.92rem;
}

.canvas-toolbar input[type="range"] {
  width: 100%;
}

@media (max-width: 860px) {
  .canvas-layout {
    grid-template-columns: 1fr;
  }

  .canvas-toolbar {
    position: static;
  }

  .replace-form {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-file {
    max-width: 100%;
  }
}

.export-status-card {
  margin-bottom: 18px;
}

.validation-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin: 16px 0;
}

.validation-item {
  background: var(--panel-soft);
  border-radius: 6px;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.validation-item span {
  color: var(--muted);
  font-weight: 700;
}

.validation-item.ok strong {
  color: var(--success);
}

.validation-item.bad strong {
  color: var(--danger);
}

.save-mode-box {
  border: 1px solid var(--border);
  border-radius: 6px;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.save-mode-box legend {
  color: var(--muted);
  font-weight: 700;
  padding: 0 4px;
}

.save-mode-box label {
  align-items: center;
  display: flex;
  gap: 8px;
  font-weight: 600;
}

.structure-summary {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 16px;
}

.summary-card {
  background: var(--panel-soft);
  border-radius: 6px;
  color: var(--text);
  display: grid;
  gap: 8px;
  padding: 14px;
  text-decoration: none;
}

.summary-card span {
  color: var(--muted);
  font-weight: 700;
}

.summary-card strong {
  font-size: 1.7rem;
}

.structure-section {
  margin-top: 18px;
}

.candidate-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.object-card {
  margin-top: 14px;
}

.confidence {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 5px 9px;
  text-transform: uppercase;
}

.confidence-high { background: #ddf4e9; color: var(--success); }
.confidence-medium { background: #fff3d6; color: var(--warning); }
.confidence-low { background: #e7eef8; color: #3b4b5f; }

.json-path {
  color: var(--muted);
  cursor: pointer;
  font-family: Consolas, "SFMono-Regular", "Liberation Mono", monospace;
  font-size: 0.82rem;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.json-path.expanded-path {
  max-width: none;
  overflow-wrap: anywhere;
  white-space: normal;
}

.editable-table input,
.editable-table select,
.compact-form input,
.compact-form select {
  border: 1px solid #b8c2d0;
  border-radius: 6px;
  min-height: 34px;
  padding: 6px 8px;
}

.compact-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.changed-value {
  outline: 2px solid var(--warning);
}
