/* WebNote 樣式 */
:root {
  --accent: #00a82d;
  --accent-dark: #008f26;
  --side-bg: #1f2124;
  --side-fg: #cfd2d6;
  --side-hover: #2c2f33;
  --side-active: #3a3e44;
  --line: #e3e5e8;
  --muted: #8a9099;
  --bg: #ffffff;
  --list-bg: #f7f8f9;
  --danger: #d93025;
  --mark: #fff1a8;
  --radius: 6px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", "Segoe UI", sans-serif;
  font-size: 14px; color: #202124; background: var(--bg);
}
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }
[hidden] { display: none !important; }
mark { background: var(--mark); color: inherit; padding: 0 1px; border-radius: 2px; }
.muted { color: var(--muted); }

/* ---------- 共用按鈕／輸入 ---------- */
.btn {
  border: 1px solid #d0d4d9; background: #fff; color: #202124;
  padding: 7px 14px; border-radius: var(--radius); text-decoration: none; display: inline-block; line-height: 1.2;
}
.btn:hover { background: #f1f3f4; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--danger); border-color: #f0c2be; }
.btn.danger:hover { background: #fdecea; }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn.block { width: 100%; padding: 10px; font-size: 15px; }
.btn:disabled { opacity: .6; cursor: default; }
.input {
  width: 100%; padding: 9px 11px; border: 1px solid #d0d4d9; border-radius: var(--radius); outline: none; background: #fff;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(0,168,45,.15); }
.icon-btn {
  border: none; background: transparent; font-size: 17px; padding: 4px 8px; border-radius: var(--radius); color: #555; line-height: 1;
}
.icon-btn:hover { background: #eceef0; }
.mobile-only { display: none; }

/* ---------- 版面 ---------- */
#app { display: flex; height: 100vh; overflow: hidden; }
#sidebar { width: 240px; flex: none; background: var(--side-bg); color: var(--side-fg); display: flex; flex-direction: column; }
#list-pane { width: 330px; flex: none; background: var(--list-bg); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
#editor-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
#sidebar-mask { display: none; }

/* ---------- 側邊欄 ---------- */
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 8px 16px; }
.brand { font-weight: 700; font-size: 17px; color: #fff; letter-spacing: .5px; }
.user-btn { background: none; border: none; color: var(--side-fg); padding: 4px 6px; border-radius: 4px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-btn:hover { background: var(--side-hover); }
.btn-new {
  margin: 6px 12px 10px; padding: 9px; border: none; border-radius: 20px; background: var(--accent); color: #fff; font-weight: 600;
}
.btn-new:hover { background: var(--accent-dark); }
.side-scroll { flex: 1; overflow-y: auto; padding-bottom: 12px; }
.nav-section {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 12px 4px 16px; font-size: 12px; color: #8b9097; text-transform: uppercase; letter-spacing: 1px;
}
.sec-actions button { background: none; border: none; color: #8b9097; padding: 2px 5px; border-radius: 4px; font-size: 13px; }
.sec-actions button:hover { background: var(--side-hover); color: #fff; }
.nav-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 16px; cursor: pointer; user-select: none; position: relative;
}
.nav-item:hover { background: var(--side-hover); }
.nav-item.active { background: var(--side-active); color: #fff; }
.nav-item.indent { padding-left: 34px; }
.nav-item.stack { color: #e4e6e9; }
.nav-icon { width: 18px; text-align: center; flex: none; font-size: 13px; }
.nav-icon.caret { font-size: 11px; color: #8b9097; }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: 12px; color: #8b9097; }
.nav-more {
  display: none; background: none; border: none; color: #c0c4c9; padding: 0 5px; border-radius: 3px; font-size: 15px; line-height: 18px;
}
.nav-item:hover .nav-more { display: inline-block; }
.nav-item:hover .nav-count { display: none; }
.nav-more:hover { background: #4a4f56; color: #fff; }
.nav-empty { padding: 4px 16px 4px 42px; font-size: 12.5px; color: #6b7078; }
.nav-sep { height: 1px; background: #33363b; margin: 12px 12px 6px; }

/* ---------- 清單 ---------- */
.search-bar { display: flex; gap: 6px; padding: 12px 12px 6px; align-items: center; }
.search-box { flex: 1; position: relative; }
.search-box input {
  width: 100%; padding: 8px 30px 8px 32px; border: 1px solid #d6d9dd; border-radius: 18px; background: #fff; outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: .6; }
.search-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: none; background: none; font-size: 17px; color: #888; }
.list-head { display: flex; justify-content: space-between; align-items: flex-end; padding: 8px 14px 10px; border-bottom: 1px solid var(--line); gap: 8px; }
.list-title { font-size: 18px; font-weight: 700; word-break: break-all; }
.list-count { font-size: 12px; color: var(--muted); margin-top: 3px; }
.list-tools { display: flex; gap: 6px; align-items: center; flex: none; }
.list-tools select { border: 1px solid #d6d9dd; border-radius: 4px; padding: 3px 4px; background: #fff; font-size: 12.5px; }
#note-list { flex: 1; overflow-y: auto; }
.note-item { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; background: #fff; }
.note-item:hover { background: #f2f7f3; }
.note-item.active { background: #e6f4ea; box-shadow: inset 3px 0 0 var(--accent); }
.note-title { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-snippet {
  color: #5f6368; font-size: 13px; margin-top: 4px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all;
}
.note-meta { display: flex; gap: 10px; margin-top: 6px; font-size: 11.5px; color: var(--muted); overflow: hidden; white-space: nowrap; }
.meta-tags, .meta-nb { overflow: hidden; text-overflow: ellipsis; }
.list-empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- 編輯區 ---------- */
.editor-empty { margin: auto; text-align: center; color: var(--muted); }
.empty-icon { font-size: 46px; margin-bottom: 10px; opacity: .6; }
#editor-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.ed-head { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
#ed-notebook { border: 1px solid transparent; background: #f1f3f4; border-radius: 4px; padding: 4px 6px; max-width: 200px; }
#ed-notebook:hover { border-color: #d0d4d9; }
.ed-tags { display: flex; align-items: center; gap: 5px; flex: 1; flex-wrap: wrap; min-width: 140px; }
#ed-tag-input { border: none; outline: none; padding: 4px 2px; min-width: 70px; flex: 1; background: transparent; }
.chip { display: inline-flex; align-items: center; gap: 3px; background: #e8f0fe; color: #1a4f9c; padding: 2px 4px 2px 9px; border-radius: 12px; font-size: 12.5px; }
.chip-x { border: none; background: none; color: #5a7bb0; padding: 0 3px; font-size: 14px; line-height: 1; border-radius: 50%; }
.chip-x:hover { background: #c9daf8; }
.ed-status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.trash-banner { display: flex; align-items: center; gap: 10px; background: #fff4e5; color: #8a5300; padding: 8px 16px; border-bottom: 1px solid #f5dfba; }
.trash-banner span { flex: 1; }
.ed-title {
  border: none; outline: none; font-size: 26px; font-weight: 700; padding: 18px 28px 6px; width: 100%; color: #202124;
}
.ed-title::placeholder { color: #c4c7cc; }

/* Quill */
#editor-wrap .ql-toolbar.ql-snow { border: none; border-bottom: 1px solid var(--line); padding: 6px 22px; }
#editor-wrap .ql-toolbar.disabled { pointer-events: none; opacity: .4; }
#editor-wrap .ql-container.ql-snow { border: none; flex: 1; overflow-y: auto; font-family: inherit; font-size: 15px; }
#ed-quill .ql-editor { padding: 16px 28px 80px; line-height: 1.7; min-height: 100%; }
#ed-quill .ql-editor.ql-blank::before { left: 28px; color: #b0b4ba; font-style: normal; }
#ed-quill .ql-editor img { max-width: 100%; }
#ed-quill .ql-editor a { color: #1a73e8; }
#ed-quill .ql-editor table { border-collapse: collapse; margin: 8px 0; }
#ed-quill .ql-editor td { border: 1px solid #c8ccd1; padding: 5px 9px; min-width: 60px; }
#ed-quill .ql-editor li[data-list=checked] { color: #80868b; text-decoration: line-through; }
.ql-snow .ql-tooltip[data-mode=link]::before { content: "連結網址："; }
.ql-snow .ql-tooltip::before { content: "開啟連結："; }
.ql-snow .ql-tooltip.ql-editing a.ql-action::after { content: "儲存"; }
.ql-snow .ql-tooltip a.ql-action::after { content: "編輯"; }
.ql-snow .ql-tooltip a.ql-remove::before { content: "移除"; }
.ql-snow .ql-picker.ql-header .ql-picker-label::before,
.ql-snow .ql-picker.ql-header .ql-picker-item::before { content: "內文"; }
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="1"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="1"]::before { content: "標題 1"; }
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before { content: "標題 2"; }
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before { content: "標題 3"; }
.ql-snow.ql-toolbar button.ql-table-row, .ql-snow.ql-toolbar button.ql-table-col,
.ql-snow.ql-toolbar button.ql-table-delrow, .ql-snow.ql-toolbar button.ql-table-delcol,
.ql-snow.ql-toolbar button.ql-table-del { width: auto; padding: 3px 4px; }
.tbtxt { font-size: 12px; color: #444; white-space: nowrap; }
.ql-snow.ql-toolbar button:hover .tbtxt { color: #06c; }

/* ---------- 對話框／選單／提示 ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 10px; width: 400px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal.wide { width: 760px; }
.modal-title { font-size: 16px; font-weight: 700; padding: 16px 20px 4px; }
.modal-body { padding: 12px 20px; overflow-y: auto; }
.modal-body p { margin: 4px 0; line-height: 1.6; }
.modal-err { color: var(--danger); padding: 0 20px; font-size: 13px; min-height: 0; }
.modal-err:not(:empty) { padding-bottom: 6px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 20px 16px; }
.form { display: flex; flex-direction: column; gap: 10px; }
.check { display: flex; align-items: center; gap: 6px; }
.info div { padding: 3px 0; }
.popmenu { position: fixed; background: #fff; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.2); padding: 5px 0; z-index: 200; min-width: 160px; }
.popmenu-item { padding: 8px 16px; cursor: pointer; white-space: nowrap; color: #202124; }
.popmenu-item:hover { background: #f1f3f4; }
.popmenu-item.danger { color: var(--danger); }
#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #323232; color: #fff; padding: 10px 18px; border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.25); transition: opacity .4s; max-width: 90vw; }
.toast.error { background: #b3261e; }
.toast.hide { opacity: 0; }

/* 附件清單 */
.attach-list { display: flex; flex-direction: column; gap: 6px; }
.attach-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid #f0f1f2; }
.attach-row > a:first-child { flex: 1; color: #1a73e8; word-break: break-all; text-decoration: none; }

/* 帳號管理 */
.users-toolbar { margin-bottom: 10px; }
table.users { width: 100%; border-collapse: collapse; font-size: 13px; }
table.users th, table.users td { text-align: left; padding: 7px 6px; border-bottom: 1px solid #eceef0; white-space: nowrap; }
table.users th { color: var(--muted); font-weight: 600; }
table.users tr.inactive td { color: #aaa; }
table.users td.ops { display: flex; gap: 4px; }

/* ---------- 登入頁 ---------- */
.login-page { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1f2124, #2e3a31); min-height: 100vh; padding: 16px; }
.login-card { background: #fff; width: 360px; max-width: 100%; padding: 32px 28px; border-radius: 12px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 16px 50px rgba(0,0,0,.35); }
.login-brand { font-size: 26px; font-weight: 800; color: var(--accent); text-align: center; }
.login-sub { text-align: center; color: var(--muted); margin-bottom: 6px; }
.login-err { color: var(--danger); font-size: 13px; min-height: 18px; }
.login-foot { text-align: center; font-size: 12px; color: var(--muted); }

/* ---------- 窄螢幕 ---------- */
@media (max-width: 1100px) {
  #list-pane { width: 280px; }
  #sidebar { width: 210px; }
}
@media (max-width: 820px) {
  .mobile-only { display: inline-block; }
  #sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  body.show-sidebar #sidebar { transform: none; }
  body.show-sidebar #sidebar-mask { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  #list-pane { width: 100%; border-right: none; }
  #editor-pane { display: none; }
  body.m-editor #list-pane { display: none; }
  body.m-editor #editor-pane { display: flex; }
  .ed-head { padding: 8px 10px; gap: 6px; }
  .ed-title { padding: 14px 16px 4px; font-size: 21px; }
  #ed-quill .ql-editor { padding: 12px 16px 60px; }
  #ed-quill .ql-editor.ql-blank::before { left: 16px; }
  #editor-wrap .ql-toolbar.ql-snow { padding: 4px 8px; }
  .ed-status { display: none; }
}
