:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #666666;
  --line: #e6e6e6;
  --hover: #f0f0f0;
  --active: #e4e4e4;
  --danger: #b00020;
  --ok: #1a7f37;
  --warn: #8a6d00;
  --hl: #ffe566;
  --radius: 10px;
  --bar: 220px;
  --pad: 16px;
  --fast: 0.15s;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); }
body {
  font-family: system-ui, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }

.hidden { display: none !important; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.muted { color: var(--muted); }
.danger { color: var(--danger); }
.ok { color: var(--ok); }
.right { margin-left: auto; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; }
.full { width: 100%; }

.btn, .field, .card, .note-row, .plan-card, .chip, .menu, .modal, .toast, .sidebar, .topbar, .editor-bar, .gate-box {
  border-radius: var(--radius);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  background: #fff;
  border: 1px solid #d8d8d8;
  cursor: pointer;
  transition: background var(--fast) ease, transform var(--fast) ease, border-color var(--fast) ease;
  user-select: none;
}
.btn:hover { background: var(--hover); }
.btn:active { background: var(--active); transform: scale(0.98); }
.btn.primary { background: #111; color: #fff; border-color: #111; }
.btn.primary:hover { background: #333; }
.btn.danger { border-color: #e2b4bc; color: var(--danger); }
.btn.danger:hover { background: #fdecee; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.icon-btn { min-width: 36px; padding: 6px 10px; }

.field {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid #d8d8d8;
  background: #fff;
  outline: none;
  transition: border-color var(--fast) ease, background var(--fast) ease;
}
.field:hover { background: var(--hover); }
.field:focus { border-color: #111; background: #fff; }
textarea.field { min-height: 120px; resize: vertical; }
label.lbl { font-size: 13px; color: var(--muted); }

.card {
  border: 1px solid var(--line);
  padding: 16px;
  background: #fff;
}
.card:hover { background: #fafafa; }

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-box {
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
}
.auth-box h1 { margin: 0 0 6px; font-size: 22px; font-weight: 650; }
.auth-box p { margin: 0 0 18px; }

.dash {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--bar);
  border-right: 1px solid var(--line);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
}
.nav-btn {
  width: 100%;
  justify-content: flex-start;
}
.nav-btn.active { background: var(--hover); border-color: #cfcfcf; }
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 8px;
}
.content { padding: 20px; max-width: 980px; width: 100%; }

.progress {
  height: 10px;
  background: #f2f2f2;
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress > span {
  display: block;
  height: 100%;
  background: #111;
  width: 0;
  transition: width var(--fast) ease;
}

.note-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  cursor: pointer;
  background: #fff;
  transition: background var(--fast) ease, transform var(--fast) ease;
}
.note-row:hover { background: var(--hover); }
.note-row:active { background: var(--active); transform: scale(0.995); }
.note-row .name { font-weight: 600; }
.note-list { display: flex; flex-direction: column; gap: 8px; }

.kv { display: grid; grid-template-columns: 140px 1fr auto; gap: 8px 12px; align-items: center; }
.kv .k { color: var(--muted); font-size: 13px; }

.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.plan-card { border: 1px solid var(--line); padding: 12px; }
.plan-card img {
  width: 100%;
  height: auto;
  max-height: 280px;
  object-fit: contain;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fafafa;
}
.plan-card h3 { margin: 10px 0 4px; }

.gate-wrap, .fix-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.gate-box {
  width: 100%;
  max-width: 460px;
  border: 1px solid var(--line);
  padding: 24px;
  position: relative;
}
.close-x {
  position: absolute;
  top: 10px;
  right: 10px;
}

.note-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
}
.note-main { flex: 1; min-height: 0; overflow: auto; }
.editor {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 20px 12px;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}
.editor:empty:before {
  content: "Type here";
  color: #999;
}
.editor.noselect { user-select: none; -webkit-user-select: none; }
.editor img { max-width: 100%; border-radius: 8px; }

.editor-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 12px 12px;
  padding: 8px;
  border: 1px solid var(--line);
  background: #fff;
  position: relative;
  flex-shrink: 0;
  z-index: 20;
}
.mode-pop {
  position: absolute;
  left: 8px;
  bottom: 52px;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  min-width: 140px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}
.mode-pop .btn { width: 100%; justify-content: flex-start; }
.btn.active { background: var(--hover); border-color: #111; }
.size-range { width: 88px; }
.search-pop {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toast-wrap {
  position: fixed;
  right: 16px;
  top: 16px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  max-width: 320px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 10px 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,.06);
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.18);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 16px;
}
.modal {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 18px;
}
.modal h3 { margin: 0 0 10px; }
.menu {
  position: absolute;
  z-index: 40;
  background: #fff;
  border: 1px solid var(--line);
  padding: 6px;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}
.menu .btn { width: 100%; justify-content: flex-start; border: 0; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  align-content: start;
}
.g-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
.g-item .thumb {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  overflow: hidden;
}
.g-item img, .g-item video { width: 100%; height: 120px; object-fit: cover; }
.g-item .meta { padding: 8px; font-size: 12px; }

canvas.board {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 0;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
}

.hl { background: var(--hl); }

.turnstile {
  border: 1px dashed #ccc;
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 800px) {
  .dash { flex-direction: column; }
  .sidebar {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    flex-wrap: wrap;
  }
  .nav-btn { width: auto; }
  .plan-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .content { padding: 14px; }
}
