/* ============================================================
   双语通 · 设计系统
   一份 CSS 供四个页面共用（登录 / 主界面 / 管理后台 / 组件）
   原则：克制的配色、统一的间距节奏、明确的层级、够大的触控区
   ============================================================ */

/* ============================================================
   1. 主题令牌
   ============================================================ */

:root {
  /* ---------- 品牌色：一个主蓝，三种用法 ---------- */
  --brand: #1668e3;             /* 主色：填充按钮、选中态 */
  --brand-dark: #0f52b8;        /* 悬停/按下 */
  --brand-ink: #0b3f8f;         /* 深色文字（用在浅底上） */
  --brand-soft: #eef4ff;        /* 极浅底：选中背景、提示条 */
  --brand-soft-2: #dde9fd;      /* 浅底加深：hover */
  --brand-line: #c3d9fb;        /* 浅底上的描边 */
  --brand-ring: rgba(22, 104, 227, .22);   /* 焦点环 */

  /* ---------- 辅助色：交流模式乙方 ---------- */
  --accent: #f0813c;
  --accent-dark: #d96a24;
  --accent-soft: #fff4ec;
  --accent-line: #ffd9bd;

  /* ---------- 语义色 ---------- */
  --ok: #12a150;
  --ok-soft: #e9f8ef;
  --ok-line: #a9e3c1;
  --warn: #b26a00;
  --warn-soft: #fff6e5;
  --warn-line: #f2d59a;
  --danger: #dc3a3f;
  --danger-dark: #bf2c31;
  --danger-soft: #fdeeee;
  --danger-line: #f6c0c1;

  /* ---------- 中性色阶 ---------- */
  --bg: #f2f5fa;               /* 页面底 */
  --card: #ffffff;             /* 卡片面 */
  --card-2: #f7f9fc;           /* 浅面：表头、次级区块 */
  --card-3: #eff3f9;           /* 更深一档：hover 底 */
  --line: #e6ebf2;             /* 常规描边 */
  --line-strong: #d3dbe6;      /* 输入框/按钮描边 */

  --text: #131c29;             /* 标题、正文强调 */
  --text-2: #55637a;           /* 正文次要 */
  --text-3: #8b96a8;           /* 说明、占位 */

  /* ---------- 圆角 ---------- */
  --r-xs: 8px;
  --r-sm: 10px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* ---------- 阴影：三层，越往上越"浮" ---------- */
  --shadow-1: 0 1px 2px rgba(19, 28, 41, .04), 0 1px 3px rgba(19, 28, 41, .06);
  --shadow-2: 0 2px 6px rgba(19, 28, 41, .06), 0 8px 24px rgba(19, 28, 41, .08);
  --shadow-3: 0 8px 20px rgba(19, 28, 41, .10), 0 24px 56px rgba(19, 28, 41, .16);

  /* ---------- 间距节奏（4 的倍数） ---------- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* ---------- 字阶 ---------- */
  --fs-xs: 12px;
  --fs-sm: 13.5px;
  --fs-body: 15px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 21px;
  --fs-2xl: 26px;

  /* ---------- 控件高度 ---------- */
  --h-xs: 30px;
  --h-sm: 36px;
  --h-md: 44px;                /* 桌面默认 */
  --h-lg: 52px;                /* 手机默认 / 强调按钮 */
  --h-xl: 60px;
  --tap: 44px;                 /* 旧名，保持兼容 */

  --ease: cubic-bezier(.2, .7, .3, 1);
}

/* ============================================================
   2. 基础
   ============================================================ */

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

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--brand-soft-2); color: var(--brand-ink); }

/* 统一焦点样式：键盘可达性，也是"做得细"的体现 */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
button:focus:not(:focus-visible) { outline: none; }

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.rtl { direction: rtl; text-align: right; }

/* ============================================================
   3. 排版
   ============================================================ */

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.32; letter-spacing: -.2px; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0; }

.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }

/* ============================================================
   4. 按钮
   尺寸只由 height + padding + font-size 三个变量决定，
   改一处即可整体调比例，不会再出现"这个按钮比那个高一点"。
   ============================================================ */

.btn {
  --btn-h: var(--h-md);
  --btn-px: var(--sp-5);
  --btn-fs: var(--fs-body);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--btn-h);
  padding: 0 var(--btn-px);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--card);
  color: var(--text);
  font-size: var(--btn-fs);
  font-family: inherit;
  font-weight: 550;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  transition: background .14s var(--ease), border-color .14s var(--ease),
    color .14s var(--ease), box-shadow .14s var(--ease), transform .08s var(--ease);
}
.btn:hover { border-color: var(--brand-line); background: var(--brand-soft); color: var(--brand-ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .48; cursor: not-allowed; transform: none; }
.btn:disabled:hover { border-color: var(--line-strong); background: var(--card); color: var(--text); }

.btn-primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 1px 2px rgba(22, 104, 227, .28);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-primary:disabled:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--card-3); color: var(--text); }

.btn-danger { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.btn-block { width: 100%; }
.btn-lg { --btn-h: 52px; --btn-px: var(--sp-6); --btn-fs: var(--fs-md); border-radius: var(--r-lg); }
.btn-sm { --btn-h: var(--h-sm); --btn-px: var(--sp-4); --btn-fs: var(--fs-sm); border-radius: var(--r-sm); }
.btn-xs { --btn-h: var(--h-xs); --btn-px: var(--sp-3); --btn-fs: var(--fs-xs); border-radius: var(--r-xs); }

.btn .btn-loading { display: inline-flex; align-items: center; gap: var(--sp-2); }

/* ============================================================
   5. 表单
   ============================================================ */

.field { display: block; margin-bottom: var(--sp-4); }
.field > .label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 550;
  color: var(--text-2);
  margin-bottom: var(--sp-2);
}
.input, .select, .textarea {
  width: 100%;
  min-height: var(--h-md);
  padding: 11px var(--sp-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--card);
  color: var(--text);
  font-size: var(--fs-md);
  font-family: inherit;
  line-height: 1.5;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--brand-line); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3.5px var(--brand-ring);
}
.textarea { resize: vertical; min-height: 118px; }
.select { cursor: pointer; }

.field-hint { font-size: var(--fs-xs); color: var(--text-3); margin-top: 6px; }

.switch {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-sm); color: var(--text-2); cursor: pointer;
}
.switch input { width: 18px; height: 18px; accent-color: var(--brand); }

/* ============================================================
   6. 卡片与布局
   ============================================================ */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: var(--sp-5); }

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--sp-4);
  padding-bottom: calc(var(--sp-6) + env(safe-area-inset-bottom));
}

.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

.divider { height: 1px; background: var(--line); margin: var(--sp-4) 0; }

/* ============================================================
   7. 顶栏（登录页与管理后台共用；主界面另有专用顶栏）
   ============================================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  padding-top: calc(var(--sp-3) + env(safe-area-inset-top));
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.3px;
}
/* 品牌图标统一做成圆角色块 + 白色线条，和左侧导航的品牌标识保持一致 */
.topbar .brand svg {
  width: 30px; height: 30px;
  flex: none;
  padding: 4px;
  border-radius: var(--r-xs);
  color: #fff;
  background: linear-gradient(140deg, var(--brand) 0%, #4b93ff 100%);
  box-shadow: 0 3px 10px rgba(22, 104, 227, .26);
}

/* ============================================================
   8. 徽章
   ============================================================ */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 22px;
  padding: 1px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 550;
  background: var(--card-2);
  color: var(--text-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.badge-brand { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-line); }

/* ============================================================
   9. 提示条
   ============================================================ */

.alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r);
  font-size: var(--fs-sm);
  line-height: 1.65;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text-2);
}
.alert b, .alert strong { font-weight: 650; }
.alert-info { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-ink); }
.alert-ok { background: var(--ok-soft); border-color: var(--ok-line); color: #0b7a3c; }
.alert-warn { background: var(--warn-soft); border-color: var(--warn-line); color: #8a5300; }
.alert-danger { background: var(--danger-soft); border-color: var(--danger-line); color: #b32b30; }

/* ============================================================
   10. Toast
   ============================================================ */

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sp-6) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: 92vw;
}
.toast {
  padding: 11px 20px;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 550;
  color: #fff;
  background: #1b2534;
  box-shadow: var(--shadow-3);
  animation: toast-in .2s var(--ease);
  text-align: center;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
.toast.warn { background: #b8791a; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   11. 弹层
   ============================================================ */

.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 36, .48);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  animation: mask-in .16s var(--ease);
}
@keyframes mask-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  padding: var(--sp-6);
  animation: modal-in .2s var(--ease);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to { opacity: 1; transform: none; }
}
.modal h3 {
  margin-bottom: var(--sp-5);
  font-size: var(--fs-xl);
  letter-spacing: -.3px;
}
.modal > .row:last-child { margin-top: var(--sp-5); }

/* ============================================================
   12. 表格
   ============================================================ */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  min-width: 660px;
}
table.data th, table.data td {
  padding: 11px var(--sp-3);
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data th {
  background: var(--card-2);
  font-weight: 600;
  color: var(--text-2);
  font-size: var(--fs-xs);
  letter-spacing: .2px;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .12s var(--ease); }
table.data tbody tr:hover { background: var(--card-2); }

/* ============================================================
   13. 加载 / 空态
   ============================================================ */

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
  flex: none;
}
.spinner.dark { border-color: var(--line-strong); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-sm);
}

/* ============================================================
   14. 「我的」面板
   （这一整块以前完全没有样式，是界面显粗糙的主因之一）
   ============================================================ */

.me-head {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--brand-soft) 0%, #fbfdff 70%);
}
.me-avatar {
  width: 56px; height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--brand) 0%, #4b93ff 100%);
  color: #fff;
  font-size: var(--fs-xl);
  font-weight: 650;
  letter-spacing: .5px;
  box-shadow: 0 4px 14px rgba(22, 104, 227, .3);
  user-select: none;
}
.me-name {
  font-size: var(--fs-lg);
  font-weight: 650;
  line-height: 1.35;
  color: var(--text);
}

/* 额度框 */
.quota-box {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--card-2);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.quota-box-main {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-3);
  border-bottom: 1px dashed var(--line-strong);
}
.quota-box-main strong {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--brand);
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
}
.quota-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-3);
}
.quota-grid > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.quota-grid > div b {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 订单行 */
.order-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  margin-bottom: var(--sp-2);
}
.order-row .grow { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* 套餐卡 */
.plan-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--card);
  margin-bottom: var(--sp-2);
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.plan-card:hover { border-color: var(--brand-line); box-shadow: var(--shadow-1); }
.plan-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.plan-name { font-size: var(--fs-md); font-weight: 650; color: var(--text); }
.plan-meta { font-size: var(--fs-xs); color: var(--text-3); }
.plan-price {
  flex: none;
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--brand);
  letter-spacing: -.3px;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   15. 语言选择列表
   （同样以前完全没有样式）
   ============================================================ */

.lang-body {
  max-height: 52vh;
  overflow-y: auto;
  margin: 0 calc(var(--sp-2) * -1);
  padding: 0 var(--sp-2);
}
.lang-region {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: var(--sp-2) var(--sp-3);
  margin-top: var(--sp-1);
  font-size: var(--fs-xs);
  font-weight: 650;
  letter-spacing: .6px;
  color: var(--text-3);
  background: linear-gradient(180deg, var(--card) 72%, rgba(255, 255, 255, 0));
}
.lang-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  width: 100%;
  min-height: var(--h-md);
  padding: 10px var(--sp-3);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-md);
  text-align: left;
  cursor: pointer;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.lang-row:hover { background: var(--brand-soft); }
.lang-row .code {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.lang-row.on {
  background: var(--brand-soft);
  border-color: var(--brand-line);
  color: var(--brand-ink);
  font-weight: 600;
}
.lang-row.on .code { color: var(--brand); }

/* ============================================================
   16. 滚动条
   ============================================================ */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: #cbd5e3;
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #b3c0d2; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* 触摸设备上不显示滚动条，避免误以为可拖动 */
@media (hover: none) {
  ::-webkit-scrollbar { width: 0; height: 0; }
}

/* ============================================================
   17. 响应式：手机上调大控件、拉开间距
   ============================================================ */

@media (max-width: 700px) {
  :root {
    --fs-body: 15px;
    --h-md: 48px;      /* 拇指可点 */
    --h-lg: 54px;
  }
  .modal {
    padding: var(--sp-5) var(--sp-4);
    border-radius: var(--r-lg);
    max-height: 90vh;
  }
  .quota-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan-card { flex-direction: column; align-items: stretch; gap: var(--sp-3); }
  .plan-price { font-size: var(--fs-lg); }
  .order-row { flex-wrap: wrap; }
  .modal h3 { font-size: var(--fs-lg); }
  .me-avatar { width: 48px; height: 48px; font-size: var(--fs-lg); }
}

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