:root {
  --bg:        #f6f6f4;
  --panel:     #ffffff;
  --panel-2:   #efefec;
  --text:      #22221f;
  --text-dim:  #8a8a82;
  --line:      #e3e3de;
  --accent:    #3f7d58;
  --accent-sf: #e6f0e9;
  --danger:    #b4453a;
  --radius:    12px;
  --shadow:    0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #16181a;
    --panel:     #1e2124;
    --panel-2:   #262a2e;
    --text:      #e6e6e3;
    --text-dim:  #8b9095;
    --line:      #2f3438;
    --accent:    #6fae86;
    --accent-sf: #22302a;
    --danger:    #d97a6f;
    --shadow:    0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; }

code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: .9em;
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---------------------------------------------------------- 登录 */

.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 20px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: .02em;
}

.login-tip {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}

.login-card input {
  width: 100%;
  padding: 11px 13px;
  margin-bottom: 12px;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
}

.login-card input:focus { border-color: var(--accent); }

.login-card button {
  width: 100%;
  padding: 11px;
  font-size: 15px;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 9px;
}

.login-error {
  min-height: 20px;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--danger);
  text-align: center;
}

/* ---------------------------------------------------------- 布局 */

.app { display: flex; height: 100%; }

.sidebar {
  width: 240px;
  flex: 0 0 240px;
  display: flex;
  flex-direction: column;
  background: var(--panel-2);
  border-right: 1px solid var(--line);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 10px;
}

.brand {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
}

.taglist {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
}

.taglist-empty {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-dim);
}

.tag-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  font-size: 14px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--text);
}

.tag-row:hover { background: rgba(128,128,128,.12); }

.tag-row.active {
  background: var(--accent-sf);
  color: var(--accent);
  font-weight: 600;
}

.tag-row .tag-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-row .tag-count {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.tag-row.active .tag-count { color: inherit; opacity: .75; }

.tag-children { margin-left: 12px; border-left: 1px solid var(--line); padding-left: 2px; }

.sidebar-foot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--line);
}

.linkish {
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-dim);
  background: none;
  border: 0;
  text-align: left;
}

.linkish:hover { color: var(--accent); }

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 15;
  background: rgba(0,0,0,.35);
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.search {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.search:focus { border-color: var(--accent); }

.icon-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  font-size: 16px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--text-dim);
}

.icon-btn:hover { background: rgba(128,128,128,.14); color: var(--text); }

.scroller {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 16px 16px 80px;
}

/* ---------------------------------------------------------- 输入框 */

.composer {
  max-width: 720px;
  margin: 0 auto 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color .15s;
}

.composer:focus-within { border-color: var(--accent); }

.composer textarea {
  display: block;
  width: 100%;
  padding: 14px 16px 8px;
  font: inherit;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: none;
  resize: none;
  max-height: 45vh;
  overflow-y: auto;
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 12px 10px;
}

.hint {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary {
  flex: 0 0 auto;
  padding: 7px 22px;
  font-size: 14px;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
}

.primary:disabled { opacity: .45; cursor: default; }

/* ---------------------------------------------------------- 列表 */

.filter-bar {
  max-width: 720px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.list { max-width: 720px; margin: 0 auto; }

.date-head {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 18px 0 8px;
  padding: 4px 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text-dim);
  background: linear-gradient(var(--bg) 72%, transparent);
}

.list > .date-head:first-child { margin-top: 0; }

.memo {
  position: relative;
  margin-bottom: 10px;
  padding: 13px 15px 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.memo.pinned { border-left: 3px solid var(--accent); }

.memo-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.memo-body mark {
  padding: 0 2px;
  background: #ffe9a8;
  color: inherit;
  border-radius: 3px;
}

@media (prefers-color-scheme: dark) {
  .memo-body mark { background: #6b5a1e; }
}

.memo-body .tag {
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

.memo-body .tag:hover { text-decoration: underline; }

.memo-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.memo-foot .spacer { flex: 1; }

.memo-foot .act {
  padding: 2px 0;
  font-size: 12px;
  color: var(--text-dim);
  background: none;
  border: 0;
  opacity: 0;
  transition: opacity .12s;
}

.memo:hover .memo-foot .act,
.memo:focus-within .memo-foot .act { opacity: 1; }

@media (hover: none) {
  .memo-foot .act { opacity: 1; }
}

.memo-foot .act:hover { color: var(--accent); }
.memo-foot .act.danger:hover { color: var(--danger); }
.memo-foot .act.on { color: var(--accent); }

.memo-edit textarea {
  display: block;
  width: 100%;
  min-height: 88px;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  resize: vertical;
}

.memo-edit textarea:focus { border-color: var(--accent); }

.memo-edit-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.memo-edit-bar button { padding: 6px 16px; font-size: 13px; border-radius: 7px; }
.memo-edit-bar .save { color: #fff; background: var(--accent); border: 0; }
.memo-edit-bar .cancel { background: none; border: 1px solid var(--line); }

.empty {
  padding: 60px 20px;
  text-align: center;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 2;
}

.more-wrap { max-width: 720px; margin: 18px auto 0; text-align: center; }

/* ---------------------------------------------------------- 提示条 */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 40;
  transform: translateX(-50%);
  max-width: 88vw;
  padding: 9px 18px;
  font-size: 13px;
  color: #fff;
  background: rgba(30,32,34,.92);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.toast.bad { background: var(--danger); }

/* ---------------------------------------------------------- 窄屏 */

@media (max-width: 720px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 20;
    width: 76vw;
    max-width: 300px;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: var(--shadow);
  }

  .app.nav-open .sidebar { transform: translateX(0); }
  .app.nav-open .scrim { display: block; }

  .scroller { padding: 14px 12px 80px; }
  .topbar { padding: 8px 12px; }
}
