/* ========================================================================
   我的工作台 —— 样式
   轻量、无框架、深浅双主题
   ===================================================================== */

:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-2: #f2f4f9;
  --border: #e4e7ef;
  --text: #1c2033;
  --text-soft: #6b7280;
  --text-faint: #9aa1b1;
  --accent: #5b5bd6;
  --accent-soft: #ececfd;
  --accent-text: #ffffff;
  --high: #ef4444;
  --normal: #f59e0b;
  --low: #10b981;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px -12px rgba(16, 24, 40, .18);
  --radius: 14px;
  --radius-sm: 9px;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --panel: #171a23;
  --panel-2: #1e222d;
  --border: #2a2f3d;
  --text: #e7e9f0;
  --text-soft: #9ba3b6;
  --text-faint: #6c7488;
  --accent: #7c7cf0;
  --accent-soft: #23243d;
  --accent-text: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -16px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }

/* 关键：全局兜底，确保 hidden 属性优先于任何 display 规则 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ───────────────────────────── 侧栏 ───────────────────────────── */

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
  gap: 18px;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.brand-mark { font-size: 26px; line-height: 1; }
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 15px; letter-spacing: .2px; }
.brand-text small { color: var(--text-faint); font-size: 11px; letter-spacing: .4px; }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 11px;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
[data-theme="dark"] .nav-item.is-active { color: #b9b9ff; }
.nav-icon { font-size: 13px; opacity: .9; }
.nav-count {
  margin-left: auto;
  font-size: 11px;
  background: var(--panel-2);
  color: var(--text-soft);
  border-radius: 99px;
  padding: 1px 7px;
  min-width: 22px;
  text-align: center;
}
.nav-item.is-active .nav-count { background: rgba(91, 91, 214, .16); color: inherit; }

.side-section { display: flex; flex-direction: column; gap: 8px; }
.side-title {
  font-size: 11px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--text-faint); padding-left: 4px; font-weight: 600;
}

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 2px; }
.empty-hint { color: var(--text-faint); font-size: 12px; }

.tag {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-soft);
  border-radius: 99px;
  padding: 2px 9px;
  font-size: 11.5px;
  transition: .15s;
}
.tag:hover { border-color: var(--accent); color: var(--accent); }
.tag.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.stats { gap: 6px; margin-top: auto; }
.stat-row {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-soft);
  padding: 5px 4px;
  border-bottom: 1px dashed var(--border);
}
.stat-row b { color: var(--text); font-variant-numeric: tabular-nums; }

.side-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 10px; border-top: 1px solid var(--border);
}

.user-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 4px 0;
}
.avatar {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12px; font-weight: 700;
  text-transform: uppercase;
}
.user-name {
  flex: 1; min-width: 0;
  font-size: 12.5px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-bar .ghost-btn { padding: 4px 9px; font-size: 11.5px; }
.user-bar .ghost-btn:hover { color: var(--high); border-color: var(--high); }
.ghost-btn {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 10px;
  font-size: 12px; color: var(--text-soft);
}
.ghost-btn:hover { color: var(--text); border-color: var(--accent); }
.server-dot { color: var(--low); font-size: 14px; transition: color .3s; }
.server-dot.is-off { color: var(--high); }

/* ───────────────────────────── 主区 ───────────────────────────── */

.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 18px 26px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.topbar-title h1 { margin: 0; font-size: 19px; letter-spacing: .2px; }
.topbar-title p { margin: 2px 0 0; font-size: 12px; color: var(--text-faint); }

.search-wrap { position: relative; margin-left: auto; width: min(360px, 40vw); }
.search {
  width: 100%;
  padding: 9px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.search-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 420px; max-height: 60vh; overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 40;
}
.search-group-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--text-faint); padding: 8px 10px 4px;
}
.search-hit {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer;
}
.search-hit:hover { background: var(--panel-2); }
.search-hit small { color: var(--text-faint); font-size: 11px; margin-left: auto; }
.search-empty { padding: 14px; text-align: center; color: var(--text-faint); }

.primary-btn {
  background: var(--accent); color: var(--accent-text);
  border: none; border-radius: var(--radius-sm);
  padding: 9px 16px; font-weight: 600;
  box-shadow: 0 6px 16px -8px var(--accent);
  transition: transform .12s, filter .15s;
  white-space: nowrap;
}
.primary-btn:hover { filter: brightness(1.07); }
.primary-btn:active { transform: scale(.97); }

.view { flex: 1; overflow: auto; padding: 20px 26px 40px; }

/* ───────────────────────────── 月历 ───────────────────────────── */

.calendar-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px 14px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.calendar-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.cal-title { font-size: 13.5px; letter-spacing: .3px; }
.cal-nav {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; width: 26px; height: 26px;
  display: grid; place-items: center;
  color: var(--text-soft); font-size: 15px; line-height: 1;
}
.cal-nav:hover { color: var(--accent); border-color: var(--accent); }
.cal-today { margin-left: 4px; padding: 4px 10px; font-size: 11.5px; }

.cal-chip {
  margin-left: auto;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
  border-radius: 99px;
  padding: 4px 11px;
  font-size: 11.5px;
  font-weight: 600;
}
.cal-chip:hover { filter: brightness(.96); }
[data-theme="dark"] .cal-chip { color: #b9b9ff; }

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.calendar-weekdays span {
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: .5px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 46px;
  padding: 5px 2px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  transition: background .15s, border-color .15s, transform .1s;
}
.cal-day:hover { border-color: var(--accent); transform: translateY(-1px); }
.cal-day.is-other { color: var(--text-faint); opacity: .55; }
.cal-day.is-today {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}
.cal-day.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.cal-day.is-selected .cal-num { color: inherit; }

.cal-num { font-size: 12.5px; line-height: 1.1; font-variant-numeric: tabular-nums; }

.cal-dots {
  display: flex; gap: 2px; height: 5px; align-items: center;
}
.cal-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--normal);
}
.cal-dot[data-p="high"] { background: var(--high); }
.cal-dot[data-p="low"] { background: var(--low); }
.cal-day.is-selected .cal-dot { background: rgba(255, 255, 255, .85); }
.cal-more { font-size: 9px; color: var(--text-faint); line-height: 1; }

/* ───────────────────────────── 看板 ───────────────────────────── */

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 16px;
  align-items: start;
}

.column {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 200px;
  display: flex; flex-direction: column; gap: 10px;
}
.column.drag-over { outline: 2px dashed var(--accent); outline-offset: -4px; }

.column-head {
  display: flex; align-items: center; gap: 8px;
  padding: 0 4px 2px;
}
.column-dot { width: 8px; height: 8px; border-radius: 50%; }
.column-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.column-count {
  margin-left: auto; font-size: 11px; color: var(--text-faint);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 99px; padding: 0 7px;
}

.cards { display: flex; flex-direction: column; gap: 9px; min-height: 60px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--normal);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  box-shadow: var(--shadow);
  cursor: grab;
  transition: transform .12s, box-shadow .15s, opacity .15s;
}
.card:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -14px rgba(16,24,40,.5); }
.card.dragging { opacity: .45; }
.card[data-priority="high"] { border-left-color: var(--high); }
.card[data-priority="low"] { border-left-color: var(--low); }
.card.is-done .card-title { text-decoration: line-through; color: var(--text-faint); }

.card-title { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; word-break: break-word; }
.card-detail {
  font-size: 12px; color: var(--text-soft);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 7px;
}
.card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  font-size: 10.5px; padding: 1px 7px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
}
[data-theme="dark"] .chip { color: #b9b9ff; }
.due { font-size: 11px; color: var(--text-faint); margin-left: auto; }
.due.is-over { color: var(--high); font-weight: 600; }

.empty-col {
  text-align: center; color: var(--text-faint); font-size: 12px;
  padding: 22px 0; border: 1px dashed var(--border); border-radius: var(--radius-sm);
}

/* ─────────────────────────── 知识库 ─────────────────────────── */

.notes-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  height: 100%;
  min-height: 0;
}
.notes-list-wrap {
  display: flex; flex-direction: column; gap: 10px; min-height: 0;
}
.mini-input {
  width: 100%; padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-2); outline: none;
}
.mini-input:focus { border-color: var(--accent); }

.notes-list {
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; padding-right: 4px;
}
.note-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  cursor: pointer;
  transition: border-color .15s, transform .12s;
}
.note-item:hover { border-color: var(--accent); transform: translateX(2px); }
.note-item.is-active { border-color: var(--accent); background: var(--accent-soft); }
.note-item h4 { margin: 0 0 4px; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.note-item p {
  margin: 0 0 6px; font-size: 12px; color: var(--text-soft);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.note-item .meta { font-size: 11px; color: var(--text-faint); display: flex; gap: 8px; }
.pin-mark { font-size: 11px; }

.notes-detail {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  overflow-y: auto;
  min-height: 0;
  display: flex; flex-direction: column; gap: 12px;
}

.note-editor-head { display: flex; gap: 10px; align-items: center; }
.note-title-input {
  flex: 1; font-size: 19px; font-weight: 700;
  border: none; background: transparent; outline: none;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
}
.note-title-input:focus { border-bottom-color: var(--accent); }

.note-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.note-toolbar .spacer { margin-left: auto; }
.save-state { font-size: 11px; color: var(--text-faint); }
.save-state.is-dirty { color: var(--normal); }

.note-body {
  flex: 1; min-height: 320px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.note-body.single { grid-template-columns: 1fr; }
.note-textarea {
  width: 100%; min-height: 320px; resize: vertical;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel-2); padding: 12px 14px;
  font-family: "Cascadia Code", Consolas, "SFMono-Regular", monospace;
  font-size: 13px; line-height: 1.7; outline: none;
}
.note-textarea:focus { border-color: var(--accent); }

.note-preview {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 16px; overflow-y: auto; min-height: 320px;
  background: var(--panel);
}
.note-preview h1, .note-preview h2, .note-preview h3 { margin: 14px 0 8px; line-height: 1.35; }
.note-preview h1 { font-size: 20px; }
.note-preview h2 { font-size: 17px; }
.note-preview h3 { font-size: 15px; }
.note-preview p { margin: 8px 0; }
.note-preview ul, .note-preview ol { padding-left: 22px; margin: 8px 0; }
.note-preview code {
  background: var(--panel-2); padding: 1px 5px; border-radius: 5px;
  font-family: "Cascadia Code", Consolas, monospace; font-size: 12.5px;
}
.note-preview pre {
  background: var(--panel-2); padding: 12px; border-radius: var(--radius-sm);
  overflow-x: auto; border: 1px solid var(--border);
}
.note-preview pre code { background: none; padding: 0; }
.note-preview blockquote {
  margin: 10px 0; padding: 4px 14px; border-left: 3px solid var(--accent);
  color: var(--text-soft); background: var(--panel-2); border-radius: 0 6px 6px 0;
}
.note-preview a { color: var(--accent); }
.note-preview hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.blank-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  color: var(--text-faint);
}
.blank-emoji { font-size: 40px; opacity: .55; }

/* ───────────────────────────── 弹窗 ───────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 17, 23, .45);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(560px, 100%);
  max-height: 88vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 70px -24px rgba(0, 0, 0, .5);
  display: flex; flex-direction: column;
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex; align-items: center;
  padding: 16px 18px 10px;
}
.modal-head h2 { margin: 0; font-size: 16px; }
.icon-btn {
  margin-left: auto; background: transparent; border: none;
  color: var(--text-faint); font-size: 15px; padding: 4px 8px; border-radius: 7px;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

.modal-body {
  padding: 6px 18px 18px;
  display: flex; flex-direction: column; gap: 13px;
  overflow-y: auto;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-soft); font-weight: 600; }
.field input[type="text"], .field input[type="date"], .field textarea, .field select {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel-2); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; padding: 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--panel-2);
  color: var(--text-soft); font-size: 12.5px;
}
.seg button.is-on {
  border-color: var(--accent); background: var(--accent-soft);
  color: var(--accent); font-weight: 600;
}
[data-theme="dark"] .seg button.is-on { color: #b9b9ff; }

.modal-foot {
  display: flex; gap: 10px; align-items: center;
  padding: 0 18px 18px;
}
.modal-foot .spacer { margin-left: auto; }
.danger-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--high); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 12.5px;
}
.danger-btn:hover { background: rgba(239, 68, 68, .1); border-color: var(--high); }
.ghost-lg {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 16px;
}

/* ───────────────────────────── 提示条 ───────────────────────────── */

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 99px;
  font-size: 12.5px; z-index: 200;
  box-shadow: var(--shadow);
  animation: toastIn .2s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ───────────────────────────── 响应式 ───────────────────────────── */

@media (max-width: 1080px) {
  .board { grid-template-columns: 1fr; }
  .notes-layout { grid-template-columns: 1fr; }
  .note-body { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { flex-wrap: wrap; }
  .search-wrap { width: 100%; order: 3; }
  .search-panel { width: 100%; }
}
