:root {
  --ink: #10241f;
  --ink-soft: #3a524b;
  --paper: #e8f0ec;
  --panel: rgba(255, 255, 255, 0.72);
  --line: rgba(16, 36, 31, 0.12);
  --accent: #0f7a62;
  --accent-2: #d97706;
  --sidebar: #0c1f1a;
  --sidebar-text: #d7e8e1;
  --sidebar-muted: #8aa89c;
  --shadow: 0 18px 50px rgba(8, 28, 22, 0.14);
  --radius: 18px;
  --font: "Manrope", system-ui, sans-serif;
  --display: "Syne", "Manrope", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(15, 122, 98, 0.18), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(217, 119, 6, 0.12), transparent 55%),
    linear-gradient(160deg, #dce8e2 0%, #eef3f0 45%, #e3ebe7 100%);
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w, minmax(280px, 340px)) 1fr;
  min-height: 100vh;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(15, 122, 98, 0.18), transparent 30%),
    var(--sidebar);
  color: var(--sidebar-text);
  padding: 18px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-right: 1px solid rgba(255,255,255,0.06);
  max-height: 100vh;
  position: sticky;
  top: 0;
  min-width: 0;
  z-index: 2;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 8px;
  flex: none;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 800;
  background: linear-gradient(145deg, #14a384, #0b5c4a);
  color: #fff;
  letter-spacing: -0.04em;
}
.brand-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}
.brand-sub {
  color: var(--sidebar-muted);
  font-size: 0.78rem;
}

.sidebar-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 5;
}
.app { position: relative; }
body.resizing-sidebar {
  cursor: col-resize;
  user-select: none;
}
body.resizing-sidebar .main {
  pointer-events: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.browse-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

.search {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: none;
}
.search input {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.06);
  color: #fff;
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  font-size: 0.88rem;
  outline: none;
}
.search input::placeholder { color: var(--sidebar-muted); }
.search input:focus {
  border-color: rgba(20, 163, 132, 0.7);
  background: rgba(255,255,255,0.1);
}
.search-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.chip {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--sidebar-text);
  border-radius: 999px;
  padding: 3px 9px;
  font: inherit;
  font-size: 0.7rem;
  cursor: pointer;
}
.chip:hover,
.chip.active {
  background: rgba(20, 163, 132, 0.35);
  border-color: rgba(20, 163, 132, 0.55);
}

.tree-shell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
  padding: 8px;
}

.tree-filter input {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 0.82rem;
  outline: none;
}
.tree-filter input::placeholder { color: var(--sidebar-muted); }
.tree-filter input:focus {
  border-color: rgba(240, 180, 41, 0.55);
  background: rgba(255,255,255,0.09);
}

.tree-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 2px;
}
.tree-tool {
  border: 0;
  background: rgba(255,255,255,0.06);
  color: var(--sidebar-muted);
  width: 28px;
  height: 26px;
  border-radius: 7px;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1;
}
.tree-tool:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.tree-tool-spacer { flex: 1; }
.tree-stats {
  font-size: 0.68rem;
  color: var(--sidebar-muted);
  font-variant-numeric: tabular-nums;
}

.tree-recents {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding: 2px 2px 4px;
}
.tree-recents-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sidebar-muted);
  margin-right: 2px;
}
.tree-recent {
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: var(--sidebar-text);
  border-radius: 6px;
  padding: 2px 7px;
  font: inherit;
  font-size: 0.68rem;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.tree-recent:hover {
  border-color: rgba(20, 163, 132, 0.5);
  background: rgba(20, 163, 132, 0.2);
}

.tree {
  overflow: auto;
  flex: 1;
  min-height: 0;
  padding: 2px 0 8px;
  outline: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.tree:focus-visible {
  box-shadow: inset 0 0 0 1px rgba(20, 163, 132, 0.45);
  border-radius: 8px;
}

.tree ul,
.tree-children {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tree > .tree-children {
  padding: 0;
}

.tree-item.filter-hide {
  display: none !important;
}

.tree-item:not(.expanded) > .tree-children {
  display: none;
}

.tree-row {
  display: flex;
  align-items: stretch;
  position: relative;
  padding-left: calc(var(--depth, 0) * 12px);
  min-height: 30px;
}

/* indent guides */
.tree-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: calc(var(--depth, 0) * 12px);
  background-image: repeating-linear-gradient(
    to right,
    transparent 0,
    transparent 11px,
    rgba(255, 255, 255, 0.07) 11px,
    rgba(255, 255, 255, 0.07) 12px
  );
  pointer-events: none;
}

.tree-twist,
.tree-twist-spacer {
  width: 22px;
  flex: none;
  display: grid;
  place-items: center;
  align-self: stretch;
}
.tree-twist {
  border: 0;
  background: transparent;
  color: var(--sidebar-muted);
  cursor: pointer;
  padding: 0;
  border-radius: 6px;
  position: relative;
}
.tree-twist::before {
  content: "";
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent currentColor;
  transition: transform 0.12s ease;
  transform: rotate(0deg);
}
.tree-item.expanded > .tree-row > .tree-twist::before {
  transform: rotate(90deg);
}
.tree-twist:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}

.tree-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 5px 8px 5px 4px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.84rem;
  line-height: 1.25;
}
.tree-btn:hover {
  background: rgba(255,255,255,0.07);
}
.tree-btn:focus-visible {
  outline: 1px solid rgba(20, 163, 132, 0.7);
  outline-offset: -1px;
}
.tree-btn.active,
.tree-item.is-active > .tree-row > .tree-btn {
  background: rgba(20, 163, 132, 0.28);
  box-shadow: inset 2px 0 0 #14a384;
}
.tree-item.filter-hit > .tree-row > .tree-btn .tree-label {
  color: #ffe7a3;
}

.tree-item.is-root > .tree-row > .tree-btn {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: -0.02em;
  margin-top: 4px;
}
.tree-item[data-level="1"] > .tree-row > .tree-btn {
  font-weight: 600;
}

.tree-icon {
  width: 1.05em;
  height: 1.05em;
  flex: none;
  opacity: 0.85;
  background: currentColor;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}
.tree-icon[data-kind="folder"] {
  color: #7ec8b4;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M1.5 3.5A1.5 1.5 0 0 1 3 2h3.172a1.5 1.5 0 0 1 1.06.44L8.5 3.7H13A1.5 1.5 0 0 1 14.5 5.2v6.3A1.5 1.5 0 0 1 13 13H3A1.5 1.5 0 0 1 1.5 11.5z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M1.5 3.5A1.5 1.5 0 0 1 3 2h3.172a1.5 1.5 0 0 1 1.06.44L8.5 3.7H13A1.5 1.5 0 0 1 14.5 5.2v6.3A1.5 1.5 0 0 1 13 13H3A1.5 1.5 0 0 1 1.5 11.5z'/%3E%3C/svg%3E");
}
.tree-icon[data-kind="card"] {
  color: #f0b429;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M3 2.5A1.5 1.5 0 0 1 4.5 1h7A1.5 1.5 0 0 1 13 2.5v11a.5.5 0 0 1-.8.4L8 11.1l-4.2 2.8a.5.5 0 0 1-.8-.4z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M3 2.5A1.5 1.5 0 0 1 4.5 1h7A1.5 1.5 0 0 1 13 2.5v11a.5.5 0 0 1-.8.4L8 11.1l-4.2 2.8a.5.5 0 0 1-.8-.4z'/%3E%3C/svg%3E");
}
.tree-icon[data-kind="group"] {
  color: #9bb7ff;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M1 3.5A1.5 1.5 0 0 1 2.5 2H6l1.2 1.2H13.5A1.5 1.5 0 0 1 15 4.7v7.8A1.5 1.5 0 0 1 13.5 14h-11A1.5 1.5 0 0 1 1 12.5z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M1 3.5A1.5 1.5 0 0 1 2.5 2H6l1.2 1.2H13.5A1.5 1.5 0 0 1 15 4.7v7.8A1.5 1.5 0 0 1 13.5 14h-11A1.5 1.5 0 0 1 1 12.5z'/%3E%3C/svg%3E");
}

.tree-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-count {
  font-size: 0.65rem;
  color: var(--sidebar-muted);
  background: rgba(255,255,255,0.06);
  padding: 1px 6px;
  border-radius: 999px;
  flex: none;
  font-variant-numeric: tabular-nums;
}

.empty-hint {
  color: var(--sidebar-muted);
  font-size: 0.9rem;
  padding: 8px;
  line-height: 1.45;
}
.empty-hint code {
  color: #b7f0d8;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 28px 8px;
  min-width: 0;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}
.sync-wrap,
.notify-wrap {
  position: relative;
}
.sync-btn,
.notify-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.7);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.sync-btn.running {
  background: rgba(15, 122, 98, 0.15);
  border-color: rgba(15, 122, 98, 0.4);
}
.notify-btn {
  position: relative;
  width: 42px;
  padding: 8px 0;
}
.notify-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #c2410c;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.sync-menu,
.notify-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(360px, 92vw);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 40;
  padding: 10px;
}
.sync-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 280px;
}
.sync-menu button {
  border: 0;
  background: rgba(16, 36, 31, 0.04);
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  font: inherit;
  cursor: pointer;
}
.sync-menu button:hover {
  background: rgba(15, 122, 98, 0.12);
}
.sync-auto-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--ink-soft);
  padding: 6px 4px;
}
.sync-auto-line input[type="number"] {
  width: 52px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  font: inherit;
}
.sync-status-text {
  font-size: 0.75rem;
  color: var(--ink-soft);
  padding: 4px 6px 2px;
  line-height: 1.35;
}
.notify-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 8px;
  border-bottom: 1px solid var(--line);
}
.notify-link {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}
.notify-list {
  max-height: 360px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
}
.notify-empty {
  margin: 0;
  padding: 16px 8px;
  color: var(--ink-soft);
  font-size: 0.88rem;
}
.notify-item {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
}
.notify-item:hover {
  background: rgba(16, 36, 31, 0.05);
}
.notify-item.unread {
  background: rgba(15, 122, 98, 0.08);
  box-shadow: inset 3px 0 0 var(--accent);
}
.notify-kind {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  font-weight: 700;
}
.notify-item strong {
  font-size: 0.9rem;
}
.notify-detail {
  font-size: 0.78rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notify-time {
  font-size: 0.72rem;
  color: var(--ink-soft);
}
.notify-open-new {
  width: 100%;
  padding: 8px;
  border-top: 1px solid var(--line);
}
.item-new {
  box-shadow: inset 3px 0 0 #0f7a62;
}
.item-updated {
  box-shadow: inset 3px 0 0 #d97706;
}
.flag-new-badge {
  background: rgba(15, 122, 98, 0.16) !important;
  color: #0f7a62 !important;
}
.flag-upd-badge {
  background: rgba(217, 119, 6, 0.18) !important;
  color: #b45309 !important;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: var(--ink-soft);
  font-size: 0.92rem;
  min-width: 0;
  overflow: hidden;
}
.crumbs button {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.crumbs button:hover { text-decoration: underline; }
.crumbs .sep { opacity: 0.4; }
.meta-pill {
  font-size: 0.8rem;
  color: var(--ink-soft);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  backdrop-filter: blur(8px);
  flex: none;
}

.content {
  padding: 8px 28px 40px;
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
}

.home h1,
.panel-title {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.04em;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  margin: 8px 0 10px;
}
.home p { color: var(--ink-soft); max-width: 46ch; line-height: 1.55; }
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 28px;
  max-width: 720px;
}
.home-card {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  box-shadow: var(--shadow);
  font: inherit;
  transition: transform .15s ease, border-color .15s ease;
}
.home-card:hover {
  transform: translateY(-2px);
  border-color: rgba(15, 122, 98, 0.35);
}
.home-card strong {
  display: block;
  font-family: var(--display);
  font-size: 1.2rem;
  margin-bottom: 6px;
}
.home-card span { color: var(--ink-soft); font-size: 0.92rem; }
.home-note {
  margin-top: 22px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  max-width: 52ch;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 22px 24px 28px;
  backdrop-filter: blur(10px);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
  min-width: 0;
}
.panel-title {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.badge {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  font-weight: 700;
}

.grid-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 12px;
  width: 100%;
  min-width: 0;
}

.list-block {
  margin-top: 8px;
  min-width: 0;
}
.list-block + .list-block {
  margin-top: 22px;
}
.list-block-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 10px;
}
.list-block-title span {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: rgba(16, 36, 31, 0.06);
  padding: 2px 8px;
  border-radius: 999px;
}

.entry-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.item-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}
.item-row .item {
  flex: 1;
}
.item-row .item-chevron {
  display: grid;
  place-items: center;
  width: 28px;
  color: var(--ink-soft);
  font-size: 1.2rem;
  opacity: 0.45;
  flex: none;
}
.item-row-folder:hover .item-chevron,
.item-row-card:hover .item-chevron {
  opacity: 1;
  color: var(--accent);
}
.item-row .item-dl {
  width: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink-soft);
  background: rgba(255,255,255,0.55);
  border: 1px dashed rgba(16, 36, 31, 0.16);
}
.item-row .item-dl:hover {
  background: #fff;
  border-style: solid;
  border-color: rgba(15, 122, 98, 0.35);
  color: var(--accent);
}

.item {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.55);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: border-color .15s ease, background .15s ease, transform .12s ease;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}
.item:hover {
  border-color: rgba(15, 122, 98, 0.4);
  background: #fff;
}
.item-folder {
  background: linear-gradient(90deg, rgba(15, 122, 98, 0.08), rgba(255,255,255,0.65) 42%);
  border-color: rgba(15, 122, 98, 0.18);
}
.item-folder:hover {
  border-color: rgba(15, 122, 98, 0.45);
  background: linear-gradient(90deg, rgba(15, 122, 98, 0.14), #fff 50%);
}
.item-card {
  background: linear-gradient(90deg, rgba(217, 119, 6, 0.1), rgba(255,255,255,0.65) 42%);
  border-color: rgba(217, 119, 6, 0.2);
}
.item-card:hover {
  border-color: rgba(217, 119, 6, 0.45);
  background: linear-gradient(90deg, rgba(217, 119, 6, 0.16), #fff 50%);
}
.item-file {
  background: rgba(255,255,255,0.72);
  border-style: dashed;
  border-color: rgba(16, 36, 31, 0.16);
}
.item-file:hover {
  border-style: solid;
  border-color: rgba(16, 36, 31, 0.28);
  background: #fff;
}

.item-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex: none;
  display: grid;
  place-items: center;
  background: rgba(16, 36, 31, 0.06);
  color: var(--ink-soft);
  position: relative;
}
.item-icon::before {
  content: "";
  width: 18px;
  height: 18px;
  background: currentColor;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}
.item-folder .item-icon {
  background: rgba(15, 122, 98, 0.16);
  color: #0f7a62;
}
.item-folder .item-icon::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M1.5 3.5A1.5 1.5 0 0 1 3 2h3.172a1.5 1.5 0 0 1 1.06.44L8.5 3.7H13A1.5 1.5 0 0 1 14.5 5.2v6.3A1.5 1.5 0 0 1 13 13H3A1.5 1.5 0 0 1 1.5 11.5z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M1.5 3.5A1.5 1.5 0 0 1 3 2h3.172a1.5 1.5 0 0 1 1.06.44L8.5 3.7H13A1.5 1.5 0 0 1 14.5 5.2v6.3A1.5 1.5 0 0 1 13 13H3A1.5 1.5 0 0 1 1.5 11.5z'/%3E%3C/svg%3E");
}
.item-card .item-icon {
  background: rgba(217, 119, 6, 0.18);
  color: #b45309;
}
.item-card .item-icon::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M3 2.5A1.5 1.5 0 0 1 4.5 1h7A1.5 1.5 0 0 1 13 2.5v11a.5.5 0 0 1-.8.4L8 11.1l-4.2 2.8a.5.5 0 0 1-.8-.4z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M3 2.5A1.5 1.5 0 0 1 4.5 1h7A1.5 1.5 0 0 1 13 2.5v11a.5.5 0 0 1-.8.4L8 11.1l-4.2 2.8a.5.5 0 0 1-.8-.4z'/%3E%3C/svg%3E");
}
.item-file .item-icon {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}
.item-file .item-icon::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M4 1.5A1.5 1.5 0 0 0 2.5 3v10A1.5 1.5 0 0 0 4 14.5h8a1.5 1.5 0 0 0 1.5-1.5V5.207L9.793 1.5H4zm5.5.707L12.793 5H10A.5.5 0 0 1 9.5 4.5z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M4 1.5A1.5 1.5 0 0 0 2.5 3v10A1.5 1.5 0 0 0 4 14.5h8a1.5 1.5 0 0 0 1.5-1.5V5.207L9.793 1.5H4zm5.5.707L12.793 5H10A.5.5 0 0 1 9.5 4.5z'/%3E%3C/svg%3E");
}

.item-archive .item-icon {
  background: rgba(100, 60, 180, 0.12);
  color: #6d28d9;
}
.item-arch-paired .item-icon {
  background: rgba(15, 122, 98, 0.16);
  color: #0f7a62;
}
.item-arch-orphan .item-icon {
  background: rgba(180, 83, 9, 0.16);
  color: #b45309;
}
.item-archive .item-icon::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M3 2.5A1.5 1.5 0 0 1 4.5 1h2.586a1.5 1.5 0 0 1 1.06.44L9.5 2.9H13A1.5 1.5 0 0 1 14.5 4.4v.6H1.5v-.5A1.5 1.5 0 0 1 3 2.5zM1.5 6h13v6.5A1.5 1.5 0 0 1 13 14H3a1.5 1.5 0 0 1-1.5-1.5z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M3 2.5A1.5 1.5 0 0 1 4.5 1h2.586a1.5 1.5 0 0 1 1.06.44L9.5 2.9H13A1.5 1.5 0 0 1 14.5 4.4v.6H1.5v-.5A1.5 1.5 0 0 1 3 2.5zM1.5 6h13v6.5A1.5 1.5 0 0 1 13 14H3a1.5 1.5 0 0 1-1.5-1.5z'/%3E%3C/svg%3E");
}

.item-arch-paired {
  background: linear-gradient(90deg, rgba(15, 122, 98, 0.1), rgba(255,255,255,0.7) 48%);
  border-color: rgba(15, 122, 98, 0.28);
  border-style: solid;
}
.item-arch-orphan {
  background: linear-gradient(90deg, rgba(180, 83, 9, 0.12), rgba(255,255,255,0.7) 48%);
  border-color: rgba(180, 83, 9, 0.35);
  border-style: solid;
  box-shadow: inset 3px 0 0 #d97706;
}
.item-arch-paired:hover {
  border-color: rgba(15, 122, 98, 0.5);
}
.item-arch-orphan:hover {
  border-color: rgba(180, 83, 9, 0.55);
}

.arch-badge {
  font-style: normal;
  font-weight: 700;
  font-size: 0.66rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 6px;
  flex: none;
}
.arch-badge-paired {
  background: rgba(15, 122, 98, 0.16);
  color: #0f7a62;
}
.arch-badge-orphan {
  background: rgba(180, 83, 9, 0.18);
  color: #b45309;
}

.arch-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: -2px 0 10px;
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.arch-legend-paired { color: #0f7a62; font-weight: 600; }
.arch-legend-orphan { color: #b45309; font-weight: 600; }

.arch-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  margin: 12px 0 16px;
}
.arch-banner p {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.arch-banner-paired {
  background: rgba(15, 122, 98, 0.1);
  border: 1px solid rgba(15, 122, 98, 0.28);
}
.arch-banner-orphan {
  background: rgba(217, 119, 6, 0.1);
  border: 1px solid rgba(217, 119, 6, 0.3);
}
.arch-toc {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.65);
  max-height: 420px;
  overflow: auto;
}
.arch-toc-row {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(16, 36, 31, 0.06);
  font-size: 0.86rem;
}
.arch-toc-row:last-child { border-bottom: 0; }
.arch-toc-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.8rem;
}
.arch-toc-size {
  flex: none;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.item-title,
.item strong {
  display: block;
  margin: 0;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  font-weight: 650;
}
.item-folder .item-title { color: #0b4f40; }
.item-file .item-title { font-weight: 550; }

.item-meta,
.item span.item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}
.item-kind,
.item-ext {
  font-style: normal;
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 6px;
  flex: none;
}
.item-folder .item-kind {
  background: rgba(15, 122, 98, 0.14);
  color: #0f7a62;
}
.item-card .item-kind {
  background: rgba(217, 119, 6, 0.16);
  color: #b45309;
}
.item-file .item-ext {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}
.item-meta-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-action-hint {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
  flex: none;
}

.item span:not(.item-meta):not(.item-icon):not(.item-body):not(.item-action-hint):not(.item-meta-text) {
  color: var(--ink-soft);
  font-size: 0.82rem;
}
.readme {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-left: 3px solid var(--accent-2);
  background: rgba(217, 119, 6, 0.08);
  border-radius: 0 12px 12px 0;
  color: var(--ink-soft);
  white-space: pre-wrap;
}

.md-body {
  line-height: 1.65;
  font-size: 1.02rem;
}
.md-body h1 { display: none; }
.md-body h2 {
  font-family: var(--display);
  font-size: 1.15rem;
  margin: 1.4em 0 0.5em;
  letter-spacing: -0.02em;
}
.md-body ul { padding-left: 1.2em; }
.md-body a { color: var(--accent); }

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 16px 0 8px;
}
.field {
  background: rgba(16, 36, 31, 0.04);
  border-radius: 12px;
  padding: 10px 12px;
}
.field b {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.section-title {
  font-family: var(--display);
  font-size: 1.05rem;
  margin: 24px 0 10px;
}
.files {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.6);
}
.file-row .name {
  font-weight: 600;
  word-break: break-word;
}
.file-row .size {
  color: var(--ink-soft);
  font-size: 0.82rem;
  white-space: nowrap;
}
.file-actions {
  display: flex;
  gap: 8px;
  flex: none;
}
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 7px 12px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn:hover { filter: brightness(0.97); }

.links a {
  display: block;
  color: var(--accent);
  margin: 6px 0;
  word-break: break-all;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.search-hit {
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.65);
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  font: inherit;
  min-width: 0;
  overflow: hidden;
}
.search-hit:hover { border-color: rgba(15, 122, 98, 0.4); }
.search-hit strong {
  display: block;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-hit .snippet {
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-hit .section {
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.search-hit .kind {
  display: inline-block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  background: rgba(16, 36, 31, 0.06);
  border-radius: 999px;
  padding: 2px 8px;
  flex: none;
}
.hit-crumbs,
.hit-links {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin: 4px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  min-width: 0;
}
.hit-crumbs button,
.hit-links a {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: inherit;
  padding: 0;
  text-decoration: none;
}
.hit-crumbs button:hover,
.hit-links a:hover { text-decoration: underline; }
.hit-crumbs .sep { opacity: 0.4; }

.origin-box {
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(15, 122, 98, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.origin-nav,
.origin-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  align-items: start;
  min-width: 0;
}
.origin-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  padding-top: 2px;
}
.origin-crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  min-width: 0;
}
.origin-crumbs button {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.origin-crumbs button:hover { text-decoration: underline; }
.origin-crumbs .sep { opacity: 0.4; color: var(--ink-soft); }
.origin-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0;
}
.origin-link:hover { text-decoration: underline; }
.origin-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.origin-stack strong {
  font-size: 0.92rem;
}

dialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: calc(100vw - 24px);
  max-width: none;
  height: calc(100vh - 24px);
  max-height: calc(100vh - 24px);
  box-shadow: var(--shadow);
  background: #fff;
  overflow: hidden;
}
dialog:not([open]) { display: none; }
dialog[open] {
  display: flex;
  flex-direction: column;
}
dialog::backdrop { background: rgba(8, 24, 20, 0.55); }
.preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.preview-actions { display: flex; gap: 8px; align-items: center; }
.preview-actions a, .preview-actions button {
  font: inherit;
  font-size: 0.88rem;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 7px 12px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
}
.preview-body {
  padding: 0;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  background: #1a1a1a;
}
.preview-body img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  margin: auto;
}
.preview-body video {
  width: 100%;
  height: 100%;
  border: 0;
  background: #111;
}
.preview-body p {
  color: #eee;
  padding: 24px;
  margin: auto;
}

.office-wrap,
.office-loading {
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 24px 28px 40px;
  background: #f7f5f1;
  color: #1a1a1a;
  box-sizing: border-box;
}
.office-loading p {
  color: #444;
  margin: 0;
  padding: 0;
}
.office-doc {
  max-width: 860px;
  margin: 0 auto;
  font: 15px/1.55 "Segoe UI", system-ui, sans-serif;
}
.office-doc h1,
.office-doc h2,
.office-doc h3,
.office-doc h4 {
  margin: 1.1em 0 0.4em;
  line-height: 1.25;
}
.office-doc p {
  color: inherit;
  margin: 0 0 0.75em;
  padding: 0;
}
.office-h {
  margin-top: 1.5em;
  font-size: 1rem;
  color: #444;
}
.office-table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5em 0 1.2em;
  font-size: 13px;
  background: #fff;
}
.office-table th,
.office-table td {
  border: 1px solid #ccc;
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
  max-width: 280px;
  word-break: break-word;
}
.office-table th {
  background: #eee;
  font-weight: 600;
}
.office-sheet-title {
  margin: 1.4em 0 0.5em;
  font-size: 1.05rem;
}
.office-note {
  color: #666;
  font-size: 13px;
  margin-top: 1em;
}

.pdf-viewer {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #3c3c3c;
}
.pdf-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #2b2b2b;
  border-bottom: 1px solid #111;
  color: #eee;
  font-size: 0.9rem;
}
.pdf-btn {
  font: inherit;
  border: 1px solid #555;
  background: #3a3a3a;
  color: #fff;
  border-radius: 8px;
  padding: 4px 12px;
  cursor: pointer;
}
.pdf-btn:hover { background: #4a4a4a; }
.pdf-zoom-label { min-width: 3.5rem; text-align: center; }
.pdf-page-label { margin-left: auto; color: #bbb; }
.pdf-pages {
  flex: 1;
  overflow: auto;
  padding: 16px;
  text-align: center;
}
.pdf-page {
  display: block;
  margin: 0 auto 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  background: #fff;
  max-width: none;
}
.pdf-loading { color: #ddd; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    max-height: none;
  }
  .sidebar-resizer { display: none; }
  .browse-sidebar { max-height: 55vh; }
  .tree { max-height: none; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}
