/* ============================================================
   记事本 · 样式
   ============================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', 'PingFang SC', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: linear-gradient(160deg, #1b2242 0%, #2a2f5e 40%, #3b3160 70%, #4a3a6b 100%);
  background-attachment: fixed;
  color: #e6e9ff;
  display: flex;
  justify-content: center;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* 星空层 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 20% 30%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 60% 15%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 80% 40%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 15% 70%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 45% 85%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 90% 80%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 35% 50%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 70% 65%, #fff 50%, transparent 51%);
  opacity: 0.7;
  animation: twinkle 6s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  top: 4%;
  right: 6%;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff8e0, #f6e6b8 55%, #e6cd7a 100%);
  box-shadow:
    0 0 30px rgba(255, 240, 200, 0.55),
    0 0 70px rgba(255, 220, 160, 0.3),
    inset -8px -8px 16px rgba(180, 150, 90, 0.25);
  pointer-events: none;
  z-index: 0;
}

@keyframes twinkle {
  0%   { opacity: 0.5; }
  100% { opacity: 0.9; }
}

/* ========== 主容器 ========== */
.note-app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1100px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0.9rem 1rem 0;
  padding-top: calc(4.5rem + env(safe-area-inset-top));
  overflow: hidden;
}

/* ========== 顶部 ========== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 0.85rem 1.1rem;
  margin-bottom: 0.7rem;
  flex-shrink: 0;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #e6e9ff;
  letter-spacing: 0.5px;
}

.title-icon {
  font-size: 1.3rem;
  filter: drop-shadow(0 0 8px rgba(255, 200, 180, 0.4));
}

.new-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.5rem 1rem;
  border-radius: 40px;
  border: none;
  background: linear-gradient(135deg, #a0b4ff, #c7a0ff);
  color: #1b2242;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 6px 16px rgba(140, 160, 240, 0.4);
}

.new-btn:active {
  transform: scale(0.96);
}

.new-btn span {
  font-size: 1.1rem;
  font-weight: 700;
}

/* ========== 搜索框 ========== */
.search-box {
  position: relative;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 40px;
  margin-bottom: 0.7rem;
  flex-shrink: 0;
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  opacity: 0.6;
}

#searchInput {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.7rem;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  color: #f0f3ff;
  outline: none;
  border-radius: 40px;
}

#searchInput::placeholder {
  color: rgba(230, 235, 255, 0.45);
}

/* ========== 主体 ========== */
.note-body {
  flex: 1;
  display: flex;
  gap: 0.7rem;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

/* 左侧列表 */
.note-list {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 10px;
}

.note-list::-webkit-scrollbar { width: 4px; }
.note-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 10px;
}
.note-list::-webkit-scrollbar-track { background: transparent; }

.note-item {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.note-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.note-item.active {
  background: linear-gradient(120deg, rgba(160, 180, 255, 0.22), rgba(200, 160, 255, 0.22));
  border-color: rgba(180, 200, 255, 0.4);
  box-shadow: 0 6px 20px rgba(120, 140, 220, 0.2);
}

.note-item .note-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 0.3rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-item .note-preview {
  font-size: 0.8rem;
  color: rgba(230, 235, 255, 0.55);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 0.35rem;
}

.note-item .note-time {
  font-size: 0.72rem;
  color: rgba(230, 235, 255, 0.4);
}

/* 空列表提示 */
.list-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: rgba(230, 235, 255, 0.45);
  font-size: 0.85rem;
  line-height: 1.6;
}

/* ========== 右侧编辑区 ========== */
.note-editor {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* 空状态 */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(230, 235, 255, 0.5);
  padding: 2rem;
  text-align: center;
}

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: 0.7;
  filter: drop-shadow(0 0 20px rgba(255, 200, 180, 0.3));
}

.empty-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: rgba(230, 235, 255, 0.75);
  margin-bottom: 0.5rem;
}

.empty-sub {
  font-size: 0.85rem;
  line-height: 1.6;
  max-width: 280px;
}

/* 编辑面板 */
.editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.2rem;
  min-height: 0;
}

.editor-title {
  border: none;
  background: transparent;
  font-size: 1.3rem;
  font-weight: 700;
  color: #ffffff;
  outline: none;
  padding: 0.3rem 0;
  margin-bottom: 0.4rem;
  width: 100%;
  font-family: inherit;
}

.editor-title::placeholder {
  color: rgba(230, 235, 255, 0.35);
}

.editor-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: rgba(230, 235, 255, 0.5);
  padding-bottom: 0.6rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
  margin-bottom: 0.6rem;
}

.editor-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 4px 8px;
  font-size: 0.9rem;
  cursor: pointer;
  color: #e6e9ff;
  transition: all 0.2s;
  line-height: 1;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn.danger:hover {
  background: rgba(255, 120, 120, 0.2);
  border-color: rgba(255, 150, 150, 0.4);
}

.editor-content {
  flex: 1;
  border: none;
  background: transparent;
  color: #e6e9ff;
  font-size: 0.98rem;
  line-height: 1.75;
  outline: none;
  resize: none;
  padding: 0.3rem 0;
  font-family: inherit;
  min-height: 0;
  width: 100%;
}

.editor-content::placeholder {
  color: rgba(230, 235, 255, 0.3);
}

/* ========== 底部状态栏 ========== */
.app-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.4rem;
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
  font-size: 0.78rem;
  color: rgba(230, 235, 255, 0.5);
  letter-spacing: 0.3px;
}

#saveStatus {
  color: rgba(180, 230, 180, 0.7);
  transition: color 0.3s;
}

#saveStatus.saving {
  color: rgba(255, 220, 150, 0.85);
}

/* ========== 响应式 ========== */
@media (max-width: 720px) {
  .note-app {
    padding: 0.6rem 0.6rem 0;
    padding-top: calc(4rem + env(safe-area-inset-top));
  }

  .app-header {
    padding: 0.7rem 0.9rem;
    border-radius: 16px;
    margin-bottom: 0.55rem;
  }

  .header-title { font-size: 1rem; }
  .title-icon { font-size: 1.15rem; }
  .new-btn { padding: 0.42rem 0.85rem; font-size: 0.85rem; }

  #searchInput {
    padding: 0.65rem 1rem 0.65rem 2.5rem;
    font-size: 0.9rem;
  }

  .note-body {
    flex-direction: column;
    gap: 0.55rem;
  }

  .note-list {
    width: 100%;
    max-height: 30vh;
    max-height: 30dvh;
    flex-shrink: 0;
    border-radius: 16px;
    padding: 8px;
  }

  .note-item {
    padding: 0.6rem 0.8rem;
    border-radius: 12px;
  }

  .note-item .note-title { font-size: 0.88rem; }
  .note-item .note-preview { font-size: 0.75rem; }
  .note-item .note-time { font-size: 0.68rem; }

  .note-editor {
    border-radius: 16px;
    flex: 1;
  }

  .editor-panel {
    padding: 0.8rem 0.9rem;
  }

  .editor-title {
    font-size: 1.1rem;
  }

  .editor-content {
    font-size: 0.92rem;
  }
}

@media (max-width: 375px) {
  .header-title { font-size: 0.92rem; }
  .new-btn { padding: 0.38rem 0.7rem; font-size: 0.8rem; }
  .note-list { max-height: 26vh; max-height: 26dvh; }
  .editor-title { font-size: 1rem; }
}

@media (max-width: 320px) {
  .header-title { font-size: 0.85rem; }
  .new-btn span:not(:first-child) { display: none; }
}

/* ========== 通用返回按钮 ========== */
.back-fab {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top));
  left: 1rem;
  z-index: 999;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e6e9ff;
  font-size: 1.3rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.22s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
}

.back-fab:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateX(-2px);
}

.back-fab:active { transform: scale(0.92); }

@media (max-width: 480px) {
  .back-fab {
    top: calc(0.7rem + env(safe-area-inset-top));
    left: 0.7rem;
    width: 40px;
    height: 40px;
    font-size: 1.15rem;
  }
}