:root {
  --bg: #f3efe8;
  --bg-side: #efeae2;
  --paper: #fffdf9;
  --ink: #1f1a17;
  --muted: #7d746c;
  --line: #e4dbd1;
  --line-strong: #d5c9bb;
  --accent: #c45c26;
  --accent-soft: rgba(196, 92, 38, 0.12);
  --shadow: 0 12px 28px rgba(72, 44, 22, 0.06);
  --side: 276px;
  --radius: 16px;
  color-scheme: light;
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; }
::selection { background: #f0d2c2; }

.app {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  height: 100vh;
}

.side {
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: 22px 14px 28px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 8px 18px;
}
.logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--ink);
  color: #f6f1ea;
  display: grid;
  place-items: center;
  font-family: "Palatino Linotype", "Songti SC", "SimSun", serif;
  font-size: 20px;
  flex: none;
}
.brand strong { display: block; font-size: 16px; letter-spacing: 0.02em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.quick { display: flex; flex-direction: column; gap: 2px; }
.side-label {
  margin: 18px 10px 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.nav-item, .quick-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}
.nav-item:hover, .quick-item:hover { background: rgba(255, 255, 255, 0.55); }
.nav-item.is-active, .quick-item.is-active {
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
}
.nav-name, .quick-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-count, .quick-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  flex: none;
}
.grip {
  width: 18px;
  height: 28px;
  flex: none;
  color: #b7ada4;
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none;
  border-radius: 6px;
}
.grip:hover { color: var(--ink); background: rgba(255, 255, 255, 0.7); }
.grip:active { cursor: grabbing; }
.nav-item.is-dragging { opacity: 0.4; }
.nav-item.is-drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.nav-item.is-drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.twist {
  width: 14px;
  flex: none;
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: transform 0.15s ease;
}
.twist svg { display: block; }
.twist.is-open { transform: rotate(90deg); }
.twist.is-empty { visibility: hidden; }

.work { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 22px 8px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(var(--bg) 70%, rgba(243, 239, 232, 0));
}
.menu-btn {
  display: none;
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
  flex: none;
}
.search {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
  max-width: 720px;
}
.search-icon {
  position: absolute;
  left: 14px;
  color: var(--muted);
  display: grid;
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  padding: 0 92px 0 42px;
  outline: none;
}
.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search input::-webkit-search-cancel-button { display: none; }
.search-kbd, #clear {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}
.search-kbd {
  right: 64px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
  color: var(--muted);
  font-size: 12px;
  font-family: inherit;
  pointer-events: none;
}
#clear {
  right: 8px;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
}
#clear:hover { background: var(--bg); color: var(--ink); }

.content { overflow: auto; min-height: 0; }
.inner { max-width: 1120px; margin: 0 auto; padding: 8px 28px 56px; }

.page-head { margin: 8px 0 18px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 8px; }
.crumb, .crumb-sep { color: var(--muted); font-size: 13px; }
.crumb { cursor: pointer; border-radius: 6px; padding: 2px 4px; }
.crumb:hover { color: var(--accent); }
.crumb.is-current { color: var(--ink); cursor: default; }
h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.03em;
}
.sub { margin: 6px 0 0; color: var(--muted); }

.section-label {
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.folder-grid, .site-grid {
  display: grid;
  gap: 12px;
}
.folder-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); margin-bottom: 22px; }
.site-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

.folder-tile {
  position: relative;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 118px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}
.folder-hit {
  width: 100%;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 118px;
  padding: 14px 14px 13px;
}
.folder-tile.has-edit .folder-hit { padding-right: 62px; }
.folder-edit {
  position: absolute;
  top: 10px;
  right: 8px;
  background: var(--paper);
}
.folder-tile:hover {
  border-color: #e0bba6;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.folder-top { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 99px; flex: none; }
.folder-name {
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-count { color: var(--muted); font-size: 13px; }
.folder-count b {
  color: var(--ink);
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  margin-right: 4px;
}
.folder-sample {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.site-card {
  display: flex;
  align-items: stretch;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 74px;
  position: relative;
}
.site-card:hover {
  border-color: #e0bba6;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.site-hit {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 8px 12px 12px;
  text-decoration: none;
  color: inherit;
  border-radius: 14px;
}
.mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  position: relative;
  flex: none;
  overflow: hidden;
}
.mark img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #fff;
  padding: 6px;
  opacity: 0;
}
.mark img.is-on { opacity: 1; }
.site-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.site-title {
  font-weight: 650;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.site-host, .site-path {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.star {
  width: 36px;
  flex: none;
  cursor: pointer;
  color: #d9d0c7;
  font-size: 16px;
  border-radius: 12px;
}
.star:hover, .star.is-on { color: var(--accent); }
mark {
  background: #f6ddcf;
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

.empty {
  padding: 48px 8px;
  color: var(--muted);
}
.empty strong { display: block; color: var(--ink); font-size: 18px; margin-bottom: 6px; }
.foot {
  margin-top: 28px;
  color: var(--muted);
  font-size: 12px;
}
.more-note { margin: 12px 0 0; color: var(--muted); font-size: 13px; }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(40, 28, 20, 0.35);
  z-index: 15;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #f6f1ea;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 50;
}
.top-actions { display: flex; gap: 8px; flex: none; }
.top-actions[hidden] { display: none; }
.page-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  cursor: pointer;
}
.btn:hover { border-color: #e0bba6; }
.btn.primary { background: var(--ink); color: #f6f1ea; border-color: var(--ink); }
.btn.danger { color: #8c3d4b; }
.btn.danger-solid { background: #8c3d4b; color: #fff; border-color: #8c3d4b; }
.btn:disabled { opacity: 0.6; cursor: default; }
.card-tools { display: flex; align-items: center; padding-right: 4px; flex: none; }
.mini {
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}
.mini:hover { color: var(--accent); background: var(--bg); }
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(40, 28, 20, 0.38);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal[hidden] { display: none; }
.dialog {
  width: min(460px, 100%);
  background: var(--paper);
  border-radius: 18px;
  padding: 20px 20px 16px;
  box-shadow: var(--shadow);
}
.dialog h2 { margin: 0; font-size: 20px; letter-spacing: -0.03em; }
.dialog-note { margin: 8px 0 0; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field span { font-size: 13px; color: var(--muted); }
.field input, .field select {
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
  padding: 0 10px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dialog-error { margin: 10px 0 0; color: #8c3d4b; }
.dialog-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.dialog-spacer { flex: 1; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    z-index: 20;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .side.is-open { transform: none; }
  .menu-btn { display: inline-flex; align-items: center; }
  .top-actions { width: 100%; }
  .top-actions .btn { flex: 1; }
  .search-kbd { display: none; }
  .search input { padding-right: 64px; }
  .inner { padding: 4px 16px 40px; }
  h1 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .folder-tile, .site-card, .side, .twist { transition: none; }
  .folder-tile:hover, .site-card:hover { transform: none; }
}
