/* ==========================================================================
   授权中心 & 激活码管理 —— 页面专属样式
   （独立文件，符合 CSP style-src 'self'）
   ========================================================================== */

/* ---------------------------------------------------------- 登录/注册页 */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 34px 30px;
  box-shadow: var(--shadow);
}
.auth-brand {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .2px;
  margin-bottom: 4px;
}
.auth-brand em { font-style: normal; color: var(--green); }
.auth-desc {
  font-size: 13px;
  color: var(--ink-3);
  margin-bottom: 24px;
}
.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}
.auth-tabs a {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  font-size: 13.5px;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  transition: color .12s, border-color .12s;
}
.auth-tabs a:hover { color: var(--ink-2); text-decoration: none; }
.auth-tabs a.on {
  color: var(--green);
  border-bottom-color: var(--green);
  font-weight: 500;
}
.auth-field { margin-bottom: 16px; }
.auth-row { display: flex; gap: 8px; }
.auth-row input { flex: 1; }
.auth-row button {
  white-space: nowrap;
  font-size: 13px;
  padding: 9px 14px;
}
.auth-submit {
  width: 100%;
  padding: 11px;
  margin-top: 4px;
  font-size: 14px;
}
.auth-hint {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.9;
}
.auth-hint b {
  display: block;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 12.5px;
  margin-bottom: 6px;
}
.auth-msg {
  margin-bottom: 16px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: none;
  line-height: 1.6;
}
.auth-msg.ok {
  display: block;
  background: var(--green-soft);
  border: 1px solid #d8e8de;
  color: var(--green-dark);
}
.auth-msg.err {
  display: block;
  background: var(--red-soft);
  border: 1px solid #f0dbd9;
  color: var(--red);
}

/* ---------------------------------------------------------- 我的设备页 */
.acct-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--ink-3);
}
.acct-nav a { color: var(--ink-2); }
.acct-nav a:hover { color: var(--green); text-decoration: none; }

.redeem-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.redeem-row input { flex: 1; min-width: 200px; }
.redeem-row input.pair-input { max-width: 210px; }

.net-hint {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.8;
}
.net-hint code {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 12px;
  color: var(--ink-2);
}

.pair {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--amber);
}

.redeem-msg {
  margin-top: 14px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: none;
  line-height: 1.6;
}
.redeem-msg.ok {
  display: block;
  background: var(--green-soft);
  border: 1px solid #d8e8de;
  color: var(--green-dark);
}
.redeem-msg.err {
  display: block;
  background: var(--red-soft);
  border: 1px solid #f0dbd9;
  color: var(--red);
}

.btn-pick { font-size: 12px; padding: 5px 11px; }

/* ---------------------------------------------------------- 激活码管理页 */
.gen-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.gen-row .num { width: 96px; }
.gen-row .note { flex: 1; min-width: 200px; }

.gen-result {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  background: var(--green-soft);
  border: 1px solid #d8e8de;
  display: none;
}
.gen-result .ttl {
  font-size: 12.5px;
  color: var(--green-dark);
  font-weight: 600;
  margin-bottom: 10px;
}
.gen-result .codes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.gen-result .codes span {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13.5px;
  letter-spacing: .5px;
  background: #fff;
  border: 1px solid #d8e8de;
  border-radius: 4px;
  padding: 5px 11px;
  color: var(--green-dark);
  font-weight: 600;
}

.code-cell {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  letter-spacing: .5px;
  font-weight: 600;
  color: var(--ink);
}

.op-msg {
  margin-top: 14px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: none;
  line-height: 1.6;
}
.op-msg.ok {
  display: block;
  background: var(--green-soft);
  border: 1px solid #d8e8de;
  color: var(--green-dark);
}
.op-msg.err {
  display: block;
  background: var(--red-soft);
  border: 1px solid #f0dbd9;
  color: var(--red);
}

.btn-xs { font-size: 12px; padding: 4px 10px; }


/* ============ 客户端下载 ============ */
.dl-grid {
  display: grid;
  /* minmax(0, 1fr) 而非 minmax(300px, 1fr)：
     后者在窄屏会强制 300px 撑破容器 */
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 14px;
  margin: 4px 0 18px;
  /* 桌面端两块并排，窄屏自动单列 */
  max-width: 100%;
}

/* 宽度 ≥ 620px 时两列，否则一列 */
@media (min-width: 620px) {
  .dl-grid { grid-template-columns: 1fr 1fr; }
}

.dl-card {
  display: flex;
  align-items: center;
  gap: 14px;
  box-sizing: border-box;
  /* 关键：允许收缩，防止内容撑破 grid 轨道 */
  min-width: 0;
  max-width: 100%;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: border-color .16s, box-shadow .16s;
}

.dl-card:hover {
  border-color: var(--green);
  box-shadow: 0 3px 10px rgba(45, 106, 79, .1);
}

.dl-icon {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--green-soft);
  color: var(--green);
  border-radius: var(--radius);
}

.dl-icon svg {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
}

.dl-body {
  flex: 1 1 auto;
  /* min-width:0 让 flex 子项可以窄于内容宽度 */
  min-width: 0;
  overflow: hidden;
}

.dl-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
}

.dl-tag {
  display: inline-block;
  flex: 0 0 auto;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 9px;
  white-space: nowrap;
}

.dl-desc {
  margin-top: 3px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink);
  opacity: .62;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dl-meta {
  margin-top: 6px;
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink);
  opacity: .5;
  /* 允许多行，不再 nowrap 撑破 */
  line-height: 1.5;
  word-break: break-all;
}

.dl-sep {
  opacity: .45;
  margin: 0 2px;
}

.dl-action {
  flex: 0 0 auto;
  padding: 7px 15px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  background: var(--green);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: background .16s;
}

.dl-card:hover .dl-action {
  background: var(--green-dark);
}

/* ---- 安装提示 ---- */
.dl-tips {
  box-sizing: border-box;
  max-width: 100%;
  padding: 14px 18px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink);
}

.dl-tips b {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.dl-tips ul {
  margin: 0;
  padding-left: 18px;
  opacity: .72;
}

.dl-tips li + li {
  margin-top: 2px;
}

/* ============ 窄屏适配 ============ */
@media (max-width: 560px) {
  /* 容器内边距收窄，给卡片留空间 */
  .auth-wrap {
    padding: 14px;
  }

  main {
    padding-left: 0;
    padding-right: 0;
  }

  .section {
    padding-left: 14px;
    padding-right: 14px;
    box-sizing: border-box;
  }

  .dl-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 14px;
  }

  .dl-card {
    padding: 12px 13px;
    gap: 10px;
  }

  .dl-icon {
    width: 42px;
    height: 42px;
  }

  .dl-icon svg {
    width: 23px;
    height: 23px;
  }

  .dl-title {
    font-size: 14px;
    gap: 3px 6px;
  }

  .dl-tag {
    font-size: 10px;
    padding: 1px 6px;
  }

  .dl-desc {
    font-size: 12px;
    white-space: normal;
  }

  .dl-meta {
    font-size: 11px;
    line-height: 1.45;
  }

  /* 手机上「下载」按钮改小，避免挤占文本区 */
  .dl-action {
    padding: 6px 12px;
    font-size: 12px;
  }

  .dl-tips {
    padding: 11px 13px;
    font-size: 12.5px;
  }

  .dl-tips ul {
    padding-left: 15px;
  }

  /* 修复已有的激活输入框在手机上溢出 */
  .redeem-row input {
    min-width: 0;
    flex: 1 1 100%;
  }

  .redeem-row input.pair-input,
  .redeem-row input.name-input {
    max-width: none;
  }

  .redeem-row button {
    flex: 1 1 100%;
  }
}

/* ============ 超窄屏（≤360px）======= */
@media (max-width: 360px) {
  .dl-card {
    flex-wrap: wrap;
  }

  .dl-body {
    flex: 1 1 100%;
    padding-left: 0;
  }

  .dl-action {
    flex: 1 1 100%;
    text-align: center;
  }
}


/* ============ 设备信息展示 ============ */
.dev-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}

.dev-spec {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin-top: 3px;
}

.spec-item {
  display: inline-block;
  padding: 1px 6px;
  font-size: 11px;
  line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 3px;
  white-space: nowrap;
}

.spec-item.quiet {
  color: var(--ink);
  background: transparent;
  opacity: .5;
  padding-left: 0;
  padding-right: 0;
}

.spec-item.quiet + .spec-item.quiet:before {
  content: "·";
  margin-right: 4px;
  opacity: .6;
}

.dev-vid {
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--ink);
  opacity: .38;
  letter-spacing: .2px;
}

/* ---- 播放计数 ---- */
.cnt-today {
  font-weight: 600;
  color: var(--green);
}

.cnt-sep {
  margin: 0 2px;
  opacity: .35;
}

.cnt-total {
  opacity: .5;
}

/* ---- 手机上压缩表格 ---- */
@media (max-width: 720px) {
  .dev-spec {
    gap: 3px 5px;
  }

  .spec-item {
    font-size: 10px;
    padding: 1px 5px;
  }

  .dev-vid {
    display: none;
  }
}

/* 设备页小字补充 */
.muted.small {
  font-size: 11.5px;
  line-height: 1.7;
  margin-top: 2px;
}

.muted.small strong {
  font-weight: 600;
}

/* ============ 解析额度 ============ */
.quota-box {
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.quota-bar {
  height: 10px;
  background: var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.quota-fill {
  height: 100%;
  background: var(--green);
  border-radius: 5px;
  transition: width .3s ease;
}

.quota-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 9px;
  font-size: 12.5px;
  color: var(--ink);
  opacity: .75;
}

.quota-meta b {
  font-weight: 600;
  font-size: 13.5px;
}

.quota-remain {
  color: var(--green);
}

.quota-remain.quota-low {
  color: var(--red);
}

.quota-remain.quota-low b {
  color: var(--red);
}

@media (max-width: 560px) {
  .quota-box {
    padding: 11px 13px;
  }

  .quota-meta {
    font-size: 12px;
  }

  .quota-meta b {
    font-size: 13px;
  }
}

/* ============ 一键复制按钮 ============ */
.gen-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.gen-result-actions {
  display: flex;
  gap: 8px;
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: #fff;
  background: var(--green);
  border: 1px solid var(--green);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
}

.btn-copy:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
}

.btn-copy.ghost {
  color: var(--green);
  background: transparent;
  border-color: var(--line-strong);
}

.btn-copy.ghost:hover {
  background: var(--green-soft);
  border-color: var(--green);
}

.btn-copy svg {
  flex: 0 0 auto;
}

/* ============ 配额管理页 ============ */
.quota-email {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  word-break: break-all;
}

.quota-input {
  width: 74px;
  padding: 4px 7px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  text-align: right;
}

.quota-input:focus {
  outline: 2px solid var(--green);
  outline-offset: -1px;
  border-color: var(--green);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.switch input {
  width: 15px;
  height: 15px;
  accent-color: var(--green);
  cursor: pointer;
}

.btn-save.has-change {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
  font-weight: 600;
}

/* ---- toast ---- */
.quota-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  padding: 9px 20px;
  font-size: 13.5px;
  color: #fff;
  background: var(--green);
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(31, 36, 32, .22);
  opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 9999;
  max-width: 88vw;
  text-align: center;
}

.quota-toast.err {
  background: var(--red);
}

.quota-toast.show,
.quota-toast {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.quota-toast.out {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
}

@media (max-width: 720px) {
  .gen-result-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .gen-result-actions {
    width: 100%;
  }

  .btn-copy {
    flex: 1;
    justify-content: center;
  }

  .quota-input {
    width: 64px;
  }
}
