:root {
  --bg: #f4f1ec;
  --surface: #ffffff;
  --border: #e2ddd3;
  --text: #262220;
  --text-muted: #6f6a63;
  --primary: #c87a53;
  --primary-dark: #a8613f;
  --error-bg: #fbe7e4;
  --error-text: #9c3b2c;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.page-header h1 {
  font-size: 1.5rem;
  margin: 0 0 8px;
}

.page-header p {
  color: var(--text-muted);
  margin: 0 0 28px;
  line-height: 1.5;
}

.mode-switch {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 20px;
}

.mode-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 12px;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mode-btn.active {
  background: var(--primary);
  color: white;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel.hidden { display: none; }

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

.field-row {
  display: flex;
  gap: 12px;
}

label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

input, textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

textarea { resize: vertical; }

.primary-btn, .secondary-btn {
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  padding: 12px 16px;
  border: none;
  cursor: pointer;
}

.primary-btn {
  background: var(--primary);
  color: white;
}

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

.secondary-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

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

.error-text {
  color: var(--error-text);
  background: var(--error-bg);
  border-radius: 8px;
  padding: 0;
  min-height: 0;
  margin: 14px 0 0;
}

.error-text:not(:empty) {
  padding: 10px 12px;
  margin-top: 14px;
}

.output {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.output.hidden { display: none; }

.qr-box {
  display: flex;
  justify-content: center;
}

.qr-box canvas, .qr-box img {
  border-radius: 8px;
}

.payload-box {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.payload-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

#payload-preview {
  display: block;
  word-break: break-all;
  font-size: 0.8rem;
  line-height: 1.4;
}

.output-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.output-actions button { flex: 1; }

.page-footer {
  margin-top: 32px;
  text-align: center;
}

.page-footer p {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.hidden { display: none !important; }
