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

[hidden] { display: none !important; }

:root {
  --bg: #fafafa;
  --panel: #ffffff;
  --border: #e5e5e5;
  --text: #1a1a1a;
  --muted: #888;
  --accent: #1a1a1a;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --radius: 8px;
}

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

.topbar {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.topbar h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 1.3fr;
  gap: 1px;
  background: var(--border);
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  padding: 28px 32px;
}

.form-panel {
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.step { margin-bottom: 28px; }

.step h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 12px;
}

.muted {
  color: var(--muted);
  font-weight: normal;
  text-transform: none;
  letter-spacing: 0;
}

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: #fafafa;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
  overflow: hidden;
  aspect-ratio: 3/4;
  max-height: 300px;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: #f5f5f5;
}

.dropzone-small {
  aspect-ratio: 1/1;
  max-height: 130px;
  max-width: 130px;
}

.dropzone-empty {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  padding: 16px;
}

.dropzone-icon {
  font-size: 22px;
  color: var(--muted);
}

.dropzone-text { font-weight: 500; }
.dropzone-hint { font-size: 12px; color: var(--muted); }

.dropzone-preview {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dropzone.has-image .dropzone-empty { display: none; }
.dropzone.has-image .dropzone-preview { display: block; }
.dropzone.has-image { border-style: solid; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.span-2 { grid-column: span 2; }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.field select {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
  color: var(--text);
}

.field select:focus {
  outline: none;
  border-color: var(--accent);
}

.generate-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.15s;
}

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

.generate-btn:not(:disabled):hover { opacity: 0.85; }

.hint {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  margin-top: 8px;
}

.hint-small {
  color: var(--muted);
  font-size: 11px;
  margin-top: 8px;
}

.result-panel {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  max-height: calc(100vh - 100px);
}

.result-panel h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 16px;
}

.result-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 400px;
  position: relative;
}

.result-empty {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.result-loading {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.timer {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.result-image-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.result-image-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 4px;
}

.result-error {
  text-align: center;
  padding: 24px;
}

.error-title {
  color: var(--danger);
  font-weight: 600;
  margin-bottom: 6px;
}

.error-msg {
  color: var(--muted);
  font-size: 13px;
  word-break: break-word;
}

.download-btn {
  margin-top: 16px;
  padding: 12px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s;
}

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

.footer {
  padding: 12px 32px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .form-panel, .result-panel { max-height: none; position: static; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
