:root {
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #202c3c;
  background: #f3f6fa;
  --muted: #536377;
  --line: #e1e7ee;
  --accent: #145b50;
  --nav: #172639;
  --white: #fff;
  --header-height: 60px;
  --header-inset: var(--header-height);
  --page-padding: clamp(15px, 3vw, 42px);
  scroll-padding-top: calc(var(--header-inset) + 8px);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; position: relative; }
body, h1, h2, p { margin: 0; }

h2 { font-size: 1.1rem; }
a, button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
:where(button, a, input):focus-visible { outline: 3px solid #36a594; outline-offset: 3px; }
[hidden] { display: none !important; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 9;
  background: var(--nav);
  color: white;
  transition: transform .18s ease-out;
}
:root.header-hidden { --header-inset: 0px; }
.header-hidden .site-header { transform: translateY(-100%); pointer-events: none; }
.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--header-height);
  max-width: 1540px;
  margin: auto;
  padding: 6px var(--page-padding);
}
.site-title { min-width: 0; font-size: clamp(1rem, 2vw, 1.25rem); line-height: 1.25; }
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}
.brand-icon {
  display: block;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  object-fit: contain;
}
.tree-toggle {
  flex-shrink: 0;
  min-height: 36px;
  padding: 5px 9px;
  border: 1px solid #64768c;
  border-radius: 7px;
  background: transparent;
  color: #fff;
  font-size: .82rem;
  font-weight: 650;
  white-space: nowrap;
}
.tree-toggle:hover, .tree-toggle[aria-expanded="true"] { background: #29425b; }
.content { max-width: 1540px; margin: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 14px var(--page-padding) 42px; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 13px; padding: 19px 20px; min-width: 0; }
.primary, .secondary { min-height: 42px; border-radius: 8px; padding: 10px 15px; font-size: .88rem; font-weight: 650; white-space: nowrap; }
.primary { border: 1px solid var(--accent); background: var(--accent); color: white; }
.secondary { border: 1px solid #c9d5e1; background: white; color: #1e354c; }
.quiet { border: 0; background: none; padding: 8px; color: var(--accent); font-weight: 700; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; }
.feedback { color: var(--accent); font-size: .86rem; }
.feedback:empty { display: none; }
.empty { color: var(--muted); font-size: .87rem; padding: 5px 0; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .82rem; }
th, td { padding: 9px 8px; border-bottom: 1px solid #eaf0f4; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
td:first-child, th:first-child { padding-inline-start: 0; }
tbody tr:last-child td { border-bottom: 0; }

@media (max-width: 620px) {
  :root { --header-height: 54px; }
  .brand-icon { width: 30px; height: 30px; }
  .content { padding-top: 10px; }
  .panel { padding: 15px; }
}

.library-explorer {
  display: grid;
  grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.library-explorer.tree-collapsed { grid-template-columns: minmax(0, 1fr); }
.library-tree {
  position: sticky;
  top: calc(var(--header-inset) + 12px);
  max-height: calc(100vh - var(--header-inset) - 24px);
  overflow: auto;
  padding: 14px 11px;
}
.library-tree h2 { padding: 0 6px 10px; }

.folder-tree { list-style: none; margin: 0; padding: 0; }
.folder-tree .folder-tree { margin-left: 13px; padding-left: 4px; border-left: 1px solid var(--line); }
.tree-line { min-width: 0; display: flex; align-items: start; gap: 2px; border-radius: 7px; }
.tree-line:hover { background: #f2f6fa; }
.tree-folder, .tree-expander, .link-control, .file-name {
  background: none;
  border: 0;
  color: inherit;
  text-align: left;
  text-decoration: none;
}
.tree-expander, .tree-spacer { flex: 0 0 29px; }
.tree-expander { min-height: 33px; padding: 4px; text-align: center; color: #39536a; }
.tree-folder, .file-name {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-width: 0;
  overflow-wrap: anywhere;
  border-radius: 6px;
  font-size: .9rem;
}
.tree-folder { width: 100%; padding: 7px 5px; }
.tree-folder[aria-current] { background: #dcefe8; color: #145b50; font-weight: 650; }
.tree-more { padding: 5px 4px; color: var(--muted); font-size: .85rem; }

.folder-icon {
  position: relative;
  display: inline-block;
  flex: 0 0 15px;
  height: 11px;
  border-radius: 2px;
  background: #edbd57;
}
.folder-icon::before { content: ''; position: absolute; left: 1px; top: -3px; width: 7px; height: 4px; border-radius: 2px; background: #edbd57; }

.file-icon {
  flex: 0 0 24px;
  height: 24px;
  background: url('/file-icons.png') no-repeat 0 0 / 264px 24px;
}

.file-icon--pdf { background-position-x: -24px; }
.file-icon--word { background-position-x: -48px; }
.file-icon--sheet { background-position-x: -72px; }
.file-icon--slides {
  position: relative;
  background: none;
}
.file-icon--slides::before {
  content: '';
  position: absolute;
  inset: 1px 0 2px 5px;
  border-radius: 1px;
  background: linear-gradient(#ff926f 0 25%, #ee714b 25% 50%, #d65330 50% 75%, #b53a20 75%);
  box-shadow: 0 1px 2px rgb(0 0 0 / 22%);
}
.file-icon--slides::after {
  content: 'P';
  position: absolute;
  top: 6px;
  left: 0;
  display: grid;
  place-items: center;
  width: 12px;
  height: 12px;
  border-radius: 1px;
  background: #b8391e;
  color: #fff;
  font: 700 9px/1 "Segoe UI", sans-serif;
  box-shadow: 1px 1px 2px rgb(85 23 12 / 34%);
}
.file-icon--image { background-position-x: -120px; }
.file-icon--text { background-position-x: -144px; }
.file-icon--archive { background-position-x: -168px; }
.file-icon--audio { background-position-x: -192px; }
.file-icon--video { background-position-x: -216px; }
.file-icon--cad { background-position-x: -240px; }

.library-files { min-height: 300px; }
.library-path {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}
.path-separator { color: #7a8b9c; }
.path-current { font-weight: 650; }
.link-control { padding: 2px 0; color: var(--accent); font-size: .9rem; }
.link-control:hover, .file-name:hover { text-decoration: underline; }
.file-name { padding: 0; min-height: 26px; align-items: center; }
button.file-name { width: 100%; }
.file-name > .folder-icon { margin-inline: 4.5px; }
.file-table td { vertical-align: middle; }
.file-date, .file-size, .file-actions { white-space: nowrap; }
.file-table .file-actions { width: 5.75rem; text-align: center; }
.file-more { margin-top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@media (max-width: 850px) {
  .library-explorer { display: block; }
  .library-tree {
    position: fixed;
    inset: calc(var(--header-height) + 6px) var(--page-padding) auto;
    z-index: 8;
    max-height: 65vh;
    max-height: 65dvh;
    overscroll-behavior: contain;
    box-shadow: 0 8px 24px rgb(23 38 57 / 16%);
  }
}

@media (max-width: 620px) {
  .library-files { padding-inline-end: 10px; }
  .file-table-scroll { overflow-x: auto; }
  .file-table {
    --file-size-width: 5.25rem;
    --file-date-width: 10.5rem;
    width: calc(100% + var(--file-size-width) + var(--file-date-width));
    table-layout: fixed;
  }
  .file-table td { padding-block: 5px; }
  .file-table .file-size { width: var(--file-size-width); }
  .file-table .file-actions { width: 4.75rem; padding-inline: 0; }
  .file-table .file-date { width: var(--file-date-width); }
  .file-name { font-size: .86rem; }
}

@media (prefers-reduced-motion: reduce) {
  .site-header { transition: none; }
}

.file-controls { display: flex; justify-content: flex-end; }
.file-action {
  display: inline-grid;
  place-items: center;
  width: 2.375rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  text-decoration: none;
}
.file-action:hover { background: #edf0f2; }
.file-action:focus-visible { outline-color: #666; outline-offset: -3px; }
.file-action--download { --action-image: url('/wddf-download.png'); }
.file-action--share { --action-image: url('/wddf-share.png'); }
.file-action-icon {
  width: 18px;
  height: 18px;
  background: var(--action-image) center / contain no-repeat;
}

@media (max-width: 620px) {
  .file-action-icon { width: 16px; height: 16px; }
  @supports (mask-image: none) or (-webkit-mask-image: none) {
    .file-action-icon {
      /* Offset two copies of the alpha mask to keep the smaller strokes legible. */
      --action-mask:
        var(--action-image) calc(50% - .15px) calc(50% - .15px) / contain no-repeat,
        var(--action-image) calc(50% + .15px) calc(50% + .15px) / contain no-repeat;
      background: #777;
      -webkit-mask: var(--action-mask);
      mask: var(--action-mask);
    }
  }
}

.share-feedback { position: fixed; right: 16px; bottom: 16px; z-index: 10; background: var(--nav); color: #fff; border-radius: 8px; padding: 12px 16px; }
.share-dialog { width: min(440px, calc(100% - 30px)); color: inherit; }
.share-dialog::backdrop { background: #0d192866; }
.share-dialog form { display: grid; gap: 12px; }
.share-dialog label { font-weight: 650; }
.share-dialog input { min-width: 0; padding: 8px; border: 1px solid #c9d5e1; border-radius: 5px; }
.share-dialog button { justify-self: end; }
