/* ============================================================
   微博会话管家 — Apple/iOS 风格设计系统
   浅色 / 深色自动适配（prefers-color-scheme），移动端优先
   ============================================================ */

:root {
  /* 系统色（iOS 语义色） */
  --blue: #007AFF;
  --green: #34C759;
  --red: #FF3B30;
  --orange: #FF9500;
  --yellow: #FFCC00;
  --purple: #AF52DE;
  --teal: #5AC8FA;
  --gray: #8E8E93;

  /* 浅色表面 */
  --bg: #F2F2F7;
  --bg-elevated: #FFFFFF;
  --fill: rgba(120, 120, 128, 0.12);
  --fill-strong: rgba(120, 120, 128, 0.2);
  --card: rgba(255, 255, 255, 0.72);
  --card-solid: #FFFFFF;
  --hairline: rgba(60, 60, 67, 0.12);
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.35);
  --nav-bg: rgba(249, 249, 249, 0.82);
  --tab-bg: rgba(249, 249, 249, 0.92);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-strong: 0 4px 12px rgba(0, 0, 0, 0.1), 0 16px 40px rgba(0, 0, 0, 0.12);
  --overlay: rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elevated: #1C1C1E;
    --fill: rgba(120, 120, 128, 0.24);
    --fill-strong: rgba(120, 120, 128, 0.36);
    --card: rgba(28, 28, 30, 0.72);
    --card-solid: #1C1C1E;
    --hairline: rgba(255, 255, 255, 0.1);
    --label: #FFFFFF;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.35);
    --nav-bg: rgba(22, 22, 24, 0.82);
    --tab-bg: rgba(22, 22, 24, 0.92);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-strong: 0 4px 12px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.5);
    --overlay: rgba(0, 0, 0, 0.55);
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", "Helvetica Neue", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--label);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶部导航（大标题 + 毛玻璃） ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--hairline);
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 20px 12px;
}
.nav-inner { max-width: 760px; margin: 0 auto; }
.nav-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.35px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", sans-serif;
}
.nav-sub { font-size: 13px; color: var(--label-2); margin-top: 2px; }
.nav-sub b { color: var(--blue); font-weight: 600; }

/* ---------- 主区域 ---------- */
.main {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px calc(env(safe-area-inset-bottom, 0px) + 96px);
}

/* ---------- 分组卡片（iOS Settings 风格） ---------- */
.group { margin-bottom: 28px; }
.group-title {
  font-size: 13px;
  font-weight: 400;
  color: var(--label-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 16px 8px;
}
.card {
  background: var(--card);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
@media (prefers-color-scheme: dark) {
  .card { background: var(--card-solid); }
}

/* 列表行 */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 44px;
  position: relative;
}
.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  height: 0.5px;
  background: var(--hairline);
}
.row-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #fff;
}
.row-icon svg { width: 17px; height: 17px; }
.row-body { flex: 1; min-width: 0; }
.row-label { font-size: 15px; }
.row-sub { font-size: 12px; color: var(--label-2); margin-top: 1px; }
.row-value { font-size: 15px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.row-value.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- 会话主卡片 ---------- */
.session-card { padding: 24px 20px 20px; text-align: center; }
.avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 600;
  color: #fff;
  box-shadow: var(--shadow-strong);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.session-name { font-size: 21px; font-weight: 700; }
.session-uid { font-size: 13px; color: var(--label-2); margin-top: 2px; font-variant-numeric: tabular-nums; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--fill);
  color: var(--label-2);
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.ok { background: rgba(52, 199, 89, 0.15); color: var(--green); }
.badge.bad { background: rgba(255, 59, 48, 0.15); color: var(--red); }
.badge.warn { background: rgba(255, 149, 0, 0.15); color: var(--orange); }

/* TTL 进度条 */
.ttl-block { margin-top: 18px; text-align: left; }
.ttl-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--label-2); margin-bottom: 6px; }
.ttl-head b { color: var(--label); font-variant-numeric: tabular-nums; font-weight: 600; }
.ttl-track { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.ttl-fill { height: 100%; border-radius: 3px; background: var(--green); transition: width 0.6s ease, background 0.3s; }

/* ---------- 按钮（iOS 填充/普通） ---------- */
.btn {
  appearance: none;
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  user-select: none;
}
.btn:active { transform: scale(0.96); opacity: 0.85; }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-plain { background: var(--fill); color: var(--blue); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; margin-top: 16px; }
.btn-row .btn { flex: 1; }

/* ---------- 分段控件 ---------- */
.segmented {
  display: flex;
  background: var(--fill);
  border-radius: 10px;
  padding: 2px;
  margin: 0 0 16px;
  position: relative;
}
.segmented button {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--label-2);
  padding: 7px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.2s;
  position: relative;
  z-index: 1;
  white-space: nowrap;
}
.segmented button.active { color: var(--label); }
.segmented .thumb {
  position: absolute;
  top: 2px;
  bottom: 2px;
  background: var(--card-solid);
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: left 0.25s cubic-bezier(0.32, 0.72, 0, 1), width 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 0;
}

/* ---------- 表单 ---------- */
.field { padding: 12px 16px; }
/* 字段分隔线用绝对定位伪元素：不再参与流/弹性布局，也不会像负外边距那样把整行顶偏 */
.field + .field { position: relative; padding-top: 12.5px; }
.field + .field::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0.5px;
  background: var(--hairline);
}
/* 一行内并排两个控件（如 验证码 + 发送验证码），用 flex 而不是给 .field 加 inline style */
.field-row { display: flex; align-items: flex-end; gap: 10px; }
.field-row .field-main { flex: 1 1 auto; min-width: 0; }
.field-row .btn { flex: 0 0 auto; white-space: nowrap; }
.field label { display: block; font-size: 12px; color: var(--label-2); margin-bottom: 4px; }
.field input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  color: var(--label);
  outline: none;
  padding: 2px 0;
}
.field input::placeholder { color: var(--label-3); }

/* ---------- 二维码面板 ---------- */
.qr-panel { padding: 24px 16px; text-align: center; }
.qr-frame {
  width: 200px;
  height: 200px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.qr-frame img { width: 180px; height: 180px; }
.qr-frame .placeholder { color: #C7C7CC; font-size: 13px; }
.qr-status { font-size: 13.5px; color: var(--label-2); min-height: 20px; }
.qr-status.ok { color: var(--green); font-weight: 600; }
.qr-status.err { color: var(--red); }
.qr-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--blue);
  text-decoration: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Cookie 列表 ---------- */
.cookie-item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; }
.cookie-item + .cookie-item::before {
  content: "";
  position: absolute;
}
.cookie-name {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  font-weight: 700;
  min-width: 92px;
}
.cookie-name.important { color: var(--blue); }
.cookie-meta { flex: 1; min-width: 0; font-size: 11.5px; color: var(--label-2); }
.cookie-meta .dom { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cookie-ttl { text-align: right; font-size: 11.5px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.cookie-ttl b { display: block; font-size: 12.5px; color: var(--label); }

/* ---------- 调试面板 ---------- */
.method-row { display: flex; gap: 10px; padding: 12px 16px; align-items: center; }
.method-select {
  appearance: none;
  border: none;
  background: var(--fill);
  color: var(--blue);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: 8px;
  padding: 8px 10px;
}
.url-input { flex: 1; }
.url-input input { font-size: 14px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.resp-view {
  margin-top: 12px;
  background: var(--bg-elevated);
  border-radius: 12px;
  padding: 14px 16px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 380px;
  overflow: auto;
  color: var(--label-2);
  border: 0.5px solid var(--hairline);
}
.resp-view .ok { color: var(--green); }
.resp-view .err { color: var(--red); }

/* ---------- 底部标签栏（移动端） ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  background: var(--tab-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--hairline);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar button {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  color: var(--label-3);
  padding: 7px 0 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  transition: color 0.2s;
}
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button.active { color: var(--blue); }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  color: var(--label);
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-strong);
  border: 0.5px solid var(--hairline);
  animation: toast-in 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  max-width: 86%;
  text-align: center;
}
.toast.ok { color: var(--green); }
.toast.err { color: var(--red); }
.toast.leaving { animation: toast-out 0.3s ease forwards; }
@keyframes toast-in {
  from { transform: translateY(-16px) scale(0.92); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes toast-out {
  to { transform: translateY(-12px) scale(0.95); opacity: 0; }
}

/* ---------- 加载指示器 ---------- */
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.btn-plain .spinner { border-color: var(--fill-strong); border-top-color: var(--blue); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 空状态 ---------- */
.empty { padding: 44px 20px; text-align: center; color: var(--label-3); }
.empty svg { width: 44px; height: 44px; margin-bottom: 10px; opacity: 0.5; }
.empty p { font-size: 14px; }

/* ---------- 面板切换 ---------- */
.panel { display: none; animation: panel-in 0.3s cubic-bezier(0.32, 0.72, 0, 1); }
.panel.active { display: block; }
/* 登录方式分页：三块卡片只能显示当前选中的那块（缺了这两行，三块会同时铺在页面上，切换看似无效） */
.login-pane { display: none; }
.login-pane.active { display: block; }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 桌面端适配（≥768px） ---------- */
@media (min-width: 768px) {
  body { font-size: 16px; }
  .nav { padding-top: calc(env(safe-area-inset-top, 0px) + 20px); }
  .nav-title { font-size: 32px; }
  .main { padding-top: 24px; padding-bottom: 48px; }

  /* 标签栏上移为顶部胶囊导航 */
  .tabbar {
    position: sticky;
    top: 0;
    left: auto;
    right: auto;
    max-width: 760px;
    margin: 0 auto;
    border-top: none;
    border-bottom: 0.5px solid var(--hairline);
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 10px 16px;
    gap: 6px;
  }
  .tabbar button {
    flex-direction: row;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 999px;
    gap: 6px;
  }
  .tabbar button.active { background: var(--blue); color: #fff; }
  .tabbar button svg { width: 17px; height: 17px; }
  .nav { position: static; }
  .main { padding-bottom: 24px; }

  .qr-frame { width: 220px; height: 220px; }
  .qr-frame img { width: 200px; height: 200px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================================================
   多通道（web / wap）
   ============================================================ */

/* 导航内的通道切换 */
.chan-switch { display: flex; gap: 8px; margin-top: 12px; }
.chan-switch button {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  align-items: flex-start;
  padding: 8px 12px;
  border-radius: 12px;
  border: 0.5px solid var(--hairline);
  background: var(--fill);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}
.chan-switch button:active { transform: scale(0.98); }
.chan-switch button.active {
  background: var(--card-solid);
  border-color: rgba(0, 122, 255, 0.55);
  box-shadow: 0 2px 10px rgba(0, 122, 255, 0.14);
}
.chan-label { font-size: 13.5px; font-weight: 600; color: var(--label); }
.chan-site { font-size: 11px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.chan-switch button.active .chan-label { color: var(--blue); }

/* 总览行 */
.overview-row { cursor: pointer; }
.overview-row:active { background: var(--fill); }
.ov-mark {
  width: 4px;
  align-self: stretch;
  border-radius: 2px;
  background: var(--fill-strong);
  flex-shrink: 0;
  margin: 4px 0;
}
.overview-row.current .ov-mark { background: var(--blue); }
.overview-row .row-label { font-weight: 600; }
.ov-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.ov-state { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.ov-state .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ov-state.ok { color: var(--green); }
.ov-state.bad { color: var(--red); }
.ov-state.idle { color: var(--gray); }
.ov-ttl { font-size: 11px; color: var(--label-3); font-variant-numeric: tabular-nums; }

/* 会话卡上方的通道标识 */
.session-chan {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--blue);
  background: rgba(0, 122, 255, 0.12);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

/* 登录面板通道提示 */
.login-chan-hint {
  font-size: 12.5px;
  color: var(--label-2);
  padding: 0 16px 10px;
}
.login-chan-hint b { color: var(--label); font-weight: 600; }

/* 接口调试预置 */
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 2px 0; }
.preset-chip {
  appearance: none;
  border: 0.5px solid var(--hairline);
  background: var(--fill);
  color: var(--label-2);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.preset-chip:hover { background: var(--fill-strong); color: var(--label); }
.preset-chip:active { transform: scale(0.97); }

/* ---------- 访问密码（login.php） ---------- */
.nav-inner { position: relative; }
.nav-tools {
  position: absolute;
  top: 4px;
  right: 0;
  display: flex;
  gap: 6px;
  align-items: center;
}

.nav-tool {
  font-size: 12.5px;
  line-height: 1;
  color: var(--label-2);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--fill);
  transition: background 0.2s, color 0.2s;
}
.nav-tool:hover { background: var(--fill-strong); color: var(--label); }
.nav-tool:active { transform: scale(0.96); }

.nav-logout {
  position: absolute;
  top: 4px;
  right: 0;
  font-size: 12.5px;
  line-height: 1;
  color: var(--label-2);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--fill);
  transition: background 0.2s, color 0.2s;
}
.nav-logout:hover { background: var(--fill-strong); color: var(--label); }
.nav-logout:active { transform: scale(0.96); }

.gate-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 40px;
}
.gate-wrap { width: 100%; max-width: 420px; }
.gate-card {
  padding: 28px 20px 20px;
  text-align: center;
}
.gate-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fill);
  color: var(--blue);
}
.gate-icon svg { width: 26px; height: 26px; }
.gate-title { font-size: 20px; font-weight: 650; margin: 0 0 6px; color: var(--label); }
.gate-sub {
  font-size: 13px;
  line-height: 1.55;
  color: var(--label-2);
  margin: 0 auto 18px;
  max-width: 300px;
}
.gate-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 59, 48, 0.12);
  color: #d70015;
  font-size: 13px;
  text-align: left;
}
@media (prefers-color-scheme: dark) {
  .gate-error { background: rgba(255, 69, 58, 0.16); color: #ff6961; }
}
.gate-card .field { text-align: left; padding: 12px 0 0; }
.gate-card .field + .field { padding-top: 12.5px; }
.gate-card .field + .field::before { left: 0; right: 0; }
.gate-card .field input {
  background: var(--fill);
  border-radius: 10px;
  padding: 11px 12px;
}
.gate-actions { padding: 18px 0 4px; }
.gate-foot {
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--label-3, var(--label-2));
  margin: 6px 0 0;
}
.gate-foot code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: var(--fill);
  padding: 1px 5px;
  border-radius: 5px;
}

