:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-subtle: #f2f2ef;
  --ink: #18181b;
  --ink-2: #52525b;
  --ink-3: #a1a1aa;
  --line: rgba(24, 24, 27, 0.08);
  --line-strong: rgba(24, 24, 27, 0.14);
  --accent: #18181b;
  --accent-hover: #27272a;
  --red: #dc2626;
  --amber: #d97706;
  --green: #059669;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 224px;
  background: var(--bg);
  border-right: 1px solid var(--line);
  padding: 24px 14px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 24px;
}
.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink);
}
.brand-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.78; }
.nav-item:hover { background: rgba(24, 24, 27, 0.045); color: var(--ink); }
.nav-item.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.nav-item.active svg { opacity: 1; }

.nav-count {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--ink);
  color: #fff;
  padding: 1px 7px;
  border-radius: 999px;
}

.sidebar-foot {
  padding: 14px 10px 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.mini-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-3);
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d4d4d8;
  display: inline-block;
  flex-shrink: 0;
}
.dot.online { background: var(--green); }
.dot.warn { background: var(--amber); }

/* Main Area */
.main {
  flex: 1;
  min-width: 0;
  padding: 36px 32px 60px;
}
.mobile-bar, .mobile-nav { display: none; }

.view { display: none; }
.view.active { display: block; }

.container { max-width: 740px; margin: 0 auto; }
.container.wide { max-width: 960px; }
.container.narrow { max-width: 640px; }

.view-head { margin-bottom: 24px; }
.view-head h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.subtitle { margin: 5px 0 0; color: var(--ink-2); font-size: 14px; }
.row-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }

/* Unified Composer */
.composer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 16px 12px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within, .composer.dragover {
  border-color: var(--line-strong);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
}
.composer.dragover { background: #fafafa; }

.composer-input {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: transparent;
}
.composer-input::placeholder { color: var(--ink-3); }

.staged-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.staged-files[hidden] { display: none; }
.staged-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 5px 10px;
  font-size: 12.5px;
  color: var(--ink);
  max-width: 100%;
}
.staged-chip .staged-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}
.staged-chip button {
  border: none;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}
.staged-chip button:hover { color: var(--red); }

.composer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.composer-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--ink-2);
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { background: var(--surface-subtle); color: var(--ink); }

.mode-pill {
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--ink-2);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.mode-pill.is-chat { background: var(--ink); color: #fff; border-color: var(--ink); }

.btn-solid {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.14s, opacity 0.14s;
}
.btn-solid:hover { background: var(--accent-hover); }
.btn-solid:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-round {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-round svg { width: 16px; height: 16px; }

.btn-outline {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 7px 13px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-outline:hover { background: var(--surface-subtle); }

.btn-text {
  border: none;
  background: transparent;
  color: var(--ink-2);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
.btn-text:hover { background: var(--surface-subtle); color: var(--ink); }
.btn-text.danger:hover { color: var(--red); background: rgba(220, 38, 38, 0.06); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.busy-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-2);
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Section bar & Approval Cards */
.section-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 30px 0 12px;
}
.section-bar h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink-2); }
.count-label { font-size: 12.5px; color: var(--ink-3); }

.stack { display: flex; flex-direction: column; gap: 12px; }

.item-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.item-head { display: flex; gap: 14px; align-items: flex-start; }
.thumb {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; font-size: 15.5px; color: var(--ink); }
.item-summary { margin-top: 5px; font-size: 13.5px; color: var(--ink-2); line-height: 1.55; }

.meta-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.zone-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}
.zone-dot { width: 6px; height: 6px; border-radius: 50%; }
.zone-strict_local .zone-dot { background: var(--red); }
.zone-private_local .zone-dot { background: var(--amber); }
.zone-cloud_drive .zone-dot { background: var(--green); }
.sep { color: var(--ink-3); }
.due-text { color: #b45309; font-weight: 500; }

.item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.footer-left { display: flex; gap: 4px; align-items: center; }
.footer-right { display: flex; gap: 8px; align-items: center; }

.edit-drawer {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: 10px;
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 10px;
}
.edit-drawer[hidden] { display: none; }

.mini-field { display: flex; flex-direction: column; gap: 4px; }
.mini-field label { font-size: 12px; color: var(--ink-2); }
.mini-field input, .mini-field select, .mini-field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
}
.mini-field input:focus, .mini-field select:focus, .mini-field textarea:focus {
  outline: none;
  border-color: var(--ink);
}

/* Chat */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 96px);
}
.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.chat-welcome {
  margin: auto;
  text-align: center;
  max-width: 420px;
  padding: 40px 16px;
}
.chat-welcome h2 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.chat-welcome p { margin: 0; color: var(--ink-2); font-size: 14px; }

.bubble {
  max-width: 86%;
  font-size: 14.5px;
  line-height: 1.65;
  word-break: break-word;
}
.bubble.user {
  align-self: flex-end;
  background: var(--ink);
  color: #fff;
  padding: 10px 15px;
  border-radius: 16px 16px 4px 16px;
  white-space: pre-wrap;
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 14px 16px;
  border-radius: 16px 16px 16px 4px;
  box-shadow: var(--shadow-sm);
}
.md-h { font-weight: 650; margin: 6px 0 4px; }
.md-li { padding-left: 6px; margin: 2px 0; }
.md-gap { height: 8px; }
.md-code {
  background: var(--surface-subtle);
  padding: 1px 5px;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}
.md-pre {
  background: #18181b;
  color: #f4f4f5;
  padding: 10px 12px;
  border-radius: 10px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  margin: 8px 0;
}

.ref-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.ref-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 12.5px;
  text-decoration: none;
  transition: border-color 0.14s;
}
.ref-chip:hover { border-color: var(--ink); }
.chat-img {
  display: block;
  max-width: 100%;
  max-height: 300px;
  border-radius: 10px;
  margin-top: 10px;
  border: 1px solid var(--line);
  cursor: zoom-in;
}

/* WeChat-style Fullscreen Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.96);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  touch-action: none;
}
.lightbox[hidden] { display: none; }
.lb-close {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
}
.lb-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 20px 10px;
}
.lb-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.16s ease-out;
  user-select: none;
  -webkit-user-drag: none;
}
.lb-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
}
.lb-btn {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}
.lb-btn-primary {
  background: #fff;
  color: #18181b;
  border-color: #fff;
}

.chat-dock { padding-top: 12px; }
.suggestions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.suggest-chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
}
.suggest-chip:hover { border-color: var(--line-strong); color: var(--ink); }

.chat-input-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 6px 6px 18px;
  box-shadow: var(--shadow);
}
.chat-input-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14.5px;
  background: transparent;
  color: var(--ink);
}

/* Vault */
.search-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 14px;
  width: 280px;
  max-width: 100%;
}
.search-pill svg { width: 15px; height: 15px; color: var(--ink-3); flex-shrink: 0; }
.search-pill input { border: none; outline: none; background: transparent; width: 100%; font-size: 13.5px; color: var(--ink); }

.tabs-line {
  display: flex;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab-link {
  border: none;
  background: transparent;
  padding: 9px 2px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab-link.active { color: var(--ink); border-bottom-color: var(--ink); }

.vault-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.vault-list.photo-grid {
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
}
.v-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.14s;
}
.v-card:hover { border-color: var(--line-strong); }
.v-photo {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: 9px;
  margin-bottom: 4px;
}
.v-title { font-weight: 600; font-size: 14.5px; }
.v-desc {
  font-size: 13px;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.v-foot {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--ink-3);
}
.v-foot a { color: var(--ink); text-decoration: none; font-weight: 500; }
.v-foot a:hover { text-decoration: underline; }

/* Settings */
.group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  margin: 22px 0 8px 4px;
  letter-spacing: 0.02em;
}
.setting-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 15px 18px;
}
.setting-row.clickable { cursor: pointer; }
.row-title { font-weight: 550; font-size: 14.5px; }
.row-desc { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.pill-tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--ink-2);
  white-space: nowrap;
}
.pill-tag.ok { background: rgba(5, 150, 105, 0.1); color: var(--green); }

.subtle-details {
  border-top: 1px solid var(--line);
  padding: 0 18px;
}
.subtle-details.inner {
  border-top: none;
  padding: 0;
  margin-top: 10px;
}
.subtle-details summary {
  list-style: none;
  padding: 11px 0;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}
.subtle-details summary::after { content: " ▾"; color: var(--ink-3); }
.subtle-details[open] summary::after { content: " ▴"; }
.details-body {
  padding-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cloud-fields {
  border-top: 1px solid var(--line);
  padding: 14px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cloud-fields[hidden] { display: none; }
.preset-pills { display: flex; gap: 6px; }
.pill-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}
.pill-btn:hover { border-color: var(--ink); color: var(--ink); }
.hint { color: var(--ink-3); font-weight: 400; }

.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}
.toggle { width: 18px; height: 18px; accent-color: var(--ink); cursor: pointer; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.settings-save { margin-top: 22px; display: flex; justify-content: flex-end; }

.empty {
  text-align: center;
  padding: 44px 16px;
  color: var(--ink-3);
  font-size: 13.5px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  z-index: 999;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.lock-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  padding: 20px;
}
.lock-overlay[hidden] { display: none; }
.lock-card {
  width: 100%;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}
.lock-card h2 { margin: 0; font-size: 18px; font-weight: 650; }
.lock-card input {
  width: 100%;
  margin-top: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14.5px;
  text-align: center;
}
.lock-card input:focus { outline: none; border-color: var(--ink); }

/* Mobile (Android) */
@media (max-width: 780px) {
  .sidebar { display: none; }
  .main { padding: 0 16px 84px; }
  .mobile-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 2px 10px;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 20;
  }
  .mobile-title { font-size: 17px; font-weight: 650; }
  .mobile-dots { display: flex; gap: 8px; align-items: center; }

  .view-head h1 { font-size: 21px; }
  .edit-drawer { grid-template-columns: 1fr; }
  .search-pill { width: 100%; }
  .chat-container { height: calc(100vh - 132px); }
  .toast { bottom: 76px; }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding: 10px 6px calc(10px + env(safe-area-inset-bottom));
    z-index: 30;
  }
  .m-nav-item {
    position: relative;
    border: none;
    background: transparent;
    color: var(--ink-3);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 0;
  }
  .m-nav-item.active { color: var(--ink); font-weight: 650; }
  .m-dot-badge {
    position: absolute;
    top: -2px;
    right: 16%;
    background: var(--ink);
    color: #fff;
    font-size: 10px;
    padding: 0 5px;
    border-radius: 999px;
  }
}
