:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;

  --accent-h: 174;
  --accent-s: 72%;
  --accent-l: 39%;
  --accent: hsl(var(--accent-h) var(--accent-s) var(--accent-l));
  --accent-hover: hsl(var(--accent-h) var(--accent-s) 33%);
  --accent-subtle: hsl(var(--accent-h) var(--accent-s) 95%);

  --danger: hsl(0 72% 51%);
  --danger-hover: hsl(0 72% 45%);
  --danger-subtle: hsl(0 72% 97%);

  --success: hsl(145 63% 40%);
  --warning: hsl(38 92% 45%);

  --bg: hsl(220 20% 98%);
  --surface: hsl(0 0% 100%);
  --surface-raised: hsl(220 18% 100%);
  --surface-inset: hsl(220 14% 96%);
  --ink: hsl(220 24% 12%);
  --ink-secondary: hsl(220 12% 38%);
  --ink-muted: hsl(220 10% 52%);
  --border: hsl(220 13% 90%);
  --border-subtle: hsl(220 14% 94%);

  --shadow-card:
    0 0 0 1px rgba(0, 0, 0, 0.04),
    0 1px 2px -1px rgba(0, 0, 0, 0.04),
    0 2px 4px rgba(0, 0, 0, 0.03);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --header-h: 56px;
  --footer-h: 36px;
  --sidebar-w: 280px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
}

[data-theme='dark'] {
  --bg: hsl(220 16% 8%);
  --surface: hsl(220 14% 11%);
  --surface-raised: hsl(220 14% 13%);
  --surface-inset: hsl(220 14% 9%);
  --ink: hsl(220 18% 94%);
  --ink-secondary: hsl(220 12% 68%);
  --ink-muted: hsl(220 10% 52%);
  --border: hsl(220 12% 20%);
  --border-subtle: hsl(220 12% 16%);

  --accent: hsl(174 62% 46%);
  --accent-hover: hsl(174 62% 52%);
  --accent-subtle: hsl(174 40% 14%);

  --danger: hsl(0 70% 58%);
  --danger-hover: hsl(0 70% 64%);
  --danger-subtle: hsl(0 30% 14%);

  --success: hsl(145 55% 50%);
  --warning: hsl(38 90% 55%);

  --shadow-card: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
}

.logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: var(--radius-md);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  overflow: hidden;
}

.logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.header-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header-title h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.header-meta {
  font-size: 12px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.app-layout {
  display: flex;
  height: calc(100vh - var(--header-h) - var(--footer-h));
  overflow: hidden;
}

.app-footer {
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 0 var(--space-md);
  font-size: 12px;
  color: var(--ink-muted);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.app-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.app-footer a:hover {
  text-decoration: underline;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.sidebar-tabs {
  display: flex;
  gap: var(--space-xs);
  background: var(--surface-inset);
  padding: var(--space-xs);
  border-radius: var(--radius-md);
}

.sidebar-tab {
  flex: 1;
  height: 28px;
  padding: 0 var(--space-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
}

.sidebar-tab:hover {
  color: var(--ink);
}

.sidebar-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-card);
}

.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  padding: var(--space-sm) var(--space-sm) var(--space-sm) 32px;
  font-size: 13px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  pointer-events: none;
}

.event-list,
.param-list {
  flex: 1;
  margin: 0;
  padding: var(--space-sm) 0;
  list-style: none;
  overflow-y: auto;
}

.param-list .event-item-count {
  font-size: 10px;
}

.event-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-lg);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 120ms;
}

.event-item:hover {
  background: var(--bg);
}

.event-item.active {
  background: var(--accent-subtle);
  border-left-color: var(--accent);
}

.event-item-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}

.event-item-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  background: var(--surface-inset);
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.main-panel {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xl);
  background: var(--bg);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--ink-secondary);
}

.empty-illustration {
  color: var(--ink-muted);
  margin-bottom: var(--space-lg);
  opacity: 0.7;
}

.empty-state h2 {
  margin: 0 0 var(--space-sm);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

.empty-state p {
  max-width: 420px;
  margin: 0;
  font-size: 14px;
}

.event-detail {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.event-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
}

.event-hero-main {
  min-width: 0;
}

.event-name-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.event-name {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  padding: 0;
}

.platform-badges {
  display: flex;
  gap: var(--space-xs);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-inset);
  color: var(--ink-secondary);
}

.badge-ga4 { color: hsl(217 90% 45%); background: hsl(217 80% 96%); border-color: hsl(217 80% 88%); }
[data-theme='dark'] .badge-ga4 { color: hsl(217 90% 72%); background: hsl(217 50% 18%); border-color: hsl(217 50% 26%); }

.badge-appsflyer { color: hsl(145 70% 32%); background: hsl(145 60% 95%); border-color: hsl(145 60% 86%); }
[data-theme='dark'] .badge-appsflyer { color: hsl(145 60% 58%); background: hsl(145 40% 16%); border-color: hsl(145 40% 24%); }

.badge-quantummetric { color: hsl(280 60% 48%); background: hsl(280 50% 96%); border-color: hsl(280 50% 88%); }
[data-theme='dark'] .badge-quantummetric { color: hsl(280 70% 72%); background: hsl(280 35% 20%); border-color: hsl(280 35% 28%); }

.badge-datalayer { color: hsl(210 80% 42%); background: hsl(210 80% 96%); border-color: hsl(210 80% 88%); }
[data-theme='dark'] .badge-datalayer { color: hsl(210 80% 70%); background: hsl(210 45% 20%); border-color: hsl(210 45% 28%); }

.badge-scope-event { color: var(--ink-secondary); background: var(--surface-inset); }
.badge-scope-item { color: hsl(35 80% 35%); background: hsl(35 80% 96%); border-color: hsl(35 80% 88%); }
[data-theme='dark'] .badge-scope-item { color: hsl(35 80% 65%); background: hsl(35 50% 16%); border-color: hsl(35 50% 24%); }
.badge-scope-user { color: hsl(210 80% 42%); background: hsl(210 80% 96%); border-color: hsl(210 80% 88%); }
[data-theme='dark'] .badge-scope-user { color: hsl(210 80% 70%); background: hsl(210 45% 20%); border-color: hsl(210 45% 28%); }

.event-description {
  margin: var(--space-sm) 0 0;
  color: var(--ink-secondary);
  font-size: 14px;
}

.event-hero-actions {
  display: flex;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.content-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.section-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-secondary);
}

.section-actions {
  display: flex;
  gap: var(--space-sm);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  height: 36px;
  padding: 0 var(--space-md);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  transition: background 120ms, border-color 120ms, color 120ms, transform 100ms;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink-secondary);
}

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

.btn-danger {
  background: var(--danger-subtle);
  color: var(--danger);
  border-color: hsl(0 60% 88%);
}

[data-theme='dark'] .btn-danger {
  border-color: hsl(0 30% 28%);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.theme-toggle {
  width: 36px;
  padding: 0;
  font-size: 16px;
}

.lang-toggle {
  width: 36px;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
}

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 140px;
  display: none;
  flex-direction: column;
  padding: var(--space-xs);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card), 0 8px 24px rgba(0, 0, 0, 0.08);
  z-index: 200;
}

.dropdown.open .dropdown-menu {
  display: flex;
}

.dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  height: 32px;
  padding: 0 var(--space-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}

.dropdown-item:hover {
  background: var(--surface-inset);
  color: var(--ink);
}

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

.params-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.params-table th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.params-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.params-table tr:last-child td {
  border-bottom: none;
}

.params-table tbody tr:hover {
  background: var(--bg);
}

.col-name { width: 26%; }
.col-scope { width: 10%; }
.col-type { width: 12%; }
.col-example { width: 18%; }
.col-desc { width: 26%; }
.col-actions { width: 8%; text-align: right; }

.param-name {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--ink);
}

.param-aliases {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

.param-alias {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-muted);
  background: var(--surface-inset);
  padding: 1px 5px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
}

.event-image-ref {
  margin-top: var(--space-sm);
}

.event-image-link {
  display: inline-block;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  transition: box-shadow 0.15s ease;
}

.event-image-link:hover {
  box-shadow: 0 0 0 2px var(--accent);
}

.event-ref-image {
  display: block;
  max-width: 100%;
  max-height: 240px;
  width: auto;
  height: auto;
  object-fit: contain;
  background: var(--surface-inset);
}

.event-image-text {
  font-size: 12px;
  color: var(--ink-muted);
  word-break: break-all;
}

.param-parent {
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.param-row.child .param-name {
  padding-left: var(--space-lg);
  position: relative;
}

.param-row.child .param-name::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-left: 1.5px solid var(--border);
  border-bottom: 1.5px solid var(--border);
  border-radius: 0 0 0 3px;
}

.param-type {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-secondary);
}

.param-example {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.param-desc {
  color: var(--ink-secondary);
  line-height: 1.45;
}

.param-actions {
  display: flex;
  gap: var(--space-xs);
  justify-content: flex-end;
}

.icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
}

.icon-btn:hover {
  background: var(--surface-inset);
  color: var(--ink);
}

.icon-btn.delete:hover {
  background: var(--danger-subtle);
  color: var(--danger);
}

.params-empty {
  padding: var(--space-xl);
  text-align: center;
  color: var(--ink-muted);
  font-size: 13px;
}

.code-tabs {
  display: flex;
  gap: var(--space-xs);
  background: var(--surface-inset);
  padding: var(--space-xs);
  border-radius: var(--radius-md);
}

.code-tab {
  height: 28px;
  padding: 0 var(--space-md);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
}

.code-tab:hover {
  color: var(--ink);
}

.code-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-card);
}

.code-tab.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.code-tab.disabled:hover {
  color: var(--ink-muted);
}

.code-block-wrap {
  position: relative;
  margin-top: var(--space-md);
}

.code-block-wrap pre {
  margin: 0;
  padding: var(--space-lg);
  background: hsl(220 24% 10%);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.code-block-wrap code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: hsl(220 12% 90%);
  white-space: pre;
}

.copy-btn {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  height: 30px;
  background: hsl(220 20% 18%);
  color: hsl(220 12% 80%);
  border-color: hsl(220 14% 26%);
}

.copy-btn:hover {
  background: hsl(220 20% 24%);
  color: white;
}

.changelog {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.changelog-item {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  padding: var(--space-md);
  background: var(--surface-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.changelog-version {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
  white-space: nowrap;
}

.changelog-date {
  font-size: 12px;
  color: var(--ink-muted);
  white-space: nowrap;
}

.changelog-summary {
  flex: 1;
  color: var(--ink-secondary);
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  padding: var(--space-lg);
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 22px;
  line-height: 1;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  background: var(--surface-inset);
  color: var(--ink);
}

.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-subtle);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.platforms-group {
  gap: var(--space-md);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.platform-alias-control {
  gap: var(--space-xs);
}

.platform-alias-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-secondary);
  cursor: pointer;
}

.platform-alias-label input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.qm-event-control {
  gap: var(--space-xs);
}

.qm-event-control label:not(.platform-alias-label) {
  font-size: 12px;
  color: var(--ink-secondary);
  margin-top: var(--space-xs);
}

.qm-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-secondary);
  cursor: pointer;
}

.qm-checkbox-label input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.qm-hint {
  font-size: 12px;
  color: var(--ink-muted);
}

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

.ga4-targets-group {
  padding-left: var(--space-lg);
  border-left: 2px solid var(--accent-subtle);
}

.ga4-targets-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.ga4-target-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ga4-target-chip:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
}

.ga4-target-chip input[type='checkbox'] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

.ga4-target-chip:has(input[type='checkbox']:checked) {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--ink);
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: var(--space-sm) var(--space-md);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.checkbox-group {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 13px;
  color: var(--ink-secondary);
  cursor: pointer;
}

.checkbox-label input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

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

.save-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.save-status.saved { color: var(--success); }
.save-status.unsaved { color: var(--warning); }

.md-editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.md-toolbar {
  display: flex;
  gap: var(--space-xs);
}

.md-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 var(--space-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  transition: background 120ms, border-color 120ms;
}

.md-btn:hover {
  background: var(--surface-inset);
  border-color: var(--accent);
  color: var(--accent);
}

.md-tabs {
  display: flex;
  gap: var(--space-xs);
}

.md-tab {
  padding: var(--space-xs) var(--space-sm);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
}

.md-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.form-group .md-textarea {
  min-height: 110px;
}

.md-preview {
  min-height: 110px;
  padding: var(--space-sm) var(--space-md);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: auto;
}

.md-body p {
  margin: 0 0 var(--space-sm);
  line-height: 1.55;
}

.md-body p:last-child {
  margin-bottom: 0;
}

.md-body ul {
  margin: 0 0 var(--space-sm);
  padding-left: var(--space-lg);
}

.md-body li {
  margin-bottom: var(--space-xs);
  line-height: 1.5;
}

.md-body strong {
  font-weight: 700;
  color: var(--ink);
}

.md-body em {
  font-style: italic;
}

.md-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-inset);
  padding: 1px 4px;
  border-radius: 4px;
  color: var(--ink-secondary);
}

.md-body a {
  color: var(--accent);
  text-decoration: none;
}

.md-body a:hover {
  text-decoration: underline;
}

.param-desc.md-body p,
.param-desc.md-body ul {
  margin-bottom: var(--space-xs);
}

@media (max-width: 900px) {
  .app-layout {
    flex-direction: column;
    overflow: auto;
  }

  .sidebar {
    width: 100%;
    height: auto;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .main-panel {
    padding: var(--space-md);
  }

  .event-hero {
    flex-direction: column;
  }

  .event-hero-actions {
    width: 100%;
    justify-content: flex-end;
  }

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

@media (max-width: 720px) {
  .header-actions {
    display: none;
  }

  .app-header {
    padding: 0 var(--space-md);
  }
}
