:root {
  --ink: #1b2430;
  --ink-2: #46566b;
  --muted: #6f7f94;
  --faint: #9aa8ba;
  --line: #e4eaf1;
  --line-2: #eef2f7;
  --bg: #f5f7fa;
  --card: #ffffff;
  --brand: #1f6feb;
  --brand-dark: #1a5cc4;
  --brand-soft: #eaf1fe;
  --ok: #0f766e;
  --ok-soft: #e7f4f1;
  --warn: #a16207;
  --warn-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 32, 48, .04), 0 10px 28px -18px rgba(20, 32, 48, .35);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: "SF Mono", Consolas, Menlo, monospace;
  font-size: 13px;
  background: var(--line-2);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ------------------------------------------------------------- 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  height: 58px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.topnav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.topnav form.inline { display: inline; margin: 0; }
.linkbtn {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.linkbtn:hover { color: var(--danger); }

/* ------------------------------------------------------------- 容器 */
.wrap { max-width: 960px; margin: 0 auto; padding: 28px 20px 64px; }
body.centered .wrap { max-width: 460px; padding-top: 12vh; }

.foot {
  text-align: center;
  color: var(--faint);
  font-size: 12px;
  padding: 0 20px 40px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }

h1 { font-size: 22px; margin: 0 0 10px; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 12.5px; }

/* ------------------------------------------------------------- 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card.narrow { padding: 28px; }
.card.center { text-align: center; }
.card h1 { font-size: 19px; margin-bottom: 8px; }
.card > .muted { margin-bottom: 18px; }

.bigcode { font-size: 40px; font-weight: 700; color: #d7dfe9; line-height: 1; margin-bottom: 6px; }

/* ------------------------------------------------------------- 表单 */
.form .field { display: block; margin-bottom: 18px; }
.field > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 7px;
}
.field > span em { font-style: normal; font-weight: 400; color: var(--faint); }

/*
 * 注意：不要用 input[type="text"] 这种属性选择器 —— 没写 type 属性的 input
 * 虽然行为上就是 text，但选择器不匹配，会退回浏览器默认样式（宽度、边框全乱）。
 * 所以这里反过来排除掉 radio / checkbox / file。
 */
input:not([type="radio"]):not([type="checkbox"]):not([type="file"]),
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { resize: vertical; }
input[readonly] { background: var(--line-2); color: var(--ink-2); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-hint { margin-top: 16px; line-height: 1.7; }

/* 类型选择：分段控件
   选中态用 input:checked + span 选中，不用 :has()，
   这样老一点的浏览器内核（学校平板上的 WebView）也能正确显示。 */
.kinds { display: flex; gap: 8px; flex-wrap: wrap; }
.kind {
  position: relative;
  flex: 1 1 0;
  min-width: 110px;
  cursor: pointer;
}
.kind input { position: absolute; opacity: 0; pointer-events: none; }
.kind span {
  display: block;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 8px;
  font-size: 13.5px;
  color: var(--ink-2);
  background: #fff;
  transition: border-color .15s, background .15s, color .15s;
}
.kind:hover span { border-color: #c7d6ea; }
.kind input:checked + span {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 600;
}
.kind input:focus-visible + span {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* 拖放区 */
.dropzone {
  display: block;
  border: 1.5px dashed #c6d3e4;
  border-radius: 11px;
  padding: 26px 18px;
  margin-bottom: 18px;
  text-align: center;
  cursor: pointer;
  background: #fbfcfe;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone strong { display: block; font-size: 14.5px; color: var(--ink-2); margin-bottom: 4px; }
.dropzone .hint { font-size: 12.5px; color: var(--faint); }

.filelist { display: block; margin-top: 12px; font-size: 13px; color: var(--ink-2); }
.filelist .fitem {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-top: 1px dashed var(--line);
  text-align: left;
}
.filelist .fitem span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist .fitem .fsize { color: var(--faint); flex: none; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.primary:disabled { background: #9dbdf0; cursor: default; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { border-color: #c7d6ea; color: var(--ink); }
.btn.danger { background: #fff; border-color: #f0c9c9; color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.block { width: 100%; margin-top: 8px; }

.actions { display: flex; align-items: center; gap: 14px; margin-top: 6px; }

progress { width: 200px; height: 8px; border-radius: 6px; overflow: hidden; }
progress::-webkit-progress-bar { background: var(--line-2); border-radius: 6px; }
progress::-webkit-progress-value { background: var(--brand); border-radius: 6px; }
progress::-moz-progress-bar { background: var(--brand); border-radius: 6px; }

/* ------------------------------------------------------------- 提示 */
.alert {
  background: var(--danger-soft);
  border: 1px solid #f3cccc;
  color: var(--danger);
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 14px;
}
.alert.ok { background: var(--ok-soft); border-color: #bfe3dc; color: var(--ok); }
.alert.warn { background: var(--warn-soft); border-color: #f3e0a8; color: var(--warn); }

/* ------------------------------------------------------------- 表格 */
.tablewrap { padding: 4px 6px; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table .t-title { font-weight: 600; color: var(--ink); }
.table .t-sub { font-size: 12px; color: var(--faint); }
.table .ops { white-space: nowrap; }
.mini {
  display: inline-block;
  font-size: 12.5px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink-2);
  margin-right: 6px;
}
.mini:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }

.pill {
  display: inline-block;
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.pill.active { background: var(--ok-soft); color: var(--ok); }
.pill.expired { background: var(--danger-soft); color: var(--danger); }
.pill.draft { background: var(--line-2); color: var(--muted); }

.empty { text-align: center; padding: 48px 20px; }
.empty p { color: var(--muted); margin: 0 0 16px; }

/* ------------------------------------------------------------- 结果页 */
.result { display: flex; gap: 28px; align-items: flex-start; }
.qr-panel { flex: none; width: 168px; height: 168px; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.qr-panel svg { display: block; width: 100%; height: 100%; }
.qr-panel.small { width: 140px; height: 140px; margin: 12px 0; }
.result-main { flex: 1; min-width: 0; }
.result-main .label { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.linkrow { display: flex; gap: 8px; margin-bottom: 18px; }
.linkrow input { flex: 1; min-width: 0; font-family: "SF Mono", Consolas, Menlo, monospace; font-size: 13.5px; }

.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 20px; margin: 0; }
.kv div { display: flex; gap: 8px; font-size: 13.5px; }
.kv dt { color: var(--muted); margin: 0; }
.kv dd { margin: 0; font-weight: 600; }

/* ------------------------------------------------------------- 清单 */
.itemlist { list-style: none; margin: 0; padding: 0; }
.itemlist li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-2);
}
.itemlist li:last-child { border-bottom: none; }
.badge {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--line-2);
  color: var(--ink-2);
}
.it-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.it-size, .it-meta { color: var(--faint); font-size: 12.5px; flex: none; }
.itemlist .btn { height: 36px; padding: 0 14px; font-size: 13px; flex: none; }

.itemlist.public { padding: 4px 0; }
.itemlist.public li { padding: 14px 0; }
.it-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.it-body .it-name { flex: none; }

/* ------------------------------------------------------------- 公开页 */
.public-head { text-align: center; padding: 18px 0 22px; }
.public-head h1 { font-size: 24px; margin-bottom: 8px; }
.public-head .note { color: var(--ink-2); margin: 0 auto 12px; max-width: 34em; font-size: 14.5px; }
.meta-row { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.tag {
  font-size: 12.5px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 3px 12px;
}

.qr-details summary {
  cursor: pointer;
  font-size: 13.5px;
  color: var(--muted);
  list-style: none;
}
.qr-details summary::-webkit-details-marker { display: none; }
.qr-details[open] summary { margin-bottom: 6px; color: var(--ink-2); }

/* ------------------------------------------------------------- 危险区 */
.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-color: #f0dede;
}
.danger-zone h2 { margin-bottom: 4px; }

/* ------------------------------------------------------------- 响应式 */
@media (max-width: 700px) {
  .wrap { padding: 20px 14px 48px; }
  .card { padding: 18px; }
  .grid2 { grid-template-columns: 1fr; }
  .result { flex-direction: column; align-items: center; text-align: center; }
  .result-main { width: 100%; text-align: left; }
  .kv { grid-template-columns: 1fr; }
  .kinds { flex-direction: column; }
  .kind { min-width: 0; }

  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  .table td { border: none; padding: 4px 12px; }
  .table td::before {
    content: attr(data-label);
    display: inline-block;
    width: 5em;
    color: var(--faint);
    font-size: 12px;
  }
  .table td.ops::before { content: ""; width: 0; }
  .tablewrap { padding: 4px; }

  .public-head h1 { font-size: 20px; }
  .itemlist li { flex-wrap: wrap; }
  .it-body { flex-basis: calc(100% - 60px); }

  /* 手机上把下载按钮拉成通栏，手指好点 */
  .itemlist.public li { row-gap: 12px; }
  .itemlist.public li .btn { width: 100%; height: 40px; font-size: 14px; }
}

/* --------------------------------------------------------------- 首页 */
.home-actions { margin: 22px 0 18px; }
.card code,
p code {
  font-family: "SF Mono", Consolas, Menlo, monospace;
  font-size: 12px;
  background: var(--line-2, #eef2f7);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  overflow-wrap: anywhere;
}

/* 链接过长时二维码退化为文字提示 */
.qr-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  text-align: center;
}
