:root {
  --ink: #14130F;
  --paper: #FBF8F1;
  --panel: #FFFFFF;
  --line: #E4DECF;
  --muted: #8A8475;
  --accent: #2D5F4C;
  --accent-soft: #E6EFE9;
  --gold: #B8893A;
  --danger: #A8432E;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20,19,15,.04), 0 8px 24px rgba(20,19,15,.06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--paper); color: var(--ink);
  -webkit-font-smoothing: antialiased; line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: 14px; }
a { color: inherit; text-decoration: none; }
.mono { font-family: "SF Mono", Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
code { background:#F1EDE2; padding:1px 5px; border-radius:4px; font-size:.92em; }

.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 40px 36px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 11px; margin-bottom: 28px; }
.brand-mark { width: 38px; height: 38px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color:#fff; font-weight:700; font-size:17px; flex-shrink:0; }
.brand-name { font-size: 17px; font-weight: 650; }
.brand-sub { font-size: 12px; color: var(--muted); }
.field { margin-bottom: 16px; }
.field label { display:block; font-size:12.5px; font-weight:600; color:var(--muted); margin-bottom:6px; }
.inp { width:100%; padding:11px 13px; border:1px solid var(--line); border-radius:var(--radius); background:#fff; color:var(--ink); transition:border-color .15s, box-shadow .15s; }
.inp:focus { outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
.btn { display:block; width:100%; text-align:center; padding:12px; border-radius:var(--radius); background:var(--accent); color:#fff; font-weight:600; font-size:14.5px; transition:filter .15s, transform .05s; }
.btn:hover { filter:brightness(1.08); }
.btn:active { transform:translateY(1px); }
.alert { padding:12px 14px; border-radius:var(--radius); font-size:13.5px; margin-bottom:18px; line-height:1.6; }
.alert-err { background:#F6E3DD; color:var(--danger); }
.alert-ok { background:var(--accent-soft); color:var(--accent); }

.topbar { height:58px; border-bottom:1px solid var(--line); background:var(--panel); display:flex; align-items:center; justify-content:space-between; padding:0 22px; position:sticky; top:0; z-index:20; }
.topbar-left { display:flex; align-items:center; gap:10px; }
.topbar-mark { width:30px; height:30px; border-radius:7px; background:var(--accent); display:grid; place-items:center; color:#fff; font-weight:700; font-size:14px; }
.topbar-title { font-weight:650; font-size:15px; }
.topbar-right { display:flex; align-items:center; gap:14px; }
.user-chip { display:flex; align-items:center; gap:9px; }
.avatar { width:28px; height:28px; border-radius:50%; background:var(--gold); color:#fff; display:grid; place-items:center; font-size:12px; font-weight:600; }
.user-name { font-size:13.5px; font-weight:600; }
.role-tag { font-size:10.5px; font-weight:700; padding:2px 7px; border-radius:5px; text-transform:uppercase; letter-spacing:.04em; }
.role-admin { background:var(--accent-soft); color:var(--accent); }
.role-user { background:#F0EAD9; color:var(--gold); }
.ghost-btn { font-size:13px; color:var(--muted); font-weight:600; padding:6px 10px; border-radius:7px; }
.ghost-btn:hover { background:#F1EDE2; color:var(--ink); }
.link-btn { font-size:13px; color:var(--accent); font-weight:600; padding:6px 10px; border-radius:7px; }
.link-btn:hover { background:var(--accent-soft); }

.body { display:flex; width:100%; min-height:calc(100vh - 58px); }
.sidebar { width:264px; border-right:1px solid var(--line); padding:18px 14px; flex-shrink:0; }
.side-label { font-size:11px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.06em; padding:0 8px; margin:4px 0 10px; }
.lib-item { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:9px 10px; border-radius:8px; margin-bottom:2px; transition:background .12s; width:100%; text-align:left; cursor:pointer; }
.lib-item:hover { background:#F1EDE2; }
.lib-item.active { background:var(--accent-soft); }
.lib-item.active .lib-name { color:var(--accent); }
.lib-name { font-size:13.5px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.lib-count { font-size:11px; color:var(--muted); flex-shrink:0; }
.add-lib-btn { width:100%; padding:9px; margin-top:8px; border:1px dashed var(--line); border-radius:8px; color:var(--accent); font-weight:600; font-size:13px; transition:background .12s; }
.add-lib-btn:hover { background:var(--accent-soft); }
.nav-btn { display:flex; align-items:center; gap:9px; width:100%; padding:9px 10px; border-radius:8px; font-size:13.5px; font-weight:600; color:var(--ink); text-align:left; transition:background .12s; }
.nav-btn:hover { background:#F1EDE2; }
.nav-btn.active { background:var(--accent-soft); color:var(--accent); }

.main { flex:1; padding:26px 30px; min-width:0; }
.page-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin-bottom:22px; flex-wrap:wrap; }
.page-title { font-size:22px; font-weight:700; letter-spacing:-.02em; }
.page-sub { font-size:13px; color:var(--muted); margin-top:3px; }
.toolbar { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.search { display:flex; align-items:center; gap:8px; padding:8px 12px; background:var(--panel); border:1px solid var(--line); border-radius:9px; min-width:200px; }
.search input { border:none; outline:none; flex:1; background:transparent; }
.pill-btn { padding:9px 15px; border-radius:9px; background:var(--accent); color:#fff; font-weight:600; font-size:13.5px; transition:filter .15s; display:inline-block; }
.pill-btn:hover { filter:brightness(1.08); }
.pill-btn.secondary { background:var(--panel); color:var(--ink); border:1px solid var(--line); }
.pill-btn.secondary:hover { background:#F1EDE2; filter:none; }

.script-list { display:flex; flex-direction:column; gap:10px; }
.script-card { background:var(--panel); border:1px solid var(--line); border-radius:12px; overflow:hidden; transition:box-shadow .15s; }
.script-card:hover { box-shadow:var(--shadow); }
/* 五列：中文 | 英文 | 西班牙语 | 图片 | 操作 */
.sc-grid { display:grid; grid-template-columns:1.2fr 1.2fr 1.2fr 130px 92px; align-items:stretch; }
.sc-cell { padding:14px 16px; border-right:1px solid var(--line); display:flex; flex-direction:column; min-width:0; }
.sc-cell:last-child { border-right:none; }
.sc-lang { font-size:10.5px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.06em; margin-bottom:8px; }
.sc-text { font-size:14.5px; line-height:1.55; white-space:pre-wrap; word-break:break-word; flex:1; }
.sc-text.en, .sc-text.es { color:#2B2A24; }
/* 每列底部的复制按钮 */
.sc-copy-btn { align-self:flex-end; font-size:12px; font-weight:600; color:var(--accent); background:var(--accent-soft); padding:5px 11px; border-radius:7px; cursor:pointer; transition:filter .12s, background .12s; white-space:nowrap; }
.sc-copy-btn:hover { filter:brightness(.96); }
.sc-copy-btn.copied { background:var(--accent); color:#fff; }
/* 图片列 */
.sc-cell.img { align-items:center; justify-content:flex-start; }
.sc-cell.img .sc-lang { align-self:flex-start; }
.sc-cell.img .sc-copy-btn { align-self:center; }
.sc-img-thumb { width:74px; height:74px; object-fit:cover; border-radius:8px; border:1px solid var(--line); cursor:zoom-in; }
.sc-img-none { font-size:12px; color:var(--muted); flex:1; display:flex; align-items:center; }
/* 操作列 */
.sc-cell.ops { align-items:stretch; justify-content:flex-start; gap:6px; }
.sc-cell.ops .op-btn { font-size:12.5px; font-weight:600; padding:7px 0; border-radius:7px; text-align:center; cursor:pointer; transition:background .12s, color .12s; }
.sc-cell.ops .op-edit { color:var(--accent); background:var(--accent-soft); }
.sc-cell.ops .op-edit:hover { filter:brightness(.96); }
.sc-cell.ops .op-del { color:var(--danger); background:#F6E3DD; }
.sc-cell.ops .op-del:hover { filter:brightness(.97); }
/* 底部标签条 */
.sc-foot { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:9px 16px; border-top:1px solid var(--line); background:#FCFAF4; }
.sc-tags { display:flex; gap:6px; flex-wrap:wrap; }
.sc-foot-copies { display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; margin-left:auto; }
.tag { font-size:11px; padding:2px 8px; border-radius:5px; background:#F0EAD9; color:var(--gold); font-weight:600; }
.icon-btn { padding:6px 11px; border-radius:7px; font-size:12.5px; font-weight:600; color:var(--muted); transition:background .12s, color .12s; }
.icon-btn:hover { background:#EFEAE0; color:var(--ink); }
.icon-btn.copy { background:var(--accent-soft); color:var(--accent); }
.icon-btn.copy.copied { background:var(--accent); color:#fff; }
.icon-btn.del:hover { background:#F6E3DD; color:var(--danger); }

.empty { text-align:center; padding:70px 20px; color:var(--muted); }
.empty-icon { font-size:40px; margin-bottom:14px; opacity:.5; }
.empty-title { font-size:16px; font-weight:650; color:var(--ink); margin-bottom:6px; }
.empty-sub { font-size:13.5px; }

.table { width:100%; background:var(--panel); border:1px solid var(--line); border-radius:12px; overflow:hidden; }
.trow { display:grid; align-items:center; gap:12px; padding:13px 18px; border-bottom:1px solid var(--line); }
.trow:last-child { border-bottom:none; }
.trow.head { background:#FCFAF4; font-size:11.5px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.05em; }
.users-grid { grid-template-columns:1.3fr .9fr .7fr 1.4fr auto; }
.perm-chips { display:flex; gap:5px; flex-wrap:wrap; }
.perm-chip { font-size:11px; padding:2px 7px; border-radius:5px; background:var(--accent-soft); color:var(--accent); font-weight:600; }
.perm-chip.none { background:#F0EAD9; color:var(--muted); }
.pw-cell { display:flex; align-items:center; gap:6px; }
.pw-text { font-size:12.5px; color:var(--ink); }
.pw-dots { letter-spacing:2px; color:var(--muted); }
.pw-toggle { font-size:11px; color:var(--accent); font-weight:600; cursor:pointer; padding:1px 5px; border-radius:4px; }
.pw-toggle:hover { background:var(--accent-soft); }

.overlay { position:fixed; inset:0; background:rgba(20,19,15,.42); display:grid; place-items:center; z-index:50; padding:20px; }
.overlay.hidden { display:none; }
.modal { width:100%; max-width:560px; background:var(--panel); border-radius:16px; box-shadow:0 24px 60px rgba(20,19,15,.25); overflow:hidden; }
.modal-head { padding:20px 24px; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between; }
.modal-title { font-size:16.5px; font-weight:700; }
.modal-body { padding:22px 24px; max-height:70vh; overflow-y:auto; }
.modal-foot { padding:16px 24px; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:10px; }
.txt-area { width:100%; padding:11px 13px; border:1px solid var(--line); border-radius:var(--radius); resize:vertical; min-height:76px; background:#fff; line-height:1.55; }
.txt-area:focus { outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
.x-btn { font-size:20px; color:var(--muted); width:30px; height:30px; border-radius:7px; }
.x-btn:hover { background:#F1EDE2; }
.seg { display:inline-flex; background:#F1EDE2; border-radius:8px; padding:3px; gap:2px; }
.seg button { padding:6px 14px; border-radius:6px; font-size:13px; font-weight:600; color:var(--muted); }
.seg button.on { background:#fff; color:var(--ink); box-shadow:0 1px 2px rgba(0,0,0,.06); }
.check-row { display:flex; align-items:center; gap:9px; padding:9px 11px; border:1px solid var(--line); border-radius:8px; margin-bottom:7px; cursor:pointer; transition:background .12s; }
.check-row:hover { background:#F8F5EC; }
.check-row input { width:16px; height:16px; accent-color:var(--accent); }

.toast { position:fixed; bottom:26px; left:50%; transform:translateX(-50%); background:var(--ink); color:#fff; padding:11px 20px; border-radius:10px; font-size:13.5px; font-weight:500; z-index:80; box-shadow:0 8px 24px rgba(0,0,0,.2); opacity:0; transition:opacity .2s, transform .2s; pointer-events:none; }
.toast.show { opacity:1; transform:translate(-50%,-4px); }

/* ---------- 图片库 ---------- */
.img-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(190px, 1fr)); gap:14px; }
.img-card { background:var(--panel); border:1px solid var(--line); border-radius:12px; overflow:hidden; transition:box-shadow .15s; }
.img-card:hover { box-shadow:var(--shadow); }
.img-thumb { width:100%; aspect-ratio:4/3; object-fit:cover; background:#F1EDE2; display:block; cursor:zoom-in; }
.img-meta { padding:10px 12px; }
.img-title { font-size:13.5px; font-weight:600; margin-bottom:6px; word-break:break-word; }
.img-title.empty { color:var(--muted); font-weight:500; }
.img-foot { display:flex; align-items:center; justify-content:space-between; gap:6px; padding:0 12px 12px; }
.img-actions { display:flex; gap:5px; }
.lib-type-tag { font-size:10px; font-weight:700; padding:1px 5px; border-radius:4px; background:#EDE7D6; color:var(--muted); margin-left:6px; }

/* 上传区 */
.upload-zone { border:2px dashed var(--line); border-radius:12px; padding:30px; text-align:center; cursor:pointer; transition:border-color .15s, background .15s; }
.upload-zone:hover, .upload-zone.drag { border-color:var(--accent); background:var(--accent-soft); }
.upload-zone .uz-icon { font-size:32px; margin-bottom:8px; opacity:.6; }
.upload-zone .uz-text { font-size:14px; font-weight:600; }
.upload-zone .uz-sub { font-size:12.5px; color:var(--muted); margin-top:4px; }

/* 图片放大预览 */
.lightbox { position:fixed; inset:0; background:rgba(20,19,15,.82); display:none; place-items:center; z-index:90; padding:30px; cursor:zoom-out; }
.lightbox.show { display:grid; }
.lightbox img { max-width:92vw; max-height:88vh; border-radius:8px; box-shadow:0 20px 60px rgba(0,0,0,.4); }

/* ---------- 后台专属主题（深青蓝背景，与前台米色区分）---------- */
body.admin-theme {
  --paper: #EEF2F4;
  --panel: #FFFFFF;
  --line:  #D3DDE2;
  --accent:#1F4E5F;
  --accent-soft:#DCEAEF;
  --accent-strong:#163945;
  background: var(--paper);
}
body.admin-theme .topbar { background:#163945; border-bottom-color:#0F2A33; }
body.admin-theme .topbar-mark { background:#3E7C8C; }
body.admin-theme .topbar-title { color:#EAF2F4; }
body.admin-theme .topbar .link-btn { color:#BFE0E8; }
body.admin-theme .topbar .link-btn:hover { background:rgba(255,255,255,.12); }
body.admin-theme .topbar .user-name { color:#EAF2F4; }
body.admin-theme .topbar .ghost-btn { color:#A9C7D0; }
body.admin-theme .topbar .ghost-btn:hover { background:rgba(255,255,255,.12); color:#fff; }
body.admin-theme .topbar .role-admin { background:#3E7C8C; color:#fff; }
body.admin-theme .sidebar { background:#E4EBEE; border-right-color:#D3DDE2; }
body.admin-theme .lib-item.active, body.admin-theme .nav-btn.active { background:var(--accent-soft); }
body.admin-theme .admin-banner { background:#163945; color:#CFE6EC; font-size:12px; font-weight:600; text-align:center; padding:6px; letter-spacing:.04em; }

@media (max-width:760px) {
  .body { flex-direction:column; }
  .sidebar { width:100%; border-right:none; border-bottom:1px solid var(--line); }
  .sc-grid { grid-template-columns:1fr; }
  .sc-cell { border-right:none; border-bottom:1px solid var(--line); }
  .sc-cell:last-child { border-bottom:none; }
  .sc-cell.ops { flex-direction:row; }
  .sc-cell.ops .op-btn { flex:1; }
  .users-grid { grid-template-columns:1fr 1fr; }
  .main { padding:20px 16px; }
}
