:root {
  --bg: #eef3f1;
  --panel: #fbfdfc;
  --panel-strong: #ffffff;
  --ink: #16211e;
  --muted: #66746f;
  --line: #d4ddd8;
  --line-strong: #aebdb7;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #d9efec;
  --danger: #b64735;
  --danger-soft: #f7dfda;
  --warning: #a16914;
  --warning-soft: #f5ead5;
  --stage: #141a1f;
  --stage-grid: rgba(255, 255, 255, 0.09);
  --shadow: 0 10px 30px rgba(32, 45, 40, 0.10);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  overflow: hidden;
}

[v-cloak] {
  display: none;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
  min-height: 36px;
  padding: 7px 12px;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

button.small {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 12px;
}

button.ghost {
  border-color: transparent;
  background: transparent;
}

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

code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(15, 118, 110, 0.10);
  color: var(--accent-strong);
}

pre {
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  min-width: 0;
}

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 253, 252, 0.96);
  backdrop-filter: blur(16px);
  z-index: 5;
}

.brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
}

.subtitle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf4f1;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 30px;
  border-radius: 6px;
  white-space: nowrap;
}

.segmented button.active {
  background: var(--panel-strong);
  color: var(--accent-strong);
  box-shadow: 0 1px 6px rgba(35, 54, 48, 0.12);
}

.segmented.compact {
  width: 100%;
  margin-bottom: 12px;
}

.segmented.compact button {
  flex: 1;
}

.segmented.tiny button {
  min-height: 28px;
  padding: 3px 9px;
  font-size: 12px;
}

.mobile-tabs {
  display: none;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 360px) minmax(420px, 1fr) minmax(330px, 410px);
  overflow: hidden;
}

.panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--panel);
}

.resources-panel {
  border-right: 1px solid var(--line);
}

.canvas-panel {
  display: flex;
  flex-direction: column;
  background: #e4ebe7;
}

.export-panel {
  border-left: 1px solid var(--line);
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-section h2 {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.3;
}

.panel-section h3 {
  margin: 16px 0 8px;
  font-size: 13px;
}

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

.section-head h2 {
  margin: 0;
}

.section-head.sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
  margin-bottom: 8px;
}

.field,
.upload-box,
.switch,
.range-row {
  display: flex;
  gap: 8px;
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.field {
  flex-direction: column;
  margin-bottom: 12px;
}

.field span,
.range-row span {
  color: var(--muted);
  font-size: 12px;
}

.field input,
.field select,
.area-title input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  padding: 7px 9px;
  outline: none;
}

.field input:focus,
.field select:focus,
.area-title input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

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

.field-grid.three {
  grid-template-columns: repeat(3, 1fr);
}

.note {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: #244843;
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 12px;
  margin-bottom: 12px;
}

.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.choice-row button {
  min-height: 38px;
  background: #f5fbf9;
  color: var(--muted);
  font-weight: 700;
}

.choice-row button.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.helper-section p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

button.secondary-primary {
  width: 100%;
}

.advanced-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  padding: 10px;
  margin-top: 12px;
}

.advanced-box summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 800;
  font-size: 13px;
}

.advanced-box[open] summary {
  margin-bottom: 12px;
}

.upload-box {
  align-items: center;
  justify-content: space-between;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  margin-bottom: 8px;
}

.upload-box strong {
  display: block;
  margin-bottom: 2px;
}

.upload-box p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.file-button {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  color: var(--accent-strong);
  background: #f5fbf9;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  overflow: hidden;
  cursor: pointer;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  margin-bottom: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  background: #f3f7f5;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 12px;
}

.file-summary.empty {
  border-style: dashed;
  border-color: var(--line);
}

.file-summary .name {
  color: var(--ink);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-summary .meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-summary .meta span {
  padding: 2px 6px;
  border-radius: 999px;
  background: #ffffff;
}

.switch {
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

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

.switch.line {
  margin: 8px 0;
}

.clip-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.clip-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.clip-name {
  color: var(--accent-strong);
  font-weight: 800;
  font-size: 12px;
}

.clip-file {
  min-width: 0;
}

.clip-file strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.clip-file span {
  color: var(--muted);
  font-size: 11px;
}

.clip-empty {
  color: var(--muted);
  font-size: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
}

.area-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  padding: 10px;
  margin-bottom: 10px;
}

.area-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 10px;
}

.range-row {
  align-items: center;
  margin: 2px 0 10px;
}

.range-row input {
  flex: 1;
  accent-color: var(--accent);
}

.range-row strong {
  width: 58px;
  text-align: right;
  font-size: 12px;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.canvas-toolbar h2 {
  margin: 0;
  font-size: 15px;
}

.canvas-toolbar span,
.toolbar-meta {
  color: var(--muted);
  font-size: 12px;
}

.stage-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.stage {
  position: relative;
  width: min(100%, 980px);
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(90deg, var(--stage-grid) 1px, transparent 1px),
    linear-gradient(0deg, var(--stage-grid) 1px, transparent 1px),
    radial-gradient(circle at 28% 28%, rgba(15, 118, 110, 0.28), transparent 35%),
    linear-gradient(135deg, #12181e, #26302d);
  background-size: 80px 80px, 80px 80px, auto, auto;
  box-shadow: var(--shadow);
  touch-action: none;
}

.stage-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000000;
}

.stage-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #dce8e4;
  text-align: center;
  padding: 24px;
}

.stage-title {
  font-size: 24px;
  font-weight: 800;
}

.stage-subtitle {
  margin-top: 6px;
  color: rgba(220, 232, 228, 0.72);
}

.hotspot {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: rgba(182, 71, 53, 0.34);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  cursor: grab;
  box-shadow: 0 0 0 1px rgba(182, 71, 53, 0.8), 0 8px 20px rgba(0, 0, 0, 0.28);
  user-select: none;
}

.hotspot.dragging {
  cursor: grabbing;
  background: rgba(15, 118, 110, 0.45);
  box-shadow: 0 0 0 1px rgba(15, 118, 110, 0.9), 0 10px 28px rgba(0, 0, 0, 0.34);
}

.hotspot span {
  max-width: 76%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-footer {
  padding: 12px 18px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}

.status-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.status-line.ok {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-line.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-line span {
  font-size: 12px;
}

.issue-list {
  margin: 0;
  padding-left: 18px;
  color: var(--danger);
  font-size: 12px;
}

.issue-list.warn {
  color: var(--warning);
  margin-top: 8px;
}

.issue-list li + li {
  margin-top: 5px;
}

.tree,
.xml-preview {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #18211e;
  color: #dfece8;
  font: 12px/1.55 "SF Mono", Menlo, Consolas, monospace;
  max-height: 340px;
}

.xml-preview {
  max-height: 420px;
}

.spec-grid {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px 12px;
  margin-bottom: 12px;
  font-size: 12px;
}

.spec-grid span {
  color: var(--muted);
}

.spec-grid strong {
  color: var(--ink);
}

@media (max-width: 1160px) {
  .workspace {
    grid-template-columns: minmax(300px, 340px) minmax(360px, 1fr) minmax(300px, 360px);
  }

  .topbar {
    gap: 12px;
  }
}

@media (max-width: 900px) {
  body {
    overflow: hidden;
  }

  .topbar {
    min-height: auto;
    align-items: stretch;
    flex-direction: column;
    padding: 12px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .topbar-actions .segmented {
    flex: 1;
  }

  .topbar-actions .segmented button {
    flex: 1;
  }

  .mobile-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
  }

  .mobile-tabs button {
    min-height: 34px;
    font-size: 13px;
  }

  .mobile-tabs button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
  }

  .workspace {
    display: block;
    overflow: hidden;
  }

  .panel {
    display: none;
    height: 100%;
    border: 0;
  }

  .panel.mobileActive {
    display: block;
  }

  .canvas-panel.mobileActive {
    display: flex;
  }

  .stage-wrap {
    padding: 12px;
  }

  .stage-title {
    font-size: 20px;
  }
}

@media (max-width: 560px) {
  .brand {
    font-size: 16px;
  }

  .subtitle {
    font-size: 11px;
  }

  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  button.primary {
    width: 100%;
  }

  .panel-section {
    padding: 14px 12px;
  }

  .upload-box {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-field,
  .choice-row {
    grid-template-columns: 1fr;
  }

  .file-button {
    width: 100%;
  }

  .field-grid,
  .field-grid.three {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .clip-row {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .clip-row .file-button,
  .clip-row button.ghost {
    grid-column: 1 / -1;
  }

  .area-title {
    grid-template-columns: 1fr;
  }

  .canvas-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
