/* ==========================================================================
   微信分享卡片生成器 —— 深色工具界面
   预览区固定浅色，还原微信真实观感
   ========================================================================== */

:root {
  --bg:        #0e1013;
  --panel:     #161a21;
  --panel-2:   #1c2129;
  --line:      #272d38;
  --line-2:    #333a47;
  --text:      #e7eaef;
  --muted:     #8d97a8;
  --dim:       #5f6878;
  --accent:    #22c55e;
  --accent-dk: #16a34a;
  --accent-ink:#04220f;
  --warn:      #f0b429;
  --danger:    #ef5350;
  --radius:    10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 40px;
}

h1, h2 { margin: 0; font-weight: 500; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: rgba(255, 255, 255, .07);
  padding: 1px 5px;
  border-radius: 4px;
}

.is-hidden { display: none !important; }

/* ------------------------------ 顶栏 ------------------------------ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; }

.logo {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent);
  position: relative;
  flex: none;
}
.logo::after {
  content: "";
  position: absolute;
  inset: 6px 6px auto 6px;
  height: 2px;
  background: var(--accent-ink);
  box-shadow: 0 4px 0 var(--accent-ink), 0 8px 0 var(--accent-ink);
}

.topbar h1 { font-size: 15px; }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.badge {
  font-size: 12px;
  color: var(--accent);
  border: 1px solid rgba(34, 197, 94, .35);
  background: rgba(34, 197, 94, .1);
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ------------------------------ 提示条 ------------------------------ */
.notice {
  margin: 14px 22px 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.7;
  border: 1px solid;
}
.notice-warn {
  background: rgba(240, 180, 41, .1);
  border-color: rgba(240, 180, 41, .35);
  color: #f6d68a;
}
.notice-warn code { background: rgba(0, 0, 0, .3); color: #f6d68a; }

/* ------------------------------ 布局 ------------------------------ */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  padding: 18px 22px 0;
  align-items: start;
}

@media (max-width: 940px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .panel-preview { order: -1; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.panel-title {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-preview { position: sticky; top: 82px; }

/* ------------------------------ 表单 ------------------------------ */
.field { margin-bottom: 18px; }

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.field-head label { font-size: 13px; color: var(--text); }

.counter { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.counter.is-warn { color: var(--warn); }
.counter.is-over { color: var(--danger); }

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%238d97a8' stroke-width='1.5'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  cursor: pointer;
}
select option { background: var(--panel-2); color: var(--text); }

textarea { resize: vertical; min-height: 62px; line-height: 1.55; }

input::placeholder, textarea::placeholder { color: var(--dim); }

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .15);
}

.hint { font-size: 12px; color: var(--muted); margin: 7px 0 0; line-height: 1.6; }
.hint-strong { color: #f6d68a; }
.hint-error { color: var(--danger); min-height: 18px; }
.hint-ok { color: var(--accent); }

.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }

/* ------------------------------ Tab ------------------------------ */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--panel-2);
  padding: 4px;
  border-radius: var(--radius);
  margin-bottom: 10px;
}

.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--line-2); color: var(--text); }

/* ------------------------------ 上传区 ------------------------------ */
.drop {
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  outline: none;
}
.drop:hover, .drop:focus-visible, .drop.is-over {
  border-color: var(--accent);
  background: rgba(34, 197, 94, .06);
}

.drop-main { display: block; font-size: 13px; color: var(--text); }
.drop-sub { display: block; font-size: 12px; color: var(--dim); margin-top: 5px; }

.thumb {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.thumb img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 7px;
  background: var(--line);
  flex: none;
}
.thumb-meta { flex: 1; font-size: 12px; color: var(--muted); min-width: 0; word-break: break-all; }

/* ------------------------------ 按钮 ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  padding: 10px 18px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
  line-height: 1.2;
}

.btn-primary { background: var(--accent); color: var(--accent-ink); font-weight: 500; }
.btn-primary:hover { background: #2ee06a; }
.btn-primary:active { background: var(--accent-dk); color: #fff; }

.btn-ghost {
  background: transparent;
  border-color: var(--line-2);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--muted); background: var(--panel-2); }

.btn-sm { font-size: 12px; padding: 6px 12px; }

.btn:disabled { opacity: .45; cursor: not-allowed; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }

/* ------------------------------ 微信预览 ------------------------------ */
.pv-label {
  font-size: 12px;
  color: var(--dim);
  margin: 0 0 8px;
}

.wx {
  background: #ededed;
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
}

.wx-bubble {
  background: #fff;
  border-radius: 6px;
  padding: 10px;
  max-width: 268px;
  position: relative;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .06);
}
.wx-bubble::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 13px;
  width: 10px;
  height: 10px;
  background: #fff;
  transform: rotate(45deg);
  border-radius: 1px;
}

.wx-avatar {
  width: 34px;
  height: 34px;
  border-radius: 4px;
  background: #c8cdd4;
  flex: none;
}

.wx-link { display: flex; gap: 10px; align-items: flex-start; }
.wx-link-text { flex: 1; min-width: 0; }

.wx-link-title {
  font-size: 14px;
  line-height: 1.4;
  color: #1a1a1a;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.wx-link-desc {
  font-size: 12px;
  line-height: 1.45;
  color: #9a9a9a;
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.wx-link-thumb {
  width: 60px;
  height: 60px;
  border-radius: 3px;
  background: #e4e6e9 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23b9bfc7'%3E%3Cpath d='M4 5h16v14H4z' opacity='.25'/%3E%3Cpath d='M6 17l4.5-5.5L14 15l4-4.5v5.5H6z'/%3E%3C/svg%3E") center/26px no-repeat;
  background-size: cover;
  flex: none;
}

.wx-link-src {
  font-size: 11px;
  color: #9a9a9a;
  margin-top: 8px;
}

.wx-moments { display: block; }

.wx-moments-card {
  background: #fff;
  border-radius: 5px;
  width: 210px;
  overflow: hidden;
}

.wx-moments-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #e4e6e9 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23b9bfc7'%3E%3Cpath d='M4 5h16v14H4z' opacity='.25'/%3E%3Cpath d='M6 17l4.5-5.5L14 15l4-4.5v5.5H6z'/%3E%3C/svg%3E") center/34px no-repeat;
  background-size: cover;
}

.wx-moments-title {
  font-size: 13px;
  line-height: 1.45;
  color: #1a1a1a;
  padding: 8px 10px 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.pv-notes {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
}
.pv-notes b { color: var(--text); font-weight: 500; }

/* ------------------------------ 结果区 ------------------------------ */
.result { margin: 16px 22px 0; }

.result-row { display: flex; gap: 8px; flex-wrap: wrap; }
.result-row input { flex: 1; min-width: 240px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

.steps {
  margin: 16px 0 10px;
  padding-left: 20px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.9;
}
.steps b { color: var(--text); font-weight: 500; }

/* ------------------------------ 最近列表 ------------------------------ */
#recentPanel { margin: 16px 22px 0; }

.recent-list { display: grid; gap: 8px; }

.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.recent-item img {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--line);
  flex: none;
}
.recent-item .ri-text { flex: 1; min-width: 0; }
.recent-item .ri-title {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-item .ri-meta { font-size: 11px; color: var(--dim); margin-top: 2px; }
.recent-item .ri-actions { display: flex; gap: 6px; flex: none; }

/* ------------------------------ 弹窗 / Toast ------------------------------ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 11, .78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-box {
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  padding: 22px;
  width: 100%;
  max-width: 340px;
}
.modal-title { font-size: 15px; margin-bottom: 8px; }
.modal-box input { margin: 14px 0 4px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  background: #232a35;
  border: 1px solid var(--line-2);
  color: var(--text);
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 22px;
  z-index: 200;
  pointer-events: none;
}

/* ------------------------------ 页脚 ------------------------------ */
.footer {
  margin: 22px 22px 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--dim);
  line-height: 1.8;
}
.footer p { margin: 0; }

.trouble {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.trouble summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--warn);
  list-style: none;
  outline: none;
}
.trouble summary::-webkit-details-marker { display: none; }
.trouble summary::before { content: "＋ "; }
.trouble[open] summary::before { content: "－ "; }
.trouble[open] summary { margin-bottom: 10px; }
.trouble .hint { color: var(--muted); }
.trouble .hint b { color: var(--text); font-weight: 500; }

.trouble-list {
  margin: 10px 0;
  padding-left: 20px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.9;
}
.trouble-list b { color: var(--text); font-weight: 500; }

.compliance { margin-top: 14px !important; }

.trouble-inline {
  margin: 14px 0 4px;
  background: var(--panel-2);
}
.trouble-inline summary { color: var(--accent); }
.trouble-inline .trouble-list { line-height: 1.85; }
.trouble-inline .trouble-list li { margin-bottom: 8px; }
.trouble-inline .trouble-list li:last-child { margin-bottom: 0; }
