:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e5e9ef;
  --accent: #1d4ed8;
  --accent-soft: #eff4ff;
  --danger: #dc2626;
  --ok: #15803d;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  background-image:
    radial-gradient(900px 400px at 100% -10%, #e8effb 0%, transparent 60%),
    radial-gradient(700px 380px at -10% 110%, #eef2f7 0%, transparent 55%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.brand .mark {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: linear-gradient(145deg, #1d4ed8, #0f172a);
  position: relative;
  box-shadow: 0 4px 10px -3px rgba(29, 78, 216, .6);
}

.brand .mark::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 2px;
  background: #fff;
}

.tagline {
  color: var(--ink-3);
  font-size: 13.5px;
}

/* ---------- 用户区 ---------- */
.userbar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-2);
}

.userbar .who {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}

.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #0f172a;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0;
}

.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 9px; }

/* ---------- 布局 ---------- */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .92fr);
  gap: 20px;
  align-items: stretch;
}

@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  .app { padding: 20px 14px 48px; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-body { padding: 22px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }

.label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 7px;
  letter-spacing: .01em;
}

.label .hint { font-weight: 400; color: var(--ink-3); font-size: 12px; }

textarea, input[type="text"], input[type="password"], select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfcfd;
  padding: 11px 13px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s, background .15s;
  outline: none;
}

textarea {
  min-height: 148px;
  resize: vertical;
  line-height: 1.65;
}

textarea:focus, input:focus, select:focus {
  border-color: #b9cdf5;
  background: #fff;
  box-shadow: 0 0 0 3.5px rgba(29, 78, 216, .1);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%2394a3b8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
  cursor: pointer;
}

.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 62px; }

.pwd-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.pwd-toggle:hover { background: #f1f5f9; color: var(--ink-2); }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .row2 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 11px 18px;
  font-size: 14.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .06s, border-color .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: translateY(.5px); }

.btn-primary {
  background: var(--ink);
  color: #fff;
  width: 100%;
  padding: 13px 18px;
  box-shadow: 0 6px 18px -8px rgba(15, 23, 42, .6);
}
.btn-primary:hover { background: #1e293b; }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }

.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink-2);
}
.btn-ghost:hover { border-color: #cfd8e3; background: #fbfcfd; }

.btn-soft {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #dbe6fd;
}
.btn-soft:hover { background: #e4edff; }

.msg {
  margin-top: 12px;
  font-size: 13px;
  min-height: 18px;
  color: var(--danger);
}

/* ---------- 结果区 ---------- */
.result { min-height: 420px; display: flex; flex-direction: column; }

.result-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 24px;
  color: var(--ink-3);
  text-align: center;
}

.result-empty .glyph {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  border: 1.5px dashed #cfd8e3;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}
.result-empty .glyph svg { width: 28px; height: 28px; opacity: .55; }
.result-empty strong { color: var(--ink-2); font-weight: 600; font-size: 14.5px; }
.result-empty p { margin: 0; font-size: 13px; max-width: 230px; }

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.tabs {
  display: inline-flex;
  background: #f1f4f8;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.tab {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink-3);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .1);
}

.badge {
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--mono);
  letter-spacing: .02em;
}

.preview {
  padding: 16px 16px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background:
    linear-gradient(#fff, #fff) padding-box,
    repeating-linear-gradient(45deg, #fbfcfe 0 10px, #f7f9fc 10px 20px);
}

.preview canvas {
  display: block;
  max-width: 100%;
  max-height: 420px;
  width: auto;
  height: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 12px -5px rgba(15, 23, 42, .22);
}

.result-meta { padding: 14px 20px 20px; }

.link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 8px 8px 12px;
  margin-bottom: 14px;
}

.link-box code {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-box .btn { padding: 6px 11px; font-size: 12.5px; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.note {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.55;
  display: flex;
  gap: 7px;
}
.note::before { content: "·"; }
.note span { flex: 1; }

.warn {
  margin-top: 12px;
  font-size: 12.5px;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 9px;
  padding: 9px 12px;
  line-height: 1.5;
}

/* ---------- 历史记录 ---------- */
.history-panel { margin-top: 20px; overflow: hidden; }

.history-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.history-head h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -.01em;
}

.hist-count {
  font-size: 12.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.hist-search {
  margin-left: auto;
  position: relative;
  display: flex;
  align-items: center;
}

.hist-search svg {
  position: absolute;
  left: 11px;
  color: var(--ink-3);
  pointer-events: none;
}

.hist-search input {
  width: 210px;
  padding: 8px 12px 8px 32px;
  font-size: 13px;
  border-radius: 9px;
}

.history-list { display: flex; flex-direction: column; }

/* ---------- 批量选择 ---------- */
.hist-all {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.hist-all input,
.hist-check {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}

.batch-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: #f7f9fc;
  border-bottom: 1px solid var(--line);
}

.batch-info {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-right: auto;
}

.hist-btn.danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  font-weight: 600;
}
.hist-btn.danger-solid:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

.hist-item {
  display: grid;
  grid-template-columns: 18px 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid #f1f4f8;
  transition: background .12s;
}

.hist-item:last-child { border-bottom: 0; }
.hist-item:hover { background: #fbfcfd; }
.hist-item.is-expired { opacity: .55; }

.hist-thumb {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.hist-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.hist-thumb span { font-size: 11px; color: var(--ink-3); }

.hist-main { min-width: 0; }

.hist-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hist-meta {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.hist-actions { display: flex; gap: 6px; }

.hist-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-size: 12.5px;
  font-family: inherit;
  padding: 6px 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .14s, border-color .14s, color .14s;
  white-space: nowrap;
}

.hist-btn:hover { border-color: #cfd8e3; background: #f8fafc; }

.hist-btn.primary {
  background: var(--accent-soft);
  border-color: #dbe6fd;
  color: var(--accent);
  font-weight: 600;
}
.hist-btn.primary:hover { background: #e4edff; }

.hist-btn.danger:hover { border-color: #fecaca; background: #fef2f2; color: var(--danger); }
.hist-btn:disabled { opacity: .6; cursor: default; }

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 46px 20px;
  color: var(--ink-3);
  font-size: 13px;
}

@media (max-width: 640px) {
  .hist-item {
    grid-template-columns: 18px 40px minmax(0, 1fr);
    gap: 11px;
    padding: 12px 14px;
  }
  .hist-thumb { width: 40px; height: 40px; }
  .hist-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .hist-search { margin-left: 0; width: 100%; }
  .hist-search input { width: 100%; }
  .history-head { padding: 14px; }
  .batch-bar { padding: 10px 14px; }
}

footer {
  text-align: center;
  color: var(--ink-3);
  font-size: 12.5px;
  margin-top: 32px;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  backdrop-filter: blur(2px);
}

.modal-card {
  width: 100%;
  max-width: 390px;
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 24px 60px -16px rgba(15, 23, 42, .45);
  animation: fade .18s ease;
}

.modal-card h3 {
  margin: 0 0 4px;
  font-size: 17px;
  letter-spacing: -.01em;
}

.modal-sub {
  margin: 0 0 18px;
  font-size: 12.5px;
  color: var(--ink-3);
  word-break: break-all;
}

.modal-card .field { margin-bottom: 13px; }

.modal-show {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  margin-bottom: 2px;
}

.modal-show input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.modal-card .err { margin-top: 8px; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-actions .btn {
  flex: 1;
  width: auto;
}
