:root {
  color-scheme: dark;
  --bg: #0b1020;
  --bg2: #0f1730;
  --card: #151d36;
  --line: #263252;
  --text: #eef2ff;
  --muted: #93a0bd;
  --accent: #5b8cff;
  --accent2: #8b5cf6;
  --ok: #3ddc97;
  --warn: #ffb020;
  --err: #ff5c6c;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1b2a57 0%, transparent 60%),
    radial-gradient(800px 400px at 100% 0%, #2a1a4a 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Segoe UI", Roboto, sans-serif;
}

body {
  min-height: 100dvh;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding:
    calc(18px + env(safe-area-inset-top))
    16px
    calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- 顶部 ---------- */
.head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 2px;
}

.logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 24px;
  background: linear-gradient(135deg, #2b3a70, #1a2244);
  border: 1px solid var(--line);
}

.head h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.5px;
}

.head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- 卡片 ---------- */
.card {
  background: linear-gradient(180deg, rgba(26, 35, 62, 0.92), rgba(18, 25, 46, 0.92));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.field {
  display: block;
  margin-bottom: 10px;
}

.field span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0d1428;
  color: var(--text);
  font-size: 15px;
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.18);
}

.field select {
  width: 100%;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0d1428;
  color: var(--text);
  font-size: 15px;
  outline: none;
  appearance: none;
}

.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.18);
}

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

.btn {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #121a33;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

.btn:disabled {
  opacity: 0.45;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
}

.btn.ghost {
  background: transparent;
}

.tip {
  margin: 10px 0 0;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- 状态 ---------- */
.status {
  align-self: center;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  transition: all 0.2s ease;
}

.status.ok {
  color: var(--ok);
  border-color: rgba(61, 220, 151, 0.35);
  background: rgba(61, 220, 151, 0.08);
}

.status.warn {
  color: var(--warn);
  border-color: rgba(255, 176, 32, 0.35);
  background: rgba(255, 176, 32, 0.08);
}

.status.err {
  color: var(--err);
  border-color: rgba(255, 92, 108, 0.4);
  background: rgba(255, 92, 108, 0.08);
}

/* ---------- 模式切换 ---------- */
.modes {
  display: flex;
  gap: 8px;
  padding: 0 2px;
}

.mode {
  flex: 1;
  padding: 11px 6px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #121a33;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.mode.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 22px rgba(91, 140, 255, 0.25);
}

/* ---------- 说话按钮 ---------- */
.talk-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 0 2px;
}

.talk {
  position: relative;
  width: 176px;
  height: 176px;
  border-radius: 50%;
  border: none;
  color: #fff;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.25), transparent 45%),
    linear-gradient(145deg, #5b8cff, #7c4dff 55%, #4a2fb0);
  box-shadow: 0 18px 45px rgba(80, 90, 255, 0.35), inset 0 0 0 2px rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.talk:disabled {
  filter: grayscale(0.7) brightness(0.6);
  box-shadow: none;
}

.talk.active {
  transform: scale(0.96);
  box-shadow: 0 0 0 14px rgba(91, 140, 255, 0.16), 0 0 60px rgba(124, 77, 255, 0.65);
}

.talk-icon {
  font-size: 34px;
  line-height: 1;
}

.talk-text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1px;
}

.hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ---------- 对话记录 ---------- */
.chat {
  padding: 12px 12px 6px;
}

.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  padding: 0 4px 8px;
}

.link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  padding: 4px;
}

.log {
  max-height: 34dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 2px 10px;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin: 18px 0;
}

.msg {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2f6bff, #4b53d6);
  border-bottom-right-radius: 4px;
}

.msg.ai {
  align-self: flex-start;
  background: #1d2745;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.msg.sys {
  align-self: center;
  background: rgba(255, 92, 108, 0.1);
  border: 1px solid rgba(255, 92, 108, 0.3);
  color: #ffb3ba;
  font-size: 12px;
}

/* ---------- 调试 ---------- */
.debug summary {
  font-size: 12px;
  color: var(--muted);
  outline: none;
}

.debug pre {
  margin: 10px 0 0;
  max-height: 26dvh;
  overflow: auto;
  font-size: 11px;
  line-height: 1.5;
  color: #9fb0d0;
  white-space: pre-wrap;
  word-break: break-all;
}
