:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --bg: #f8fafc;
  --panel-bg: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --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.6;
  padding: 2rem 1rem;
}

.container {
  max-width: 800px;
  margin: 0 auto;
}

h1 {
  font-size: 2rem;
  text-align: center;
  margin-bottom: 0.25rem;
}

.subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.panel {
  background: var(--panel-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

textarea, select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-row .form-group {
  flex: 1;
  min-width: 200px;
}

.quality-options {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.quality-option {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

.quality-option.locked {
  opacity: 0.5;
  pointer-events: none;
}

.unlock-area {
  margin: 0.8rem 0;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.cost-display {
  margin: 1rem 0;
  font-size: 1.1rem;
  background: #f1f5f9;
  padding: 0.5rem 1rem;
  border-radius: 8px;
}

.action-area {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.7rem 1.8rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: white;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 0.5rem 1.2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: underline;
}

.hint {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.history-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
  text-align: center;
  font-size: 0.8rem;
  transition: transform 0.2s;
  cursor: pointer;
}

.history-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.history-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
}

.history-item .meta {
  padding: 0.4rem;
  line-height: 1.3;
}

.history-item .cost {
  color: var(--primary);
  font-weight: 600;
}

#resultPanel img {
  margin-top: 0.8rem;
}