/* ── Responsive ── */
@media (max-width: 768px) {
  header { padding: 20px 24px; }

  main { padding: 36px 16px 0; }

  .page-title { font-size: clamp(22px, 7vw, 36px); letter-spacing: -1px; }

  .custom-grid { grid-template-columns: 1fr; gap: 16px; }
}

@media (max-width: 480px) {
  header { padding: 16px; }

  .logo { font-size: 18px; }

  .page-title { font-size: clamp(16px, 8vw, 20px); }

  .page-subtitle { font-size: 12px; margin-bottom: 28px; }

  .card { padding: 20px 16px 16px; }

  .input-row { flex-direction: column; }

  .preview-actions {
    flex-wrap: wrap;
  }

  .preview-actions .btn {
    flex: 1 1 calc(50% - 5px);
    text-align: center;
    padding: 10px 8px;
  }

  .preview-actions .btn:first-child {
    flex: 1 1 100%;
  }

  .code-block {
    padding-right: 60px; /* prevent copy button overlap */
  }

  .theme-option-name { font-size: 12px; min-width: 64px; }

  .dot { width: 14px; height: 11px; }
}


/* ── Variables ── */
:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface2: #e8e8e8;
  --border: #d8d6cf;
  --text: #1a1917;
  --text-muted: #7a7871;
  --accent: #1a1917;
  --accent-inv: #f5f4f0;
  --green: #2da44e;
  --green-soft: #d4edda;
  --red: #cf222e;
  --toggle-knob: #1a1917;
  --toggle-track: #d8d6cf;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.22s cubic-bezier(0.4,0,0.2,1);
}

[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #e6edf3;
  --accent-inv: #0d1117;
  --green: #3fb950;
  --green-soft: #1b3a25;
  --red: #f85149;
  --toggle-knob: #e6edf3;
  --toggle-track: #30363d;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.25);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}

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

body {
  font-family: 'DM Mono', monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  padding: 0 0 80px;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 78px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  transition: background var(--transition), border-color var(--transition);
}

.logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.5px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ── Toggle ── */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle input { display: none; }

.toggle-track {
  width: 100%;
  height: 100%;
  background: var(--toggle-track);
  border-radius: 999px;
  transition: background var(--transition);
  border: 1px solid var(--border);
}

.toggle-knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--toggle-knob);
  transition: transform var(--transition), background var(--transition);
}

.toggle input:checked ~ .toggle-track { background: var(--accent); }
.toggle input:checked ~ .toggle-knob { transform: translateX(20px); background: var(--accent-inv); }

/* ── Main layout ── */
main {
  max-width: 800px;
  margin: 0 auto;
  padding: 52px 24px 0;
}

.page-title {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: clamp(32px, 5vw, 48px);
  line-height: 1.1;
  letter-spacing: -1.5px;
  margin-bottom: 10px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 44px;
  line-height: 1.6;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
  box-shadow: var(--shadow);
  transition: background var(--transition), border-color var(--transition);
  margin-bottom: 20px;
}

.section-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Input group ── */
.input-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.input-wrap {
  position: relative;
  flex: 1;
}

.input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

input[type="text"] {
  width: 100%;
  padding: 10px 12px 10px 36px;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input[type="text"]:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(26,25,23,0.08);
}

[data-theme="dark"] input[type="text"]:focus {
  box-shadow: 0 0 0 3px rgba(230,237,243,0.08);
}

input[type="text"]::placeholder { color: var(--text-muted); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  margin-top: 9px;
  font-weight: 400;
  letter-spacing: 0.02em;
  transition: all var(--transition);
}
.status-badge.checking { color: var(--text-muted); background: var(--surface2); border: 1px solid var(--border); }
.status-badge.valid    { color: var(--green); background: var(--green-soft); border: 1px solid var(--green); }
.status-badge.invalid  { color: var(--red); background: #ffeef0; border: 1px solid var(--red); }
[data-theme="dark"] .status-badge.invalid { background: #3d0f0f; }
.status-badge.hidden   { visibility: hidden; }

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ── Buttons ── */
.btn {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

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

.btn-primary:hover { opacity: 0.85; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: var(--surface2);
  color: var(--text);
}

.btn-ghost:hover { background: var(--border); }

/* ── Preview area ── */
.preview-area {
  min-height: 160px;
  background: var(--surface2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  transition: background var(--transition), border-color var(--transition);
}

.preview-area img {
  max-width: 100%;
  display: block;
  border-radius: 4px;
}

.preview-placeholder {
  text-align: center;
  color: var(--text-muted);
}

.preview-placeholder .placeholder-icon {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.4;
}

.preview-placeholder p { font-size: 12px; }

.preview-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

/* ── Customization ── */
.custom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: block;
}

select {
  width: 100%;
  padding: 9px 12px;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b949e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color var(--transition), background-color var(--transition);
}

select:focus { border-color: var(--text); }

/* ── Theme Dropdown ── */
.theme-select-container {
  position: relative;
  user-select: none;
}

.theme-selected {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  
}

.theme-selected:hover { border-color: var(--text);}
.theme-selected.open  { border-color: var(--text); border-radius:  0 0 var(--radius-sm) var(--radius-sm); }

.theme-chevron {
 margin-left: auto;
  font-size: 16px;
  color: var(--text-muted);
  transition: transform var(--transition);
  display: inline-block;
}

.theme-selected.open .theme-chevron { transform: rotate(180deg); }

.theme-list {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0; right: 0;
  top:unset;
  background: var(--surface);
  border: 0.5px solid var(--text);
  border-bottom: none;
  border-top: 1px solid var(--text);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  max-height: 220px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow-lg);
}

.theme-list.open { display: block; }

.theme-list::-webkit-scrollbar { width: 4px; }
.theme-list::-webkit-scrollbar-track { background: var(--surface2); }
.theme-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.theme-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: background var(--transition);
}

.theme-option:hover  { background: var(--surface2); }
.theme-option.active { background: var(--surface2); }

.theme-option-name {
  font-size: 14px;
  color: var(--text);
  min-width: 82px;
  text-transform: lowercase;
}

.theme-option-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}

.dot {
  width: 18px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
}

/* ── Syntax block ── */
.code-block {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 12px;
  color: var(--text-muted);
  overflow-x: auto;
  white-space: nowrap;
  position: relative;
  transition: background var(--transition), border-color var(--transition);
}

.code-block code { color: var(--text); }

.copy-inline {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  padding: 4px 9px;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--accent);
  color: var(--accent-inv);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  z-index: 999;
  pointer-events: none;
}

.toast.show { transform: translateY(0); opacity: 1; }

/* ── Loading shimmer ── */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.preview-area.loading {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
}

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.card { animation: fadeUp 0.4s ease both; }
.card:nth-child(2) { animation-delay: 0.06s; }
.card:nth-child(3) { animation-delay: 0.12s; }

/* ── Responsive ── */
@media (max-width: 600px) {
  header { padding: 20px 20px; }
  main { padding: 36px 16px 0; }
  .custom-grid { grid-template-columns: 1fr; }
  .input-row { flex-direction: column; }
}
