:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-soft: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --accent: var(--primary);
}

* {
  box-sizing: border-box;
}

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

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

.hidden {
  display: none !important;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

/* ------------------------------ buttons ------------------------------ */

.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 7px 14px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn:hover {
  background: #eef2f7;
}

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

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

.btn-ghost {
  background: transparent;
  border-color: var(--border);
}

.btn-danger-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
}

.btn-danger-ghost:hover {
  background: #fef2f2;
}

.btn-small {
  padding: 4px 10px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
  padding: 10px;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-soft);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  font-size: 15px;
  line-height: 1;
}

.icon-btn:hover {
  background: #eef2f7;
  color: var(--text);
}

/* ------------------------------- login ------------------------------- */

.login-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #1e3a8a 0%, #0f172a 100%);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(2, 6, 23, 0.35);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.login-tip {
  margin: 0 0 6px;
  color: var(--text-soft);
}

.login-card input {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
}

.login-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

/* ------------------------------ topbar ------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

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

.brand-logo {
  font-size: 17px;
  font-weight: 700;
}

.brand-summary {
  color: var(--text-soft);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 9px;
  padding: 7px 12px;
  min-width: 200px;
  font-size: 14px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-soft);
  font-size: 13px;
  user-select: none;
  cursor: pointer;
}

/* -------------------------------- board ------------------------------ */

main {
  padding: 20px 22px 60px;
}

.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  align-items: start;
}

.empty-state {
  text-align: center;
  color: var(--text-soft);
  padding: 80px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* --------------------------------- card ------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.12s, box-shadow 0.12s;
}

.card[data-color="blue"] {
  --accent: #2563eb;
}
.card[data-color="green"] {
  --accent: #16a34a;
}
.card[data-color="amber"] {
  --accent: #d97706;
}
.card[data-color="rose"] {
  --accent: #e11d48;
}
.card[data-color="violet"] {
  --accent: #7c3aed;
}
.card[data-color="cyan"] {
  --accent: #0891b2;
}
.card[data-color="slate"] {
  --accent: #475569;
}

.card.dragging {
  opacity: 0.5;
  transform: rotate(1deg);
}

.card-head {
  border-top: 4px solid var(--accent);
  padding: 12px 14px 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: grab;
}

.card-drag-handle {
  color: #cbd5e1;
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: -2px;
}

.card-title-wrap {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: 15px;
  font-weight: 650;
  margin: 0;
  word-break: break-word;
}

.card-desc {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.card-menu {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.card-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 14px 8px;
  color: var(--text-soft);
  font-size: 12px;
}

.node-list {
  list-style: none;
  margin: 0;
  padding: 4px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 8px;
}

.node-toggle {
  align-self: flex-start;
  margin: 0 14px 8px;
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 12.5px;
  padding: 2px 0;
  cursor: pointer;
}

.node-toggle:hover {
  text-decoration: underline;
}

.node-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 9px;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}

.node-row:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.node-row.dragging {
  opacity: 0.45;
  background: #eef2f7;
}

.node-name {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  text-align: left;
  padding: 0;
  color: var(--text);
  font-size: 13.5px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-name:hover {
  color: var(--primary);
}

.node-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 1px 7px;
  flex-shrink: 0;
}

.node-tooltip {
  position: fixed;
  z-index: 45;
  max-width: 360px;
  max-height: 260px;
  overflow: hidden;
  padding: 9px 12px;
  border-radius: 10px;
  background: #1f2937;
  color: #f8fafc;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
  pointer-events: none;
}

.card-empty {
  color: var(--text-soft);
  font-size: 13px;
  padding: 6px 12px 10px;
}

.card-foot {
  display: flex;
  gap: 8px;
  padding: 8px 10px 12px;
  border-top: 1px dashed var(--border);
  margin-top: auto;
}

.add-node-trigger {
  flex: 1;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-soft);
  border-radius: 9px;
  padding: 8px;
  font-size: 13px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.add-node-trigger:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #eff6ff;
}

.node-composer {
  border-top: 1px dashed var(--border);
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface-2);
  margin-top: auto;
}

.composer-title,
.composer-content {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 11px;
  font-family: inherit;
  font-size: 13px;
  background: #fff;
}

.composer-content {
  min-height: 92px;
  line-height: 1.6;
  resize: vertical;
}

.composer-title:focus,
.composer-content:focus {
  outline: none;
  border-color: var(--primary);
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.composer-files {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.composer-file {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12.5px;
}

.composer-file .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.node-index {
  width: 20px;
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.card.archived {
  opacity: 0.62;
}

/* ------------------------------- drawer ------------------------------ */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 40;
  animation: fade 0.15s ease;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  width: min(560px, 100vw);
  background: var(--surface);
  z-index: 41;
  box-shadow: -16px 0 50px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  animation: slide-in 0.2s ease;
}

@keyframes slide-in {
  from {
    transform: translateX(30px);
    opacity: 0.4;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.drawer-title {
  flex: 1;
  border: none;
  font-size: 18px;
  font-weight: 650;
  padding: 4px 2px;
  background: transparent;
}

.drawer-title:focus {
  outline: none;
  border-bottom: 2px solid var(--primary);
}

.drawer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
}

.drawer-meta-hint {
  color: var(--text-soft);
  font-size: 12.5px;
}

.drawer-body {
  padding: 16px 18px 40px;
  overflow-y: auto;
  flex: 1;
}

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
  margin: 4px 0 6px;
}

.content-editor {
  width: 100%;
  min-height: 180px;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.65;
  resize: vertical;
  background: var(--surface-2);
}

.content-editor:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}

.save-hint {
  height: 18px;
  font-size: 12px;
  color: var(--text-soft);
  text-align: right;
}

.attach-section {
  margin-top: 14px;
}

.attach-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: 11px;
  padding: 16px;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
}

.attach-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attach-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.attach-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: #e2e8f0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-soft);
  border: 1px solid var(--border);
}

.attach-info {
  flex: 1;
  min-width: 0;
}

.attach-name {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-name:hover {
  color: var(--primary);
}

.attach-size {
  font-size: 12px;
  color: var(--text-soft);
}

.attach-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-soft);
}

.upload-progress {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-progress-track {
  flex: 1;
  height: 6px;
  border-radius: 99px;
  background: #e2e8f0;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--primary);
  transition: width 0.15s ease;
}

.upload-progress-text {
  font-size: 12px;
  color: var(--text-soft);
  min-width: 64px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.storage-picker {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
  font-size: 12.5px;
}

.storage-label {
  color: var(--text-soft);
}

.storage-opt {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
}

.storage-opt.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.composer-storage {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 12.5px;
  background: #fff;
}

.attach-badge {
  display: inline-block;
  margin-left: 2px;
  padding: 0 6px;
  border-radius: 99px;
  background: #eef2f7;
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 11px;
  vertical-align: middle;
}

/* -------------------------------- modal ------------------------------ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 22px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.3);
  display: flex;
  flex-direction: column;
}

.modal h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 6px;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
}

.color-picker {
  display: flex;
  gap: 9px;
  margin: 4px 0 12px;
}

.color-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}

.color-dot.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px #fff inset;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

/* ------------------------------- trash ------------------------------- */

.modal-wide {
  max-width: 640px;
}

.trash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.trash-head h3 {
  margin: 0;
}

.trash-tip {
  margin: 8px 0 14px;
  font-size: 12.5px;
  color: var(--text-soft);
}

.trash-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 52vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
}

.trash-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.trash-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.trash-title {
  font-size: 14px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trash-parent,
.trash-meta {
  font-size: 12px;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trash-days {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-soft);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 9px;
}

/* ------------------------------ preview ------------------------------ */

.preview-dialog {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 900px;
  height: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.35);
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.preview-title {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.preview-body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  overflow: auto;
  padding: 12px;
}

.preview-media {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.preview-audio {
  width: min(420px, 100%);
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

.preview-text {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 16px;
  background: #fff;
  border-radius: 10px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ------------------------------ settings ----------------------------- */

.settings-body {
  max-height: 58vh;
  overflow-y: auto;
  margin: 8px 0 14px;
  padding-right: 4px;
}

.settings-tabs {
  display: flex;
  gap: 6px;
  margin: 10px 0 2px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
}

.settings-tab {
  flex: 1 1 auto;
  border: none;
  background: transparent;
  color: var(--text-soft);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}

.settings-tab:hover {
  color: var(--text);
}

.settings-tab.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

@media (max-width: 600px) {
  .settings-tabs {
    flex-wrap: wrap;
  }

  .settings-tab {
    flex: 1 1 40%;
  }
}

.settings-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.settings-section-head h4 {
  margin: 0;
  font-size: 14.5px;
}

.settings-status {
  font-size: 12px;
  padding: 1px 9px;
  border-radius: 99px;
  background: #f1f5f9;
  color: var(--text-soft);
  border: 1px solid var(--border);
}

.settings-status.on {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.settings-hint {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--text-soft);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}

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

.settings-field > span {
  font-size: 12.5px;
  color: var(--text-soft);
}

.settings-field-wide {
  grid-column: 1 / -1;
}

.settings-field .input {
  margin-bottom: 0;
}

.settings-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-soft);
}

.settings-message {
  margin: 12px 0 0;
  font-size: 13px;
}

.settings-message.ok {
  color: #047857;
}

.settings-message.err {
  color: var(--danger);
}

.settings-message.info {
  color: var(--text-soft);
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.settings-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.settings-row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.settings-row-title {
  font-size: 13.5px;
  font-weight: 600;
}

.settings-row-desc {
  font-size: 12.5px;
  color: var(--text-soft);
}

.settings-row .btn {
  flex-shrink: 0;
}

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

/* ------------------------------- update ------------------------------ */

.update-step {
  margin: 12px 0 8px;
  font-size: 13.5px;
  font-weight: 600;
}

.update-log {
  margin: 0;
  padding: 12px;
  background: #0f172a;
  color: #cbd5e1;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.5;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* -------------------------------- toast ------------------------------ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 9px 18px;
  border-radius: 99px;
  font-size: 13px;
  z-index: 60;
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.3);
}

/* ------------------------------ markdown ----------------------------- */

.rendered {
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------------------------- task detail ---------------------------- */

.detail-view {
  position: fixed;
  inset: 0;
  z-index: 44;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: fade 0.15s ease;
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.detail-title-wrap {
  flex: 1;
  min-width: 0;
}

.detail-title {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  word-break: break-word;
}

.detail-desc {
  margin: 3px 0 0;
  color: var(--text-soft);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 18px 60px;
}

.detail-empty {
  color: var(--text-soft);
  font-size: 13px;
  padding: 40px 12px;
  text-align: center;
}

.acc-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
}

.acc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
}

.acc-head:hover {
  background: var(--surface-2);
}

.acc-index {
  width: 22px;
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.acc-title {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acc-chevron {
  flex-shrink: 0;
  color: var(--text-soft);
  font-size: 18px;
  line-height: 1;
  transition: transform 0.15s;
}

.acc-item.open .acc-chevron {
  transform: rotate(90deg);
}

.acc-body {
  border-top: 1px solid var(--border);
  padding: 14px;
  display: flex;
  flex-direction: column;
}

.detail-save-hint {
  min-height: 18px;
  font-size: 12px;
  color: var(--text-soft);
  text-align: right;
}

.detail-node-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.card-detail-trigger {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 9px;
  padding: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.card-detail-trigger:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #eff6ff;
}

/* --------------------------- mobile & touch -------------------------- */

@media (hover: none) {
  /* 触屏设备没有 hover，隐藏依赖悬停的浮层 */
  .node-tooltip {
    display: none !important;
  }
  .btn,
  .icon-btn,
  .node-name,
  .settings-tab,
  .color-dot,
  .storage-opt,
  .switch {
    touch-action: manipulation;
  }
  .card-head,
  .node-row {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
}

@media (max-width: 640px) {
  /* 顶部栏：品牌与搜索同行，操作按钮换行 */
  .topbar {
    padding: 10px 12px;
    gap: 10px;
  }
  .brand {
    flex: 0 0 auto;
  }
  .brand-logo {
    font-size: 16px;
  }
  .brand-summary {
    display: none;
  }
  .topbar-actions {
    flex: 1 1 auto;
    gap: 8px;
  }
  .search-input {
    order: -1;
    flex: 1 1 100%;
    min-width: 0;
    padding: 10px 12px;
    font-size: 16px;
  }
  .switch {
    margin-right: auto;
  }
  .btn {
    padding: 9px 12px;
    min-height: 40px;
  }
  .btn-small {
    min-height: 34px;
  }
  .icon-btn {
    width: 40px;
    height: 40px;
    font-size: 17px;
  }

  /* 看板单列布局 */
  main {
    padding: 12px 12px calc(72px + env(safe-area-inset-bottom));
  }
  .board {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* 卡片与节点：更大的触控区域与字号 */
  .card-title {
    font-size: 16px;
  }
  .card-drag-handle {
    font-size: 18px;
    padding: 2px 4px;
  }
  .node-row {
    padding: 10px 8px;
  }
  .node-name {
    font-size: 15px;
  }
  .color-dot {
    width: 32px;
    height: 32px;
  }
  .card-detail-trigger,
  .add-node-trigger {
    min-height: 40px;
  }

  /* 任务详情页 */
  .detail-head {
    flex-wrap: wrap;
    padding: 12px 12px;
    padding-top: calc(12px + env(safe-area-inset-top));
  }
  .detail-actions {
    flex: 1 1 100%;
    justify-content: flex-end;
  }
  .detail-body {
    padding: 12px 12px calc(40px + env(safe-area-inset-bottom));
  }

  /* 输入框 16px 以上避免 iOS 聚焦时自动放大 */
  .login-card input,
  .input,
  .content-editor,
  .composer-title,
  .composer-content,
  .drawer-title,
  .composer-storage {
    font-size: 16px;
  }

  /* 节点抽屉全屏并适配安全区 */
  .drawer {
    width: 100vw;
  }
  .drawer-head {
    padding-top: calc(14px + env(safe-area-inset-top));
  }
  .drawer-body {
    padding: 14px 14px calc(40px + env(safe-area-inset-bottom));
  }
  .content-editor {
    min-height: 140px;
  }

  /* 附件条目允许换行，避免横向溢出 */
  .attach-item {
    flex-wrap: wrap;
  }
  .attach-info {
    min-width: 120px;
  }

  /* 弹窗改为底部抽屉式 */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    max-width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
    overflow-y: auto;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  }
  .settings-body {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
  .trash-list {
    max-height: none;
  }

  /* 设置标签横向滚动 */
  .settings-tabs {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .settings-tab {
    flex: 0 0 auto;
    padding: 8px 14px;
  }

  /* 回收站条目换行 */
  .trash-item {
    flex-wrap: wrap;
  }
  .trash-info {
    min-width: 140px;
  }

  /* 附件预览全屏 */
  .preview-dialog {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .preview-head {
    padding-top: calc(12px + env(safe-area-inset-top));
  }

  .toast {
    bottom: calc(20px + env(safe-area-inset-bottom));
  }
}
