:root {
  --bg: #f8f7f4;
  --surface: #ffffff;
  --surface2: #f2f1ee;
  --border: #e4e2dd;
  --border2: #d0cec9;
  --accent: #6366f1;
  --accent-light: #eef0ff;
  --text: #1a1917;
  --muted: #78766f;
  --muted2: #a09e97;
  --font: 'Inter', sans-serif;
  --mono: 'DM Mono', monospace;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* Header */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo span { color: var(--accent); }

.header-sub {
  color: var(--muted);
  font-size: 13px;
  border-left: 1px solid var(--border);
  padding-left: 20px;
}

/* Layout */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
}

/* Preview Panel */
.preview-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 24px;
}

.preview-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.preview-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  padding: 40px;
  background:
    linear-gradient(rgba(99,102,241,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  background-color: #fafaf9;
}

.preview-box {
  width: 160px;
  height: 100px;
  background: var(--surface);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  transition: all 0.15s ease;
  border: 1px solid var(--border);
}

/* CSS Output */
.css-output-wrap {
  border-top: 1px solid var(--border);
}

.css-output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.css-output-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn-copy {
  background: var(--accent);
  color: #fff;
  border: none;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.02em;
}

.btn-copy:hover { background: #4f51d6; }
.btn-copy.copied { background: #16a34a; }

.css-output {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text);
  padding: 16px 20px;
  background: var(--surface);
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 80px;
}

/* Controls Panel */
.controls-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1;
  min-width: fit-content;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 10px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--surface); }

/* Tab Content */
.tab-content { display: none; padding: 20px; }
.tab-content.active { display: block; }

/* Controls */
.control-group {
  margin-bottom: 18px;
}

.control-group label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.val {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--accent);
  background: var(--accent-light);
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0;
  text-transform: none;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(99,102,241,0.3);
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="color"] {
  -webkit-appearance: none;
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 3px;
  background: var(--surface);
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; border-radius: 6px; overflow: hidden; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }

.text-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.text-input:focus { border-color: var(--accent); }

.control-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.control-group.half { margin-bottom: 0; }

/* Toggle */
.toggle {
  display: flex !important;
  align-items: center;
  cursor: pointer;
  margin-bottom: 0 !important;
}

.toggle input { display: none; }

.toggle-track {
  width: 36px;
  height: 20px;
  background: var(--border2);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
  box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }

/* Segmented */
.segmented {
  display: flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.seg {
  flex: 1;
  background: none;
  border: none;
  padding: 7px 10px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.seg:hover { color: var(--text); }
.seg.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

/* Add layer button */
.btn-add-layer {
  width: 100%;
  background: var(--surface2);
  border: 1px dashed var(--border2);
  border-radius: 8px;
  padding: 9px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 4px;
}

.btn-add-layer:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* Shadow layers */
#shadow-layers { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }

.layer-tag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.layer-tag button {
  background: none;
  border: none;
  color: var(--muted2);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.15s;
}

.layer-tag button:hover { color: #ef4444; }

/* Gradient stops */
#gradient-stops { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }

.stop-row {
  display: grid;
  grid-template-columns: 44px 1fr 36px;
  gap: 10px;
  align-items: center;
}

.stop-row input[type="color"] {
  height: 36px;
  padding: 2px;
}

.stop-pct {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

/* Radius grid */
.radius-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Footer */
footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted2);
  font-size: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--text); }