:root {
  --bg: #f6f7f8;
  --panel: #ffffff;
  --text: #1c2024;
  --muted: #6b7280;
  --line: #e6e8eb;
  --accent: #0d7c66;
  --accent-soft: #e8f4f0;
  --danger: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #cfd4da; background: #fafbfb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: #eef0f2; color: var(--text); }
.btn.danger { color: var(--danger); border-color: #f0d6d3; }
.btn.danger:hover { background: #fdf3f2; }
.btn.block { width: 100%; padding: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
  border: none; background: transparent; font-size: 22px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.icon-btn:hover { background: #eef0f2; color: var(--text); }

/* ---------- login ---------- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo { font-size: 34px; }
.login-card h1 { font-size: 19px; margin: 8px 0 4px; }
.login-card p { margin: 0 0 18px; font-size: 13px; }
.login-card input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 15px; margin-bottom: 12px; outline: none; background: #fbfcfc;
}
.login-card input:focus { border-color: var(--accent); background: #fff; }
.login-error { color: var(--danger); font-size: 13px; min-height: 20px; margin-top: 8px; }

/* ---------- layout ---------- */
.app { max-width: 860px; margin: 0 auto; padding: 0 16px 40px; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; white-space: nowrap; }
.brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.search-wrap { position: relative; flex: 1; min-width: 0; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: .6; }
#search {
  width: 100%; padding: 10px 34px 10px 34px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); font-size: 14px; outline: none;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: none; background: #eceff1; color: var(--muted); border-radius: 50%;
  width: 22px; height: 22px; cursor: pointer; font-size: 14px; line-height: 1;
}
.top-actions { display: flex; gap: 6px; }

.menu {
  position: fixed; right: 16px; top: 62px; z-index: 60;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; min-width: 190px;
}
.menu button {
  display: block; width: 100%; text-align: left; border: none; background: transparent;
  padding: 9px 12px; border-radius: 8px; font-size: 14px; cursor: pointer; color: var(--text);
}
.menu button:hover { background: #f2f4f5; }

.filters { display: flex; gap: 8px; align-items: center; padding: 10px 0 4px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  padding: 4px 11px; border-radius: 999px; font-size: 13px; cursor: pointer;
}
.chip.on { background: var(--accent-soft); border-color: #b9dcd2; color: var(--accent); font-weight: 600; }
.select {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 5px 8px; font-size: 13px; color: var(--muted); outline: none; max-width: 160px;
}

/* ---------- list ---------- */
.list { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; transition: .15s;
}
.card:hover { border-color: #d3d8dd; box-shadow: var(--shadow); transform: translateY(-1px); }
.card-title { font-weight: 600; font-size: 15.5px; margin-bottom: 4px; }
.card-excerpt { color: var(--muted); font-size: 13.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-meta { display: flex; gap: 8px; align-items: center; margin-top: 9px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.badge {
  font-size: 11.5px; padding: 1px 8px; border-radius: 999px;
  background: #eef1f3; color: #4b5563; border: 1px solid #e3e7ea;
}
.badge.ok { background: var(--accent-soft); color: var(--accent); border-color: #c9e4dc; }
.badge.warn { background: #fff6e5; color: #a15c00; border-color: #f5e2c0; }
.badge.todo { background: #fdf1f0; color: var(--danger); border-color: #f2d9d6; }
.tag { font-size: 11.5px; color: var(--muted); }
mark { background: #fff1b8; color: inherit; padding: 0 2px; border-radius: 3px; }
.empty {
  text-align: center; color: var(--muted); padding: 60px 20px; font-size: 14px;
}
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }

.foot { display: flex; gap: 6px; justify-content: center; color: var(--muted); font-size: 12px; padding: 22px 0 0; }
.dot { opacity: .4; }

/* ---------- drawer ---------- */
.drawer { position: fixed; inset: 0; z-index: 80; }
.drawer-mask { position: absolute; inset: 0; background: rgba(16, 24, 40, .32); }
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: min(620px, 100%); background: var(--panel);
  padding: 18px 20px 20px; overflow-y: auto;
  box-shadow: -12px 0 40px rgba(16, 24, 40, .12);
}
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drawer-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.drawer-panel h2 { font-size: 21px; line-height: 1.35; margin: 12px 0 4px; }
.drawer-foot { display: flex; gap: 8px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* ---------- markdown ---------- */
.markdown { font-size: 15px; line-height: 1.75; word-break: break-word; }
.markdown h1, .markdown h2, .markdown h3 { line-height: 1.4; margin: 22px 0 8px; }
.markdown h1 { font-size: 20px; }
.markdown h2 { font-size: 17px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.markdown h3 { font-size: 15.5px; }
.markdown p { margin: 8px 0; }
.markdown ul, .markdown ol { padding-left: 22px; margin: 8px 0; }
.markdown li { margin: 3px 0; }
.markdown code {
  background: #f0f2f4; padding: 1px 5px; border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px;
}
.markdown pre {
  background: #1e2429; color: #e6edf3; padding: 13px 14px; border-radius: 10px;
  overflow-x: auto; margin: 12px 0;
}
.markdown pre code { background: none; color: inherit; padding: 0; font-size: 13px; }
.markdown blockquote {
  margin: 12px 0; padding: 2px 14px; border-left: 3px solid var(--accent-soft);
  color: var(--muted); background: #fafbfb;
}
.markdown a { color: var(--accent); }
.markdown table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 14px; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.markdown th { background: #f7f8f9; }
.markdown hr { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
.markdown img { max-width: 100%; border-radius: 8px; }

/* ---------- editor ---------- */
.editor { position: fixed; inset: 0; z-index: 90; background: rgba(16, 24, 40, .32); display: grid; place-items: center; padding: 16px; }
.editor-panel {
  width: min(720px, 100%); max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden;
}
.editor-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.editor-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.editor-body label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.editor-body label em { font-style: normal; font-size: 11px; color: #9aa3ad; margin-left: 6px; }
.editor-body input, .editor-body textarea, .editor-body select {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  font-size: 14px; font-family: inherit; color: var(--text); background: #fbfcfc; outline: none; width: 100%;
}
.editor-body textarea { resize: vertical; line-height: 1.65; }
.editor-body input:focus, .editor-body textarea:focus, .editor-body select:focus {
  border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.editor-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.editor-foot .muted { margin-right: auto; font-size: 12px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #1c2024; color: #fff; padding: 9px 18px; border-radius: 999px;
  font-size: 13.5px; z-index: 120; box-shadow: var(--shadow); max-width: 88vw; text-align: center;
}

@media (max-width: 640px) {
  .app { padding: 0 12px 32px; }
  .brand span:last-child { display: none; }
  .top-actions .btn.primary { padding: 8px 10px; }
  .row2 { grid-template-columns: 1fr; }
  .drawer-panel { width: 100%; padding: 14px 16px; }
  .drawer-panel h2 { font-size: 19px; }
}
