/* PNote 鈥?Prompt 绗旇鏈?   Dark, DSH-inspired two-pane layout: workspace sidebar + editable note pane. */

:root {
  color-scheme: dark;
  --sidebar-w: 304px;
  --bg: #090b10;
  --bg-soft: #0c0f15;
  --panel: #0e1219;
  --line: #1e2431;
  --line-soft: #171c26;
  --text: #e9ecf3;
  --muted: #939bad;
  --dim: #7a8496;
  --accent: #5c7cfa;
  --accent-2: #7c5cff;
  --accent-soft: rgba(92, 124, 250, 0.14);
  --danger: #f2636d;
  --serif: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", "Cascadia Mono", Consolas,
    "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font-family: inherit;
}

img,
svg {
  display: block;
}

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ------------------------------------------------------------------ sidebar */

.sidebar {
  position: relative;
  z-index: 30;
  display: flex;
  flex: 0 0 var(--sidebar-w);
  flex-direction: column;
  width: var(--sidebar-w);
  min-height: 0;
  background: linear-gradient(180deg, #0d1118 0%, #0a0d13 100%);
  border-right: 1px solid var(--line);
}

.sidebar-top {
  padding: 20px 16px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 2px;
  user-select: none;
}

.brand-logo {
  display: grid;
  width: 34px;
  height: 34px;
  color: #fff;
  background: linear-gradient(135deg, #4a63f0, #7c5cff);
  border-radius: 9px;
  box-shadow: 0 4px 14px rgba(92, 124, 250, 0.35);
  place-items: center;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-text strong {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-text small {
  color: var(--dim);
  font-size: 10.5px;
  letter-spacing: 0.06em;
}

.new-note-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 42px;
  margin-top: 18px;
  padding: 0 12px;
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  background: linear-gradient(135deg, #4a63f0, #705cff);
  border: 0;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(77, 107, 254, 0.28);
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

.new-note-btn:hover {
  filter: brightness(1.06);
  box-shadow: 0 8px 24px rgba(77, 107, 254, 0.38);
  transform: translateY(-1px);
}

.new-note-btn:active {
  transform: translateY(0);
}

.new-note-btn kbd {
  margin-left: auto;
  padding: 2px 5px;
  color: rgba(255, 255, 255, 0.82);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
}

.search-box {
  position: relative;
  margin-top: 12px;
}

.search-box > svg {
  position: absolute;
  top: 50%;
  left: 11px;
  color: var(--dim);
  pointer-events: none;
  transform: translateY(-50%);
}

.search-box input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 33px;
  color: var(--text);
  font-size: 12.5px;
  background: #11161f;
  border: 1px solid #1b2230;
  border-radius: 9px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.search-box input::placeholder {
  color: #6b7587;
}

.search-box input:focus {
  background: #121824;
  border-color: rgba(92, 124, 250, 0.45);
}

.search-box input::-webkit-search-cancel-button {
  display: none;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 8px;
}

.section-title {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.note-count {
  padding: 2px 7px;
  color: #8d97a9;
  font-size: 10.5px;
  background: #131822;
  border: 1px solid #1c2330;
  border-radius: 999px;
}

.note-list {
  flex: 1;
  min-height: 0;
  padding: 2px 10px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.note-list-empty {
  padding: 26px 14px;
  color: var(--dim);
  font-size: 12.5px;
  line-height: 1.8;
  text-align: center;
}

.note-item {
  position: relative;
  padding: 10px 12px 9px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  outline: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.note-item + .note-item {
  margin-top: 2px;
}

.note-item:hover {
  background: #131824;
}

.note-item.active {
  background: linear-gradient(90deg, rgba(92, 124, 250, 0.14), rgba(92, 124, 250, 0.05));
  border-color: rgba(92, 124, 250, 0.22);
}

.note-item.active::before {
  position: absolute;
  top: 11px;
  bottom: 11px;
  left: 0;
  width: 2.5px;
  background: var(--accent);
  border-radius: 2px;
  content: "";
}

.note-item:focus-visible {
  border-color: rgba(92, 124, 250, 0.55);
}

.note-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.note-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.note-item.active .note-title {
  color: #f2f5ff;
}

.note-del {
  display: grid;
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  padding: 0;
  color: var(--dim);
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: 6px;
  opacity: 0;
  place-items: center;
  transition: opacity 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.note-item:hover .note-del,
.note-item.active .note-del,
.note-del:focus-visible {
  opacity: 1;
}

.note-del:hover {
  color: var(--danger);
  background: rgba(242, 99, 109, 0.12);
}

.note-preview {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.note-time {
  margin-top: 5px;
  color: var(--dim);
  font-size: 10.5px;
  letter-spacing: 0.02em;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 18px;
  color: var(--dim);
  font-size: 10.5px;
  border-top: 1px solid var(--line-soft);
}

.db-dot {
  width: 6px;
  height: 6px;
  background: #37c98b;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(55, 201, 139, 0.5);
}

.sidebar-overlay {
  display: none;
}

/* --------------------------------------------------------------------- main */

.main {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  background:
    radial-gradient(1200px 620px at 82% -12%, rgba(92, 124, 250, 0.1), transparent 62%),
    radial-gradient(900px 520px at 6% 112%, rgba(124, 92, 255, 0.06), transparent 60%),
    var(--bg);
}

.empty-state {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 460px;
  margin: 0 auto;
  padding: 40px 28px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 64px;
  height: 64px;
  color: #8ba0ff;
  background: radial-gradient(circle at 30% 20%, rgba(92, 124, 250, 0.28), rgba(124, 92, 255, 0.08));
  border: 1px solid rgba(92, 124, 250, 0.25);
  border-radius: 16px;
  place-items: center;
}

.empty-state h2 {
  margin: 20px 0 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.empty-state p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.85;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  margin-top: 22px;
  padding: 0 16px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: #11161f;
  border: 1px solid var(--line);
  border-radius: 9px;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.ghost-btn:hover {
  background: #141a25;
  border-color: rgba(92, 124, 250, 0.4);
}

.editor {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  max-width: 1060px;
  min-height: 0;
  margin: 0 auto;
  padding: 0 clamp(22px, 4vw, 46px);
  animation: editor-in 0.18s ease both;
}

@keyframes editor-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.editor-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 30px 0 16px;
  border-bottom: 1px solid var(--line-soft);
}

.head-main {
  flex: 1;
  min-width: 0;
}

.title-input {
  width: 100%;
  padding: 0 0 2px;
  color: var(--text);
  font-size: clamp(20px, 2.3vw, 25px);
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.35;
  background: transparent;
  border: 0;
  outline: none;
  transition: box-shadow 0.15s ease;
}

.title-input::placeholder {
  color: #6b7587;
  font-weight: 600;
}

.title-input:focus {
  box-shadow: inset 0 -1px 0 rgba(92, 124, 250, 0.45);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 8px;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.meta-text {
  color: var(--dim);
}

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  transition: color 0.2s ease;
}

.save-state .save-dot {
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
}

.save-state .save-text {
  white-space: nowrap;
}

.save-state[data-state="saved"] {
  color: #6ec2a0;
}

.save-state[data-state="dirty"] {
  color: #d7a55f;
}

.save-state[data-state="saving"] {
  color: #8ba0ff;
}

.save-state[data-state="saving"] .save-dot {
  animation: dot-pulse 1s ease-in-out infinite;
}

.save-state[data-state="error"] {
  color: var(--danger);
}

@keyframes dot-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

.head-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  background: #11161f;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.action-btn:hover {
  color: var(--text);
  background: #151b27;
  border-color: rgba(92, 124, 250, 0.35);
}

.icon-btn {
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  place-items: center;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  color: var(--text);
  background: #151b27;
}

.icon-btn.danger:hover {
  color: var(--danger);
  background: rgba(242, 99, 109, 0.1);
  border-color: rgba(242, 99, 109, 0.3);
}

.mobile-only {
  display: none;
}

.editor-body {
  display: flex;
  flex: 1;
  min-height: 0;
  padding-top: 4px;
}

.content-input {
  flex: 1;
  width: 100%;
  padding: 20px 0;
  color: #dde2ed;
  font-size: 15.5px;
  line-height: 1.85;
  background: transparent;
  border: 0;
  outline: none;
  resize: none;
  caret-color: var(--accent);
}

.content-input::placeholder {
  color: #67728a;
}

.editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0 16px;
  color: var(--dim);
  font-size: 11px;
  border-top: 1px solid var(--line-soft);
}

.stats {
  color: #7d8798;
}

.hint {
  color: #7d8798;
}

/* -------------------------------------------------------------------- toast */

.toast {
  position: fixed;
  bottom: 72px;
  left: calc(50% + var(--sidebar-w) / 2);
  z-index: 80;
  padding: 10px 16px;
  color: var(--text);
  font-size: 12.5px;
  background: #161b26;
  border: 1px solid #2a3242;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  border-color: rgba(242, 99, 109, 0.45);
}

/* -------------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 6, 10, 0.62);
  backdrop-filter: blur(4px);
}

.modal {
  width: min(92vw, 380px);
  padding: 22px;
  background: #10141c;
  border: 1px solid #232a38;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  animation: modal-in 0.16s ease both;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}

.modal p {
  margin: 9px 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
  word-break: break-word;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal .ghost-btn {
  margin-top: 0;
}

.danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 16px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #e0525d;
  border: 1px solid rgba(242, 99, 109, 0.7);
  border-radius: 9px;
  transition: background 0.15s ease;
}

.danger-btn:hover {
  background: #ec626d;
}

/* ----------------------------------------------------------------- scrollbars */

.note-list::-webkit-scrollbar,
.content-input::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.note-list::-webkit-scrollbar-thumb,
.content-input::-webkit-scrollbar-thumb {
  background: #1c2330;
  background-clip: content-box;
  border: 3px solid transparent;
  border-radius: 9px;
}

.note-list::-webkit-scrollbar-thumb:hover,
.content-input::-webkit-scrollbar-thumb:hover {
  background: #2a3343;
  background-clip: content-box;
}

.note-list::-webkit-scrollbar-track,
.content-input::-webkit-scrollbar-track {
  background: transparent;
}

/* ------------------------------------------------------------------ mobile fab */

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  z-index: 40;
  display: none;
  width: 48px;
  height: 48px;
  padding: 0;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #4a63f0, #705cff);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 10px 28px rgba(77, 107, 254, 0.42);
  place-items: center;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.fab:hover {
  box-shadow: 0 12px 32px rgba(77, 107, 254, 0.5);
  transform: translateY(-1px);
}

/* -------------------------------------------------------------------- mobile */

@media (max-width: 900px) {
  :root {
    --sidebar-w: 276px;
  }
}

@media (max-width: 760px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    width: min(84vw, 320px);
    height: 100dvh;
    box-shadow: none;
    transform: translateX(-102%);
    transition: transform 0.22s ease;
  }

  .sidebar.open {
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.55);
    transform: none;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: block;
    padding: 0;
    background: rgba(4, 6, 10, 0.55);
    border: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  .sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-only {
    display: grid;
    margin-top: 2px;
  }

  .fab {
    display: grid;
    margin-top: 0;
    right: 18px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 68px);
  }

  .toast {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 132px);
    left: 50%;
  }

  .content-input {
    padding-bottom: 96px;
  }

  .editor {
    padding: 0 18px;
  }

  .editor-head {
    gap: 10px;
    padding-top: 14px;
  }

  .head-main {
    order: 1;
  }

  .mobile-menu {
    order: 2;
    margin-top: 0;
  }

  .head-actions {
    order: 3;
  }

  .title-input {
    font-size: 21px;
  }

  .head-actions .action-btn {
    width: 32px;
    padding: 0;
    justify-content: center;
    font-size: 0;
    gap: 0;
  }

  .head-actions .action-btn svg {
    width: 16px;
    height: 16px;
  }

  .editor-foot .hint {
    display: none;
  }

  .empty-state {
    padding: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}

