/* ===============================================
   MandarinTreeHub · Global Design System
   Shared across all generator pages.
   Do NOT add page-specific styles here.
   =============================================== */

/* -- Variables -- */
:root {
  --bg: #f4fbf2;
  --panel: rgba(255,255,255,0.96);
  --ink: #203328;
  --muted: #667a6b;
  --accent: #F97316;
  --accent-deep: #ea6c0a;
  --accent-soft: rgba(249,115,22,0.10);
  --teal: #2d6b7a;
  --teal-soft: rgba(45,107,122,0.10);
  --line: rgba(138,191,116,0.18);
  --shadow: 0 20px 50px rgba(138,191,116,0.14);
  --red: #dc2626;
  --red-soft: rgba(220,38,38,0.10);
  --red-deep: #b91c1c;
  --green: #16a34a;
  --green-soft: rgba(22,163,74,0.10);
  --green-deep: #15803d;
}

/* -- Reset -- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button, textarea, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }

/* -- Body & Background -- */
body {
  font-family: "Nunito","Avenir Next","Segoe UI","Noto Sans SC",sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(138,191,116,0.20), transparent 30%),
    radial-gradient(circle at bottom right, rgba(185,216,166,0.22), transparent 25%),
    linear-gradient(135deg, #f4fbf2 0%, #fbfdf8 45%, #e8f4e2 100%);
}

/* -- Layout: two-column shell -- */
.shell {
  width: min(1400px, calc(100% - 32px));
  margin: 24px auto 40px;
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

/* -- Shared card style -- */
.panel, .stage {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

/* ================================
   Left Panel
   ================================ */
.panel {
  padding: 24px;
  position: sticky;
  top: 20px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  transition: color 160ms;
}
.back-link:hover { color: var(--accent); }

h1 {
  font-size: clamp(26px, 3.5vw, 38px);
  font-weight: 800;
  color: #5e8f4f;
  line-height: 1.1;
  margin-bottom: 4px;
}
.subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 20px;
  letter-spacing: 0.03em;
}

/* Form fields */
.field { margin-bottom: 14px; }

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}
.field-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.field-label-hint {
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
}

/* Text input */
input[type="text"] {
  width: 100%;
  border: 1px solid rgba(249,115,22,0.25);
  background: rgba(255,255,255,0.9);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 13px;
  outline: none;
  transition: border-color 160ms, box-shadow 160ms;
}
input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.12);
}

/* Textarea */
.textarea-wrap { position: relative; }

textarea {
  width: 100%;
  border: 1px solid rgba(249,115,22,0.25);
  background: rgba(255,255,255,0.9);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 30px 10px 13px;
  font-size: 14px;
  outline: none;
  transition: border-color 160ms, box-shadow 160ms;
  resize: vertical;
  min-height: 100px;
  line-height: 1.7;
  font-family: 'Noto Sans SC', sans-serif;
}
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.12);
}

/* Clear button inside textarea */
.textarea-clear-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  line-height: 1;
  padding: 2px;
  opacity: 0.6;
  transition: opacity 160ms;
}
.textarea-clear-btn:hover { opacity: 1; }

/* Checkbox */
input[type="checkbox"] { accent-color: var(--accent); }

/* Pinyin toggle */
.pinyin-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
}
.pinyin-toggle input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* Helper text */
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.6; }

/* Divider */
.divider { border: none; border-top: 1px solid var(--line); margin: 18px 0; }

/* -- Buttons -- */
.btn-row { display: flex; gap: 8px; margin-top: 16px; }

/* Primary: orange solid */
.btn-generate {
  flex: 1;
  padding: 11px 14px;
  min-height: 44px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 160ms, transform 140ms;
}
.btn-generate:hover { background: var(--accent-deep); transform: translateY(-1px); }

/* Secondary: orange outline */
.btn-save {
  flex: 1;
  padding: 11px 14px;
  min-height: 44px;
  background: #fff3eb;
  color: var(--accent-deep);
  border: 1.5px solid rgba(249,115,22,0.35);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 160ms, border-color 160ms, transform 140ms;
}
.btn-save:hover { background: #ffe8d6; border-color: var(--accent); transform: translateY(-1px); }

/* -- Share link box -- */
.link-box {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}
.link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 8px;
  padding: 7px 10px;
}
.link-url {
  font-size: 11px;
  color: #c2622a;
  font-family: monospace;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.copy-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 160ms, transform 140ms;
}
.copy-btn:hover { background: var(--accent-deep); transform: scale(1.08); }
.copy-btn.copied { background: var(--teal); }

/* -- QR code -- */
.qr-wrap {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.qr-wrap canvas {
  border-radius: 8px;
  border: 1px solid rgba(249,115,22,0.2);
}
.qr-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.03em;
}

/* ================================
   Right Stage
   ================================ */
.stage {
  min-height: calc(100vh - 48px);
  padding: 28px;
  padding-top: 58px;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Top-right toolbar (save, fullscreen) */
.stage-toolbar {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  display: flex;
  gap: 6px;
}

.stage-icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 8px;
  background: rgba(255,255,255,0.85);
  color: var(--muted);
  cursor: pointer;
  transition: background 160ms, color 160ms, border-color 160ms;
  flex-shrink: 0;
  outline: none;
}
.stage-icon-btn:hover { background: #fff; color: var(--ink); border-color: rgba(0,0,0,0.22); }
.stage-icon-btn:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(249,115,22,0.2); }
.stage-icon-btn svg { flex-shrink: 0; }

/* Empty state */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  text-align: center;
  padding: 60px 20px;
}
.empty-icon { font-size: 44px; margin-bottom: 4px; }
.empty-state p { font-size: 14px; line-height: 1.7; }

/* -- Modal -- */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-bg.hidden { display: none; }

.modal-card {
  background: #fff;
  border-radius: 20px;
  padding: 28px 36px 32px;
  text-align: center;
  max-width: min(90vw, 700px);
  box-shadow: 0 24px 60px rgba(0,0,0,0.18);
}

/* -- Responsive -- */
@media (max-width: 700px) {
  .shell { grid-template-columns: 1fr; }
  .panel { position: static; }
}
