/* =============================================================================
 * layout.css —— 顶栏 / 左侧悬浮隐藏侧边栏 / 画布 / 悬浮关于按钮 / 登录页
 * ========================================================================== */

/* ---------- 1. 顶栏 ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 90;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h);
  padding: 0 16px 0 20px;
  background: var(--surface); /* 不支持 color-mix 的浏览器回退 */
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; flex: none; }
.brand__mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), #7f93f0);
  display: grid; place-items: center; color: #fff;
}
.brand__mark svg { width: 15px; height: 15px; }
.brand__text { font-size: 14.5px; font-weight: 600; letter-spacing: .2px; }

/* 汉堡按钮：仅移动端出现 */
.hamburger { display: none; }

/* —— 全局搜索：只检索预览字段（提醒标题 / 收藏名称 / 便签标题） —— */
.search { position: relative; flex: 1; max-width: 460px; margin: 0 auto; }
.search__box {
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.search__box:focus-within {
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.search__box svg { color: var(--text-3); }
.search__input {
  flex: 1; border: 0; background: transparent; outline: none;
  font-size: 13px;
}
.search__kbd {
  font-family: var(--mono); font-size: 11px; color: var(--text-3);
  border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 4px;
}

.search__panel {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  max-height: 60vh; overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  display: none;
}
.search__panel.is-open { display: block; animation: pop .18s var(--ease); }
.search__group-title {
  padding: 7px 9px 4px; font-size: 11px; color: var(--text-3); letter-spacing: .4px;
}
.search__item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--dur) var(--ease);
}
.search__item:hover, .search__item.is-active { background: var(--surface-3); }
.search__item .s-name { flex: 1; font-size: 13px; }
.search__item mark { background: transparent; color: var(--brand); font-weight: 600; }

.topbar__right { display: flex; align-items: center; gap: 8px; flex: none; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
  font-size: 12px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--brand-line);
}

/* ---------- 2. 左侧悬浮隐藏侧边栏 ---------- */
/* 触发条：桌面端最左边缘一条窄条，鼠标悬浮即滑出侧边栏 */
.rail {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0; z-index: 95;
  width: var(--rail-w);
  background: linear-gradient(90deg, var(--line-strong), transparent);
  opacity: .5;
  transition: opacity var(--dur) var(--ease);
}
.rail:hover { opacity: 1; }
.rail::after { /* 视觉提示的小把手 */
  content: "";
  position: absolute; top: 50%; left: 2px;
  width: 3px; height: 46px; margin-top: -23px;
  border-radius: var(--radius-pill);
  background: var(--text-3); opacity: .5;
}

.sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0; z-index: 96;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  padding: 14px 12px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  transform: translateX(calc(-100% - 12px));
  transition: transform .26s var(--ease);
  overflow-y: auto;
}
.sidebar.is-open { transform: translateX(0); }

.side__section { margin-bottom: 16px; }
.side__title {
  padding: 0 8px 7px;
  font-size: 11px; letter-spacing: .5px; color: var(--text-3);
}
.side__link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 9px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-2);
  cursor: pointer; width: 100%; border: 0; background: transparent; text-align: left;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.side__link:hover { background: var(--surface-3); color: var(--text); }
.side__link .badge { margin-left: auto; }
.side__link .switch { margin-left: auto; }
.side__link.is-off { color: var(--text-3); }

/* 模块显示/隐藏开关 */
.switch {
  position: relative; width: 30px; height: 17px; flex: none;
  border-radius: var(--radius-pill);
  background: var(--line-strong);
  transition: background var(--dur) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 13px; height: 13px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform var(--dur) var(--ease);
}
.switch.is-on { background: var(--brand); }
.switch.is-on::after { transform: translateX(13px); }

.side__user {
  margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line);
}
.side__user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 9px; border-radius: var(--radius-sm); background: var(--surface-2);
  margin-bottom: 8px;
}
.side__user-name { font-size: 13px; font-weight: 600; }
.side__user-id { font-size: 11px; color: var(--text-3); font-family: var(--mono); }

/* ---------- 3. 画布 ---------- */
.canvas-wrap {
  position: relative;
  min-height: 100vh;
  padding: calc(var(--topbar-h) + 14px) 24px 90px 28px;   /* 顶部收紧（已移除画布上方 i 图标行） */
  background-image:
    radial-gradient(circle at 1px 1px, var(--bg-grid) 1px, transparent 0);
  background-size: 20px 20px;
}
.canvas {
  position: relative;
  width: 100%;
  max-width: 1400px;      /* 3 列栅格最大宽度，宽屏居中，两侧留白均匀 */
  margin: 0 auto;         /* 水平居中 */
  min-height: 60vh;
  isolation: isolate;   /* 独立层叠上下文：卡片 z-index 只在本层生效，
                           不会盖住顶栏(z:90)/侧边栏(z:95)/遮罩(z:500) */
}

/* 画布顶部小字提示（硬性要求 11） */
.canvas-note {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 14px;
  font-size: 12px; color: var(--text-3);
}
.canvas-note svg { width: 13px; height: 13px; }

/* 拖拽时的吸附参考线 */
.snapline {
  position: absolute; z-index: 60; background: var(--brand); opacity: .55; pointer-events: none;
}
.snapline--v { width: 1px; top: 0; bottom: 0; }
.snapline--h { height: 1px; left: 0; right: 0; }

/* ---------- 4. 右下角悬浮「关于」按钮 ---------- */
.fab-about {
  position: fixed; right: 22px; bottom: 22px; z-index: 88;
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-2);
  cursor: pointer;
  transition: transform var(--dur) var(--ease), color var(--dur) var(--ease);
}
.fab-about:hover { transform: translateY(-2px); color: var(--brand); }

.about-list { font-size: 13px; }
.about-list li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 7px 0; border-bottom: 1px dashed var(--line);
}
.about-list li:last-child { border-bottom: 0; }
.about-list span:first-child { color: var(--text-3); }
.about-list code { font-family: var(--mono); font-size: 12px; }

/* ---------- 5. 未登录遮罩（不做 JS 自动跳转，必须用户手动点击） ---------- */
.gate {
  position: fixed; inset: 0; z-index: 500;
  display: none; align-items: center; justify-content: center; padding: 20px;
  background: var(--bg);
}
.gate.is-open { display: flex; }
.gate__panel {
  width: 100%; max-width: 380px; text-align: center;
  padding: 30px 24px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-1);
}

/* ---------- 6. 登录 / 注册页 ---------- */
.auth-page {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 50% -10%, var(--brand-soft), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 392px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head .brand { justify-content: center; margin-bottom: 12px; }
.auth-head h1 { font-size: 18px; font-weight: 600; }
.auth-head p { margin-top: 5px; font-size: 12.5px; color: var(--text-3); }

.tabs {
  display: flex; gap: 4px; padding: 3px; margin-bottom: 20px;
  background: var(--surface-3); border-radius: var(--radius-sm);
}
.tabs button {
  flex: 1; height: 30px; border: 0; border-radius: var(--radius-xs);
  background: transparent; color: var(--text-2); font-size: 13px; cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tabs button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.auth-msg {
  display: none; margin-bottom: 14px; padding: 9px 11px;
  border-radius: var(--radius-sm); font-size: 12.5px;
}
.auth-msg.is-err { display: block; background: var(--danger-soft); color: var(--danger); }
.auth-msg.is-ok { display: block; background: var(--ok-soft); color: var(--ok); }

.auth-foot {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--text-3); line-height: 1.75;
}

/* ---------- 7. 响应式：移动端顶部汉堡折叠菜单 ---------- */
@media (max-width: 900px) {
  .rail { display: none; }              /* 移动端不用边缘触发条 */
  .hamburger { display: inline-flex; }  /* 改用汉堡按钮 */

  .sidebar {
    top: var(--topbar-h);
    width: 100%;
    max-width: 100%;
    padding: 14px 16px 24px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    bottom: auto;
    max-height: calc(100vh - var(--topbar-h));
    transform: translateY(-110%);
  }
  .sidebar.is-open { transform: translateY(0); }

  .search { max-width: none; }
  .search__kbd { display: none; }
  .brand__text { display: none; }

  .canvas-wrap { padding: calc(var(--topbar-h) + 14px) 14px 84px; }
  .fab-about { right: 14px; bottom: 14px; }
}

@media (max-width: 420px) {
  .search__box { height: 32px; }
}
