/* =====================================================================
   匿名单向文本收集箱 —— 全局样式
   中性灰配色，全站不出现蓝紫色；浅色/深色跟随系统。
   ===================================================================== */

:root {
  color-scheme: light dark;

  --bg: #fafaf8;
  --surface: #ffffff;
  --surface-2: #f4f4f2;
  --text: #1f1f1f;
  --text-muted: #8a8a8a;
  --border: #e8e8e5;
  --border-strong: #d8d8d4;

  --btn-bg: #1f1f1f;
  --btn-fg: #ffffff;
  --btn-bg-hover: #000000;

  --danger: #c0503a;
  --danger-soft: rgba(192, 80, 58, 0.09);

  /* 点缀色：只用于状态点与选中态 */
  --accent: #d08c3a;
  --accent-2: #5f7a6b;

  --hover: #f4f4f2;

  --radius-card: 12px;
  --radius-btn: 8px;

  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191919;
    --surface: #212121;
    --surface-2: #262626;
    --text: #ededed;
    --text-muted: #9a9a9a;
    --border: #2e2e2e;
    --border-strong: #3a3a3a;

    --btn-bg: #ededed;
    --btn-fg: #191919;
    --btn-bg-hover: #ffffff;

    --danger: #d4715c;
    --danger-soft: rgba(212, 113, 92, 0.12);

    --hover: #262626;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 选中态也保持中性，避免系统默认的蓝色选区 */
::selection {
  background: var(--border-strong);
  color: var(--text);
}

a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
}

a:hover {
  border-bottom-color: var(--text);
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* ------------------------------- 通用组件 ------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.textarea,
.input {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.65;
  transition: border-color 0.15s ease;
}

.textarea::placeholder,
.input::placeholder {
  color: var(--text-muted);
}

/* focus 只用中性深色细描边，不做发光效果 */
.textarea:focus,
.input:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: none;
}

.textarea {
  min-height: 240px;
  resize: vertical;
  display: block;
}

.input {
  border-radius: var(--radius-btn);
  padding: 10px 12px;
  font-size: 15px;
}

.input-sm {
  width: 240px;
  max-width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-btn);
  padding: 9px 16px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  background: var(--hover);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--btn-bg);
  color: var(--btn-fg);
  border-color: var(--btn-bg);
}

.btn-primary:hover {
  background: var(--btn-bg-hover);
  border-color: var(--btn-bg-hover);
  color: var(--btn-fg);
}

.btn-danger {
  color: var(--danger);
  border-color: var(--border-strong);
}

.btn-danger:hover {
  background: var(--danger-soft);
}

.btn-quiet {
  border-color: transparent;
  color: var(--text-muted);
  padding: 6px 10px;
  font-size: 14px;
}

.btn-quiet:hover {
  background: var(--hover);
  color: var(--text);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 14px;
}

.btn-block {
  width: 100%;
}

.muted {
  color: var(--text-muted);
}

.error-text {
  color: var(--danger);
  font-size: 14px;
  min-height: 22px;
  margin: 0;
}

/* 复选框统一中性色，避免浏览器默认的蓝色勾选 */
input[type='checkbox'] {
  accent-color: var(--btn-bg);
  width: 16px;
  height: 16px;
  cursor: pointer;
  margin: 0;
  flex: none;
}

/* ------------------------------- 主页 ------------------------------- */

.home {
  max-width: 680px;
  margin: 0 auto;
  padding: 96px 20px 120px;
}

.home-title {
  font-size: 26px;
  font-weight: 600;
}

.home-sub {
  margin: 10px 0 28px;
  color: var(--text-muted);
  font-size: 15px;
}

.home-card {
  padding: 20px;
}

.home-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
}

.home-actions-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.counter {
  color: var(--text-muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.home-foot {
  margin-top: 22px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ------------------------------- 登录页 ------------------------------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px;
}

.login-title {
  font-size: 20px;
  margin-bottom: 4px;
}

.login-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 24px;
}

.field {
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.login-card .btn-primary {
  margin-top: 8px;
  padding: 11px 16px;
}

.login-card .error-text {
  margin-top: 12px;
  min-height: 22px;
}

/* ------------------------------- 后台骨架 ------------------------------- */

.admin-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 190px;
  flex: none;
  border-right: 1px solid var(--border);
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg);
}

.sidebar-brand {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 10px 18px;
  letter-spacing: 0.02em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-btn);
  font-size: 15px;
  color: var(--text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  width: 100%;
}

.nav-item:hover {
  background: var(--hover);
  color: var(--text);
}

.nav-item.is-active {
  color: var(--text);
  font-weight: 500;
  background: var(--surface-2);
}

/* 选中态用点缀色小圆点，不使用蓝紫 */
.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
  flex: none;
}

.nav-item.is-active .nav-dot {
  background: var(--accent);
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.admin-main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 80px;
}

.admin-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.admin-title {
  font-size: 20px;
}

.admin-meta {
  color: var(--text-muted);
  font-size: 14px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  margin-bottom: 16px;
}

.toolbar-spacer {
  flex: 1;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

/* ------------------------------- 列表 ------------------------------- */

.list {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.12s ease;
}

.row:last-child {
  border-bottom: none;
}

.row:hover {
  background: var(--hover);
}

.row.is-selected {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--accent-2);
}

.row-check {
  padding-top: 3px;
}

.row-body {
  flex: 1;
  min-width: 0;
}

.row-time {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.row-preview {
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-height: 3.2em;
  overflow: hidden;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.tag {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 8px;
  line-height: 18px;
}

.empty {
  padding: 64px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ------------------------------- 弹层 ------------------------------- */

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 15, 15, 0.42);
}

.modal-card {
  width: 100%;
  max-width: 720px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.modal-card-sm {
  max-width: 400px;
}

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

.modal-title {
  font-size: 15px;
  font-weight: 600;
}

.modal-body {
  padding: 18px;
  overflow: auto;
}

.modal-text {
  margin: 0;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* 弹层里的次要信息（例如 UA），视觉上弱化 */
.modal-sub {
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 12px;
  word-break: break-all;
}

.modal-sub[hidden] {
  display: none;
}

.modal-message {
  margin: 0;
  font-size: 15px;
  color: var(--text);
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

.modal-foot .muted {
  margin-right: auto;
  font-size: 13px;
}

/* 复制回退方案用的离屏容器（不用内联样式，保持 CSP 严格） */
.sr-copy-holder {
  position: fixed;
  top: -1000px;
  left: -1000px;
  opacity: 0;
  pointer-events: none;
}

/* ------------------------------- 来源 IP ------------------------------- */

.row-source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 7px;
  line-height: 20px;
  cursor: pointer;
}

.ip:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--hover);
}

.ip-static {
  cursor: default;
}

.ip-static:hover {
  color: var(--text-muted);
  border-color: var(--border);
  background: transparent;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 2px 6px 2px 10px;
  font-size: 13px;
  max-width: 260px;
}

.chip[hidden] {
  display: none;
}

.chip-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
}

.chip-close:hover {
  color: var(--danger);
}

/* ------------------------------- 统计监控 ------------------------------- */

.head-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px 16px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.3;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
}

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

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
}

.panel-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel-row .panel {
  margin-bottom: 16px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  overflow: hidden;
}

.seg-item {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  padding: 5px 12px;
  cursor: pointer;
}

.seg-item:hover {
  background: var(--hover);
  color: var(--text);
}

.seg-item.is-active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 500;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.bar-col {
  flex: 1;
  min-width: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.bar-value {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-height: 15px;
}

.bar {
  width: 100%;
  max-width: 44px;
  height: 150px;
  display: flex;
  align-items: flex-end;
  background: var(--surface-2);
  border-radius: 6px;
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  min-height: 2px;
  border-radius: 6px;
  background: var(--accent);
  transition: height 0.25s ease;
}

.bar-empty {
  background: transparent;
}

.bar-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table th {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 13px;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--hover);
}

.cell-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.cell-num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.cell-preview {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
  margin-right: 7px;
}

.dot-fail {
  background: var(--danger);
}

/* ------------------------------- 响应式 ------------------------------- */

@media (max-width: 720px) {
  .admin-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px;
    gap: 6px;
    overflow-x: auto;
  }

  .sidebar-brand {
    display: none;
  }

  .nav-item {
    width: auto;
  }

  .sidebar-foot {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }

  .admin-main {
    padding: 20px 16px 60px;
  }

  .home {
    padding: 56px 18px 80px;
  }

  .row {
    flex-wrap: wrap;
  }

  .row-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .input-sm {
    width: 100%;
  }

  .panel-row {
    grid-template-columns: 1fr;
  }

  .head-right {
    width: 100%;
  }
}
