/* 趣AI · 话术教练 —— 原生 CSS，无第三方库 */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --line: #e4e6ea;
  --line-strong: #d3d7de;
  --text: #15181d;
  --text-2: #4b5563;
  --muted: #8b93a1;
  --accent: #0f766e;
  --accent-ink: #0b5d57;
  --accent-soft: #e6f2f0;
  --amber: #a16207;
  --amber-bg: #fef7e0;
  --danger: #b42318;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 28px rgba(16, 24, 40, .06);
  --topbar: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --panel: #161a20;
    --panel-2: #1b2027;
    --line: #262c35;
    --line-strong: #333a45;
    --text: #e8eaee;
    --text-2: #b9c0cb;
    --muted: #7f8896;
    --accent: #2dd4bf;
    --accent-ink: #5eead4;
    --accent-soft: #12312d;
    --amber: #f2c46b;
    --amber-bg: #2d2413;
    --danger: #f97066;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

/* ---------- 登录页 ---------- */
.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 460px at 50% -12%, var(--accent-soft), transparent 62%),
    var(--bg);
}

.login-wrap { width: 100%; max-width: 380px; }

.login-brand { text-align: center; margin-bottom: 22px; }

.login-logo {
  width: 54px; height: 54px; margin: 0 auto 12px;
  display: grid; place-items: center;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  font-size: 26px; font-weight: 700;
  letter-spacing: 1px;
  box-shadow: 0 8px 20px rgba(15, 118, 110, .28);
}

.login-brand h1 { margin: 0; font-size: 26px; letter-spacing: .5px; }
.login-sub { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.field { display: grid; gap: 7px; }
.field > span { font-size: 13px; color: var(--text-2); }

.field input {
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-primary {
  height: 46px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  letter-spacing: .5px;
  transition: filter .15s, transform .06s;
}

.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .6; cursor: default; }

.login-err {
  background: #fff1f0;
  border: 1px solid #ffd7d3;
  color: var(--danger);
  font-size: 13px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
}

@media (prefers-color-scheme: dark) {
  .login-err { background: #2a1512; border-color: #5a2320; }
}

.login-tip { margin: 2px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; margin: 20px 0 0; }

/* ---------- 主框架 ---------- */
.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: var(--topbar) minmax(0, 1fr);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }

.logo {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px; font-weight: 700;
  align-self: center;
}

.brand-name { font-weight: 700; letter-spacing: .4px; }
.brand-sub { color: var(--muted); font-size: 12px; }
.spacer { flex: 1; }

.who { color: var(--text-2); font-size: 13px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.top-link {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
}

.top-link:hover { background: var(--panel-2); border-color: var(--line); }

.main {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 300px;
  min-height: 0;
}

.pane { min-height: 0; min-width: 0; display: flex; flex-direction: column; background: var(--panel); }
.pane-left { border-right: 1px solid var(--line); background: var(--panel-2); }
.pane-mid { position: relative; background: var(--panel); }
.pane-right { border-left: 1px solid var(--line); overflow-y: auto; }

/* 左栏 */
.pane-head { padding: 10px; display: grid; grid-template-columns: 1fr auto; gap: 8px; border-bottom: 1px solid var(--line); }

.search {
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  font-size: 13px;
  outline: none;
  min-width: 0;
}

.search:disabled { background: var(--panel-2); }

.btn-new {
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  border-radius: 9px;
  font-size: 13px;
  color: var(--text-2);
}

.btn-new:disabled { opacity: .55; cursor: default; }

.list { flex: 1; overflow-y: auto; padding: 6px; }

.empty-mini { padding: 26px 14px; text-align: center; color: var(--muted); }
.empty-mini p { margin: 0 0 4px; font-size: 13px; color: var(--text-2); }
.empty-mini span { font-size: 12px; }

.list-foot { padding: 8px 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

/* 中栏 */
.conv-head {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.conv-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.stream {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 120px;
  scroll-behavior: smooth;
}

.empty-main {
  max-width: 460px;
  margin: 8vh auto 0;
  text-align: center;
}

.empty-svg { width: 40px; height: 40px; display: block; margin: 0 auto 12px; color: var(--muted); opacity: .6; }
.empty-main h2 { font-size: 17px; margin: 0 0 8px; line-height: 1.45; }
.empty-main p { color: var(--muted); font-size: 13px; margin: 0 0 18px; line-height: 1.7; }

.steps { display: grid; gap: 8px; justify-items: center; }
.steps span {
  display: inline-block;
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
}

.paste-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(to top, var(--panel) 62%, transparent);
}

.btn-paste {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14.5px;
  box-shadow: 0 8px 20px rgba(15, 118, 110, .24);
}

.btn-paste:disabled { opacity: .5; box-shadow: none; cursor: default; }
.paste-svg { width: 16px; height: 16px; flex: 0 0 auto; }
.paste-hint { color: var(--muted); font-size: 12px; }

/* 右栏 */
.rp-block { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.rp-grow { border-bottom: 0; }
.rp-title { font-size: 12px; font-weight: 700; letter-spacing: 1.2px; color: var(--muted); margin-bottom: 8px; }
.rp-body { font-size: 13.5px; line-height: 1.7; }
.muted { color: var(--muted); }

.rp-toggle {
  margin-left: auto;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-2);
  height: 30px;
  padding: 0 11px;
  border-radius: 8px;
  font-size: 12.5px;
  display: none;
}

/* 移动端底部切换 */
.mobile-tabs { display: none; }

/* 平板：藏右栏，按钮弹出 */
@media (max-width: 1100px) {
  .main { grid-template-columns: 240px minmax(0, 1fr); }
  .pane-right {
    position: fixed;
    top: var(--topbar); right: 0; bottom: 0;
    width: 320px;
    max-width: 86vw;
    z-index: 30;
    border-left: 1px solid var(--line);
    box-shadow: -12px 0 32px rgba(16, 24, 40, .12);
    transform: translateX(102%);
    transition: transform .22s ease;
  }
  body[data-panel="right"] .pane-right { transform: translateX(0); }
  .rp-toggle { display: inline-block; }
}

/* 手机：三屏切换 */
@media (max-width: 720px) {
  .main { grid-template-columns: minmax(0, 1fr); padding-bottom: 54px; }
  .pane-left, .pane-mid, .pane-right { display: none; }
  body[data-view="list"] .pane-left,
  body[data-view="chat"] .pane-mid,
  body[data-view="right"] .pane-right { display: flex; }

  .pane-left { border-right: 0; }

  .pane-right {
    position: static;
    width: auto; max-width: none;
    transform: none;
    box-shadow: none;
    border-left: 0;
    padding-bottom: 16px;
  }

  body[data-panel="right"] .pane-right { transform: none; }
  .rp-toggle { display: none; }

  .mobile-tabs {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: calc(54px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: var(--panel);
    border-top: 1px solid var(--line);
    z-index: 40;
  }

  .mtab {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    position: relative;
  }

  .mtab.on { color: var(--accent); font-weight: 600; }
  .mtab.on::after {
    content: "";
    position: absolute;
    top: 6px; left: 50%;
    width: 18px; height: 3px;
    margin-left: -9px;
    border-radius: 2px;
    background: var(--accent);
  }

  .stream { padding: 14px 14px 110px; }
  .conv-head { padding: 0 12px; }
  .paste-bar { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .btn-paste { flex: 1; justify-content: center; }
  .paste-hint { display: none; }
  .empty-main { margin-top: 4vh; }
  .empty-main h2 { font-size: 16px; }
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%);
  background: #14171c;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 90;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .22);
  max-width: 86vw;
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  .toast { background: #e8eaee; color: #14171c; }
}
