:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #e4e7ec;
  --line-strong: #d3d8e0;
  --text: #14181f;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eef4ff;
  --danger: #dc2626;
  --ok: #0f9d58;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.spacer { flex: 1; }

button { font: inherit; cursor: pointer; }

button.primary,
button.ghost {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}

button.primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}
button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.primary:disabled { opacity: .55; cursor: default; }

button.ghost {
  background: #fff;
  border: 1px solid var(--line-strong);
  color: var(--text);
}
button.ghost:hover { background: #f3f5f8; }
button.ghost.danger { color: var(--danger); border-color: #f0c7c7; }
button.ghost.danger:hover { background: #fdeeee; }
button.icon { width: 32px; padding: 0; }

.hint { font-size: 12px; color: var(--muted); }

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: .2px; }

.logo {
  display: grid;
  place-items: center;
  width: 30px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #2563eb, #60a5fa);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
}

.filebar { display: flex; align-items: center; gap: 6px; }

#fileSelect {
  height: 32px;
  min-width: 150px;
  max-width: 240px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  outline: none;
}
#fileSelect:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }

.status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.status[data-kind="ok"] { color: var(--ok); }
.status[data-kind="dirty"] { color: #b45309; }
.status[data-kind="err"] { color: var(--danger); }
.status[data-kind="busy"] { color: var(--accent); }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.switch input { accent-color: var(--accent); margin: 0; }

/* ---------- 主体 ---------- */

main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  flex-wrap: wrap;
}

.search { display: flex; align-items: center; gap: 6px; }

#search {
  height: 32px;
  width: 230px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  outline: none;
  color: var(--text);
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }

.list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 0;
  margin-bottom: 12px;
  scrollbar-width: thin;
}
.list::-webkit-scrollbar { width: 10px; }
.list::-webkit-scrollbar-thumb {
  background: #d7dbe2;
  border-radius: 8px;
  border: 3px solid #fff;
}

.row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: start;
  padding: 1px 10px 1px 0;
  border-radius: 8px;
  transition: background .1s;
}
.row:hover { background: #f8f9fb; }
.row:focus-within { background: var(--accent-soft); }
.row.hit { background: #fffbe8; }
.row.flash { animation: flash .9s ease-out; }

@keyframes flash {
  0% { background: #ffe9a3; }
  100% { background: transparent; }
}

.num {
  padding: 10px 10px 0 0;
  text-align: right;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
  color: #a2a9b4;
  user-select: none;
}

.txtwrap { min-width: 0; padding: 2px 0; }

textarea.txt {
  display: block;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 10px;
  background: transparent;
  font: inherit;
  line-height: 1.6;
  color: inherit;
  resize: none;
  overflow: hidden;
  outline: none;
  word-break: break-word;
}
textarea.txt::placeholder { color: #c6ccd4; }
textarea.txt:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.acts {
  display: flex;
  gap: 2px;
  padding-top: 5px;
  opacity: 0;
  transition: opacity .12s;
}
.row:hover .acts,
.row:focus-within .acts { opacity: 1; }

.acts button {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}
.acts button:hover { background: #e9edf3; color: var(--text); }
.acts button.danger:hover { background: #fbe4e4; color: var(--danger); }
.acts button:disabled { opacity: .25; cursor: default; }
.acts button:disabled:hover { background: transparent; color: var(--muted); }

.empty {
  padding: 64px 20px;
  text-align: center;
  color: var(--muted);
}
.empty p { margin: 0 0 14px; }

.addbar {
  display: flex;
  gap: 8px;
  padding-bottom: 14px;
}

#quickAdd {
  flex: 1;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-size: 13.5px;
  outline: none;
  color: var(--text);
}
#quickAdd:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.addbar button { height: 40px; padding: 0 18px; border-radius: 10px; }

/* ---------- toast / 弹窗 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 14px);
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 9px 14px;
  border-radius: 10px;
  background: #1b212b;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s, transform .16s;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button {
  border: 0;
  background: none;
  color: #8ab7ff;
  font-weight: 600;
  font-size: 13px;
  padding: 0;
}
.toast button:hover { color: #bcd4ff; }

.mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .38);
  display: grid;
  place-items: center;
  z-index: 80;
  padding: 16px;
}

.modal {
  width: 340px;
  max-width: 100%;
  background: #fff;
  border-radius: 12px;
  padding: 18px 18px 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
}
.modal h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.modal p { margin: 0; }
.modal input {
  width: 100%;
  height: 36px;
  margin: 12px 0 18px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font: inherit;
  outline: none;
  color: var(--text);
}
.modal input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.modal .mrow { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 760px) {
  .brand h1 { display: none; }
  .status { order: 5; width: 100%; }
  #search { width: 140px; }
  .row { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .num { padding-right: 8px; }
  .acts { opacity: 1; }
  .pubbar .hint { display: none; }
}

/* ---------- 公开地址条 ---------- */

.pubbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  flex-wrap: wrap;
}

.publabel {
  color: var(--muted);
  flex: none;
  letter-spacing: .2px;
}

#pubUrl {
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  color: #1e3a8a;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
  max-width: 56vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: all;
}

a.ghost.mini,
button.ghost.mini {
  height: 24px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 12px;
  text-decoration: none;
  color: var(--text);
  display: inline-flex;
  align-items: center;
}

.pubbar.off #pubUrl { color: var(--muted); background: transparent; border-style: dashed; }
a.ghost.mini.disabled { pointer-events: none; opacity: .4; }

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

.login-mask { display: none; }
.login-mask.show { display: grid; }

.login-mask h3 { margin-bottom: 6px; }
.login-mask .hint { line-height: 1.5; }

.login-err {
  flex: 1;
  font-size: 12px;
  color: var(--danger);
  text-align: left;
  align-self: center;
  overflow: hidden;
}

.login-mask .mrow { align-items: center; }
.login-mask .modal input { margin: 0 0 10px; }
.login-mask .modal input:first-of-type { margin-top: 12px; }

/* ---------- 账号管理 ---------- */

#acctBtn { gap: 6px; }
#acctBtn .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  display: inline-block;
  flex: none;
}

.acct-mask { display: none; }
.acct-mask.show { display: grid; }

.modal.wide { width: 470px; }

.mhead { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.mhead h3 { flex: 1; margin: 0; }

.acct-sec { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.acct-sec:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }

.sech {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  letter-spacing: .2px;
}

.who { display: flex; align-items: center; gap: 8px; font-size: 14px; }

.tag {
  font-size: 11px;
  line-height: 1.6;
  padding: 1px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  flex: none;
}
.tag.admin { background: var(--accent-soft); color: var(--accent-dark); }

.acct-mask .modal input { margin: 0 0 8px; height: 34px; }
.acct-mask .modal .mrow { margin-top: 4px; align-items: center; }
.acct-mask .modal .mrow button { flex: none; }

.err {
  flex: 1;
  font-size: 12px;
  color: var(--danger);
  text-align: left;
  align-self: center;
  overflow: hidden;
}

.acct-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
  max-height: 190px;
  overflow-y: auto;
}

.acct-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 8px;
}
.acct-row:hover { background: #f7f9fc; }
.aname { font-size: 13px; font-weight: 600; }
.acct-row .hint.self { font-size: 12px; }

.acct-new {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
}

.acct-new input,
.acct-new select {
  margin: 0;
  height: 32px;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  outline: none;
}
.acct-new input:focus,
.acct-new select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.acct-new button { height: 32px; }

#acctNote { margin-top: 8px; line-height: 1.5; }

@media (max-width: 520px) {
  .acct-new { grid-template-columns: 1fr 1fr; }
}


