:root {
  --bg: #F8F9FA;
  --bg-alt: #E9ECEF;
  --surface: #FFFFFF;
  --border: #DEE2E6;
  --border-light: #F1F3F5;
  --text: #212529;
  --text-secondary: #6C757D;
  --text-muted: #ADB5BD;
  --accent: #1C7ED6;
  --accent-hover: #1864AB;
  --accent-light: rgba(28, 126, 214, 0.1);
  --green: #2B8A3E;
  --green-light: rgba(43, 138, 62, 0.1);
  --red: #C92A2A;
  --red-light: rgba(201, 42, 42, 0.1);
  --orange: #E67700;
  --orange-light: rgba(230, 119, 0, 0.1);
  --diff-add: #D3F9D8;
  --diff-remove: #FFC9C9;
  --diff-add-border: #8CE99A;
  --diff-remove-border: #FF8787;
  --editor-bg: #1E1E1E;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Monaco', 'Menlo', 'SF Mono', monospace;
  --topbar-h: 48px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========== Topbar ========== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: var(--topbar-h);
  padding: 0 16px;
  gap: 20px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.topbar-tabs {
  display: flex;
  gap: 2px;
  flex: 1;
  justify-content: center;
}

.tab {
  background: none;
  border: none;
  padding: 6px 18px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 150ms;
  white-space: nowrap;
}

.tab:hover { color: var(--text); background: var(--bg-alt); }

.tab.active {
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.topbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 150ms;
}

.topbar-btn:hover { border-color: var(--text-muted); color: var(--text); background: var(--bg-alt); }

/* ========== Main ========== */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 16px;
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* ========== Toolbar ========== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}

.toolbar-left { display: flex; gap: 6px; }

.toolbar-right { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 150ms;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover { border-color: var(--text-muted); background: var(--bg-alt); }

.btn-danger {
  background: var(--surface);
  color: var(--red);
  border-color: var(--border);
}

.btn-danger:hover { background: var(--red-light); border-color: var(--red); }

/* ========== Status Badge ========== */
.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  transition: all 200ms;
}

.status-badge.ready { background: var(--bg-alt); color: var(--text-muted); }
.status-badge.valid { background: var(--green-light); color: var(--green); }
.status-badge.invalid { background: var(--red-light); color: var(--red); }
.status-badge.info { background: var(--orange-light); color: var(--orange); }

/* ========== Workspace ========== */
.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

.workspace.single { grid-template-columns: 1fr; }

.workspace.diff-mode { grid-template-columns: 1fr 1fr; }

/* ========== Panels ========== */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.panel-info {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-muted);
}

.editor-wrap {
  flex: 1;
  min-height: 200px;
  position: relative;
}

.editor-wrap .monaco-editor { border-radius: 0; }

/* ========== Statusbar ========== */
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-shrink: 0;
}

.stat {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-muted);
}

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  animation: toastIn 300ms cubic-bezier(0.34,1.56,0.64,1) forwards;
  pointer-events: auto;
  max-width: 340px;
}

.toast.out { animation: toastOut 200ms ease-in forwards; }

.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-info { background: var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to { opacity: 0; transform: translateX(30px) scale(0.95); }
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .topbar-inner { padding: 0 10px; gap: 10px; }
  .topbar-tabs { gap: 0; }
  .tab { padding: 6px 10px; font-size: 12px; }
  .topbar-title { font-size: 13px; }
  .main { padding: 8px 10px; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .workspace.diff-mode { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .btn { padding: 6px 12px; font-size: 12px; }
}

@media (max-width: 480px) {
  .topbar-icon { width: 24px; height: 24px; font-size: 10px; }
  .tab { padding: 5px 8px; font-size: 11px; }
  .topbar-actions { gap: 2px; }
  .topbar-btn { width: 28px; height: 28px; }
}

/* ========== Diff Report Panel ========== */
.diff-report {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
}

.diff-report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.diff-report-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.diff-report-close {
  background: none;
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--font);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 150ms;
}

.diff-report-close:hover { background: var(--bg-alt); color: var(--text); }

.diff-report-body {
  flex: 1;
  overflow: auto;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  background: var(--editor-bg);
  color: #E0E0E0;
}

.diff-section {
  margin-bottom: 16px;
}

.diff-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
  display: inline-block;
}

.added-title { background: rgba(43, 138, 62, 0.15); color: #69DB7C; }
.removed-title { background: rgba(201, 42, 42, 0.15); color: #FF8787; }
.changed-title { background: rgba(230, 119, 0, 0.15); color: #FFA94D; }

.diff-item {
  padding: 4px 8px;
  margin: 2px 0;
  border-radius: 3px;
  font-size: 12px;
  line-height: 1.5;
}

.diff-item.added { background: rgba(43, 138, 62, 0.08); border-left: 3px solid #2B8A3E; }
.diff-item.removed { background: rgba(201, 42, 42, 0.08); border-left: 3px solid #C92A2A; }
.diff-item.changed { background: rgba(230, 119, 0, 0.08); border-left: 3px solid #E67700; }

.diff-path {
  color: #74C0FC;
  font-weight: 600;
}

.diff-val {
  color: #E0E0E0;
}

.diff-from {
  color: #FF8787;
  display: inline-block;
  margin-left: 12px;
}

.diff-to {
  color: #69DB7C;
  display: inline-block;
  margin-left: 12px;
}
