/* =========================================================
   LynxNote - アプリスタイル（Notion風ミニマル / ライト・ダーク対応）
   ========================================================= */

:root {
  --bg: #ffffff;
  --bg-sidebar: #f7f7f5;
  --bg-hover: rgba(0, 0, 0, 0.045);
  --bg-active: rgba(0, 0, 0, 0.07);
  --bg-input: #f6f6f4;
  --bg-card: #ffffff;
  --bg-modal: #ffffff;
  --bg-menu: #ffffff;
  --text: #37352f;
  --text-mid: #6f6e69;
  --text-dim: #9b9a97;
  --line: #e9e9e7;
  --line-strong: #d3d3d0;
  --accent: #2383e2;
  --accent-soft: rgba(35, 131, 226, 0.12);
  --danger: #e03e3e;
  --danger-soft: #fdebec;
  --warn-bg: #fbf3db;
  --shadow-menu: 0 4px 20px rgba(15, 15, 15, 0.12), 0 0 0 1px rgba(15, 15, 15, 0.04);
  --shadow-modal: 0 12px 44px rgba(15, 15, 15, 0.2);
  --radius: 8px;
}

:root[data-theme="dark"] {
  --bg: #191919;
  --bg-sidebar: #202020;
  --bg-hover: rgba(255, 255, 255, 0.055);
  --bg-active: rgba(255, 255, 255, 0.09);
  --bg-input: #2a2a2a;
  --bg-card: #232323;
  --bg-modal: #252525;
  --bg-menu: #2b2b2b;
  --text: #e6e6e4;
  --text-mid: #a5a29c;
  --text-dim: #7d7b76;
  --line: #333333;
  --line-strong: #454545;
  --accent: #529cca;
  --accent-soft: rgba(82, 156, 202, 0.18);
  --danger: #eb5757;
  --danger-soft: rgba(235, 87, 87, 0.15);
  --warn-bg: rgba(203, 145, 47, 0.18);
  --shadow-menu: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-modal: 0 12px 44px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Segoe UI", Meiryo, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body.resizing { user-select: none; cursor: col-resize; }

a { color: inherit; }
button { font-family: inherit; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }

/* ---------- 汎用 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.12s;
  text-decoration: none;
}
.btn:hover { opacity: 0.88; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.ghost {
  background: transparent;
  color: var(--text-mid);
  border: 1px solid var(--line-strong);
}
.btn.ghost:hover { background: var(--bg-hover); opacity: 1; }
.btn.danger { background: var(--danger); }
.danger-text { color: var(--danger) !important; }

.icon-btn {
  background: transparent;
  border: none;
  border-radius: 5px;
  padding: 4px 6px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.text-input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg-input);
  color: var(--text);
  margin-bottom: 4px;
}
.text-input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); background: var(--bg); }

kbd {
  font-family: inherit;
  font-size: 10.5px;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

/* =========================================================
   ログイン
   ========================================================= */

.login-body {
  background: var(--bg-sidebar);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-wrap { width: 100%; max-width: 380px; }
.login-logo {
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 22px;
}
.login-logo span { color: var(--accent); }
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.login-card h1 { font-size: 18px; margin-bottom: 2px; }
.login-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }
.login-card label { display: block; font-size: 12.5px; font-weight: 600; margin: 13px 0 5px; color: var(--text-mid); }
.login-card input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font-size: 14px;
  background: var(--bg-input);
}
.login-card input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); background: var(--bg); }
.login-btn {
  width: 100%;
  margin-top: 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.login-btn:hover { opacity: 0.9; }
.login-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 4px;
}

/* =========================================================
   レイアウト
   ========================================================= */

#app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  position: relative;
  width: 250px;
  min-width: 190px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: margin-left 0.18s ease;
}
.sidebar.collapsed { margin-left: -251px; }
.sidebar-resizer {
  position: absolute;
  top: 0; right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 5;
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  min-height: 45px;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topbar-btn {
  background: transparent;
  border: none;
  border-radius: 5px;
  padding: 5px 10px;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--text);
}
.topbar-btn:hover { background: var(--bg-hover); }
.save-status { font-size: 12px; color: var(--text-dim); }
.save-status.error { color: var(--danger); }

.content { flex: 1; overflow-y: auto; overflow-x: hidden; }

/* ---------- パンくず ---------- */

.breadcrumbs { display: flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; }
.crumb {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13.5px;
  text-decoration: none;
  padding: 3px 6px;
  border-radius: 5px;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
a.crumb:hover { background: var(--bg-hover); }
.crumb-icon { display: inline-flex; font-size: 14px; }
.crumb-sep { color: var(--text-dim); font-size: 13px; }

/* =========================================================
   サイドバー
   ========================================================= */

.sidebar-head {
  display: flex;
  align-items: center;
  padding: 10px 10px 4px;
  gap: 4px;
}
.ws-button {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  min-width: 0;
}
.ws-button:hover { background: var(--bg-hover); }
.ws-avatar {
  width: 22px; height: 22px;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ws-name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ws-caret { color: var(--text-dim); flex-shrink: 0; }

.sidebar-actions { padding: 4px 8px 8px; }
.sidebar-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 13.5px;
  color: var(--text-mid);
  cursor: pointer;
  text-align: left;
}
.sidebar-item:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-item svg { flex-shrink: 0; }
.sidebar-item kbd { margin-left: auto; }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 0 8px; }
.sidebar-foot { padding: 8px; border-top: 1px solid var(--line); }

.tree-section { margin-bottom: 14px; }
.tree-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 6px 9px 3px;
  letter-spacing: 0.02em;
}
.tree-add { opacity: 0; font-size: 14px; }
.tree-section-label:hover .tree-add { opacity: 1; }

.tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-mid);
  position: relative;
  min-width: 0;
}
.tree-row:hover { background: var(--bg-hover); color: var(--text); }
.tree-row.active { background: var(--bg-active); color: var(--text); font-weight: 600; }
.tree-row.dragging { opacity: 0.4; }
.tree-row.drop-above::before,
.tree-row.drop-below::after {
  content: "";
  position: absolute;
  left: 6px; right: 6px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}
.tree-row.drop-above::before { top: -1px; }
.tree-row.drop-below::after { bottom: -1px; }
.tree-row.drop-inside { outline: 2px solid var(--accent); outline-offset: -2px; }

.tree-caret {
  width: 18px; height: 18px;
  border: none;
  background: transparent;
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.12s;
}
.tree-caret:hover { background: var(--bg-active); }
.tree-caret.open { transform: rotate(90deg); }

.tree-icon { display: inline-flex; font-size: 14.5px; flex-shrink: 0; width: 18px; justify-content: center; }
.tree-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.tree-lock { display: inline-flex; opacity: 0.6; flex-shrink: 0; }
.tree-lock svg { width: 11px; height: 11px; }
.tree-actions { display: none; align-items: center; gap: 1px; flex-shrink: 0; }
.tree-row:hover .tree-actions { display: inline-flex; }
.tree-action-btn {
  border: none;
  background: transparent;
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  line-height: 1.2;
}
.tree-action-btn:hover { background: var(--bg-active); color: var(--text); }
.tree-empty { font-size: 12px; color: var(--text-dim); padding: 3px 9px; }

/* =========================================================
   ページ本体
   ========================================================= */

.page-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 32px 30vh;
}
.page-inner.wide { max-width: 1150px; }

.page-cover-wrap.has-cover { height: 200px; }
.page-cover {
  height: 200px;
  position: relative;
  background: #ddd;
}
.cover-controls {
  position: absolute;
  right: 16px;
  bottom: 12px;
  display: none;
  gap: 6px;
}
.page-cover:hover .cover-controls { display: flex; }
.cover-btn {
  background: rgba(255, 255, 255, 0.9);
  color: #37352f;
  border: none;
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.cover-btn:hover { background: #fff; }
.cover-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 6px; }
.cover-swatch { width: 52px; height: 34px; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; }
.cover-swatch:hover { outline: 2px solid var(--accent); }
.cover-menu-body { padding: 4px 6px 8px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

.page-head { padding-top: 40px; position: relative; }
.page-head.has-cover { padding-top: 6px; }
.page-head.has-cover .page-icon { margin-top: -44px; }

.page-icon {
  font-size: 64px;
  line-height: 1.1;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 8px;
  padding: 2px 6px;
  margin-left: -6px;
}
.page-icon:hover { background: var(--bg-hover); }
.page-icon.static { cursor: default; }
.page-icon.static:hover { background: transparent; }

.page-hover-actions { display: flex; gap: 4px; height: 28px; margin-top: 4px; opacity: 0; transition: opacity 0.12s; }
.page-head:hover .page-hover-actions { opacity: 1; }
.ghost-action {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.ghost-action svg { width: 13px; height: 13px; }
.ghost-action:hover { background: var(--bg-hover); }

.page-title-input {
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  font-size: 38px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text);
  overflow: hidden;
  padding: 4px 0 8px;
}
.page-title-input:focus { outline: none; }
.page-title-input::placeholder { color: var(--text-dim); opacity: 0.6; }

.share-title {
  font-size: 38px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  padding: 4px 0 8px;
}

.view-title { font-size: 30px; font-weight: 700; padding: 40px 0 18px; }

.page-error { text-align: center; padding: 100px 20px; color: var(--text-mid); }
.page-error-icon { margin-bottom: 12px; color: var(--text-dim); }
.page-error-icon svg { width: 40px; height: 40px; }

.trash-banner, .conflict-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--danger);
  color: #fff;
  font-size: 13.5px;
  padding: 9px 16px;
}
.conflict-banner { background: #b78500; }
.trash-banner .btn, .conflict-banner .btn { background: rgba(255, 255, 255, 0.2); }

/* ---------- Editor.js 調整 ---------- */

.editor-holder { min-height: 120px; }
.codex-editor__redactor { padding-bottom: 120px !important; }
.readonly .codex-editor__redactor { padding-bottom: 20px !important; }

.ce-block__content, .ce-toolbar__content { max-width: 100%; }
.ce-paragraph { line-height: 1.7; }
.ce-header { padding: 0.4em 0 0.2em; font-weight: 700; letter-spacing: -0.01em; }
h1.ce-header { font-size: 1.75em; }
h2.ce-header { font-size: 1.4em; }
h3.ce-header { font-size: 1.15em; }

.ce-code__textarea, .ce-code {
  background: var(--bg-input) !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
  border-radius: 6px;
  font-family: "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px !important;
}
.cdx-quote { border-left: 3px solid var(--text); padding-left: 14px; margin: 4px 0; }
.cdx-quote__text { border: none !important; box-shadow: none !important; min-height: auto !important; margin-bottom: 4px !important; padding: 0 !important; background: transparent !important; font-size: 1.02em; }
.cdx-quote__caption { border: none !important; box-shadow: none !important; padding: 0 !important; background: transparent !important; color: var(--text-dim); font-size: 0.85em; }

.cdx-warning { background: var(--warn-bg); border-radius: 8px; padding: 12px 14px 12px 44px !important; }
.cdx-warning::before { left: 14px !important; top: 14px !important; }
.cdx-warning__title { margin-bottom: 2px !important; border: none !important; }
.cdx-warning__message { border: none !important; min-height: auto !important; }

.cdx-checklist__item-checkbox-check { border-radius: 4px !important; }
.image-tool__caption { border: none !important; box-shadow: none !important; background: transparent !important; color: var(--text-dim); font-size: 0.85em; padding: 4px 0 !important; }
.image-tool__image-picture { border-radius: 6px; }
.tc-table { font-size: 14px; }
.tc-cell { border-color: var(--line) !important; }
.tc-row { border-color: var(--line) !important; }
.tc-wrap { --color-border: var(--line); }

.cdx-marker { background: rgba(245, 235, 111, 0.6); padding: 0 1px; }
.inline-code {
  background: var(--bg-input) !important;
  color: #eb5757 !important;
  font-size: 0.85em !important;
  border-radius: 4px;
  padding: 1px 4px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

/* Editor.js UI（ツールボックス・ポップオーバー）のダーク対応 */
:root[data-theme="dark"] .ce-popover__container,
:root[data-theme="dark"] .ce-popover--opened {
  background: var(--bg-menu);
  border-color: var(--line);
  color: var(--text);
}
:root[data-theme="dark"] .ce-popover-item { color: var(--text); }
:root[data-theme="dark"] .ce-popover-item:hover { background: var(--bg-hover); }
:root[data-theme="dark"] .ce-popover-item__icon,
:root[data-theme="dark"] .ce-toolbar__plus,
:root[data-theme="dark"] .ce-toolbar__settings-btn { color: var(--text-mid); background: transparent; }
:root[data-theme="dark"] .ce-toolbar__plus:hover,
:root[data-theme="dark"] .ce-toolbar__settings-btn:hover { background: var(--bg-hover); color: var(--text); }
:root[data-theme="dark"] .ce-inline-toolbar,
:root[data-theme="dark"] .ce-conversion-toolbar {
  background: var(--bg-menu);
  border-color: var(--line);
  color: var(--text);
}
:root[data-theme="dark"] .ce-inline-tool:hover,
:root[data-theme="dark"] .ce-conversion-tool:hover { background: var(--bg-hover); }
:root[data-theme="dark"] .cdx-search-field { background: var(--bg-input); border-color: var(--line); }
:root[data-theme="dark"] ::selection { background: rgba(82, 156, 202, 0.35); }
:root[data-theme="dark"] .ce-block--selected .ce-block__content { background: var(--accent-soft); }

/* ---------- ページリンクブロック ---------- */

.page-link-block { padding: 2px 0; }
.page-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  border-bottom: none;
}
.page-link-chip:hover { background: var(--bg-hover); }
.page-link-chip.disabled { cursor: default; }
.page-link-title { border-bottom: 1px solid var(--line-strong); }
.page-link-search {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-size: 13.5px;
  background: var(--bg-input);
}
.page-link-results { margin-top: 4px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.page-link-result {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-card);
  border: none;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
}
.page-link-result:hover { background: var(--bg-hover); }
.page-link-empty { padding: 8px 10px; font-size: 12.5px; color: var(--text-dim); }

/* ---------- 添付ファイルブロック ---------- */

.attach-block { padding: 3px 0; }
.attach-pick-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-mid);
  font-size: 13.5px;
  cursor: pointer;
}
.attach-pick-btn:hover { background: var(--bg-hover); color: var(--text); }
.attach-uploading {
  padding: 10px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13px;
}
.attach-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-card);
}
.attach-card.link { display: block; text-decoration: none; }
.attach-card.link:hover { background: var(--bg-hover); }
.attach-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  min-width: 0;
}
.attach-icon { display: inline-flex; color: var(--text-dim); flex-shrink: 0; }
.attach-name {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.attach-meta { font-size: 11.5px; color: var(--text-dim); flex-shrink: 0; }
.attach-open {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  padding: 2px 8px;
  border-radius: 5px;
}
.attach-open:hover { background: var(--accent-soft); }
.attach-pdf {
  display: block;
  width: 100%;
  height: 560px;
  border: none;
  border-top: 1px solid var(--line);
  background: #fff;
}
.attach-media { display: block; width: 100%; border-top: 1px solid var(--line); }
.attach-media.audio { padding: 8px 12px; box-sizing: border-box; }

/* ---------- サブページ ---------- */

.subpages { margin-top: 6px; }
.subpage-list { display: flex; flex-direction: column; }
.subpage-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
}
.subpage-link:hover { background: var(--bg-hover); }
.subpage-icon { display: inline-flex; width: 20px; justify-content: center; }
.subpage-title { border-bottom: 1px solid var(--line-strong); }
.subpage-add {
  margin-top: 4px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
  align-self: flex-start;
}
.subpage-add:hover { background: var(--bg-hover); color: var(--text); }

/* ---------- プロパティパネル（行ページ） ---------- */

.props-panel { margin: 4px 0 10px; }
.props-line {
  display: flex;
  align-items: flex-start;
  min-height: 34px;
  border-radius: 5px;
}
.props-name {
  width: 160px;
  flex-shrink: 0;
  color: var(--text-dim);
  font-size: 13.5px;
  padding: 7px 8px;
}
.props-value {
  flex: 1;
  padding: 5px 8px;
  border-radius: 5px;
  cursor: pointer;
  min-height: 32px;
  font-size: 14px;
}
.props-panel.readonly .props-value { cursor: default; }
.props-panel:not(.readonly) .props-value:hover { background: var(--bg-hover); }
.props-divider { border-bottom: 1px solid var(--line); margin-top: 10px; }

/* =========================================================
   データベース
   ========================================================= */

.db-holder { margin-top: 6px; }

.db-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
  gap: 8px;
  flex-wrap: wrap;
}
.db-tabs { display: flex; align-items: center; gap: 2px; overflow-x: auto; }
.db-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  padding: 7px 10px;
  font-size: 13.5px;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.db-tab:hover { color: var(--text); }
.db-tab.on { color: var(--text); font-weight: 600; border-bottom-color: var(--text); }
.db-tab.add { font-size: 15px; }
.db-tab-icon { display: inline-flex; align-items: center; opacity: 0.8; }
.db-tab-icon svg { width: 12px; height: 12px; }

.db-actions { display: flex; align-items: center; gap: 3px; padding-bottom: 4px; }
.db-action {
  border: none;
  background: transparent;
  border-radius: 5px;
  padding: 5px 9px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}
.db-action:hover { background: var(--bg-hover); color: var(--text); }
.db-action.active { color: var(--accent); font-weight: 600; }
.db-new { margin-left: 4px; }

/* ---------- テーブルビュー ---------- */

.db-table-scroll { overflow-x: auto; padding-bottom: 8px; }
.db-table { min-width: 100%; width: max-content; font-size: 14px; }

.db-tr { display: flex; border-bottom: 1px solid var(--line); min-width: 100%; }
.db-head { color: var(--text-dim); font-size: 12.5px; }

.db-th {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 170px;
  flex-shrink: 0;
  padding: 7px 9px;
  border-right: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  background: transparent;
  border-top: none; border-bottom: none; border-left: none;
  font-size: 12.5px;
  color: var(--text-dim);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
}
.db-th:hover { background: var(--bg-hover); }
.db-th.title-col { width: 270px; cursor: default; }
.db-th.title-col:hover { background: transparent; }
.db-th.add-col { width: 36px; justify-content: center; font-size: 14px; }
.db-th-type { opacity: 0.65; font-size: 11px; display: inline-flex; align-items: center; }
.db-th-type svg { width: 12px; height: 12px; }
.prop-type-icon svg { width: 13px; height: 13px; vertical-align: -2px; }

.db-td {
  width: 170px;
  flex-shrink: 0;
  padding: 6px 9px;
  border-right: 1px solid var(--line);
  min-height: 36px;
  cursor: pointer;
  overflow: hidden;
}
.db-td:hover { background: var(--bg-hover); }
.db-td.title-col { width: 270px; display: flex; align-items: center; position: relative; }
.db-td.spacer { width: 36px; cursor: default; border-right: none; }
.db-td.spacer:hover { background: transparent; }
.db-td.type-number { text-align: right; }

.db-title-cell {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
}
.db-row-icon { flex-shrink: 0; display: inline-flex; }
.db-row-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.db-open-btn {
  display: none;
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 1px solid var(--line-strong);
  background: var(--bg-card);
  border-radius: 5px;
  font-size: 11.5px;
  padding: 2px 8px;
  cursor: pointer;
  color: var(--text-mid);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.db-td.title-col:hover .db-open-btn { display: block; }

.cell-value { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 22px; }
.cell-value.type-number { justify-content: flex-end; width: 100%; }
.cell-check {
  width: 16px; height: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #fff;
}
.cell-check.on { background: var(--accent); border-color: var(--accent); }
.cell-person { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; }
.cell-url { color: var(--accent); font-size: 13px; text-decoration: none; border-bottom: 1px solid var(--accent-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.tag-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* リレーション・ロールアップ */
.rel-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  text-decoration: none;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--bg-hover);
  max-width: 100%;
  overflow: hidden;
}
a.rel-chip:hover { background: var(--bg-active); }
.rel-chip-title {
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rel-pick-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rollup-val { font-size: 13.5px; }
.rollup-val + .rollup-val::before { content: ", "; color: var(--text-dim); }
.db-td.type-rollup { cursor: default; }
.db-td.type-rollup:hover { background: transparent; }

.db-new-row {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 8px 9px;
  font-size: 13.5px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.db-new-row:hover { background: var(--bg-hover); color: var(--text); }
.db-empty { padding: 30px 10px; color: var(--text-dim); font-size: 13.5px; text-align: center; }
.db-empty p { margin-bottom: 10px; }

/* ---------- ボードビュー ---------- */

.db-board-wrap { overflow-x: auto; padding: 12px 0; }
.db-board { display: flex; gap: 12px; align-items: flex-start; min-width: max-content; }
.db-board-col {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-radius: 8px;
  padding: 8px;
}
.db-board-col.drop { outline: 2px solid var(--accent); }
.db-board-col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 8px;
  font-size: 13px;
}
.db-board-none { color: var(--text-dim); font-size: 12.5px; }
.db-board-count { color: var(--text-dim); font-size: 12px; }
.db-board-col-body { display: flex; flex-direction: column; gap: 7px; min-height: 30px; }
.db-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.db-card:hover { background: var(--bg-hover); }
.db-card-title { display: flex; gap: 6px; align-items: center; font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.db-card-prop { margin-top: 4px; font-size: 12.5px; color: var(--text-mid); }
.db-card-add {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.db-card-add:hover { background: var(--bg-hover); color: var(--text); }

/* ---------- セルエディタ・オプションピッカー ---------- */

.cell-editor-menu { padding: 6px !important; }
.cell-editor { display: flex; gap: 6px; align-items: center; min-width: 220px; }
.cell-editor-input {
  flex: 1;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-size: 13.5px;
  background: var(--bg-input);
  color: var(--text);
}
.cell-editor-input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.option-picker { min-width: 240px; }
.option-list { max-height: 260px; overflow-y: auto; margin-top: 6px; }
.option-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13.5px;
}
.option-row:hover { background: var(--bg-hover); }
.option-row .tag-chip { flex-shrink: 1; }
.option-check { margin-left: auto; color: var(--accent); font-weight: 700; }
.option-menu-btn { margin-left: auto; opacity: 0; }
.option-row:hover .option-menu-btn { opacity: 1; }
.option-row.create, .option-row.clear { color: var(--text-mid); font-size: 13px; }

/* ---------- フィルタ・ソートパネル ---------- */

.filter-menu { padding: 10px !important; }
.filter-panel { display: flex; flex-direction: column; gap: 8px; min-width: 320px; }
.filter-line { display: flex; align-items: center; gap: 6px; }
.mini-select, .mini-input {
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  font-size: 12.5px;
  background: var(--bg-input);
  color: var(--text);
  max-width: 140px;
}
.menu-input-wrap { padding: 4px 6px; }
.prop-type-icon { font-size: 12px; opacity: 0.8; width: 18px; display: inline-block; text-align: center; }

/* =========================================================
   メニュー・モーダル・トースト
   ========================================================= */

.ln-menu {
  position: fixed;
  z-index: 1000;
  background: var(--bg-menu);
  border-radius: 8px;
  box-shadow: var(--shadow-menu);
  padding: 5px;
  min-width: 200px;
  max-width: 360px;
  max-height: 70vh;
  overflow-y: auto;
}
.ln-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 6px 9px;
  border-radius: 5px;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
}
.ln-menu-item:hover { background: var(--bg-hover); }
.ln-menu-item.danger { color: var(--danger); }
.ln-menu-icon { width: 18px; display: inline-flex; justify-content: center; font-size: 13px; flex-shrink: 0; }
.ln-menu-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ln-menu-check { color: var(--accent); font-weight: 700; }
.ln-menu-hint { font-size: 11px; color: var(--text-dim); }
.ln-menu-divider { border-top: 1px solid var(--line); margin: 5px 4px; }
.ln-menu-heading { font-size: 11.5px; color: var(--text-dim); padding: 5px 9px 3px; }

.ln-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 15, 0.55);
  z-index: 900;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 9vh 20px 20px;
}
.ln-modal {
  background: var(--bg-modal);
  border-radius: 12px;
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 480px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ln-modal.wide { max-width: 860px; }
.ln-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
}
.ln-modal-title { font-size: 15.5px; font-weight: 700; }
.ln-modal-body { padding: 6px 18px 18px; overflow-y: auto; }
.ln-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.ln-confirm-msg { font-size: 14px; line-height: 1.7; }

.update-banner {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-menu);
  border-radius: 10px;
  box-shadow: var(--shadow-menu);
  padding: 12px 16px;
  font-size: 13px;
  max-width: 380px;
}

.ln-toasts {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.ln-toast {
  background: #2f2f2c;
  color: #fff;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  max-width: 90vw;
}
.ln-toast.show { opacity: 1; transform: translateY(0); }
.ln-toast.error { background: var(--danger); }

/* ---------- 絵文字ピッカー ---------- */

.emoji-menu { padding: 8px !important; }
.emoji-picker { width: 312px; }
.emoji-head { display: flex; justify-content: flex-end; margin-bottom: 4px; }
.emoji-tabs { display: flex; gap: 2px; overflow-x: auto; padding-bottom: 6px; }
.emoji-tab {
  border: none;
  background: transparent;
  font-size: 11.5px;
  color: var(--text-dim);
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.emoji-tab:hover { background: var(--bg-hover); }
.emoji-tab.on { background: var(--bg-active); color: var(--text); font-weight: 600; }
.emoji-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 1px; }
.emoji-cell {
  border: none;
  background: transparent;
  font-size: 18px;
  padding: 4px;
  border-radius: 5px;
  cursor: pointer;
  line-height: 1.2;
}
.emoji-cell:hover { background: var(--bg-hover); }

/* ---------- アバター ---------- */

.avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* =========================================================
   検索モーダル
   ========================================================= */

.search-modal { max-width: 560px; }
.search-modal .ln-modal-body { padding: 12px 12px 12px; }
.search-input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 17px;
  padding: 8px 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.search-input:focus { outline: none; }
.search-results { margin-top: 8px; max-height: 400px; overflow-y: auto; }
.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
}
.search-row:hover, .search-row.on { background: var(--bg-hover); }
.search-icon { font-size: 16px; width: 22px; display: inline-flex; justify-content: center; flex-shrink: 0; }
.search-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.search-title { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-path { font-size: 11.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-date { font-size: 11.5px; color: var(--text-dim); flex-shrink: 0; }
.search-empty { padding: 24px; text-align: center; color: var(--text-dim); font-size: 13.5px; }

/* =========================================================
   共有ダイアログ・履歴・設定
   ========================================================= */

.share-dialog { display: flex; flex-direction: column; gap: 12px; }
.share-toggle-line {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  padding: 4px 0;
}
.share-toggle-line input { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--accent); }
.share-toggle-title { font-size: 14.5px; font-weight: 600; }
.share-toggle-sub { font-size: 12.5px; color: var(--text-dim); }
.share-child-line { display: flex; align-items: center; gap: 9px; font-size: 13.5px; cursor: pointer; padding-left: 2px; }
.share-child-line input { accent-color: var(--accent); }
.share-url-line { display: flex; gap: 6px; }
.share-url {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-size: 12.5px;
  background: var(--bg-input);
  color: var(--text-mid);
  min-width: 0;
}

.versions-body { display: flex; gap: 0; min-height: 380px; }
.versions-list {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  max-height: 60vh;
}
.version-item {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 6px 0 0 6px;
}
.version-item:hover, .version-item.on { background: var(--bg-hover); }
.version-date { font-size: 13px; font-weight: 600; }
.version-by { font-size: 11.5px; color: var(--text-dim); }
.versions-preview { flex: 1; padding: 4px 0 4px 18px; overflow-y: auto; max-height: 60vh; }
.version-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.version-editor { margin-bottom: 14px; }
.version-empty { color: var(--text-dim); font-size: 13px; padding: 12px; }

.settings-body { display: flex; min-height: 380px; }
.settings-nav {
  width: 170px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  padding-right: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-tab {
  border: none;
  background: transparent;
  text-align: left;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text-mid);
  cursor: pointer;
}
.settings-tab:hover { background: var(--bg-hover); }
.settings-tab.on { background: var(--bg-active); color: var(--text); font-weight: 600; }
.settings-panel { flex: 1; padding-left: 20px; overflow-y: auto; max-height: 62vh; }
.settings-divider { border-top: 1px solid var(--line); margin: 20px 0; }
.settings-subhead { font-size: 13.5px; font-weight: 700; margin-bottom: 10px; }
.form-field { margin-bottom: 12px; }
.form-field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-mid); margin-bottom: 5px; }

.check-line {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  cursor: pointer;
  margin: 10px 0;
}
.check-line input { accent-color: var(--accent); width: 15px; height: 15px; }
.form-hint { font-size: 12.5px; color: var(--text-dim); margin-bottom: 14px; line-height: 1.7; }
.form-row { display: flex; gap: 10px; }
.form-row > .form-field { flex: 1; }
.form-actions { display: flex; gap: 8px; margin-top: 14px; }
.auth-link {
  display: inline-block;
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--text-mid);
  text-decoration: none;
}
.auth-link:hover { color: var(--accent); }

.member-list { display: flex; flex-direction: column; gap: 4px; }
.member-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.member-row.inactive { opacity: 0.5; }
.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 13.5px; font-weight: 600; }
.member-email { font-size: 12px; color: var(--text-dim); }
.member-role { font-size: 12px; color: var(--text-mid); background: var(--bg-hover); border-radius: 5px; padding: 2px 8px; }

/* =========================================================
   ゴミ箱・ホーム
   ========================================================= */

.trash-list { display: flex; flex-direction: column; gap: 2px; }
.trash-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
}
.trash-row:hover { background: var(--bg-hover); }
.trash-title { flex: 1; font-size: 14px; text-decoration: none; font-weight: 500; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trash-date { font-size: 12px; color: var(--text-dim); flex-shrink: 0; }
.trash-empty { color: var(--text-dim); padding: 20px 0; }

.home-greet { font-size: 28px; font-weight: 700; padding: 52px 0 26px; letter-spacing: -0.01em; }
.home-label { font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 10px; }
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 30px;
}
.home-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  text-decoration: none;
  transition: background 0.12s, box-shadow 0.12s;
}
.home-card:hover { background: var(--bg-hover); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); }
.home-card-icon { font-size: 26px; margin-bottom: 8px; }
.home-card-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.home-card-sub { font-size: 11.5px; color: var(--text-dim); }
.home-actions { display: flex; gap: 8px; }

/* =========================================================
   公開シェアページ
   ========================================================= */

.share-body { background: var(--bg); }
.share-wrap { min-height: 100vh; display: flex; flex-direction: column; }
.share-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.share-badge {
  font-size: 11.5px;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2px 10px;
  flex-shrink: 0;
}
.share-content { flex: 1; }
.share-cover { height: 220px; }
.share-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 30px 0 26px;
}
.share-404 { text-align: center; padding: 16vh 24px; }
.share-404-icon { margin-bottom: 16px; color: var(--text-dim); }
.share-404 h1 { font-size: 20px; margin-bottom: 8px; }
.share-404 p { color: var(--text-mid); font-size: 14px; }

/* =========================================================
   レスポンシブ
   ========================================================= */

@media (max-width: 800px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 100;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.18);
  }
  .sidebar.collapsed { margin-left: -110%; box-shadow: none; }
  .page-inner { padding: 8px 20px 20vh; }
  .page-title-input, .share-title { font-size: 30px; }
  .versions-body, .settings-body { flex-direction: column; }
  .versions-list, .settings-nav {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    overflow-x: auto;
    display: flex;
  }
  .settings-panel { padding-left: 0; padding-top: 14px; }
  .db-th, .db-td { width: 140px; }
}
