/* ============ Liam Notepad — 随身备忘录 ============ */
:root {
  --bg: #0f1115;
  --bg-soft: #161a21;
  --panel: #1b2029;
  --panel-2: #212836;
  --border: #2a3242;
  --text: #e8ecf3;
  --text-dim: #9aa5b5;
  --text-faint: #67718196;
  --accent: #ff7a1a;
  --accent-soft: #ff7a1a22;
  --danger: #ef5b5b;
  --ok: #3fbf7f;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --sidebar-w: 320px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

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

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: #29324244; border-color: #3a465a; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #ff8b3d; border-color: #ff8b3d; }
.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: #ef5b5b22; border-color: var(--danger); }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: #ffffff12; color: var(--text); }

/* ---------- 登录页 ---------- */
.login-view {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 80% -10%, #ff7a1a1f, transparent 60%),
    radial-gradient(700px 500px at 10% 110%, #3fbf7f14, transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 30px 26px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card.shake { animation: shake 0.4s; }
@keyframes shake {
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
.login-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: linear-gradient(145deg, #ff9a4a, #ff6a00);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 8px 24px #ff7a1a44;
}
.login-title { margin: 0 0 4px; font-size: 22px; font-weight: 700; }
.login-sub { margin: 0 0 24px; color: var(--text-dim); font-size: 13px; }
.login-foot { margin: 22px 0 0; color: var(--text-faint); font-size: 12px; }

.field {
  display: block;
  text-align: left;
  margin-bottom: 6px;
}
.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
#login-code {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  letter-spacing: 1px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#login-code:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-error {
  min-height: 20px;
  margin: 8px 0 4px;
  color: var(--danger);
  font-size: 13px;
}
#login-form .btn-block { margin-top: 10px; }

/* ---------- 顶部栏 ---------- */
.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  height: 54px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
#menu-toggle { display: none; }
.topbar-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 15px;
}
.logo-dot {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(145deg, #ff9a4a, #ff6a00);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
}
.topbar-actions { margin-left: auto; display: flex; gap: 4px; }

/* ---------- 工作区 ---------- */
.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}
.sidebar {
  width: var(--sidebar-w);
  flex: none;
  border-right: 1px solid var(--border);
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-top {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
}
.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  padding: 9px 0;
  font-size: 14px;
  color: var(--text);
}
.search-box input::placeholder { color: var(--text-faint); }

.note-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.note-item {
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 4px;
  transition: background 0.12s;
  position: relative;
}
.note-item:hover { background: #ffffff0a; }
.note-item.active {
  background: var(--accent-soft);
  border-color: #ff7a1a55;
}
.note-item-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-item-preview {
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.note-item-time {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 3px;
}
.empty-list {
  padding: 30px 16px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
}

/* ---------- 编辑区 ---------- */
.editor-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.editor {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 26px clamp(18px, 6vw, 72px) 10px;
  gap: 6px;
}
.note-title {
  border: none;
  background: transparent;
  outline: none;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 700;
  width: 100%;
  padding: 0;
}
.note-title::placeholder { color: var(--text-faint); }
.note-meta {
  display: flex;
  gap: 8px;
  color: var(--text-faint);
  font-size: 12px;
  flex-wrap: wrap;
}
.note-meta .dot { opacity: 0.6; }
.note-body {
  flex: 1;
  min-height: 0;
  border: none;
  background: transparent;
  outline: none;
  resize: none;
  font-size: 15.5px;
  line-height: 1.85;
  color: var(--text);
  padding: 10px 0 20px;
  overflow-y: auto;
}
.note-body::placeholder { color: var(--text-faint); }

.editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  gap: 10px;
}
.empty-mark { font-size: 44px; opacity: 0.5; }

/* ---------- 状态栏 ---------- */
.statusbar {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
}
#save-state.saving { color: var(--accent); }
#save-state.saved { color: var(--ok); }

/* ---------- 对话框 ---------- */
.dialog {
  position: fixed;
  inset: 0;
  background: #00000090;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.dialog-card {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.dialog-card h3 { margin: 0 0 8px; font-size: 16px; }
.dialog-card p { margin: 0 0 18px; color: var(--text-dim); font-size: 13.5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 48px;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  z-index: 60;
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: #ffffff20;
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #ffffff35; background-clip: content-box; }

/* ---------- 移动端 ---------- */
.scrim {
  position: absolute;
  inset: 0;
  background: #00000060;
  z-index: 20;
}
@media (max-width: 760px) {
  #menu-toggle { display: inline-flex; }
  .sidebar {
    position: absolute;
    z-index: 25;
    inset: 0 auto 0 0;
    width: min(84vw, 320px);
    transform: translateX(-102%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .editor { padding: 18px 16px 8px; }
  .topbar-title span:last-child { display: none; }
}
