:root {
  --cw-purple: #663399;
  --cw-purple-light: #7c4dbb;
  --cw-purple-dark: #4a2272;
  --cw-purple-glow: rgba(102, 51, 153, 0.3);
  --cw-purple-subtle: rgba(102, 51, 153, 0.12);
  --bg-base: #f5f5f8;
  --bg-card: #ffffff;
  --bg-elevated: #f0eff4;
  --bg-input: #ffffff;
  --border: #e0dde6;
  --border-light: #d0cdd8;
  --text: #1a1a2e;
  --text-dim: #555568;
  --text-muted: #9090a8;
  --green: #16a34a;
  --green-bg: rgba(22, 163, 74, 0.08);
  --red: #dc2626;
  --red-bg: rgba(220, 38, 38, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--bg-base);
  color: var(--text);
  min-height: 100vh;
}

/* Header */
.header {
  padding: 14px 24px;
  background: linear-gradient(
    135deg,
    var(--cw-purple-dark) 0%,
    var(--cw-purple) 100%
  );
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}
.header h1 {
  font-size: 15px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.3px;
}
.header span {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 500;
}
.header .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: calc(100vh - 47px);
}

/* Left panel */
.controls {
  padding: 16px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-base);
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.card-header {
  padding: 10px 14px;
  background: var(--bg-elevated);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--cw-purple-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.card-body {
  padding: 14px;
}

/* Fields */
.field {
  margin-bottom: 10px;
}
.field:last-child {
  margin-bottom: 0;
}
.field label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.field input,
.field select {
  width: 100%;
  padding: 9px 11px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.field input:focus,
.field select:focus {
  border-color: var(--cw-purple);
  box-shadow: 0 0 0 3px var(--cw-purple-glow);
}
.field input::placeholder {
  color: var(--text-muted);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Imp type toggle */
.imp-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.imp-toggle-btn {
  flex: 1;
  padding: 7px 12px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-input);
  border: none;
  color: var(--text-dim);
  transition: all 0.15s;
}
.imp-toggle-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}
.imp-toggle-btn:hover {
  background: var(--bg-elevated);
}
.imp-toggle-btn.active {
  background: var(--cw-purple);
  color: white;
}

/* Textarea */
textarea#bid-request {
  width: 100%;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 11px;
  line-height: 1.6;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 12px;
  resize: vertical;
  outline: none;
  min-height: 200px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
textarea#bid-request:focus {
  border-color: var(--cw-purple);
  box-shadow: 0 0 0 3px var(--cw-purple-glow);
}

/* Buttons */
.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.latency {
  margin-left: auto;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.btn {
  padding: 10px 20px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  transition: all 0.15s;
}
.btn-primary {
  background: #16a34a;
  color: white;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}
.btn-primary:hover {
  background: #22c55e;
  box-shadow: 0 4px 16px rgba(22, 163, 74, 0.4);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--border);
  color: var(--text);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Status bar */
.status-bar {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  display: none;
}
.status-bar.visible {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-bar.info {
  background: var(--cw-purple-subtle);
  color: var(--cw-purple-light);
}
.status-bar.ok {
  background: var(--green-bg);
  color: var(--green);
}
.status-bar.err {
  background: var(--red-bg);
  color: var(--red);
}
.status-bar .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Right panel */
.player-side {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg-base);
}

.player-area {
  position: relative;
  background: #1a1a2e;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.player-area .placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.3);
}
.player-area .placeholder svg {
  margin-bottom: 12px;
  stroke: rgba(255, 255, 255, 0.25);
}
.player-area .placeholder p {
  font-size: 12px;
}
#app {
  width: 100%;
  max-width: 640px;
  margin: 16px;
}

/* Response area */
.response-area {
  border-top: 1px solid var(--border);
  max-height: 40vh;
  overflow-y: auto;
}
.response-area .card {
  border: none;
  border-radius: 0;
}
.response-area pre {
  padding: 12px 14px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: none;
  overflow: visible;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
}
.tab {
  padding: 8px 16px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab:hover {
  color: var(--text-dim);
}
.tab.active {
  color: var(--cw-purple-light);
  border-bottom-color: var(--cw-purple);
}
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* Errors */
.error-detail {
  margin-top: 8px;
  padding: 12px;
  background: var(--red-bg);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text);
  font-family: "SF Mono", "Fira Code", monospace;
}
.error-detail .error-title {
  color: var(--red);
  font-weight: 700;
  margin-bottom: 6px;
  font-family: "Inter", sans-serif;
}

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