:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --border: #e5e6eb;
  --text: #1d2129;
  --text-2: #4e5969;
  --text-3: #86909c;
  --primary: #1a7f5a;
  --primary-soft: #e8f5f0;
  --danger: #c9302c;
  --danger-soft: #fdecec;
  --warn: #b7791f;
  --warn-soft: #fdf6e3;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

.hidden { display: none !important; }

button, input, select, textarea { font-family: inherit; font-size: 14px; }

.input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: none;
}
.input:focus { border-color: var(--primary); }
.input-sm { width: auto; min-width: 120px; padding: 6px 10px; }
.textarea { resize: none; min-height: 140px; max-height: 280px; line-height: 1.7; overflow-y: auto; transition: height 0.12s ease; font-size: 15px; padding: 12px 14px; }

.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: #c9cdd4; background: #fafafa; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #166b4c; border-color: #166b4c; }
.btn-danger { color: var(--danger); border-color: #f0c2c0; background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.auth-title { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.auth-sub { margin: 0 0 18px; color: var(--text-2); font-size: 13px; }
.auth-hint { min-height: 20px; margin: 8px 0 0; color: var(--danger); font-size: 13px; }
.auth-card .input { margin-top: 4px; }
.auth-card .btn { margin-top: 12px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.logo { margin: 0; font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; gap: 8px; }
.icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius);
  padding: 6px 12px;
  color: var(--text-2);
  cursor: pointer;
  font-size: 13px;
}
.icon-btn:hover { color: var(--text); border-color: #c9cdd4; }

.home {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 60px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card-title { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--text-2); }

.composer { padding: 14px; }
.composer-box { display: flex; flex-direction: column; gap: 10px; }
.composer-box.over { border: 1.5px dashed var(--primary); background: var(--primary-soft); border-radius: var(--radius); }
.composer-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.composer-bar .btn-primary { margin-left: auto; }
.send-mode { font-size: 12px; color: var(--text-3); margin-left: auto; }
.composer-bar .btn-primary + .send-mode { margin-left: 0; }

.file-queue { list-style: none; margin: 0; padding: 0; }
.file-queue li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #f7f8fa;
  font-size: 13px;
  margin-bottom: 4px;
}
.file-queue .remove-file { color: var(--danger); cursor: pointer; border: none; background: none; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row .input { flex: 1 1 140px; }
.switch { display: flex; align-items: center; gap: 8px; color: var(--text-2); cursor: pointer; }
.switch input { width: 16px; height: 16px; accent-color: var(--primary); }

.recent { margin-top: 18px; }
.recent-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.recent-head h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-2); }

.timeline { margin-top: 16px; }
.date-group { margin-bottom: 18px; }
.date-label {
  position: sticky;
  top: 56px;
  z-index: 5;
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-3);
  background: var(--bg);
  padding: 4px 0;
}

.item-card {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.item-card.pinned { border-left: 3px solid var(--primary); }
.item-card.selected { border-color: var(--primary); background: var(--primary-soft); }
.item-check { margin-top: 2px; }
.item-body { flex: 1; min-width: 0; }
.item-head { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.item-title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  word-break: break-all;
}
.item-meta { margin: 4px 0 0; color: var(--text-3); font-size: 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.item-text { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
.item-text.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.item-actions .btn { padding: 4px 10px; font-size: 12px; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 18px;
  background: #f2f3f5;
  color: var(--text-2);
}
.badge-private { background: var(--primary-soft); color: var(--primary); }
.badge-remote { background: #eaf2fd; color: #1554a5; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-soft { background: #f2f3f5; color: var(--text-2); }

.link-card {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
  text-decoration: none;
  color: inherit;
}
.link-card img { width: 88px; height: 62px; object-fit: cover; border-radius: 6px; background: #eee; flex: none; }
.link-card-body { min-width: 0; }
.link-card-title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-card-desc { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.link-card-site { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: #f2f3f5;
  flex: none;
  cursor: pointer;
}
.file-icon {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: #f2f3f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-2);
  flex: none;
}

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat {
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.stat-value { font-size: 16px; font-weight: 600; }
.stat-label { font-size: 11px; color: var(--text-3); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-2);
}
.tag-chip.active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.backend-list { list-style: none; margin: 0; padding: 0; }
.backend-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
.backend-list li:last-child { border-bottom: none; }

.load-more-wrap { text-align: center; padding: 16px 0 40px; }

.modal-root { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.35); }
.modal-panel {
  position: relative;
  width: min(680px, calc(100vw - 32px));
  max-height: 86vh;
  overflow: auto;
  background: var(--surface);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}
.modal-panel h2 { margin: 0 0 14px; font-size: 16px; font-weight: 600; }
.modal-close { position: absolute; right: 12px; top: 12px; border: none; background: none; font-size: 20px; color: var(--text-3); cursor: pointer; }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; margin-bottom: 4px; font-size: 13px; color: var(--text-2); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.preview-img, .preview-video { max-width: 100%; max-height: 64vh; display: block; margin: 0 auto; border-radius: 8px; }
.preview-text {
  white-space: pre-wrap;
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  max-height: 60vh;
  overflow: auto;
  font-size: 13px;
}
.preview-frame { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: 8px; }

.toast-root { position: fixed; left: 50%; transform: translateX(-50%); bottom: 32px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1d2129;
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--primary); }

.empty { text-align: center; color: var(--text-3); padding: 40px 0; }

.share-card { max-width: 420px; margin: 8vh auto; }
.share-file { display: flex; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); }
.share-meta { color: var(--text-3); font-size: 12px; margin-top: 8px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { order: -1; }
  .date-label { top: 52px; }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 12px; }
  .layout { padding: 12px 12px 60px; gap: 12px; }
  .search-row .input, .row .input { flex: 1 1 100%; }
  .item-actions .btn { flex: 1 1 auto; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
