/* ─── Qr Tree · 南欧午后慵懒暖阳 ─── */

:root {
  --bg: #f7f0e4;
  --bg-warm: #f3e8d4;
  --surface: #fff9f0;
  --ink: #2c2416;
  --ink-soft: #5c4e3a;
  --ink-muted: #8a7a62;
  --accent: #c4784a;
  --accent-soft: #e8a87a;
  --border: rgba(44, 36, 22, 0.1);
  --shadow: 0 12px 40px rgba(80, 50, 20, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, monospace;
}

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

html, body, #root { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(ellipse 120% 80% at 20% 0%, rgba(255, 220, 170, 0.35), transparent 50%),
    radial-gradient(ellipse 100% 60% at 90% 100%, rgba(200, 160, 100, 0.15), transparent 45%);
}

.app {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 2rem 1rem;
  gap: 1rem;
}

@media (min-width: 960px) {
  .app {
    height: 100%;
    padding: 1.25rem 2.5rem 1rem;
  }
  .main {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 2rem;
    min-height: 0;
    align-items: stretch;
  }
}

.header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.header h1 {
  font-size: 1.65rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.header .tagline {
  font-size: 0.9rem;
  color: var(--ink-muted);
}

/* Stage */
.stage {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 360px;
}

@media (min-width: 960px) {
  .stage { min-height: 0; }
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 249, 240, 0.85);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.stage-label {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
}

.stage-actions { display: flex; gap: 0.4rem; }

.stage-canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  min-height: 0;
  overflow: auto;
  cursor: pointer;
  background: radial-gradient(ellipse at 50% 30%, rgba(255, 236, 200, 0.4), transparent 60%);
}

.stage-canvas-wrap canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
  border-radius: 4px;
}

.stage.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  border-radius: 0;
  max-width: none;
}

.stage.is-fullscreen .stage-canvas-wrap { padding: 2rem; }

/* Panel */
.panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
  overflow-y: auto;
}

.panel label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 0.4rem;
}

.input-url {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-warm);
  color: var(--ink);
  font-size: 0.95rem;
  font-family: var(--mono);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-url:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196, 120, 74, 0.18);
}

.input-url::placeholder { color: var(--ink-muted); opacity: 0.7; }

.error-msg {
  font-size: 0.8rem;
  color: #b54a3a;
  margin-top: 0.35rem;
}

.presets { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.preset-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-warm);
  color: var(--ink-soft);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.preset-btn:hover { border-color: var(--accent-soft); background: #fff5e8; }
.preset-btn.is-active {
  border-color: var(--accent);
  background: #fff0e0;
  color: var(--ink);
  font-weight: 600;
}

.preset-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.1);
}

.color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.color-field { display: flex; flex-direction: column; gap: 0.3rem; }
.color-field span { font-size: 0.72rem; color: var(--ink-muted); }

.color-field input[type="color"],
.leaf-colors input[type="color"] {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  cursor: pointer;
  background: var(--bg-warm);
}

.leaf-colors {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 4px;
}

.leaf-colors input[type="color"] { width: 36px; }

.style-row { display: flex; gap: 0.4rem; }

.style-btn {
  flex: 1;
  padding: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-warm);
  color: var(--ink-soft);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.style-btn.is-active {
  border-color: var(--accent);
  background: #fff0e0;
  color: var(--ink);
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-warm);
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover {
  background: #fff5e8;
  border-color: var(--accent-soft);
  color: var(--ink);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fffaf5;
}

.btn-primary:hover {
  background: #b0683c;
  border-color: #b0683c;
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-muted);
  padding: 0.4rem 0.6rem;
}

.btn-ghost:hover {
  background: rgba(196, 120, 74, 0.1);
  color: var(--ink);
}

.export-row { display: flex; flex-direction: column; gap: 0.45rem; }
.export-row .btn { width: 100%; }

.footer {
  text-align: center;
  font-size: 0.78rem;
  color: var(--ink-muted);
  padding: 0.5rem 0;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.footer a:hover { border-bottom-color: var(--accent); }

.section-title {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 0.15rem 0;
}

@media (max-width: 959px) {
  .app { padding: 0.75rem; padding-bottom: 2rem; }
  .header { margin-bottom: 0.5rem; }
  .header h1 { font-size: 1.35rem; }
  .tagline { font-size: 0.8rem; }
  .main {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
  }
  /* canvas takes most of the viewport on phone */
  .stage {
    min-height: min(72vw, 58vh);
    height: min(92vw, 62vh);
  }
  .stage-canvas-wrap {
    padding: 0.5rem;
  }
  .panel {
    border-radius: var(--radius);
  }
  .footer { font-size: 0.75rem; margin-top: 0.5rem; }
}

@media (max-width: 480px) {
  .stage {
    min-height: 58vw;
    height: 78vw;
  }
  .stage-toolbar { padding: 0.5rem 0.75rem; }
  .btn { font-size: 0.8rem; }
  .color-grid { grid-template-columns: 1fr 1fr; }
}
