/* ── HEADER ──────────────────────────────────────────────────────────── */
header { margin-bottom: 48px; text-align: center; }
header h1 { font-size: 2.5rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: 12px; }
header h1 span { color: var(--accent); }
.subtitle { color: var(--muted); font-size: 1.1rem; }

/* ── DOWNLOAD BUTTON ────────────────────────────────────────────────── */
.download-container {
  display: flex;
  justify-content: center;
  margin-bottom: 40px;
}
.btn-primary-large {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 16px 40px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}
.btn-primary-large:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(var(--accent-rgb), 0.4);
  opacity: 0.95;
}

.btn-outline-large {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  color: var(--text);
  border: 2px solid var(--border);
  padding: 16px 40px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-outline-large:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface);
}

/* ── GENERATOR PANEL ─────────────────────────────────────────────────── */
.generator-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: visible;
  box-shadow: 0 4px 24px rgba(0,0,0,.04);
  margin-bottom: 72px;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.generator-panel.maximized {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2000;
  margin: 0;
  border-radius: 0;
}

.generator-panel.maximized .panel-content {
  height: calc(100vh - 120px);
}

.panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  border-radius: 12px 12px 0 0;
}

.generator-panel.maximized .panel-top {
  border-radius: 0;
}

.btn-icon-sm.rendering {
  color: var(--accent);
  animation: pulse-ring 1s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

/* ── SNIPPET TOOLBAR ───────────────────────────────────────────────── */
.snippet-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  min-height: 44px;
}
.snippet-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.snippet-btn:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.3s;
}
.status-indicator.rendering { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.4; }
  100% { opacity: 1; }
}
.controls { display: flex; gap: 16px; align-items: center; }

.panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 4px;
}

.btn-icon-sm {
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--border);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.8rem;
}
.btn-icon-sm:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface);
}

.panel-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 450px;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}

/* ── BUTTONS & CONTROLS ──────────────────────────────────────────────── */
#typeSelect {
  appearance: none;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 32px 7px 12px; font-size: .85rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  transition: border-color .2s;
}
#typeSelect:focus { outline: none; border-color: var(--accent); }

/* ── TEMPLATE PICKER ────────────────────────────────────────────────── */
.template-picker {
  position: relative;
}
.template-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 280px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.15);
  z-index: 100;
  padding: 8px;
  display: none;
  max-height: 400px;
  overflow-y: auto;
}
.template-menu.show {
  display: block;
  animation: menuIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes menuIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.template-group-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 12px 6px;
  letter-spacing: 0.05em;
}
.template-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  transition: background 0.2s;
}
.template-item:hover {
  background: var(--accent-bg);
  color: var(--accent);
}
.template-item i {
  width: 14px;
  font-size: 0.8rem;
  opacity: 0.7;
}

#templateBtn i {
  font-size: 0.8rem;
}

#generateBtn {
  background: var(--accent); color: var(--bg); border: none;
  padding: 8px 20px; border-radius: 8px; font-weight: 700;
  font-size: .85rem; cursor: pointer; transition: opacity .2s, transform .2s;
}
#generateBtn:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-secondary:hover {
  background: var(--border);
  color: var(--accent);
}

.panel-content {
  display: flex;
  height: 450px;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
  position: relative;
}

/* ── RESIZER ────────────────────────────────────────────────────────── */
.resizer {
  width: 4px;
  cursor: col-resize;
  background: var(--border);
  transition: background 0.2s;
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}
.resizer:hover, .resizer.resizing {
  background: var(--accent);
}
.resizer::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 24px;
  background: rgba(255,255,255,0.2);
  border-radius: 1px;
}

textarea {
  width: 50%;
  height: 100%;
  border: none;
  padding: 20px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px; resize: none; outline: none;
  background: transparent; color: var(--text);
  flex-shrink: 0;
}

#output {
  flex: 1;
  padding: 20px;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: #ffffff;
  border-left: none;
}
svg { max-width: 100%; height: auto; }

.code-block {
  display: block; background: var(--code-bg); padding: 12px;
  border-radius: 8px; border: 1px solid var(--border);
  margin: 10px 0; font-size: 0.8rem; overflow-x: auto;
  color: var(--muted);
}

@media (max-width: 768px) {
  .panel-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }
  .controls {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }
  .controls div[data-i18n="live_playground"] {
    width: 100%;
    margin-bottom: 4px;
  }
  .panel-right-group {
    width: 100%;
    justify-content: space-between;
  }
  .panel-content {
    flex-direction: column;
    height: auto;
  }
  .resizer {
    display: none;
  }
  textarea { width: 100% !important; height: 250px; }
  #output { border-left: none; border-top: 1px solid var(--border); height: 400px; padding: 10px; }

  #typeSelect, #templateBtn {
    flex: 1;
  }

  .template-menu {
    position: fixed;
    top: auto;
    bottom: 20px;
    left: 20px;
    right: 20px;
    width: auto;
    max-width: none;
    max-height: 60vh;
  }
}
