/* ============================================================
   航标 · 个人导航站
   设计规范（对齐参考站）：工具型 · 扁平极简 · 低饱和清爽
   深灰侧栏 #2C3135 + 浅灰内容区 #F5F6F7 + 白卡片 + 蓝色强调 #1677FF
   ============================================================ */

:root {
  --bg: #f5f6f7;
  --card: #ffffff;
  --side: #2c3135;
  --side-hover: #3a3f44;
  --ink: #1f2329;
  --ink-2: #66696e;
  --ink-3: #747a80;
  --line: #e6e8eb;
  --line-2: #d9dde3;
  --accent: #1677ff;
  --accent-soft: #e6f4ff;
  --danger: #d4380d;
  --ok: #18a058;

  --r-card: 8px;
  --r-sm: 4px;

  --font: "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong",
    "SimSun", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button {
  font-family: inherit;
  font-weight: inherit;
}

#root {
  min-height: 100vh;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 1px;
}

.boot {
  min-height: 60vh;
  display: grid;
  place-items: center;
  color: var(--ink-3);
}

/* ---------------- 通用控件 ---------------- */

.btn {
  appearance: none;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.btn-primary:hover {
  background: var(--side-hover);
  border-color: var(--side-hover);
  color: #fff;
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background: #0f6ae8;
  border-color: #0f6ae8;
  color: #fff;
}

.btn-danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-lg {
  height: 40px;
  font-size: 14px;
  width: 100%;
  justify-content: center;
}

.icon-btn {
  appearance: none;
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-3);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-btn.danger:hover {
  background: #fff1f0;
  color: var(--danger);
}

input,
select,
textarea {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  height: 34px;
  padding: 0 12px;
  width: 100%;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input::placeholder {
  color: var(--ink-3);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

label.field {
  display: block;
}

label.field > span,
.field-caption {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 4px;
}

label.field > span svg,
.field-caption svg {
  color: var(--ink-3);
}

.field input {
  height: 40px;
}

.password-control {
  position: relative;
}

.password-input {
  font-family: system-ui, sans-serif;
  padding-right: 58px;
  min-width: 0;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 4px;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.password-toggle:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.f-err {
  color: var(--danger);
  font-size: 12px;
  min-height: 1.2em;
  margin: 8px 0 0;
}

.f-tip {
  color: var(--ink-3);
  font-size: 12px;
  min-height: 1.1em;
  margin: 4px 0 0;
}

.linkish {
  border: 0;
  background: none;
  padding: 0;
  color: var(--ink-3);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.linkish:hover {
  color: var(--accent);
}

/* ---------------- 登录 / 注册 ---------------- */

.auth {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

.auth-side {
  --ink-3: #bdc5ce;
  background: var(--side);
  color: #fff;
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--r-card);
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 600;
  flex: none;
}

.brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.2;
}

.brand-sub {
  display: block;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.18em;
  color: var(--ink-3);
  margin-top: 2px;
}

.auth-side h1 {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
}

.auth-side h1 em {
  font-style: normal;
  color: var(--accent);
}

.auth-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.auth-points li {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--ink-3);
  font-size: 14px;
  padding: 6px 0;
  border-radius: var(--r-sm);
  border-bottom: 1px solid var(--side-hover);
}

.auth-points li:last-child {
  border-bottom: 0;
}

.auth-points li svg {
  flex: none;
  color: var(--accent);
}

.auth-foot {
  margin-top: auto;
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: 0.14em;
}

.auth-main {
  display: grid;
  place-items: center;
  padding: 32px;
}

.auth-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 32px;
  animation: rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.auth-card h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px;
}

.auth-hint {
  color: var(--ink-3);
  font-size: 12px;
  margin: 0 0 24px;
}

.auth-fields {
  display: grid;
  gap: 20px;
}

.auth-acts {
  display: grid;
  gap: 14px;
  margin-top: 24px;
  justify-items: center;
}

/* ---------------- 应用骨架：侧栏 + 内容 ---------------- */

.app {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.app.side-collapsed {
  grid-template-columns: 64px minmax(0, 1fr);
}

.side {
  --ink-3: #bdc5ce;
  background: var(--side);
  color: var(--ink-3);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 12px;
  min-height: 0;
  z-index: 10;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.side-head .brand {
  min-width: 0;
  gap: 8px;
}

.side-head .brand-sub {
  font-size: 9px;
  letter-spacing: 0.08em;
}

.side-toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
}

.side-toggle:hover {
  background: var(--side-hover);
  color: #fff;
}

.side-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-collapsed .side-head .brand,
.side-collapsed .side-text,
.side-collapsed .side-label,
.side-collapsed .side-item .count {
  display: none;
}

.side-collapsed .side-head,
.side-collapsed .side-user,
.side-collapsed .side-nav .side-item,
.side-collapsed .settings-trigger {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.side-nav {
  display: grid;
  gap: 8px;
  overflow-y: auto;
  min-height: 0;
  align-content: start;
  flex: 0 1 auto;
}

.side-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  padding: 0 16px;
  margin-bottom: 2px;
}

.side-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.18s ease, color 0.18s ease;
}

.side-item svg {
  flex: none;
  color: currentColor;
}

.side-item:hover {
  background: var(--side-hover);
  color: #fff;
}

.side-item.active {
  background: var(--side-hover);
  color: #fff;
}

.side-item .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--ink-3);
}

.side-item.active .count {
  color: var(--ink-3);
}

.side-foot {
  flex: none;
  margin-top: auto;
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--side-hover);
  padding-top: 14px;
}

.side-settings {
  position: relative;
}

.settings-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  width: 196px;
  padding: 8px;
  border: 1px solid var(--side-hover);
  border-radius: var(--r-card);
  background: var(--side);
  box-shadow: 0 8px 24px #0003;
}

.settings-menu[hidden] {
  display: none;
}

.settings-menu .side-item {
  width: 100%;
  white-space: nowrap;
}

.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px 6px;
  color: #fff;
  font-size: 13px;
}

.side-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  flex: none;
}

/* ---------------- 内容区 ---------------- */

.main {
  padding: 24px clamp(16px, 3vw, 32px) 56px;
  min-width: 0;
  width: 100%;
}

.main-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.search {
  min-width: 0;
  flex: 1 1 60%;
  max-width: 640px;
  display: flex;
  gap: 8px;
}

.search input {
  min-width: 0;
  height: 40px;
  flex: 1;
  background: var(--bg);
}

.search input:focus {
  background: var(--card);
}

.search-btn {
  width: 40px;
  height: 40px;
  flex: none;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.18s ease;
}

.search-btn:hover {
  background: var(--side-hover);
}

.top-r {
  flex-shrink: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.save-chip {
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
}

.save-chip[data-state="saved"] {
  color: var(--ok);
}

.save-chip[data-state="error"] {
  color: var(--danger);
  cursor: pointer;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 32px;
}

.tag {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.tag:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.tag.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.pw-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 24px;
  margin-bottom: 24px;
  display: grid;
  gap: 16px;
  max-width: 560px;
  animation: rise 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.pw-panel .f-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.pw-panel .f-acts,
.p-form .f-acts {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------------- 分组与链接卡片 ---------------- */

.board {
  display: grid;
  gap: 40px;
}

.g-group {
  animation: rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 50ms);
}

.g-group.hide,
.l-item.hide {
  display: none;
}

.g-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.g-head svg {
  color: var(--ink-3);
  flex: none;
}

.g-name {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
  line-height: 1.4;
  cursor: default;
}

.editing .g-name {
  cursor: text;
}

.g-count {
  color: var(--ink-3);
  font-size: 12px;
}

.g-note {
  color: var(--ink-3);
  font-size: 12px;
  margin-left: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.g-tools {
  margin-left: auto;
  display: none;
  align-items: center;
  gap: 2px;
}

.editing .g-tools {
  display: flex;
}

.g-name-input {
  font-size: 16px;
  font-weight: 500;
  height: 30px;
  max-width: 16ch;
}

.l-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 16px;
}

.l-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease,
    opacity 0.18s ease;
}

.l-item:hover {
  transform: translateY(-2px);
  border-color: var(--line-2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.editing .l-item:hover {
  transform: none;
  box-shadow: none;
}

.l-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  text-decoration: none;
  min-width: 0;
}

.l-icon-box {
  width: 56px;
  height: 56px;
  border-radius: var(--r-card);
  background: var(--bg);
  display: grid;
  place-items: center;
  flex: none;
  overflow: hidden;
  font-size: 22px;
  font-weight: 600;
  color: #fff;
}

.l-icon-box img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.l-text {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.l-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.l-desc {
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editing .l-card {
  opacity: 0.66;
  pointer-events: none;
}

.l-tools {
  display: none;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
  background: #fafbfc;
}

.editing .l-tools {
  display: flex;
}

.drag-handle {
  cursor: grab;
  color: var(--ink-3);
  user-select: none;
  display: none;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  border: 1px dashed var(--line-2);
  background: #fff;
  font-size: 12px;
  line-height: 1.2;
}

.editing .drag-handle {
  display: inline-block;
}

.drag-handle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.drag-handle:active {
  cursor: grabbing;
}

.g-head .drag-handle {
  background: transparent;
}

.l-form {
  grid-column: 1 / -1;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: var(--r-card);
  padding: 20px;
  display: grid;
  gap: 14px;
}

.l-form .f-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.l-form select {
  width: auto;
  min-width: 120px;
}

.empty {
  background: var(--card);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-card);
  padding: 32px;
  color: var(--ink-2);
  max-width: 520px;
}

.empty b {
  display: block;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 6px;
}

.empty-hint {
  font-size: 12px;
  color: var(--ink-3);
  padding: 14px 16px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--r-card);
}

.add-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

.board-foot {
  color: var(--ink-3);
  font-size: 12px;
  padding-top: 32px;
}

/* 拖拽状态 */
.dragging {
  opacity: 0.4;
}

.drop-above {
  box-shadow: inset 0 2px 0 0 var(--accent);
}

.drop-below {
  box-shadow: inset 0 -2px 0 0 var(--accent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  font-size: 13px;
  border-radius: var(--r-sm);
  z-index: 60;
  animation: rise 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 960px) {
  .auth {
    grid-template-columns: 1fr;
  }

  .auth-side {
    padding: 28px 24px;
    gap: 20px;
  }

  .auth-foot {
    margin-top: 8px;
  }

  .app,
  .app.side-collapsed {
    grid-template-columns: 1fr;
  }

  .side {
    position: static;
    height: auto;
    gap: 14px;
    padding: 14px 12px;
  }

  .side-nav {
    overflow-y: hidden;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    gap: 6px;
  }

  .side-label {
    display: none;
  }

  .side-foot {
    margin-top: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .side-collapsed .side-head .brand,
  .side-collapsed .side-head .side-text {
    display: flex;
  }

  .side-collapsed .side-head .side-text {
    display: block;
  }

  .side-collapsed .side-head {
    justify-content: space-between;
  }

  .side-collapsed .side-nav,
  .side-collapsed .side-foot {
    display: none;
  }

  .settings-menu {
    top: 100%;
    bottom: auto;
    left: auto;
    right: 0;
  }

  .side-item {
    white-space: nowrap;
    width: auto;
  }

  .main-top {
    flex-wrap: wrap;
  }

  .search {
    flex-basis: 100%;
    max-width: none;
  }

  .l-form .f-row,
  .pw-panel .f-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
