/* R258 style.css · canvas-template-rail · v1.0 */

:root {
  --primary: #E53E3E;
  --secondary: #FC8181;
  --accent: #FF0000;
  --bg: #FFF5F5;
  --card: #FFFFFF;
  --text: #4A0000;
  --text-secondary: #9B2C2C;
  --border: #FED7D7;
  --success: #16A34A;
  --warning: #F59E0B;
  --danger: #EF4444;
  --contact-footer-h: 92px;
  --step-bar-h: 44px;
  --action-bar-h: 56px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --bottom-chrome-h: calc(var(--contact-footer-h) + var(--safe-area-bottom));
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  max-width: 480px;
  margin: 0 auto;
}

body.has-contact-footer {
  padding-bottom: calc(var(--contact-footer-h) + 12px + var(--safe-area-bottom));
}

button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

.app-header {
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 { font-size: 17px; }
.app-sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.header-row { display: flex; justify-content: space-between; align-items: center; }
.header-share { font-size: 16px; padding: 8px; color: var(--primary); }

.step-bar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 99;
  min-height: var(--step-bar-h);
}

.step-chip {
  flex: 1;
  border: none;
  background: var(--bg);
  color: var(--text-secondary);
  padding: 8px 4px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
  transition: background 0.2s, color 0.2s;
}

.step-chip.active { background: var(--primary); color: #fff; }
.step-chip.done { color: var(--primary); border: 1px solid var(--border); }

#main { padding: 12px 16px 20px; min-height: 40vh; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  cursor: pointer;
  display: inline-block;
  text-align: center;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { background: var(--card); border: 2px solid var(--border); color: var(--text); }
.btn-block { width: 100%; margin-top: 8px; }
.btn-sm { padding: 6px 10px; min-height: 32px; font-size: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
}

.form-group { display: block; margin-bottom: 10px; font-size: 12px; font-weight: 600; }
.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 4px;
  font-weight: 400;
  background: #fff;
  color: var(--text);
}

.chip-scroll {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}

.chip {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.template-rail {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.template-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.template-card.selected { border-color: var(--primary); box-shadow: 0 4px 12px rgba(229, 62, 62, 0.15); }
.template-card:active { transform: scale(0.98); }
.tpl-emoji { font-size: 32px; margin-bottom: 6px; }
.template-card strong { display: block; font-size: 13px; margin-bottom: 4px; }
.tpl-cat { font-size: 11px; color: var(--text-secondary); }

.editor-split {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  text-align: center;
}

.poster-canvas {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
}

.edit-panel h3 { font-size: 15px; margin-bottom: 10px; }

.theme-row {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}

.theme-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.theme-dot.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--card); }

.theme-dot[data-theme="loveRed"] { background: #E53E3E; }
.theme-dot[data-theme="forestGreen"] { background: #2D8B4E; }
.theme-dot[data-theme="eduBlue"] { background: #3182CE; }
.theme-dot[data-theme="elderGold"] { background: #D69E2E; }
.theme-dot[data-theme="communityPurple"] { background: #805AD5; }
.theme-dot[data-theme="warmOrange"] { background: #FF6B35; }

.size-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.copy-snippets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.action-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
  padding-bottom: var(--action-bar-h);
}

.result-wrap { text-align: center; }
.result-wrap h2 { font-size: 18px; margin-bottom: 12px; }

.result-actions { margin-top: 12px; }

.share-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 900;
  color: #fff;
  text-align: center;
  gap: 16px;
}

.share-overlay.hidden { display: none; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 950;
}

.modal { max-width: 360px; width: 100%; }

.hist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.hist-row img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
}

.empty-hint { text-align: center; padding: 24px; color: var(--text-secondary); font-size: 13px; }
.section-title { font-size: 14px; margin: 12px 0 8px; }
.meta { font-size: 12px; color: var(--text-secondary); }

.share-main {
  padding: 24px 16px;
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.share-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  width: 100%;
}

.share-icon { font-size: 40px; margin-bottom: 8px; }
.share-slogan { color: var(--text-secondary); font-size: 13px; margin: 8px 0 16px; }
.share-qr { display: flex; justify-content: center; margin: 12px 0; }
.share-link { font-size: 11px; color: var(--text-secondary); margin-bottom: 12px; word-break: break-all; }

.toast-container {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-chrome-h) + 16px);
  transform: translateX(-50%);
  z-index: 9999;
  pointer-events: none;
}

.toast-item {
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 13px;
  max-width: 90vw;
}

.toast-item.show { opacity: 1; }

.contact-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #1a1a1a;
  z-index: 850;
  padding: 0.55rem 0.75rem calc(0.55rem + var(--safe-area-bottom));
  min-height: var(--contact-footer-h);
}

.contact-footer__btns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 88px));
  justify-content: center;
  gap: 0.4rem;
  max-width: 320px;
  margin: 0 auto;
}

.contact-footer__cta,
.contact-footer__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}

.contact-footer__cta { background: #E87722 !important; color: #fff; }
.contact-footer__btn { background: #333; color: #fff; border: none; cursor: pointer; }
.contact-footer__brand { text-align: center; color: #888; font-size: 10px; margin-top: 6px; }

body.has-contact-footer .zw-root .zw-fab,
body.has-contact-footer .em-entry-btn {
  bottom: calc(var(--contact-footer-h) + 12px + var(--safe-area-bottom)) !important;
}

body[data-brand] .toast-container {
  bottom: calc(var(--bottom-chrome-h) + 16px);
}

.editable-field { outline: 2px dashed var(--warning); outline-offset: 2px; }

@media (min-width: 640px) {
  .template-rail { grid-template-columns: repeat(3, 1fr); }
  .editor-split {
    flex-direction: row;
    align-items: flex-start;
  }
  .preview-wrap { flex: 1; }
  .edit-panel { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
