
:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --overlay: rgba(15, 23, 42, 0.60);
  --line: #e5e7eb;
  --line-soft: #f1f5f9;
  --text: #111111;
  --muted: #6b7280;
  --link: #111111;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.14);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
body.modal-open {
  overflow: hidden;
}
button, a {
  -webkit-tap-highlight-color: transparent;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 20px 48px; }
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.title {
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 600;
  margin: 0 0 8px;
  text-transform: lowercase;
}
.subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.meta {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.meta strong {
  color: var(--text);
  font-weight: 600;
  margin-left: 6px;
}
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.path {
  font-size: 13px;
  color: var(--muted);
}
.path strong {
  color: var(--text);
  font-weight: 500;
  margin-right: 8px;
}
.action, .download {
  color: var(--link);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.4;
}
.action:hover,
.download:hover,
.action:focus-visible,
.download:focus-visible,
.item-link:focus-visible .item-name {
  color: #475569;
  outline: none;
}
.preview-trigger {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font: inherit;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table thead th {
  text-align: left;
  padding: 10px 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.table tbody tr {
  border-bottom: 1px solid var(--line-soft);
}
.table td {
  padding: 14px 0;
  vertical-align: middle;
  font-size: 14px;
}
.item-link {
  color: var(--text);
  text-decoration: none;
}
.item-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.item-icon {
  display: inline-block;
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1.2;
  margin-top: 1px;
}
.item-text {
  min-width: 0;
}
.item-name {
  display: block;
  font-weight: 500;
  line-height: 1.4;
  word-break: break-word;
}
.item-sub {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}
.type, .muted {
  color: var(--muted);
  font-size: 13px;
}
.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.empty {
  padding: 32px 0;
  color: var(--muted);
  font-size: 13px;
}
.footer {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}
.preview-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--overlay);
  z-index: 999;
}
.preview-modal.open {
  display: flex;
}
/* Maximized: dialog fills entire viewport */
.preview-dialog.maximized {
  width: 100vw;
  max-width: 100vw;
  max-height: 100vh;
  height: 100vh;
  border-radius: 0;
}
.preview-dialog.maximized .preview-body {
  flex: 1;
  overflow: auto;
}
.preview-dialog.maximized .preview-head {
  padding: 12px 18px;
}
.preview-dialog.maximized .img-viewer {
  height: calc(100vh - 105px);
  border-radius: 0;
}
.preview-dialog.maximized .preview-stage iframe {
  min-height: calc(100vh - 140px);
  max-height: calc(100vh - 140px);
}
.preview-dialog.maximized .preview-markdown,
.preview-dialog.maximized .preview-code,
.preview-dialog.maximized .preview-plain {
  max-height: calc(100vh - 140px);
  overflow: auto;
}
.preview-dialog {
  width: min(1120px, 100%);
  max-height: min(88vh, 920px);
  background: var(--panel);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.preview-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.preview-fullscreen {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  min-width: 36px;
  height: 36px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}
.preview-title {
  margin: 0;
  font-size: 18px;
}
.preview-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.preview-close {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  min-width: 36px;
  height: 36px;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}
.preview-fullscreen:hover,
.preview-close:hover {
  background: #f1f5f9;
}
.preview-body {
  padding: 18px;
  overflow: auto;
  min-height: 280px;
  background: #fbfdff;
}
.preview-stage {
  display: none;
  width: 100%;
}
.preview-stage.active {
  display: block;
}
.preview-stage img,
.preview-stage video,
.preview-stage iframe,
.preview-stage audio {
  width: 100%;
}
.preview-stage img,
.preview-stage video,
.preview-stage iframe {
  max-height: 70vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

/* ── Image Viewer ── */
.img-viewer {
  position: relative;
  width: 100%;
  height: 65vh;
  min-height: 400px;
  background: #1a1a2e;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
}
.img-viewer-canvas {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
  position: relative;
}
.img-viewer-canvas:active {
  cursor: grabbing;
}
.img-viewer-canvas img {
  display: block;
  max-width: none;
  max-height: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  transition: none;
  transform-origin: center center;
  will-change: transform;
  pointer-events: none;
}
.img-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  border-top: 1px solid rgba(255,255,255,0.08);
}
.img-viewer-toolbar button {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: #e2e8f0;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: background 0.15s;
}
.img-viewer-toolbar button:hover {
  background: rgba(255,255,255,0.18);
}
.img-viewer-zoom {
  min-width: 44px;
  text-align: center;
  font-size: 12px;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}
.img-viewer-sep {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.15);
  margin: 0 4px;
}
.preview-stage iframe {
  min-height: 70vh;
}
.preview-code,
.preview-plain,
.preview-markdown {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  word-break: break-word;
}
.preview-code {
  background: #0f172a;
  color: #e2e8f0;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-x: auto;
}
.preview-plain {
  background: #ffffff;
  color: var(--text);
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
}
.preview-markdown {
  background: #ffffff;
  color: var(--text);
  font-size: 15px;
  line-height: 1.8;
}
.preview-markdown > :first-child {
  margin-top: 0;
}
.preview-markdown > :last-child {
  margin-bottom: 0;
}
.preview-markdown h1,
.preview-markdown h2,
.preview-markdown h3 {
  line-height: 1.35;
  margin: 1.1em 0 0.55em;
}
.preview-markdown h1 { font-size: 28px; }
.preview-markdown h2 { font-size: 22px; }
.preview-markdown h3 { font-size: 18px; }
.preview-markdown p,
.preview-markdown ul,
.preview-markdown ol,
.preview-markdown blockquote,
.preview-markdown pre {
  margin: 0 0 1em;
}
.preview-markdown ul,
.preview-markdown ol {
  padding-left: 1.4em;
}
.preview-markdown blockquote {
  padding-left: 14px;
  border-left: 3px solid #cbd5e1;
  color: #475569;
}
.preview-markdown code {
  background: #f1f5f9;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.92em;
}
.preview-markdown pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
}
.preview-markdown pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}
.preview-markdown .codehilite { background: #272822; color: #F8F8F2; border-radius: 8px; overflow-x: auto; margin-bottom: 1em; }
.preview-markdown .codehilite pre { background: transparent; color: inherit; border: 0; padding: 14px; margin: 0; }
.preview-markdown .codehilite .hll { background-color: #49483e }
.preview-markdown .codehilite .c { color: #959077 }
.preview-markdown .codehilite .k { color: #66D9EF }
.preview-markdown .codehilite .l { color: #AE81FF }
.preview-markdown .codehilite .s { color: #E6DB74 }
.preview-markdown .codehilite .o { color: #FF4689 }
.preview-markdown .codehilite .p { color: #F8F8F2 }
.preview-markdown .codehilite .n { color: #F8F8F2 }
.preview-markdown .codehilite .nb { color: #F8F8F2 }
.preview-markdown .codehilite .nc { color: #A6E22E }
.preview-markdown .codehilite .nf { color: #A6E22E }
.preview-markdown .codehilite .fm { color: #A6E22E }
.preview-markdown .codehilite .nd { color: #A6E22E }
.preview-markdown .codehilite .ni { color: #F8F8F2 }
.preview-markdown .codehilite .ne { color: #A6E22E }
.preview-markdown .codehilite .nn { color: #F8F8F2 }
.preview-markdown .codehilite .nt { color: #FF4689 }
.preview-markdown .codehilite .nv { color: #F8F8F2 }
.preview-markdown .codehilite .ow { color: #FF4689 }
.preview-markdown .codehilite .w { color: #F8F8F2 }
.preview-markdown .codehilite .m { color: #AE81FF }
.preview-markdown .codehilite .mi { color: #AE81FF }
.preview-markdown .codehilite .mf { color: #AE81FF }
.preview-markdown .codehilite .s2 { color: #E6DB74 }
.preview-markdown .codehilite .se { color: #AE81FF }
.preview-markdown .codehilite .kc { color: #66D9EF }
.preview-markdown .codehilite .kd { color: #66D9EF }
.preview-markdown .codehilite .kn { color: #FF4689 }
.preview-markdown .codehilite .kt { color: #66D9EF }
.preview-markdown .codehilite .na { color: #A6E22E }
.preview-markdown .codehilite .bp { color: #F8F8F2 }
.preview-markdown .codehilite .vc { color: #F8F8F2 }
.preview-markdown .codehilite .vg { color: #F8F8F2 }
.preview-markdown .codehilite .vi { color: #F8F8F2 }
.preview-markdown .codehilite .il { color: #AE81FF }
.preview-markdown a {
  color: #2563eb;
}
.preview-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1em;
  font-size: 14px;
}
.preview-markdown th,
.preview-markdown td {
  padding: 8px 12px;
  text-align: left;
  border: 1px solid var(--line);
}
.preview-markdown th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--muted);
  font-size: 13px;
}
.preview-markdown tr:nth-child(even) td {
  background: #fafbfc;
}
.preview-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 20px 0;
}
.preview-empty.hidden {
  display: none;
}
.preview-error {
  color: #b91c1c;
}
@media (max-width: 720px) {
  .wrap { padding: 20px 14px 32px; }
  .header { align-items: flex-start; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tbody tr { padding: 10px 0; }
  .table td { padding: 4px 0; }
  .preview-modal { padding: 10px; }
  .preview-head, .preview-body { padding-left: 14px; padding-right: 14px; }
  .preview-stage iframe { min-height: 55vh; }
}

/* ── Password overlay ── */
.pwd-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 10001;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
}
.pwd-overlay.open {
  display: flex;
}
.pwd-dialog {
  background: #fff;
  border-radius: 8px;
  padding: 32px 36px 28px;
  max-width: 300px;
  width: calc(100% - 32px);
  box-shadow: 0 2px 16px rgba(0,0,0,0.12);
  text-align: center;
}
.pwd-dialog-title {
  font-size: 15px;
  font-weight: 500;
  margin: 0 0 28px;
  color: #333;
}
.pwd-inputs {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.pwd-digit {
  width: 44px;
  height: 44px;
  font-size: 22px;
  text-align: center;
  border: 0;
  border-bottom: 2px solid #d4d4d8;
  border-radius: 0;
  outline: none;
  background: transparent;
  color: #111;
  padding: 0;
  font-family: inherit;
  caret-color: #333;
  transition: border-color 0.15s;
}
.pwd-digit:focus {
  border-bottom-color: #333;
}
.pwd-digit.has-value {
  border-bottom-color: #a1a1aa;
}
.pwd-error {
  margin: 18px 0 0;
  font-size: 13px;
  color: #e5484d;
}
.pwd-error.hidden {
  display: none;
}
@keyframes pwd-shake {
  0%, 100% { transform: translateX(0); }
  25%  { transform: translateX(-6px); }
  75%  { transform: translateX(6px); }
}
.pwd-inputs.shaking {
  animation: pwd-shake 0.3s ease;
}