:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #242836;
  --border: #2e3345;
  --text: #e8eaed;
  --text-muted: #9aa0b0;
  --primary: #5b8def;
  --primary-hover: #4a7de0;
  --success: #3ecf8e;
  --success-hover: #34b87a;
  --radius: 12px;
}

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

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

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

header { text-align: center; margin-bottom: 1.75rem; }
header h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 0.35rem; }
.subtitle { color: var(--text-muted); font-size: 0.95rem; }

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 2.25rem 1.25rem;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}
.upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(91, 141, 239, 0.08);
}
.upload-icon { width: 44px; height: 44px; color: var(--text-muted); margin-bottom: 0.75rem; }
.upload-text { font-size: 1.05rem; margin-bottom: 0.3rem; }
.upload-or { color: var(--text-muted); font-size: 0.9rem; margin: 0.6rem 0; }
.upload-hint { margin-top: 0.9rem; font-size: 0.82rem; color: var(--text-muted); line-height: 1.4; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.65rem 1.2rem; font-size: 0.95rem; font-weight: 600;
  border: none; border-radius: 8px; cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #0a1a12; }
.btn-success:hover:not(:disabled) { background: var(--success-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

.code-section { margin-top: 1.5rem; }
.code-section label { display: block; font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0.4rem; }
#svg-code {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-family: "SF Mono", Consolas, monospace;
  font-size: 0.85rem; padding: 0.75rem 0.9rem; resize: vertical; min-height: 80px;
}
#svg-code:focus { outline: none; border-color: var(--primary); }
#load-code-btn { margin-top: 0.6rem; }

.converter-panel { margin-top: 2rem; animation: fadeIn 0.25s ease; }
.converter-panel.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.file-list-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.75rem;
}
.file-list-header h3 { font-size: 1rem; font-weight: 600; }

.file-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  max-height: 360px;
  overflow-y: auto;
  padding: 0.25rem;
}

.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}
.file-card .thumb {
  width: 100%;
  aspect-ratio: 1;
  background: #1a1d27;
  background-image:
    linear-gradient(45deg, #2a2e3a 25%, transparent 25%),
    linear-gradient(-45deg, #2a2e3a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2a2e3a 75%),
    linear-gradient(-45deg, transparent 75%, #2a2e3a 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.file-card .thumb img,
.file-card .thumb svg {
  max-width: 100%; max-height: 100%; object-fit: contain;
}
.file-card .thumb .svg-badge {
  font-size: 0.7rem; color: var(--text-muted); text-align: center; padding: 0.5rem;
}
.file-card .info {
  padding: 0.45rem 0.55rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-card .status-badge {
  position: absolute; top: 6px; right: 6px;
  font-size: 0.65rem; font-weight: 600;
  padding: 2px 6px; border-radius: 4px;
  background: var(--surface-2); color: var(--text-muted);
}
.file-card.done .status-badge { background: var(--success); color: #0a1a12; }
.file-card.error .status-badge { background: #e05c5c; color: #fff; }
.file-card .remove {
  position: absolute; top: 6px; left: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.55); color: #fff; border: none;
  font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.controls {
  display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem;
}
.control-group label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.control-group select {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 0.45rem 0.7rem; border-radius: 6px; font-size: 0.95rem; min-width: 160px;
}
.bg-options { display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: center; }
.radio-label { display: flex; align-items: center; gap: 0.3rem; font-size: 0.9rem; cursor: pointer; }
.radio-label input { accent-color: var(--primary); }
#custom-bg { width: 34px; height: 26px; border: none; border-radius: 4px; cursor: pointer; background: none; }
#custom-bg:disabled { opacity: 0.4; cursor: not-allowed; }

.actions { display: flex; flex-wrap: wrap; gap: 0.65rem; }
.status { margin-top: 1rem; font-size: 0.9rem; color: var(--text-muted); min-height: 1.4em; }

footer { margin-top: 2.5rem; text-align: center; color: var(--text-muted); font-size: 0.85rem; }

@media (max-width: 480px) {
  .file-list { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  margin: 0.75rem 0 0.25rem;
}
.btn-row .btn {
  min-width: 150px;
}
