/* ============ WAShot — 深色工具编辑器 + WhatsApp iOS 预览 ============ */
:root {
  --bg: #0c0c0c;
  --panel: #141414;
  --panel-2: #1b1b1b;
  --line: #262626;
  --text: #f5f5f5;
  --muted: #95959f;
  --accent: #00a884;
  --accent-deep: #165f49;
  --danger: #e5534b;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24rem;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- 左侧舞台 ---------- */
.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background:
    radial-gradient(circle at 1px 1px, #222 1px, transparent 1.5px) 0 0 / 26px 26px,
    var(--bg);
}
.stage-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 18px 28px 0;
  user-select: none;
}
.brand-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
  align-self: center;
  animation: pulse 2s cubic-bezier(.4,0,.6,1) infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.brand-name { font-weight: 700; letter-spacing: .02em; }
.brand-sub { color: var(--muted); font-size: 12.5px; }
.stage-canvas {
  flex: 1;
  display: grid;
  place-items: start center;
  overflow: auto;
  padding: 24px 16px 48px;
}
.phone-scale { transition: transform .25s ease-out; transform-origin: top center; }

/* 完整对话预览:手机随内容拉长 */
.phone.full { height: auto; min-height: 844px; }
.phone.full .chat-scroll { overflow: visible; height: auto; }

/* ---------- 手机外壳 ---------- */
.phone {
  width: 390px;
  height: 844px;
  border-radius: 56px;
  background: #000;
  padding: 11px;
  box-shadow:
    0 0 0 2px #2a2a2e,
    0 30px 80px rgba(0,0,0,.65),
    0 4px 18px rgba(0,0,0,.5);
  position: relative;
}
.screen {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 46px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.dynamic-island {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 112px;
  height: 32px;
  border-radius: 20px;
  background: #000;
  z-index: 5;
}
.home-indicator {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 128px;
  height: 5px;
  border-radius: 3px;
  background: rgba(0,0,0,.55);
  z-index: 5;
}
.screen.theme-dark .home-indicator { background: rgba(255,255,255,.5); }

/* ---------- 主题变量(手机内部) ---------- */
.screen.theme-light {
  --wa-chrome: #f6f6f6;
  --wa-chrome-text: #111b21;
  --wa-chrome-sub: #667781;
  --wa-link: #027eb5;
  --wa-chat-bg: #ece5dd;
  --wa-out: #e7ffdb;
  --wa-in: #ffffff;
  --wa-text: #111b21;
  --wa-meta: #667781;
  --wa-pill-date-bg: #e2f2fb;
  --wa-pill-date-text: #54656f;
  --wa-pill-e2e-bg: #fdefc3;
  --wa-pill-e2e-text: #54656f;
  --wa-field: #ffffff;
  --wa-field-hint: #8696a0;
  --wa-header-icon: #007aff;
  --doodle-opacity: .5;
  background: var(--wa-chat-bg);
}
.screen.theme-dark {
  --wa-chrome: #161d22;
  --wa-chrome-text: #e9edef;
  --wa-chrome-sub: #8696a0;
  --wa-link: #53bdeb;
  --wa-chat-bg: #0b141a;
  --wa-out: #005c4b;
  --wa-in: #1f2c34;
  --wa-text: #e9edef;
  --wa-meta: #8696a0;
  --wa-pill-date-bg: #182229;
  --wa-pill-date-text: #8696a0;
  --wa-pill-e2e-bg: #182229;
  --wa-pill-e2e-text: #ffd279;
  --wa-field: #1f2c34;
  --wa-field-hint: #8696a0;
  --wa-header-icon: #0aaef2;
  --doodle-opacity: .35;
  background: var(--wa-chat-bg);
}

/* ---------- 状态栏 ---------- */
.statusbar {
  height: 54px;
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 30px 0;
  background: var(--wa-chrome);
  color: var(--wa-chrome-text);
  font-size: 15px;
  font-weight: 600;
  position: relative;
  z-index: 4;
}
.sb-icons { display: flex; align-items: center; gap: 7px; }
.sb-ic { width: 18px; height: 12px; fill: currentColor; }
.sb-batt {
  width: 25px; height: 12px;
  border: 1.4px solid currentColor;
  border-radius: 3.5px;
  position: relative;
  display: inline-block;
  opacity: .9;
}
.sb-batt::after {
  content: "";
  position: absolute;
  right: -4px; top: 3px;
  width: 2px; height: 5px;
  border-radius: 0 2px 2px 0;
  background: currentColor;
}
.sb-batt i {
  position: absolute;
  left: 1.5px; top: 1.5px; bottom: 1.5px;
  border-radius: 1.5px;
  background: currentColor;
  display: block;
}

/* ---------- WhatsApp 头部 ---------- */
.wa-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 8px 4px;
  background: var(--wa-chrome);
  color: var(--wa-chrome-text);
  position: relative;
  z-index: 4;
  box-shadow: 0 .5px 0 rgba(0,0,0,.08);
}
.wa-back { width: 11px; height: 19px; stroke: var(--wa-header-icon); flex: none; margin-left: 4px; }
.wa-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  flex: none;
  background: linear-gradient(135deg, #b2c9d6, #7d97a6);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 600;
  overflow: hidden;
}
.wa-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wa-peer { flex: 1; min-width: 0; }
.wa-name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-status { font-size: 12px; color: var(--wa-chrome-sub); margin-top: -1px; }
.wa-actions { display: flex; gap: 20px; padding-right: 4px; }
.wa-ic { width: 21px; height: 21px; fill: var(--wa-header-icon); }
.wa-actions .wa-ic:last-child { fill: none; stroke: var(--wa-header-icon); stroke-width: 1.8; }

/* ---------- 聊天区 ---------- */
.chat {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--wa-chat-bg);
}
.chat-scroll {
  height: 100%;
  overflow-y: auto;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: rgba(128,128,128,.45) transparent;
}
.chat-scroll::-webkit-scrollbar { width: 5px; }
.chat-scroll::-webkit-scrollbar-thumb { background: rgba(128,128,128,.45); border-radius: 3px; }
.chat-inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px 8px;
  min-height: 100%;
}
.chat::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--wa-wallpaper, none);
  background-size: var(--wa-wallpaper-size, auto);
  opacity: var(--doodle-opacity, .4);
  pointer-events: none;
}
.chat.doodle::before { background-image: url("../assets/doodle.svg"); background-size: 300px; }
.chat.solid::before { display: none; }
.chat > * { position: relative; }

.pill {
  align-self: center;
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 8px;
  margin: 4px 0 2px;
  max-width: 88%;
  text-align: center;
  box-shadow: 0 1px .5px rgba(11,20,26,.13);
}
.pill.date { background: var(--wa-pill-date-bg); color: var(--wa-pill-date-text); text-transform: none; }
.pill.e2e { background: var(--wa-pill-e2e-bg); color: var(--wa-pill-e2e-text); line-height: 1.4; }
.pill.e2e b { font-weight: 600; }

/* ---------- 消息气泡 ---------- */
.msg { display: flex; margin: 2.5px 0; }
.msg.out { justify-content: flex-end; }
.msg.in { justify-content: flex-start; }
.bubble {
  position: relative;
  max-width: 76%;
  padding: 6px 8px 7px 9px;
  border-radius: 10px;
  font-size: 15.5px;
  line-height: 1.32;
  color: var(--wa-text);
  box-shadow: 0 1px .5px rgba(11,20,26,.13);
  word-break: break-word;
}
.msg.out .bubble { background: var(--wa-out); border-top-right-radius: 0; }
.msg.in .bubble { background: var(--wa-in); border-top-left-radius: 0; }
.bubble::before {
  content: "";
  position: absolute;
  top: 0;
  width: 8px;
  height: 13px;
  background: inherit;
}
.msg.out .bubble::before { right: -7.5px; clip-path: polygon(0 0, 100% 0, 0 100%); }
.msg.in .bubble::before { left: -7.5px; clip-path: polygon(100% 0, 0 0, 100% 100%); }
.msg.out .bubble::before { background: var(--wa-out); }
.msg.in .bubble::before { background: var(--wa-in); }

.bubble .txt { white-space: pre-wrap; }
.bubble .txt b { font-weight: 700; }
.bubble .txt i { font-style: italic; }
.bubble .txt s { text-decoration: line-through; }
.bubble .txt code {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 14px;
  background: rgba(0,0,0,.06);
  padding: 0 3px;
  border-radius: 4px;
}
.theme-dark .bubble .txt code { background: rgba(255,255,255,.08); }
.bubble .txt a { color: var(--wa-link); text-decoration: none; word-break: break-all; }
.bubble .txt .quote {
  display: block;
  border-left: 3px solid #00a884;
  background: rgba(0,0,0,.05);
  padding: 4px 8px;
  border-radius: 0 6px 6px 0;
  margin: 3px 0;
}
.theme-dark .bubble .txt .quote { background: rgba(255,255,255,.06); }

.meta {
  float: right;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--wa-meta);
  margin: 8px 0 -2px 8px;
  transform: translateY(2px);
  user-select: none;
}
.meta svg { width: 16px; height: 11px; }
.meta .tick-single { width: 11px; }

/* 图片消息 */
.bubble.img { padding: 4px; }
.bubble.img img.ph {
  display: block;
  max-width: 260px;
  max-height: 320px;
  border-radius: 8px;
  object-fit: cover;
}
.bubble.img .cap { padding: 5px 5px 2px; }
.bubble.img .cap .meta { margin-top: 6px; }

/* 语音消息 */
.bubble.voice { display: flex; align-items: center; gap: 8px; min-width: 200px; padding: 8px 10px; }
.vn-play {
  width: 34px; height: 34px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  background: #00a884;
}
.theme-dark .msg.out .vn-play { background: #00a884; }
.msg.in .vn-play { background: #8696a0; }
.vn-play svg { width: 13px; height: 14px; fill: #fff; margin-left: 1.5px; }
.vn-wave { display: flex; align-items: center; gap: 2px; height: 26px; flex: 1; }
.vn-wave i { width: 2.5px; border-radius: 2px; background: #8696a0; display: block; }
.vn-dur { font-size: 11.5px; color: var(--wa-meta); flex: none; align-self: flex-end; margin-bottom: 1px; white-space: nowrap; }
.bubble.voice .meta { float: none; flex: none; align-self: flex-end; margin: 0 0 1px 2px; transform: none; white-space: nowrap; }
.meta { white-space: nowrap; }

/* ---------- 输入栏 ---------- */
.wa-inputbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 26px;
  background: var(--wa-chrome);
}
.wa-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--wa-field);
  border-radius: 22px;
  padding: 9px 12px;
  min-width: 0;
}
.theme-dark .wa-field { border: .5px solid rgba(255,255,255,.12); }
.wa-field-hint { flex: 1; color: var(--wa-field-hint); font-size: 16px; white-space: nowrap; overflow: hidden; }
.wa-field-ic { width: 24px; height: 24px; stroke: #8696a0; fill: none; flex: none; }
.wa-field-ic:first-child { fill: #8696a0; stroke: #8696a0; stroke-width: 0; }
.wa-field-ic:first-child path, .wa-field-ic:first-child circle { stroke: #8696a0; }
.wa-field-ic:first-child circle:not(:first-child) { fill: #8696a0; stroke: none; }
.wa-mic {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: #00a884;
  display: grid;
  place-items: center;
  flex: none;
}
.wa-mic svg { width: 20px; height: 20px; fill: #fff; }

/* ---------- 右侧面板 ---------- */
.panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  min-height: 0;
}
.panel-scroll {
  height: 100dvh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}
.sec { padding: 20px 20px 4px; border-bottom: 1px solid var(--line); padding-bottom: 20px; }
.sec:last-child { border-bottom: none; }
.sec-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sec-count {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0 8px;
  font-size: 11px;
  color: var(--text);
}

.fld { display: block; margin-bottom: 12px; }
.fld-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; }

input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 11px;
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s ease-out;
}
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible {
  border-color: var(--accent);
  outline: 2px solid transparent;
}
select { appearance: none; cursor: pointer; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease-out, transform .1s ease-out, border-color .15s;
}
.btn:hover { background: #232323; border-color: #3a3a3a; }
.btn:active { transform: scale(.97); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #04241c;
}
.btn.primary:hover { background: #06c494; border-color: #06c494; }
.btn.big { padding: 12px 16px; font-size: 14.5px; }
.btn.wide { width: 100%; margin-bottom: 8px; }

.seg {
  display: flex;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px;
  gap: 3px;
  margin-bottom: 12px;
}
.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 0;
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s ease-out, color .15s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--accent-deep); color: #d9fff3; }

.hint { font-size: 12px; color: var(--muted); margin: 8px 0 12px; line-height: 1.6; }
.hint code {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 11.5px;
  color: #d4d4d8;
}
.time-input { max-width: 72px; text-align: center; flex: none; }
.ticks-input { flex: 1; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; margin-bottom: 12px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* 滑杆 */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #2c2c2c;
  outline: none;
  padding: 0;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}
.slider::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}
.fld-label b { color: var(--text); font-weight: 600; margin-left: 4px; }

/* 对话存档 */
.row.wrap { flex-wrap: wrap; }
.hint.err { color: #ff8a80; }
.conv-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.conv {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.conv:hover { border-color: #3a3a3a; }
.conv.active { border-color: var(--accent); background: rgba(0,168,132,.08); }
.conv-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11.5px; color: var(--muted); flex: none; }
.btn.danger:hover { background: rgba(229,83,75,.15); border-color: var(--danger); color: var(--danger); }

/* 导出模式列表 */
.exp-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.exp-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 14px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background .15s ease-out, border-color .15s, transform .1s ease-out;
}
.exp-item:hover { background: #202020; border-color: #3a3a3a; }
.exp-item:active { transform: scale(.98); }
.exp-item .exp-name { font-size: 13.5px; font-weight: 600; }
.exp-item .exp-desc { font-size: 12px; color: var(--muted); }

/* 壁纸色板 */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw {
  width: 44px; height: 32px;
  border-radius: 8px;
  border: 2px solid var(--line);
  cursor: pointer;
  transition: border-color .15s, transform .1s;
  padding: 0;
}
.sw:hover { transform: scale(1.06); }
.sw.active { border-color: var(--accent); }

/* ---------- 消息列表项 ---------- */
.msg-list { display: flex; flex-direction: column; gap: 8px; }
.mi {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  transition: border-color .15s;
}
.mi:hover { border-color: #3a3a3a; }
.mi-head { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; flex-wrap: wrap; }
.mi-dir {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  flex: none;
  cursor: pointer;
  border: none;
}
.mi-dir.out { background: rgba(0,168,132,.18); color: #3ed8b2; }
.mi-dir.in { background: rgba(149,149,159,.16); color: #b9b9c2; }
.mi-type { font-size: 11px; color: var(--muted); flex: none; }
.mi-head input.mi-time {
  width: 64px;
  flex: none;
  text-align: center;
  padding: 3px 4px !important;
  font-size: 12px !important;
}
.mi-tools { margin-left: auto; display: flex; gap: 2px; flex: none; }
.mi-tools button {
  border: none;
  background: transparent;
  color: var(--muted);
  width: 26px; height: 26px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  display: grid;
  place-items: center;
  transition: background .12s, color .12s;
}
.mi-tools button:hover { background: #2a2a2a; color: var(--text); }
.mi-tools button.del:hover { background: rgba(229,83,75,.15); color: var(--danger); }
.mi textarea { font-size: 13px; min-height: 40px; padding: 7px 9px; }
.mi .mi-extra { display: flex; gap: 6px; margin-top: 7px; }
.mi .mi-extra select { font-size: 12px; padding: 5px 8px; }
.mi-img-thumb { max-height: 60px; border-radius: 6px; display: block; }
.empty-tip { color: var(--muted); font-size: 13px; text-align: center; padding: 18px 0; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow: visible; height: auto; }
  .stage { min-height: 0; }
  .stage-canvas { padding: 24px 8px 40px; }
  .panel { border-left: none; border-top: 1px solid var(--line); }
  .panel-scroll { height: auto; overflow: visible; }
}

@media (prefers-reduced-motion: reduce) {
  .brand-dot { animation: none; }
  .phone-scale, .btn, .sw { transition: none; }
}
