:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #e4e7eb;
  --text: #1f2933;
  --muted: #7b8794;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --danger: #dc2626;
  --ok: #059669;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
}
.logout { margin: 0; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
h1 { font-size: 20px; margin: 0; }
.count {
  display: inline-block;
  min-width: 22px;
  padding: 1px 7px;
  margin-left: 4px;
  border-radius: 11px;
  background: #eef2ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
}

.flash {
  margin-bottom: 18px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
}

.empty {
  padding: 48px;
  text-align: center;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* table */
table.subs {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.subs th, .subs td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.subs th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.subs tr:last-child td { border-bottom: none; }
.subs .name { font-weight: 600; overflow-wrap: anywhere; }
.subs .time { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ops-col { width: 1%; }

/* the flex row lives in a wrapper, not on the <td> — a flex table cell drops
   out of the row box and its borders stop lining up with its neighbours */
.cell-link { display: flex; align-items: center; gap: 8px; }
.url {
  display: inline-block;
  /* prefers 360px but shrinks with the column; min-width:0 removes the
     flex-item floor that would otherwise widen the whole table */
  flex: 0 1 360px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 8px;
  background: #f3f4f6;
  border-radius: 6px;
  font-size: 12px;
  color: #374151;
}
.cell-link .btn { flex: none; }
.cell-ops { display: flex; gap: 6px; align-items: center; }
.cell-ops > * { flex: none; }
.cell-ops form { margin: 0; }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f3f4f6; }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.danger { color: var(--danger); border-color: #fcd2d2; }
.btn.danger:hover { background: #fef2f2; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: #f3f4f6; }
.btn.block { width: 100%; justify-content: center; margin-top: 12px; }
.btn.copy.ok { color: var(--ok); border-color: #a7f3d0; background: #ecfdf5; }
.btn .hint { font-weight: 400; opacity: .8; }

/* cards / forms */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.login-card { max-width: 340px; margin: 64px auto; }
.login-card h1 { margin-bottom: 18px; }

.form label, .login-card label {
  display: block;
  margin-bottom: 18px;
  font-weight: 600;
}
.hint { display: inline; font-weight: 400; color: var(--muted); font-size: 12px; }
.content-head { display: flex; align-items: center; gap: 10px; }

input[type=text], input[type=password], textarea {
  width: 100%;
  margin-top: 7px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea {
  min-height: 360px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}
.actions { margin-top: 4px; }

/* ---- mobile / narrow screens ----
   860px is where the 4-column table stops fitting: its intrinsic minimum is
   ~760px plus the container's 32px of padding. Below that it becomes cards. */
@media (max-width: 860px) {
  .topbar { padding: 0 16px; }
  .container { padding: 20px 16px 48px; }
  .toolbar { flex-wrap: wrap; gap: 12px; }
  .empty { padding: 36px 20px; }

  /* the 4-column table becomes one card per subscription */
  .subs, .subs tbody, .subs tr, .subs td { display: block; }
  .subs thead { display: none; }
  /* must out-specify the base `table.subs` rule, not just `.subs` */
  table.subs {
    border: none;
    border-radius: 0;
    background: transparent;
    overflow: visible;
  }
  .subs tr {
    margin-bottom: 12px;
    padding: 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
  .subs tr:last-child { margin-bottom: 0; }
  .subs td { padding: 0; border-bottom: none; }
  .subs .name { margin-bottom: 8px; font-size: 15px; }
  .subs .url { flex: 1 1 auto; padding: 6px 10px; }
  .subs .time { margin: 10px 0 12px; font-size: 12px; }
  .subs .time::before { content: "更新于 "; }
  .subs .cell-ops { gap: 8px; }
  .subs .cell-ops > * { flex: 1; }
  .subs .cell-ops .btn { justify-content: center; width: 100%; }

  /* touch targets */
  .btn { padding: 9px 14px; }
  .btn.small { padding: 8px 12px; font-size: 13px; }

  /* forms: 16px keeps iOS from zooming in on focus */
  .card { padding: 18px 16px; }
  .login-card { margin: 40px auto; }
  input[type=text], input[type=password] { font-size: 16px; }
  textarea { min-height: 50vh; font-size: 16px; }
  .form label .hint { display: block; margin-top: 2px; }
  .content-head { flex-wrap: wrap; }
  .actions .btn { width: 100%; justify-content: center; }
  .actions .btn .hint { display: none; }  /* no ⌘/Ctrl+S on a phone */
}
