/* 离线翻译 —— 移动优先,深色为主,跟随系统切浅色 */

:root {
  --bg: #0b0c14;
  --surface: #141726;
  --surface-2: #1c2032;
  --border: #272b3f;
  --text: #e8e9f2;
  --text-dim: #9297ae;
  --text-faint: #656a82;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-text: #ffffff;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5fa;
    --surface: #ffffff;
    --surface-2: #f0f1f7;
    --border: #e0e2ec;
    --text: #14162a;
    --text-dim: #5c6178;
    --text-faint: #8b90a6;
    --accent: #5b5ee6;
    --accent-2: #7c4fe0;
    --ok: #0f9d6e;
    --warn: #b57d00;
    --err: #d64545;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* iOS 刘海/home 条安全区 */
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  min-height: 100dvh;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 14px 40px;
}

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 14px;
}

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

.brand img {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  flex: none;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px 10px;
  white-space: nowrap;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: none;
}

.dot.on { background: var(--ok); }
.dot.off { background: var(--warn); }

/* ---------- 卡片 ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.card.tight { padding: 12px 14px; }

/* ---------- 首次下载引导 ---------- */

.setup h2 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
}

.setup p {
  margin: 0 0 12px;
  font-size: 13.5px;
  color: var(--text-dim);
}

.setup p strong { color: var(--text); font-weight: 600; }

.progress-wrap { margin-top: 4px; }

.progress {
  height: 8px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}

.progress > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s ease;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 7px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 方向切换 ---------- */

.dirbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.lang {
  flex: 1;
  text-align: center;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  padding: 6px 4px;
  min-width: 0;
}

.swap {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.swap:active { background: var(--accent); color: var(--accent-text); }
.swap.spin { transform: rotate(180deg); }

/* ---------- 输入 / 输出 ---------- */

textarea {
  width: 100%;
  min-height: 130px;
  resize: vertical;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: 1.65;
  padding: 0;
}

textarea::placeholder { color: var(--text-faint); }

.io-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.out-body {
  min-height: 130px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  -webkit-user-select: text;
  user-select: text;
}

.out-body.empty {
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 14px;
}

.out-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.out-head span {
  font-size: 12.5px;
  color: var(--text-dim);
  font-weight: 500;
}

/* ---------- 按钮 ---------- */

button {
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 13px;
  padding: 6px 13px;
  border-radius: 99px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn:active { background: var(--border); color: var(--text); }
.btn:disabled { opacity: 0.4; cursor: default; }

.btn-primary {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 15px;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-text);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  cursor: pointer;
  margin-bottom: 12px;
  transition: opacity 0.15s, transform 0.08s;
}

.btn-primary:active:not(:disabled) { transform: scale(0.985); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 13.5px;
  cursor: pointer;
  width: 100%;
}

.btn-ghost:active { background: var(--surface-2); }

/* ---------- 提示条 ---------- */

.note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.55;
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
}

.note b { color: var(--text); font-weight: 600; }
/* 自检结果是多行纯文本,要保留换行;长 URL/报错要能断行不撑破布局 */
.note > div { white-space: pre-wrap; word-break: break-word; min-width: 0; }
.note.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.note.err  { border-color: color-mix(in srgb, var(--err) 45%, var(--border)); color: var(--err); }
.note .ico { flex: none; font-size: 15px; line-height: 1.35; }

/* ---------- 底部信息 ---------- */

.foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-faint);
}

.foot-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-variant-numeric: tabular-nums;
}

.foot-row span:last-child { color: var(--text-dim); text-align: right; }

.foot-actions { margin-top: 14px; }

/* ---------- 工具类 ---------- */

.hidden { display: none !important; }

.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 7px;
}

@keyframes spin { to { transform: rotate(360deg); } }

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