/* Shared by the login page, the library page and the admin page. */

* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f1f5f9; color: #1e293b; }
button, input, select { font-family: inherit; }
[hidden] { display: none !important; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---- buttons & fields ---- */
.btn { border: 0; border-radius: 6px; padding: 5px 10px; font-size: 12px; cursor: pointer; text-decoration: none; white-space: nowrap; display: inline-block; color: inherit; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: #f43f5e; color: #fff; font-size: 14px; padding: 10px 16px; }
.btn.primary:hover:not(:disabled) { background: #e11d48; }
.btn.ghost { background: #f1f5f9; color: #334155; }
.btn.ghost:hover:not(:disabled) { background: #e2e8f0; }
.btn.blue { background: #e0f2fe; color: #0369a1; }
.btn.warn { background: #fff1f2; color: #be123c; }
.btn.dl { background: #f43f5e; color: #fff; font-size: 13px; padding: 7px 14px; }
.btn.dl:hover { background: #e11d48; }
.btn.sm { font-size: 13px; padding: 7px 12px; }
input, select { border: 1px solid #e2e8f0; border-radius: 8px; padding: 7px 10px; font-size: 14px; background: #fff; color: inherit; }
input:focus, select:focus { outline: 2px solid #bae6fd; border-color: #38bdf8; }
.err { color: #e11d48; font-size: 13px; min-height: 18px; }
.muted { color: #64748b; font-size: 13px; }

/* ---- header ---- */
header { background: #0f172a; color: #fff; padding: 0 24px; min-height: 56px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20; }
header h1 { font-size: 18px; margin: 0; }
header .stat { color: #94a3b8; font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #f43f5e; display: inline-block; flex: none; }
.user { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user .uname { color: #e2e8f0; font-size: 13px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 800px) {
  header { padding: 8px 16px; }
  header .stat { display: none; }
  .user .uname { display: none; }
}

/* ---- toast & dialog ---- */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 12px); background: #1e293b; color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 60; max-width: 90vw; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none; align-items: center; justify-content: center; padding: 24px; z-index: 50; }
.overlay.on { display: flex; }
.dialog { background: #fff; border-radius: 12px; padding: 20px; width: 100%; max-width: 400px; font-size: 14px; }
.dialog h3 { margin: 0 0 12px; font-size: 15px; }
.dialog p { margin: 0 0 12px; color: #475569; word-break: break-all; }
.dialog label { display: block; font-size: 13px; color: #475569; margin-bottom: 12px; }
.dialog input { display: block; width: 100%; margin-top: 6px; }
.dialog .field { display: flex; gap: 6px; margin-top: 6px; }
.dialog .field input { margin-top: 0; flex: 1; min-width: 0; }
.dialog .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* ---- login ---- */
body.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.panel { background: #fff; border-radius: 12px; padding: 18px; box-shadow: 0 1px 2px rgba(0,0,0,.06); margin-bottom: 18px; }
.auth { width: 100%; max-width: 380px; padding: 32px 28px; }
.auth h1 { font-size: 18px; margin: 0 0 6px; display: flex; align-items: center; gap: 10px; }
.auth .sub { margin: 0 0 22px; color: #64748b; font-size: 13px; }
.auth label { display: block; font-size: 13px; color: #475569; margin-bottom: 14px; }
.auth label input { display: block; width: 100%; margin-top: 6px; }
.auth .primary { width: 100%; margin-top: 4px; }
.auth .err { margin-bottom: 8px; }
.alt { margin: 16px 0 0; font-size: 13px; color: #64748b; text-align: center; }
.alt a { color: #0284c7; cursor: pointer; }
.hint { margin: 14px 0 0; font-size: 12px; color: #94a3b8; text-align: center; }

/* ---- library ---- */
main { max-width: 1600px; margin: 0 auto; padding: 20px 24px; }
main.narrow { max-width: 1100px; }
.bar { background: #fff; border-radius: 12px; padding: 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; box-shadow: 0 1px 2px rgba(0,0,0,.05); margin-bottom: 18px; font-size: 14px; }
.tabs { display: flex; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.tabs button { border: 0; background: #fff; padding: 7px 14px; cursor: pointer; font-size: 14px; border-left: 1px solid #e2e8f0; color: inherit; }
.tabs button:first-child { border-left: 0; }
.tabs button.on { background: #1e293b; color: #fff; }
input[type=search] { width: 240px; }
.count { margin-left: auto; color: #64748b; }
.count b { color: #e11d48; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card { background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.06); display: flex; flex-direction: column; transition: box-shadow .15s; }
.card:hover { box-shadow: 0 6px 16px rgba(0,0,0,.1); }
.pic { position: relative; cursor: zoom-in; aspect-ratio: 4/3; background: #e2e8f0; }
.pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tag { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.7); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 4px; }
.body { padding: 12px; font-size: 14px; display: flex; flex-direction: column; flex: 1; }
.drama { font-weight: 600; }
.title { margin-top: 6px; color: #334155; }
.zh { color: #64748b; font-size: 12px; margin-top: 2px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { background: #f1f5f9; color: #475569; font-size: 12px; padding: 2px 8px; border-radius: 4px; }
.chip.main { color: #1e293b; font-weight: 600; }
.link { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; }
.link .u { flex: 1; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link .none { flex: 1; color: #d97706; }
.foot { margin-top: auto; padding-top: 12px; display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: #94a3b8; }
.empty { text-align: center; color: #94a3b8; padding: 80px 0; }
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.8); display: none; align-items: center; justify-content: center; padding: 24px; z-index: 50; }
#modal.on { display: flex; }
.mbox { background: #fff; border-radius: 12px; overflow: hidden; max-width: 1100px; width: 100%; max-height: calc(100vh - 48px); display: flex; }
.mbox img { width: 66%; background: #000; aspect-ratio: 4/3; object-fit: contain; }
.minfo { padding: 20px; font-size: 14px; display: flex; flex-direction: column; gap: 8px; width: 34%; word-break: break-all; overflow-y: auto; }
.minfo .k { color: #94a3b8; }
#m-url a { color: #0284c7; }
.close { margin-left: auto; border: 0; background: none; font-size: 24px; cursor: pointer; color: #94a3b8; line-height: 1; }
@media (max-width: 800px) {
  main { padding: 16px; }
  input[type=search] { width: 100%; }
  .count { margin-left: 0; }
  .mbox { flex-direction: column; overflow-y: auto; }
  .mbox img, .minfo { width: 100%; }
}

/* ---- admin ---- */
.panel h2 { font-size: 16px; margin: 0; }
.panel-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.row input[name=email] { flex: 2 1 200px; }
.row input[name=name] { flex: 1 1 140px; }
.row input[name=password] { flex: 2 1 220px; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
th { color: #64748b; font-weight: 500; font-size: 12px; white-space: nowrap; }
td.acts { white-space: nowrap; }
td.acts .btn { margin: 2px 4px 2px 0; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 4px; background: #f1f5f9; color: #475569; white-space: nowrap; }
.pill.admin { background: #fef3c7; color: #92400e; }
.pill.off { background: #fee2e2; color: #b91c1c; }
.pill.on { background: #dcfce7; color: #166534; }
.settings label.radio { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.settings label.radio:hover { background: #f8fafc; }
.settings label.radio span { color: #64748b; font-size: 13px; }
.invite-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 14px 28px; font-size: 14px; }
.invite-row code { background: #0f172a; color: #fff; padding: 6px 12px; border-radius: 6px; letter-spacing: 2px; font-size: 15px; }
.settings > .btn { margin-top: 12px; }
