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

:root {
  --accent: #f59e0b;
  --accent-dim: #d97706;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #273549;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --success: #22c55e;
  --error: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

/* ===== Header ===== */
.header {
  text-align: center;
  padding: 56px 0 40px;
}

.header-logo {
  font-size: 2.8rem;
  margin-bottom: 12px;
}

.header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.header p {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* ===== Sections ===== */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

.section-label {
  display: inline-block;
  background: var(--accent);
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ===== Instructions ===== */
.steps-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.step {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-num {
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.step-icon { font-size: 1.4rem; }

.step-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ===== Size Selector ===== */
.size-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 600px) {
  .size-grid { grid-template-columns: repeat(2, 1fr); }
}

.size-card {
  position: relative;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
  user-select: none;
}

.size-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.size-card:hover {
  border-color: var(--accent-dim);
}

.size-card.selected {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.08);
}

.size-name {
  font-weight: 600;
  font-size: 1rem;
}

.size-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.size-badge {
  margin-top: 6px;
  display: inline-block;
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  width: fit-content;
}

/* ===== Upload Section ===== */
.upload-progress {
  margin-bottom: 16px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.progress-label {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.progress-label span {
  color: var(--text);
  font-weight: 600;
}

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #fbbf24);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-fill.complete {
  background: linear-gradient(90deg, var(--success), #4ade80);
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 16px;
}

.dropzone:hover, .dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.05);
}

.dropzone-icon { font-size: 2rem; margin-bottom: 8px; }

.dropzone-text {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.dropzone-text strong {
  color: var(--accent);
  cursor: pointer;
}

.dropzone-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
  opacity: 0.7;
}

/* ===== Thumbnail Grid ===== */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  margin-top: 4px;
}

.thumb-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface2);
  border: 1px solid var(--border);
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.thumb-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  background: rgba(239, 68, 68, 0.85);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 1;
}

.thumb-item:hover .thumb-remove { opacity: 1; }

/* ===== Error List ===== */
.error-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.error-item {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.82rem;
  color: #fca5a5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.error-dismiss {
  background: none;
  border: none;
  color: #fca5a5;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.7;
}

.error-dismiss:hover { opacity: 1; }

/* ===== Generate Section ===== */
.generate-section {
  text-align: center;
}

.generate-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.btn-generate {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: #000;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 14px 36px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.btn-generate:hover:not(:disabled) {
  background: #fbbf24;
  transform: translateY(-1px);
}

.btn-generate:active:not(:disabled) {
  transform: translateY(0);
}

.btn-generate:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-icon { font-size: 1.2rem; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0,0,0,0.3);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.btn-generate.loading .spinner { display: block; }
.btn-generate.loading .btn-icon { display: none; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.generate-info {
  margin-top: 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ===== Preview Section ===== */
.preview-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.preview-card {
  position: relative;
  cursor: pointer;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border);
  transition: border-color 0.15s, transform 0.1s;
  flex-shrink: 0;
}

.preview-card:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

.preview-card canvas {
  display: block;
}

.preview-card-num {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 0.65rem;
  color: #888;
  pointer-events: none;
}

.btn-refresh {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-refresh:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* ===== Thumbnail edit badge ===== */
.thumb-item {
  position: relative;
}

.thumb-edit-badge {
  position: absolute;
  bottom: 2px;
  left: 2px;
  font-size: 0.65rem;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.thumb-item:hover .thumb-edit-badge {
  opacity: 1;
}

/* ===== Modals ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.modal-body--image {
  flex-direction: column;
  align-items: center;
}

.modal-body canvas {
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-primary {
  background: var(--accent);
  color: #000;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 9px 22px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: #fbbf24; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 9px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s;
}

.btn-secondary:hover { color: var(--text); }

/* ===== Symbol list in card editor ===== */
.symbol-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.symbol-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.symbol-thumb {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
  flex-shrink: 0;
}

.symbol-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 52px;
  flex-shrink: 0;
}

.slider-row input[type=range] {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
}

.slider-value {
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* ===== Image editor controls ===== */
.image-controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}

.rotation-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rotation-btns {
  display: flex;
  gap: 6px;
}

.btn-rot {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-rot:hover, .btn-rot.active {
  color: var(--accent);
  border-color: var(--accent);
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 32px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}
