/* CrossStickies PWA 样式
 *
 * 设计取向：纸感浅色、低对比描边、便签本色由数据驱动。
 * 不引入任何 CDN 字体或图标库——手机弱网下首屏必须一次到位，
 * 图标一律内联 SVG，字体用系统中文字体栈。
 */

:root {
  --bg: #f4f5f7;
  --paper: #fff;
  --ink: #16181d;
  --ink-2: #5b6270;
  --ink-3: #8b93a1;
  --line: #e6e8ec;
  --line-2: #eef0f3;
  --brand: #111827;
  --accent: #b8860b;
  --ok: #0f9d58;
  --warn: #b45309;
  --danger: #c0392b;
  --radius: 16px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-2: 0 8px 28px rgba(16, 24, 40, .12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden 属性必须压过组件自己的 display：
 * .sheet 用了 display:flex，如果不加这条，未打开的弹层会一直显示在页面上。 */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
        "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button { font: inherit; color: inherit; }

/* ——— 登录 ——— */
.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 18px calc(24px + var(--safe-bottom));
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px 20px 20px;
  box-shadow: var(--shadow-1);
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }

.brand-mark {
  width: 44px; height: 44px; flex: none;
  border-radius: 12px;
  background: #ffe98a;
  border: 1px solid #f0d972;
  display: flex; align-items: center; justify-content: center;
}

.brand-mark svg { width: 24px; height: 24px; }

.brand h1 { font-size: 18px; margin: 0; letter-spacing: .2px; }
.brand p { margin: 0; font-size: 12.5px; color: var(--ink-3); }

.seg {
  display: flex; gap: 4px;
  background: #f3f4f6;
  padding: 4px; border-radius: 11px;
  margin-bottom: 6px;
}

.seg button {
  flex: 1; border: 0; background: transparent;
  padding: 8px 4px; border-radius: 8px;
  font-size: 13px; color: var(--ink-2); cursor: pointer;
}

.seg button.on {
  background: #fff; color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-1);
}

.pane { display: none; padding-top: 12px; }
.pane.on { display: block; }

label {
  display: block;
  font-size: 12.5px; color: var(--ink-3);
  margin: 12px 0 6px;
}

input, textarea {
  width: 100%;
  padding: 11px 13px;
  font: inherit; font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  -webkit-appearance: none;
}

input:focus, textarea:focus {
  border-color: #c9ced7;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, .05);
}

.btn {
  display: block; width: 100%;
  border: 0; border-radius: 11px;
  padding: 12px 16px;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: opacity .15s, transform .06s;
}

.btn:active { transform: scale(.985); opacity: .9; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #f0d5d1; font-weight: 500; }

/* 微信登录：用微信品牌绿，但只用在这一处，避免把便签墙的纸感配色带跑 */
.btn.wx {
  background: #07c160; color: #fff; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.wx::before {
  content: ""; width: 17px; height: 17px; flex: 0 0 17px;
  background: #fff;
  -webkit-mask: no-repeat center/contain url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M9 3C4.9 3 1.6 5.7 1.6 9.1c0 1.9 1.1 3.6 2.9 4.8l-.7 2.2 2.5-1.3c.8.2 1.7.4 2.6.4h.6a5.6 5.6 0 0 1-.2-1.5c0-3.3 3.1-5.9 7-5.9h.6C16.2 5.1 12.9 3 9 3Zm-2.6 3.4a1 1 0 1 1 0 2 1 1 0 0 1 0-2Zm5.2 0a1 1 0 1 1 0 2 1 1 0 0 1 0-2Z'/><path d='M22.4 13.6c0-2.9-2.8-5.2-6.2-5.2s-6.2 2.3-6.2 5.2 2.8 5.2 6.2 5.2c.7 0 1.4-.1 2.1-.3l2 1-.6-1.8c1.7-.9 2.7-2.4 2.7-4.1Zm-8.2-1.6a.9.9 0 1 1 0 1.8.9.9 0 0 1 0-1.8Zm4.2 0a.9.9 0 1 1 0 1.8.9.9 0 0 1 0-1.8Z'/></svg>");
          mask: no-repeat center/contain url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M9 3C4.9 3 1.6 5.7 1.6 9.1c0 1.9 1.1 3.6 2.9 4.8l-.7 2.2 2.5-1.3c.8.2 1.7.4 2.6.4h.6a5.6 5.6 0 0 1-.2-1.5c0-3.3 3.1-5.9 7-5.9h.6C16.2 5.1 12.9 3 9 3Zm-2.6 3.4a1 1 0 1 1 0 2 1 1 0 0 1 0-2Zm5.2 0a1 1 0 1 1 0 2 1 1 0 0 1 0-2Z'/><path d='M22.4 13.6c0-2.9-2.8-5.2-6.2-5.2s-6.2 2.3-6.2 5.2 2.8 5.2 6.2 5.2c.7 0 1.4-.1 2.1-.3l2 1-.6-1.8c1.7-.9 2.7-2.4 2.7-4.1Zm-8.2-1.6a.9.9 0 1 1 0 1.8.9.9 0 0 1 0-1.8Zm4.2 0a.9.9 0 1 1 0 1.8.9.9 0 0 1 0-1.8Z'/></svg>");
}
#wxRow { margin: 14px 0 2px; }

.hint { font-size: 12.5px; color: var(--ink-3); text-align: center; margin: 10px 0 0; }
.tiny { font-size: 11.5px; color: var(--ink-3); line-height: 1.55; margin: 10px 0 0; }

.err {
  margin: 14px 0 0;
  padding: 9px 12px;
  background: #fdecec; color: var(--danger);
  border-radius: 10px; font-size: 13px;
}

/* 扫码 */
.qr-wrap { text-align: center; padding: 8px 0 4px; }

.qr-box {
  width: 200px; height: 200px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  overflow: hidden;
}

.qr-box img { width: 192px; height: 192px; image-rendering: pixelated; }
.qr-ph { font-size: 12.5px; color: var(--ink-3); padding: 0 28px; }

/* ——— 主界面 ——— */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(244, 245, 247, .92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line-2);
  padding-top: var(--safe-top);
}

.topbar-inner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
}

.topbar-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-title b { font-size: 15.5px; letter-spacing: .2px; }

.sync-text {
  font-size: 11.5px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-3); flex: none;
}

.dot.ok { background: var(--ok); }
.dot.busy { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
.dot.bad { background: var(--danger); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.topbar-actions { margin-left: auto; display: flex; gap: 2px; }

.icon-btn {
  width: 38px; height: 38px;
  border: 0; background: transparent;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-2); cursor: pointer;
}

.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { background: rgba(17, 24, 39, .06); }

.search-row { display: flex; gap: 8px; padding: 0 14px 10px; align-items: center; }
.search-row input { flex: 1; }

.text-btn {
  border: 0; background: transparent;
  color: var(--ink-2); font-size: 14px;
  padding: 8px 4px; cursor: pointer; white-space: nowrap;
}

.text-btn.strong { color: var(--ink); font-weight: 600; }
.text-btn.danger { color: var(--danger); }

.chips {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 0 14px 10px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-size: 12.5px;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* 便签墙：CSS 多列瀑布流，卡片高度随内容自然变化 */
.grid {
  padding: 12px 14px calc(96px + var(--safe-bottom));
  column-count: 1;
  column-gap: 12px;
}

@media (min-width: 560px) { .grid { column-count: 2; } }
@media (min-width: 900px) { .grid { column-count: 3; } .topbar-inner { max-width: 1080px; margin: 0 auto; } }
@media (min-width: 1240px) { .grid { column-count: 4; } }

.note {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid rgba(0, 0, 0, .07);
  border-radius: 13px;
  padding: 13px 14px 12px;
  margin: 0 0 12px;
  cursor: pointer;
  position: relative;
  box-shadow: 0 1px 1px rgba(16, 24, 40, .04);
  transition: transform .12s, box-shadow .12s;
}

.note:active { transform: scale(.99); }
@media (hover: hover) { .note:hover { box-shadow: var(--shadow-2); } }

.note h3 {
  font-size: 14.5px; font-weight: 600;
  margin: 0 0 4px;
  line-height: 1.45;
  word-break: break-word;
}

.note p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.62;
  color: inherit;
  opacity: .88;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: hidden;
}

.note .meta {
  display: flex; align-items: center; gap: 6px;
  margin-top: 9px;
  font-size: 11px;
  opacity: .62;
}

.note .pin { position: absolute; top: 9px; right: 10px; opacity: .55; }
.note .pin svg { width: 13px; height: 13px; }

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 5px;
  background: rgba(0, 0, 0, .07);
}

.empty {
  text-align: center;
  padding: 64px 32px;
  color: var(--ink-3);
}

.empty p { font-size: 15px; margin: 0 0 6px; color: var(--ink-2); }
.empty span { font-size: 12.5px; line-height: 1.6; }

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(20px + var(--safe-bottom));
  width: 54px; height: 54px;
  border: 0; border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(17, 24, 39, .22);
  cursor: pointer;
  z-index: 30;
}

.fab svg { width: 24px; height: 24px; }
.fab:active { transform: scale(.95); }

/* ——— 弹出面板 ——— */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; }

.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(16, 24, 40, .32);
  animation: fade .16s ease-out;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet-panel {
  position: relative;
  width: 100%;
  max-height: 92dvh;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 6px 16px calc(16px + var(--safe-bottom));
  display: flex; flex-direction: column;
  animation: slide .2s cubic-bezier(.2, .9, .3, 1);
  box-shadow: 0 -8px 32px rgba(16, 24, 40, .16);
}

@keyframes slide { from { transform: translateY(18px); opacity: .6; } to { transform: none; opacity: 1; } }

.sheet-panel.compact { padding-bottom: calc(28px + var(--safe-bottom)); }

@media (min-width: 720px) {
  .sheet { align-items: center; justify-content: center; }
  .sheet-panel {
    max-width: 620px; max-height: 84dvh;
    border-radius: 18px;
    animation: pop .16s ease-out;
  }
  @keyframes pop { from { transform: scale(.98); opacity: .7; } to { transform: none; opacity: 1; } }
}

.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--line-2);
}

.sheet-head b { font-size: 15px; }

.colors { display: flex; gap: 7px; }

.swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
  cursor: pointer;
  padding: 0;
}

.swatch.on { border-color: var(--ink); }

.note-title {
  border: 0; border-radius: 0;
  padding: 14px 0 6px;
  font-size: 17px; font-weight: 600;
  background: transparent;
}

.note-title:focus, .note-text:focus { box-shadow: none; border: 0; }

.note-text {
  border: 0; border-radius: 0;
  padding: 4px 0 12px;
  min-height: 34dvh;
  flex: 1;
  resize: none;
  background: transparent;
  line-height: 1.68;
  font-size: 15px;
}

.sheet-foot {
  display: flex; align-items: center; gap: 10px;
  border-top: 1px solid var(--line-2);
  padding-top: 10px;
}

.note-tags {
  border: 0; background: #f6f7f9;
  font-size: 13px;
  padding: 8px 11px;
  flex: 1;
}

.kv {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 13.5px;
}

.kv span { color: var(--ink-3); flex: none; }
.kv b { font-weight: 600; text-align: right; word-break: break-all; }

.row-btns { display: flex; gap: 10px; margin-top: 12px; }
.row-btns .btn { margin-top: 0; }

.pair-code {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 8px;
  text-align: center;
  padding: 22px 0;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* 提示条 */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--safe-bottom));
  transform: translateX(-50%) translateY(10px);
  background: #111827;
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  max-width: 84vw;
  z-index: 90;
  text-align: center;
}

.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #a93325; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
