* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, sans-serif; background: #f5f6f8; color: #222; }
.hidden { display: none !important; }
#login-view { display: flex; justify-content: center; align-items: center; min-height: 100vh; }
.login-card { background: #fff; padding: 2rem; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,.08); width: 320px; }
.login-card h1 { font-size: 1.2rem; margin-bottom: 1rem; text-align: center; }
.login-card label { display: block; margin-bottom: .75rem; font-size: .85rem; }
.login-card input { width: 100%; padding: .5rem; border: 1px solid #ccc; border-radius: 4px; margin-top: .25rem; }
.login-card button { width: 100%; padding: .55rem; background: #2563eb; color: #fff; border: none; border-radius: 4px; cursor: pointer; }
.error { color: #dc2626; font-size: .8rem; margin-top: .5rem; min-height: 1rem; }
header { background: #1e293b; color: #fff; display: flex; justify-content: space-between; align-items: center; padding: .6rem 1rem; }
.brand { font-weight: 700; }
.user-info { display: flex; align-items: center; gap: .6rem; font-size: .85rem; }
.role { background: #334155; padding: .15rem .5rem; border-radius: 10px; font-size: .75rem; }
.user-info button { background: #475569; color: #fff; border: none; padding: .3rem .6rem; border-radius: 4px; cursor: pointer; }
.toolbar { display: flex; justify-content: space-between; align-items: center; padding: .6rem 1rem; background: #fff; border-bottom: 1px solid #e2e8f0; flex-wrap: wrap; gap: .5rem; }
#breadcrumbs { font-size: .9rem; word-break: break-all; }
#breadcrumbs a { color: #2563eb; text-decoration: none; cursor: pointer; }
#breadcrumbs a:hover { text-decoration: underline; }
#breadcrumbs .sep { color: #94a3b8; margin: 0 .25rem; }
.actions { display: flex; gap: .4rem; }
.actions button { background: #2563eb; color: #fff; border: none; padding: .35rem .7rem; border-radius: 4px; cursor: pointer; font-size: .8rem; }
.actions button:hover { background: #1d4ed8; }
.content { display: flex; gap: 1rem; padding: 1rem; }
table { width: 100%; border-collapse: collapse; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid #f1f5f9; font-size: .85rem; }
th { background: #f8fafc; font-weight: 600; }
tbody tr:hover { background: #f8fafc; }
td .entry-name { cursor: pointer; color: #0f172a; }
td .entry-name:hover { text-decoration: underline; }
td .icon { margin-right: .4rem; }
.preview { flex: 0 0 40%; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; padding: .8rem; max-height: 70vh; display: flex; flex-direction: column; }
.preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.preview-head .button-link { font-size: .8rem; color: #2563eb; }
.preview-head button { background: none; border: none; color: #64748b; cursor: pointer; }
#preview-body { overflow: auto; }
#preview-body pre { white-space: pre-wrap; word-break: break-all; font-size: .8rem; max-height: 60vh; }
#preview-body img { max-width: 100%; height: auto; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; justify-content: center; align-items: center; z-index: 100; }
.modal-content { background: #fff; border-radius: 8px; padding: 1.2rem; min-width: 320px; max-width: 480px; }
.modal-content label { display: block; margin: .5rem 0; font-size: .85rem; }
.modal-content input, .modal-content textarea { width: 100%; padding: .5rem; border: 1px solid #ccc; border-radius: 4px; }
.modal-content textarea { min-height: 120px; font-family: monospace; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.modal-actions button { padding: .4rem .9rem; border-radius: 4px; border: 1px solid #ccc; cursor: pointer; }
#modal-ok { background: #2563eb; color: #fff; border-color: #2563eb; }
.toast { position: fixed; bottom: 1rem; right: 1rem; background: #1e293b; color: #fff; padding: .6rem 1rem; border-radius: 6px; z-index: 200; font-size: .85rem; }
.toast.error { background: #dc2626; }

.preview-iframe { width: 100%; height: 72vh; border: 1px solid #e2e8f0; border-radius: 4px; background: #fff; display: block; }
.preview-unsupported { color: #64748b; padding: 1.2rem; font-size: .85rem; }
.preview-md { padding: .8rem 1rem; font-size: .85rem; line-height: 1.65; max-height: 72vh; overflow: auto; word-break: break-word; }
.preview-md h1, .preview-md h2, .preview-md h3, .preview-md h4, .preview-md h5, .preview-md h6 { margin: .7rem 0 .35rem; line-height: 1.3; }
.preview-md p { margin: .35rem 0; }
.preview-md pre { background: #f8fafc; border: 1px solid #e2e8f0; padding: .6rem; border-radius: 4px; overflow: auto; }
.preview-md code { background: #f1f5f9; padding: .1rem .3rem; border-radius: 3px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; }
.preview-md pre code { background: none; padding: 0; }
.preview-md blockquote { border-left: 3px solid #cbd5e1; margin: .45rem 0; padding: .1rem .7rem; color: #475569; }
.preview-md ul, .preview-md ol { padding-left: 1.5rem; margin: .35rem 0; }
.preview-md li { margin: .15rem 0; }
.preview-md a { color: #2563eb; text-decoration: underline; }
.preview-csv { border-collapse: collapse; width: 100%; font-size: .78rem; }
.preview-md-table { border-collapse: collapse; margin: .5rem 0; width: 100%; font-size: .78rem; }
.preview-md-table th, .preview-md-table td { border: 1px solid #e2e8f0; padding: .35rem .55rem; text-align: left; }
.preview-md-table th { background: #f1f5f9; font-weight: 600; }
.preview-md-table tbody tr:nth-child(even) { background: #f8fafc; }
.preview-csv th, .preview-csv td { border: 1px solid #e2e8f0; padding: .3rem .55rem; text-align: left; white-space: nowrap; }
.preview-csv th { background: #f8fafc; position: sticky; top: 0; z-index: 1; }
.preview-code { white-space: pre-wrap; word-break: break-all; font-size: .8rem; max-height: 72vh; overflow: auto; }

/* ===== 全屏预览 modal ===== */
.preview-modal { position: fixed; inset: 0; width: 100%; height: 100vh; height: 100dvh; background: rgba(10,12,18,.72); z-index: 200; display: flex; flex-direction: column; overflow: hidden; }
.preview-modal.hidden { display: none; }
.preview-modal-head {
  display: flex; align-items: center; gap: .8rem;
  background: #0f172a; color: #e2e8f0;
  padding: .55rem 1rem; flex: 0 0 auto;
}
.pm-title { font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 38%; }
.pm-tabs { display: flex; gap: .2rem; background: rgba(255,255,255,.06); border-radius: 6px; padding: .2rem; }
.pm-tab {
  background: none; border: none; color: #94a3b8; cursor: pointer;
  padding: .3rem .8rem; border-radius: 4px; font-size: .82rem;
}
.pm-tab.active { background: #2563eb; color: #fff; }
.pm-actions { margin-left: auto; display: flex; align-items: center; gap: .8rem; }
.pm-actions .button-link { color: #93c5fd; text-decoration: none; font-size: .82rem; }
.pm-actions .button-link:hover { color: #fff; text-decoration: underline; }
#preview-close {
  background: none; border: none; color: #94a3b8; font-size: 1.1rem; cursor: pointer; line-height: 1;
}
#preview-close:hover { color: #fff; }
.preview-modal-body { flex: 1 1 auto; overflow: auto; background: #fff; padding: 1rem; }
#preview-pane-view { height: 100%; }
#preview-pane-view.hidden, #preview-pane-src.hidden { display: none; }
#preview-pane-src { height: 100%; overflow: auto; background: #272822; }
#preview-pane-src .cm-editor { height: 100%; font-size: .85rem; }
#preview-pane-src .CodeMirror { height: 100%; }
