:root { color-scheme: light dark; --bg: #f5f6f8; --card: #fff; --line: #dfe2e8; --fg: #171a21; --muted: #667085; --accent: #2563eb; --error: #c62828; }
@media (prefers-color-scheme: dark) { :root { --bg: #111318; --card: #1b1e25; --line: #2c313b; --fg: #e8eaf0; --muted: #98a0b0; --accent: #3b76f0; --error: #ff8a80; } }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 system-ui, -apple-system, "PingFang SC", sans-serif; }
input, textarea, button, .button { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 10px 14px; }
button, .button { background: var(--accent); border-color: var(--accent); color: #fff; cursor: pointer; text-decoration: none; display: inline-block; text-align: center; }
button:disabled { opacity: .6; cursor: default; }
.secondary { background: var(--card); border-color: var(--line); color: var(--fg); }
.link { background: none; border: 0; padding: 4px 6px; color: var(--accent); }
.error { color: var(--error); min-height: 1.5em; margin: 0; }

#gate { max-width: 360px; margin: 18vh auto 0; padding: 0 20px; display: grid; gap: 12px; }
#gate h1 { margin: 0; font-size: 32px; }
#gate p { margin: 0; color: var(--muted); }
.check { color: var(--muted); font-size: 14px; }

main { max-width: 760px; margin: 0 auto; padding: 0 16px; min-height: 100dvh; display: flex; flex-direction: column; }
header { position: sticky; top: 0; z-index: 1; background: var(--bg); display: flex; gap: 12px; align-items: center; padding: 12px 0; }
#status { color: var(--muted); font-size: 14px; flex: 1; }
#notice { margin: 0 0 12px; padding: 10px 14px; border: 1px solid var(--accent); border-radius: 10px; }
#messages, #uploads, #entries { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
#empty, .hint { color: var(--muted); text-align: center; margin: 40px 0; }
#messages li, #uploads li, #entries li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.meta { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
.meta span { flex: 1; }
.body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.file { display: flex; gap: 12px; align-items: center; margin-top: 6px; }
.file div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.file small { display: block; color: var(--muted); }
.preview { display: block; max-width: 100%; max-height: 240px; margin-top: 8px; border-radius: 8px; }
#uploads { margin-top: 10px; }
progress { width: 100%; accent-color: var(--accent); }
#composer { position: sticky; bottom: 0; margin-top: auto; background: var(--bg); padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); display: grid; gap: 8px; }
textarea { width: 100%; resize: vertical; max-height: 40vh; }
.actions, .toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.actions button, .toolbar button { padding: 8px 12px; }
.actions button[type=submit] { margin-left: auto; }
#browser { padding-bottom: 12px; }
#crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin-bottom: 10px; overflow-wrap: anywhere; }
#crumbs strong { padding: 4px 6px; }
#entries { margin-top: 12px; }
#entries .file { margin-top: 0; }
.name { background: none; border: 0; padding: 0; color: inherit; text-align: left; font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.file .button, .file button:not(.link):not(.name) { white-space: nowrap; }
body.dragging { outline: 3px dashed var(--accent); outline-offset: -8px; }

.danger { background: var(--error); border-color: var(--error); color: #fff; }
button.link:disabled { opacity: .3; }
.preview { cursor: zoom-in; }
.open-name { cursor: pointer; }
.edit textarea { margin-top: 6px; }
.edit .actions { justify-content: flex-end; margin-top: 6px; }
#messages li.selectable, #entries li.selectable { cursor: pointer; padding-left: 44px; position: relative; }
li.selectable > .pick { position: absolute; left: 14px; top: 16px; width: 18px; height: 18px; accent-color: var(--accent); pointer-events: none; }
li.selected { border-color: var(--accent) !important; }
li.selectable button, li.selectable a, li.selectable .preview { pointer-events: none; opacity: .5; }
li.selectable .name { opacity: 1; }
#batch { position: sticky; bottom: 0; margin-top: auto; background: var(--bg); padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#batch span { width: 100%; color: var(--muted); font-size: 14px; }
#batch button { padding: 8px 12px; }
#viewer { width: min(960px, 100vw); height: 92dvh; max-width: 100vw; max-height: 100dvh; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--fg); flex-direction: column; }
#viewer[open] { display: flex; }
#viewer::backdrop { background: rgb(0 0 0 / .7); }
.viewer-bar { display: flex; gap: 6px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.viewer-bar strong { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.viewer-bar .link { font-size: 18px; padding: 4px 10px; }
#viewer-close { font-size: 15px; }
.viewer-bar .button { padding: 6px 12px; white-space: nowrap; }
#viewer-body { flex: 1; overflow: auto; padding: 12px; overscroll-behavior: contain; }
.media { display: block; max-width: 100%; max-height: 100%; margin: auto; }
audio.media { width: 100%; }
#viewer pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.5 ui-monospace, Menlo, monospace; }
.pdf-page { width: 100%; margin-bottom: 12px; background: #fff; }
.pdf-page canvas { display: block; width: 100%; }
.docx-holder { overflow: auto; color: #000; }
.docx-holder .docx-wrapper { padding: 0; background: transparent; }
.docx-holder section.docx { width: 100% !important; padding: 24px 16px !important; }
.table-wrap { overflow: auto; margin-bottom: 12px; }
.table-wrap table { border-collapse: collapse; font-size: 13px; }
.table-wrap td { border: 1px solid var(--line); padding: 4px 8px; white-space: pre-wrap; max-width: 320px; vertical-align: top; }

.searchbar { display: flex; gap: 6px; margin-bottom: 12px; }
.searchbar input { flex: 1; min-width: 0; padding: 8px 12px; }
.title { margin: 6px 0 0; font-weight: 700; font-size: 17px; overflow-wrap: anywhere; }
#results-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
#results-list li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
#results-summary { margin: 0 0 10px; }
#results .actions { justify-content: flex-end; margin-top: 6px; }
#results .actions .button { padding: 6px 12px; }
mark { background: #ffe58a; color: #1a1a1a; border-radius: 3px; }
.snippet { overflow-wrap: anywhere; white-space: pre-wrap; margin-top: 4px; }
.where { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
li.flash { animation: flash 2s ease-out; }
@keyframes flash { 0%, 40% { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent); } }

.meta { flex-wrap: wrap; justify-content: flex-end; }
#share { width: min(440px, 100vw); max-width: 100vw; max-height: 92dvh; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--fg); flex-direction: column; }
#share[open] { display: flex; }
#share::backdrop { background: rgb(0 0 0 / .7); }
.share-body { overflow: auto; padding: 12px 16px 16px; }
#share-current { display: grid; gap: 10px; }
#share-qr { width: 220px; height: 220px; margin: 0 auto; background: #fff; border-radius: 8px; }
#share-qr.expired { opacity: .15; }
.share-row { display: flex; gap: 8px; align-items: center; }
.share-row input, .share-row select { flex: 1; min-width: 0; padding: 8px 10px; }
select { font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
#share-left { margin: 0; text-align: center; font-weight: 600; }
.tip { margin: 0; color: var(--muted); font-size: 13px; }
.share-body h3 { margin: 18px 0 8px; font-size: 15px; }
#share-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#share-list li { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; overflow-wrap: anywhere; }
#share-list li.current { border-color: var(--accent); }
#share-list small { color: var(--muted); display: block; }
#share-list .actions { justify-content: flex-end; }

/* 窄屏：文件夹里的文件名单独占一行，按钮排到下面 */
@media (max-width: 520px) {
  #entries .file:has(> div) { flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; }
  #entries .file > div { flex-basis: 100%; }
}

#archive-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 12px; margin-bottom: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: 14px; }
#archive-bar[hidden] { display: none; }
