:root {
  --bg: #f4f3ef;
  --card: #ffffff;
  --ink: #16181c;
  --muted: #6b7280;
  --line: #e6e4dd;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --danger: #c81e1e;
  --danger-soft: #fdecec;
  --ok: #15803d;
  --chip: #eef0f3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.45; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: var(--chip); padding: 1px 6px; border-radius: 6px; word-break: break-all; }
h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 12px; }
h2 { font-size: 22px; margin: 0 0 8px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
p { margin: 0 0 12px; }
.lead { font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); background: var(--danger-soft); padding: 10px 12px; border-radius: 8px; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--card);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; font-size: 17px; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--ink); position: relative; }
.logo::after { content: ""; position: absolute; inset: 7px 8px 6px; border: 2px solid #fff; border-top-width: 3px; border-radius: 0 0 4px 4px; }
.userbox { display: flex; align-items: center; gap: 10px; }
.usermeta { display: flex; flex-direction: column; line-height: 1.2; font-size: 14px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--chip); }

main { max-width: 1040px; margin: 0 auto; padding: 20px 16px 80px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 14px; }
.center { text-align: center; max-width: 640px; margin: 48px auto; padding: 36px 28px; }
.steps { text-align: left; padding-left: 20px; }
.steps li { margin-bottom: 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 9px 14px; border-radius: 9px; font: inherit; font-weight: 500; text-decoration: none;
  transition: background .12s, transform .05s;
}
.btn:hover { background: #f7f7f5; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.big { padding: 13px 22px; font-size: 17px; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #2a2d33; }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.danger:hover { background: #a91818; }
.btn.ghost { background: transparent; }
.btn.file { position: relative; }

.input {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--ink);
}
.input:focus { outline: 2px solid #bfd1ff; outline-offset: 0; }
.input.grow { flex: 1 1 220px; min-width: 160px; }
.input.narrow { width: 80px; }
.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }

.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.toolbar .row + .row { margin-top: 12px; }
.sticky { position: sticky; top: 8px; z-index: 5; }

.progress { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.bar { flex: 1; height: 8px; background: var(--chip); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress-panel .bar { margin: 10px 0 8px; }
.progress-panel .bar i { background: var(--danger); }
.errors { max-height: 140px; overflow: auto; background: var(--danger-soft); border-radius: 8px; padding: 8px 10px; margin-top: 8px; color: var(--danger); }

.list { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; box-shadow: var(--shadow); }
.list:empty { display: none; }
.item { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: start; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item.sel { background: #fff7f7; }
.item input { margin-top: 3px; width: 16px; height: 16px; }
.item .meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 3px; flex-wrap: wrap; }
.item .text { white-space: pre-wrap; word-break: break-word; }
.item .text.empty { color: var(--muted); font-style: italic; }
.item .metrics { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; }
.item .metrics a { color: var(--muted); }
.badge { display: inline-block; padding: 1px 7px; border-radius: 99px; background: var(--chip); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.badge.rt { background: #e8f5ee; color: var(--ok); }
.badge.reply { background: #eef2ff; color: var(--accent); }
.badge.quote { background: #fdf3e2; color: #a15c00; }
.badge.media { background: #f3e8ff; color: #6b21a8; }
.badge.src { background: transparent; border: 1px dashed var(--line); font-weight: 500; }

.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 16px 0; color: var(--muted); }

.modal { position: fixed; inset: 0; background: rgba(20,20,25,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-box { max-width: 460px; width: 100%; margin: 0; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 60; box-shadow: var(--shadow); max-width: 90vw; }

@media (max-width: 640px) {
  .top { padding: 12px 14px; }
  .usermeta { display: none; }
  .item { grid-template-columns: 24px 1fr; }
  .item .metrics { grid-column: 2; text-align: left; }
  .center { margin: 20px auto; padding: 24px 18px; }
  h1 { font-size: 24px; }
}
