:root {
  --cfg-bg: #f8f9fa;
  --cfg-card: #ffffff;
  --cfg-border: #e2e8f0;
  --cfg-text: #1a202c;
  --cfg-muted: #718096;
  --cfg-accent: #4f6ef7;
  --cfg-radius: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--cfg-bg);
  color: var(--cfg-text);
  min-height: 100vh;
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.page-header {
  margin-bottom: 2.5rem;
}
.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
}
.page-header p {
  color: var(--cfg-muted);
  margin-top: 0.35rem;
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 2rem;
  align-items: start;
}

/* ---- Settings panel ---- */
.settings {
  background: var(--cfg-card);
  border: 1px solid var(--cfg-border);
  border-radius: var(--cfg-radius);
  padding: 1.5rem;
  position: sticky;
  top: 1.5rem;
}
.settings h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.field {
  margin-bottom: 1.25rem;
}
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cfg-muted);
  margin-bottom: 0.4rem;
}
.field input[type="url"],
.field input[type="text"] {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--cfg-border);
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.field input[type="url"]:focus,
.field input[type="text"]:focus {
  border-color: var(--cfg-accent);
}
.field select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--cfg-border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: var(--cfg-card);
  color: var(--cfg-text);
  cursor: pointer;
}
.field select:focus {
  border-color: var(--cfg-accent);
}

.color-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.color-row input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 42px;
  height: 42px;
  border: 2px solid var(--cfg-border);
  border-radius: 8px;
  padding: 2px;
  cursor: pointer;
  background: none;
}
.color-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-row input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }
.color-row input[type="color"]::-moz-color-swatch { border: none; border-radius: 5px; }
.color-row input[type="text"] {
  flex: 1;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.range-row input[type="range"] {
  flex: 1;
  accent-color: var(--cfg-accent);
}
.range-row .range-val {
  font-size: 0.85rem;
  font-weight: 500;
  min-width: 3.2em;
  text-align: right;
  color: var(--cfg-muted);
}

.field-divider {
  border: none;
  border-top: 1px solid var(--cfg-border);
  margin: 1.25rem 0;
}

.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--cfg-accent);
  cursor: pointer;
  flex-shrink: 0;
}
.toggle-row span {
  font-size: 0.88rem;
  color: var(--cfg-text);
}

.btn-load {
  width: 100%;
  padding: 0.7rem;
  background: var(--cfg-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  font-family: inherit;
  margin-top: 0.25rem;
}
.btn-load:hover { opacity: 0.85; }

.import-field textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--cfg-border);
  border-radius: 8px;
  font-size: 0.78rem;
  font-family: "SF Mono", "Fira Code", Menlo, monospace;
  outline: none;
  transition: border-color 0.2s;
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
  color: var(--cfg-text);
  background: var(--cfg-card);
}
.import-field textarea:focus { border-color: var(--cfg-accent); }
.import-field textarea::placeholder { font-family: inherit; font-size: 0.78rem; }
.btn-import {
  width: 100%;
  padding: 0.55rem;
  background: transparent;
  color: var(--cfg-accent);
  border: 1px solid var(--cfg-accent);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  font-family: inherit;
  margin-top: 0.5rem;
}
.btn-import:hover { background: var(--cfg-accent); color: #fff; }
.import-ok {
  color: #38a169;
  font-size: 0.8rem;
  margin-top: 0.35rem;
  display: none;
}
.import-err {
  color: #e53e3e;
  font-size: 0.8rem;
  margin-top: 0.35rem;
  display: none;
}

/* ---- Preview area ---- */
.preview-area h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

#preview { min-height: 200px; }

/* ---- Snippet area ---- */
.snippet-section {
  margin-top: 2rem;
}
.snippet-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.snippet-wrap {
  position: relative;
  background: #1a202c;
  border-radius: var(--cfg-radius);
  padding: 1.2rem 1.2rem 1.2rem 1.2rem;
}
.snippet-wrap pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.7;
  color: #e2e8f0;
}
.btn-copy {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  padding: 0.35rem 0.8rem;
  background: rgba(255,255,255,0.75);
  color: #1e293b;
  border: 1px solid rgba(255,255,255,0.8);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}
.btn-copy:hover { background: rgba(255,255,255,0.9); }

/* responsive */
@media (max-width: 740px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .settings {
    position: static;
  }
}
@media (max-width: 480px) {
  .page {
    padding: 1.5rem 1rem 3rem;
  }
  .page-header h1 {
    font-size: 1.3rem;
  }
  .settings {
    padding: 1rem;
  }
  .snippet-wrap {
    padding: 0.8rem;
  }
  .snippet-wrap pre {
    font-size: 0.72rem;
  }
}
