/* NetDesk — one stylesheet for the admin app and the public share page.
   Light palette lives on :root, dark overrides sit in the media query. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #e2e4e9;
  --text: #14161a;
  --text-dim: #6b7280;
  --accent: #2f6fed;
  --accent-soft: #e8effd;
  --danger: #d93a3a;
  --ok: #1f9d55;
  --shadow: 0 1px 2px rgba(16, 20, 30, .06), 0 8px 24px rgba(16, 20, 30, .06);
  --radius: 12px;
  --radius-sm: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f25;
    --surface-2: #23272e;
    --border: #2e333c;
    --text: #e8eaee;
    --text-dim: #9aa2ae;
    --accent: #5c8ffa;
    --accent-soft: #1e2b46;
    --danger: #f06a6a;
    --ok: #3fbe7a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
/* Author-level display rules outrank the UA stylesheet's [hidden]{display:none},
   so panels styled with display:flex/grid need this to actually hide. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }

/* --- buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-icon { padding: 7px 10px; }
.btn-block { width: 100%; padding: 10px; }
.select { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }

input[type=text], input[type=password], input[type=search], input[type=number], textarea {
  width: 100%; padding: 9px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent-soft); outline-offset: 0; border-color: var(--accent);
}

.logo-mark {
  width: 34px; height: 34px; flex: none; border-radius: 10px;
  background: linear-gradient(140deg, var(--accent), #7b5cf0);
  color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .5px;
  display: grid; place-items: center;
}
.logo-mark.sm { width: 28px; height: 28px; font-size: 11px; border-radius: 8px; }

/* --- login --- */
.auth-body { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand h1 { font-size: 18px; }
.auth-brand p { margin: 2px 0 0; color: var(--text-dim); font-size: 13px; }
.auth-card label { display: block; margin-bottom: 14px; }
.auth-card label span { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-dim); }
.form-error { color: var(--danger); font-size: 13px; margin: 0 0 12px; }

/* --- admin chrome --- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px; justify-content: space-between;
  padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tabs { display: flex; gap: 4px; }
.tab {
  padding: 6px 14px; border: 0; border-radius: 999px; background: transparent;
  color: var(--text-dim); cursor: pointer;
}
.tab.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topbar-right #search { width: 220px; }
.who { color: var(--text-dim); font-size: 13px; }

.view { padding: 18px; max-width: 1400px; margin: 0 auto; }
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 14px; min-width: 0; }
.crumbs button { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.crumbs button:hover { background: var(--surface-2); }
.crumbs .sep { color: var(--text-dim); }
.crumbs .current { color: var(--text-dim); padding: 2px 4px; }

.selbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 14px;
  background: var(--accent-soft); border-radius: var(--radius); font-size: 14px;
}
.selbar .spacer { flex: 1; }

/* --- file grid --- */
.filelist.grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.filelist.list { display: flex; flex-direction: column; gap: 2px; }

.item {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.item:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.item.is-selected { border-color: var(--accent); background: var(--accent-soft); }

.grid .item-thumb {
  aspect-ratio: 4 / 3; display: grid; place-items: center;
  background: var(--surface-2); overflow: hidden;
}
.grid .item-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid .item-meta { padding: 8px 10px; }
.grid .item-name { font-size: 13px; line-height: 1.35; max-height: 2.7em; overflow: hidden; }
.grid .item-sub { font-size: 11px; color: var(--text-dim); margin-top: 3px; }

.list .item { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: var(--radius-sm); }
.list .item-thumb { width: 40px; height: 40px; flex: none; border-radius: 6px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; }
.list .item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.list .item-meta { flex: 1; min-width: 0; }
.list .item-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .item-sub { font-size: 12px; color: var(--text-dim); }

.type-icon { font-size: 30px; opacity: .75; }
.list .type-icon { font-size: 20px; }

.item-check {
  position: absolute; top: 6px; left: 6px; width: 20px; height: 20px;
  border-radius: 6px; border: 1px solid var(--border); background: var(--surface);
  display: grid; place-items: center; font-size: 13px; color: transparent; z-index: 2;
}
.item.is-selected .item-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.list .item-check { position: static; }

.empty { text-align: center; color: var(--text-dim); padding: 60px 0; }

/* --- shares --- */
.stats { display: flex; gap: 18px; color: var(--text-dim); font-size: 13px; }
.stats b { color: var(--text); font-size: 15px; }
.sharelist { display: flex; flex-direction: column; gap: 10px; }
.share-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap;
}
.share-row.is-dead { opacity: .6; }
.share-row-main { flex: 1; min-width: 240px; }
.share-row h3 { font-size: 15px; margin-bottom: 4px; }
.share-url {
  font-size: 12px; color: var(--text-dim); word-break: break-all;
  background: var(--surface-2); padding: 6px 8px; border-radius: 6px; margin-top: 8px;
}
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim);
}
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.share-row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.logs { width: 100%; margin-top: 10px; font-size: 12px; color: var(--text-dim); }
.logs table { width: 100%; border-collapse: collapse; }
.logs td { padding: 4px 6px; border-top: 1px solid var(--border); }

/* --- uploads --- */
.uploads {
  position: fixed; right: 18px; bottom: 18px; width: min(360px, calc(100vw - 36px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 40; overflow: hidden;
}
.uploads-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.uploads ul { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; }
.uploads li { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.uploads li:last-child { border-bottom: 0; }
.bar { height: 4px; background: var(--surface-2); border-radius: 999px; margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.up-fail { color: var(--danger); }
.up-done { color: var(--ok); }

.drop-hint {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  border: 3px dashed var(--accent); color: var(--text); font-size: 18px; font-weight: 600;
  pointer-events: none;
}

/* --- modal --- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
  background: rgba(8, 10, 14, .55); padding: 18px;
}
.modal {
  width: min(460px, 100%); max-height: 90dvh; overflow-y: auto;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.modal h2 { font-size: 17px; margin-bottom: 16px; }
.modal label { display: block; margin-bottom: 14px; }
.modal label > span { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.modal .row { display: flex; gap: 10px; }
.modal .row > label { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.check-line { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 14px; }
.check-line input { width: auto; }
.result-url {
  background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 13px; word-break: break-all; margin-bottom: 12px;
}
.hint { font-size: 12px; color: var(--text-dim); margin: -8px 0 14px; }

/* --- toast --- */
.toast-root { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow); animation: pop .18s ease-out;
}
.toast.err { background: var(--danger); color: #fff; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }

/* --- share page --- */
.share-body { max-width: 720px; margin: 0 auto; padding: 0 14px 40px; }
.share-head { display: flex; align-items: center; gap: 10px; padding: 16px 2px 14px; }
.share-head-text { min-width: 0; }
.share-head h1 { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-head p { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }
.share-foot { text-align: center; color: var(--text-dim); font-size: 12px; padding: 24px 0; }
.loading { text-align: center; color: var(--text-dim); padding: 50px 0; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.notice { text-align: center; padding: 44px 18px; }
.notice .big { font-size: 40px; margin-bottom: 10px; }
.notice p { color: var(--text-dim); margin: 6px 0 0; }

.code-form { text-align: center; }
.code-form input {
  text-align: center; letter-spacing: 6px; font-size: 20px; margin: 14px 0;
  text-transform: lowercase;
}
.file-hero { text-align: center; padding: 8px 0 4px; }
.file-hero .preview-box {
  border-radius: var(--radius); overflow: hidden; background: var(--surface-2);
  margin-bottom: 14px; display: grid; place-items: center; min-height: 160px;
}
.file-hero img, .file-hero video { max-width: 100%; max-height: 60dvh; display: block; }
.file-hero .type-icon { font-size: 60px; padding: 30px; }
.file-hero h2 { font-size: 16px; margin-bottom: 4px; }
.sub { color: var(--text-dim); font-size: 13px; margin: 6px 0; }
.actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

.share-crumbs { display: flex; gap: 4px; flex-wrap: wrap; font-size: 13px; margin-bottom: 10px; }
.share-crumbs button { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 2px 4px; }
.share-list { display: flex; flex-direction: column; gap: 2px; }
.share-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer;
}
.share-item:active { background: var(--surface-2); }
.share-item .thumb { width: 44px; height: 44px; flex: none; border-radius: 6px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; }
.share-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.share-item .meta { flex: 1; min-width: 0; }
.share-item .nm { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-item .sb { font-size: 12px; color: var(--text-dim); }
.share-item .dl { flex: none; }

.wx-tip {
  position: fixed; inset: 0; z-index: 90; background: rgba(6, 8, 12, .8);
  color: #fff; padding: 22px; text-align: right;
}
.wx-tip-arrow { font-size: 40px; margin: 4px 10px 0 0; }
.wx-tip p { text-align: center; margin: 40px auto; max-width: 300px; line-height: 1.7; }
.wx-tip .btn { display: block; margin: 0 auto; }

.viewer { position: fixed; inset: 0; z-index: 95; background: #05070b; display: flex; flex-direction: column; }
.viewer-stage { flex: 1; display: grid; place-items: center; overflow: auto; padding: 40px 8px; }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 100%; display: block; }
.viewer-stage iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-stage pre {
  color: #d6dae2; font-size: 12.5px; line-height: 1.6; white-space: pre-wrap;
  max-width: 900px; width: 100%; margin: 0; padding: 12px;
}
.viewer-close, .viewer-nav {
  position: absolute; z-index: 2; border: 0; background: rgba(255, 255, 255, .12);
  color: #fff; cursor: pointer; border-radius: 999px;
}
.viewer-close { top: 12px; right: 12px; width: 38px; height: 38px; font-size: 22px; }
.viewer-nav { top: 50%; transform: translateY(-50%); width: 40px; height: 56px; font-size: 26px; border-radius: 10px; }
.viewer-nav.prev { left: 8px; }
.viewer-nav.next { right: 8px; }
.viewer-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(10, 12, 18, .9); color: #e8eaee; font-size: 13px;
}
.viewer-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .topbar-right #search { width: 100%; order: 3; }
  .view { padding: 12px; }
  .filelist.grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
  .viewer-nav { display: none; }
}
