:root {
  --brand: #c94e22;
  --brand-dark: #a83f1b;
  --bg: #f8f7f4;
  --card: #ffffff;
  --text: #2b2b2b;
  --muted: #999999;
  --border: #eeeeee;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
}

/* 顶部栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--brand);
  color: #fff;
}
.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 16px;
}
.brand { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.nav-links { display: none; gap: 24px; }
.nav-links a { color: #fff; font-size: 15px; text-decoration: none; opacity: 0.9; }
.nav-links a.active { opacity: 1; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.phone { font-size: 13px; opacity: 0.9; }
.logout { color: #fff; font-size: 13px; text-decoration: none; opacity: 0.9; }

/* 主容器 */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 80px;
}

/* 卡片 */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 18px 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--brand);
}

/* 表单 */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 6px;
}
.field input, .field textarea, .field select {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafafa;
  color: var(--text);
  outline: none;
  font-family: inherit;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--brand);
  background: #fff;
}
textarea { resize: vertical; }

.radio-row { display: flex; gap: 20px; padding: 4px 0; }
.radio-row label { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--text); margin: 0; }
.radio-row input[type="radio"] { accent-color: var(--brand); width: auto; }

/* 按钮 */
.btn-primary {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-block { display: block; width: 100%; }

.btn-send {
  flex-shrink: 0;
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
}
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-copy {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 10px;
}

.btn-del {
  background: none;
  color: #c0392b;
  border: none;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
}

.btn-mini {
  color: var(--brand);
  font-size: 13px;
  text-decoration: none;
  padding: 4px 8px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  margin-left: 6px;
}
.btn-mini-del { color: #c0392b; border-color: #c0392b; }

.btn-plain {
  background: #fff;
  color: #666;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 15px;
  cursor: pointer;
}

.code-row { display: flex; gap: 10px; }

/* 底部标签栏 */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--border);
  height: 56px;
  z-index: 10;
}
.tabbar a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  text-decoration: none;
  font-size: 15px;
}
.tabbar a.active { color: var(--brand); font-weight: 700; }

/* 提示 */
.muted { color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; font-size: 15px; }
.empty a { color: var(--brand); }

/* 登录页 */
.login-body { background: var(--brand); min-height: 100vh; }
.login-box {
  max-width: 400px;
  margin: 0 auto;
  padding: 60px 24px;
  background: var(--bg);
  border-radius: 16px;
  margin-top: 12vh;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}
.login-logo { font-size: 28px; font-weight: 800; color: var(--brand); text-align: center; letter-spacing: 2px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 8px 0 28px; }
.login-tip { text-align: center; color: var(--muted); font-size: 12px; margin-top: 14px; }

/* 登录方式切换 */
.login-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.login-tab {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  color: var(--muted);
  font-size: 15px;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.login-tab.active {
  color: var(--brand);
  font-weight: 700;
  border-bottom-color: var(--brand);
}

/* 结果区 */
.result-text { white-space: pre-wrap; line-height: 1.7; font-size: 15px; }
.script-text { white-space: pre-wrap; line-height: 1.8; font-size: 15px; }
.ai-badge { text-align: center; color: var(--muted); font-size: 12px; margin: -6px 0 16px; }

/* 历史 */
.hist-item { margin-bottom: 12px; }
.hist-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.hist-time { color: var(--muted); font-size: 12px; }
.hist-product { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.hist-hook { color: #555; font-size: 14px; line-height: 1.5; }

/* 商家列表 */
.merchant-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.merchant-item:last-child { border-bottom: none; }
.merchant-name { font-weight: 600; font-size: 15px; }
.merchant-ops { flex-shrink: 0; }

/* 弹层 */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.form-panel {
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 20px 16px 24px;
}
.form-panel h3 { margin: 0 0 16px; color: var(--brand); font-size: 17px; }
.form-ops { display: flex; gap: 12px; margin-top: 16px; }
.form-ops .btn-primary { flex: 1; }

/* Toast */
#toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  max-width: 80vw;
  text-align: center;
}
#toast.show { opacity: 1; }

/* 响应式栅格：手机单列，桌面双栏 */
.form-grid { display: block; }
.hist-grid { display: block; }
.card-narrow { max-width: 560px; margin-left: auto; margin-right: auto; }

@media (min-width: 900px) {
  .nav-links { display: flex; }
  .tabbar { display: none; }
  .container { max-width: 960px; }
  .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
  }
  .form-grid .card { margin-bottom: 0; }
  .hist-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .hist-grid .card { margin-bottom: 0; }
}
