*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #EDEDED;
  --card: #FFFFFF;
  --card-hover: #F8F9FF;
  --border: #CDD2EB;
  --border-focus: #A8B0D8;
  --text: #020B25;
  --text-secondary: #364570;
  --text-tertiary: #7080A8;
  --accent: #21D93F;
  --accent-bg: rgba(33,217,63,0.10);
  --accent-hover: #1bc038;
  --success: #21D93F;
  --success-bg: rgba(33,217,63,0.08);
  --danger: #e53e3e;
  --danger-bg: rgba(229,62,62,0.08);
  --warning: #d97706;
  --warning-bg: rgba(217,119,6,0.08);
  --navy: #03123D;
}

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── Header ─── */
.header {
  padding: 20px 28px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 100;
  box-shadow: 0 1px 0 var(--border);
}
.header-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--navy), #03123D);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.header-title { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
.header-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 1px; }

.header-steps { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.step-dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text-tertiary);
  transition: all 0.3s;
}
.step-dot.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.step-label { font-size: 11px; color: var(--text-tertiary); transition: all 0.3s; }
.step-label.active { color: var(--text); font-weight: 600; }
.step-line { width: 24px; height: 1px; background: var(--border); transition: all 0.3s; }
.step-line.active { background: var(--accent); }

.ref-count {
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--accent-bg);
  border: 1px solid rgba(33,217,63,0.35);
  font-size: 11px;
  color: var(--accent);
  margin-left: 12px;
  cursor: pointer;
}
.ref-count:hover { background: rgba(33,217,63,0.18); }

/* ─── Layout ─── */
.main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 1240px;
  margin: 0 auto;
  min-height: calc(100vh - 77px);
}
.panel { padding: 28px; display: flex; flex-direction: column; }
.panel-left { border-right: 1px solid var(--border); }

/* ─── Tabs ─── */
.tabs { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  font-family: 'DM Sans', sans-serif;
  background: none;
  border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ─── Image Upload ─── */
.image-area {
  border: 2px dashed var(--border);
  border-radius: 14px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  min-height: 200px;
  padding: 24px;
  margin-bottom: 16px;
}
.image-area:hover, .image-area.dragover {
  border-color: var(--accent);
  background: rgba(33,217,63,0.04);
}
.image-area.has-image {
  border-style: solid;
  cursor: default;
  padding: 0;
  overflow: hidden;
}
.image-area.has-image img {
  width: 100%; display: block;
  max-height: 45vh; object-fit: contain;
  background: #000;
}
.image-area-icon { font-size: 36px; margin-bottom: 10px; opacity: 0.3; }
.image-area-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.image-area-sub { font-size: 12px; color: var(--text-tertiary); }

/* ─── JSON Input ─── */
.json-input {
  width: 100%;
  min-height: 160px;
  padding: 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  resize: vertical;
  line-height: 1.6;
  transition: border-color 0.2s;
}
.json-input:focus { outline: none; border-color: var(--accent); }
.json-input::placeholder { color: var(--text-tertiary); }

/* ─── Analysis Display ─── */
.analysis-card {
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(2,11,37,0.06);
  padding: 18px;
  font-size: 13px;
  line-height: 1.7;
}
.analysis-label {
  font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--accent); margin-bottom: 12px;
}
.analysis-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 16px;
  font-size: 12px;
}
.analysis-grid dt { color: var(--text-tertiary); white-space: nowrap; }
.analysis-grid dd { color: var(--text); }
.alert-box {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
}

/* ─── Sections & Options ─── */
.section { margin-bottom: 22px; }
.section-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-tertiary); margin-bottom: 10px;
}
.option-grid { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  padding: 9px 15px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--text-tertiary); color: var(--text); }
.btn.active { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn.disabled-opt, .btn.disabled-opt:hover {
  opacity: 0.25;
  cursor: not-allowed;
  border-color: var(--border);
  color: var(--text-tertiary);
  text-decoration: line-through;
}

.btn-primary {
  padding: 13px 28px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #21D93F, #17a832);
  color: #020B25;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
  width: 100%;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.4; cursor: default; filter: none; transform: none; }

.btn-ghost {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-tertiary);
  font-size: 12px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
}
.btn-ghost:hover { border-color: var(--text-tertiary); color: var(--text-secondary); }

/* ─── Prompt Output ─── */
.prompt-box {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  font-size: 12px;
  line-height: 1.8;
  color: var(--text-secondary);
  font-family: 'DM Mono', monospace;
  white-space: pre-wrap;
  word-break: break-word;
  height: 320px;
  resize: vertical;
}
.prompt-box:focus { outline: none; border-color: var(--accent); }

.tip-box {
  margin-top: 12px;
  padding: 12px 16px;
  background: rgba(33,217,63,0.06);
  border-radius: 10px;
  border: 1px solid rgba(33,217,63,0.18);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-tertiary);
}
.tip-box strong { color: var(--accent); }

/* ─── Helper text ─── */
.help-text { font-size: 12px; color: var(--text-tertiary); line-height: 1.6; margin-bottom: 12px; }
.help-text code {
  background: var(--card);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--accent);
}

/* ─── Claude Prompt Box ─── */
.claude-prompt {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  color: var(--text-secondary);
  line-height: 1.6;
  cursor: pointer;
  position: relative;
  margin-bottom: 16px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.claude-prompt:hover { border-color: var(--accent); }
.claude-prompt .copy-hint {
  position: sticky;
  top: 0;
  float: right;
  font-size: 10px;
  color: var(--accent);
  font-family: 'DM Sans', sans-serif;
  background: var(--card);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ─── Import ─── */
.import-box {
  padding: 16px;
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

/* ─── Status ─── */
.status-valid { color: var(--success); font-size: 12px; margin-top: 8px; }
.status-invalid { color: var(--danger); font-size: 12px; margin-top: 8px; }

/* ─── Responsive ─── */
@media (max-width: 860px) {
  .main { grid-template-columns: 1fr; }
  .panel-left { border-right: none; border-bottom: 1px solid var(--border); }
  .header-steps { display: none; }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-focus); }
