/* Version: 0.1 (2026-11-17) */
:root {
  --bg: #ffffff; --panel: #f6f5f2; --text: #26241f; --muted: #7a766d; --line: #e4e1da;
  --accent: #2f6f5e; --danger: #b3261e; --hover: #ebe9e3;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1b1b1a; --panel: #232322; --text: #e9e6df; --muted: #9a968c; --line: #353431;
          --accent: #6fbfa8; --danger: #f2877f; --hover: #2e2e2c; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font: 16px/1.55 -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
button:hover { background: var(--hover); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
button.danger { color: var(--danger); }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.grow { flex: 1; }
.error { color: var(--danger); min-height: 1.2em; margin: 6px 0 0; }
.muted { color: var(--muted); font-size: 14px; }

header { position: sticky; top: 0; z-index: 5; display: flex; gap: 8px; align-items: center; padding: 8px 12px;
         background: var(--panel); border-bottom: 1px solid var(--line); }
#search { flex: 1; min-width: 0; }
.menu { position: absolute; right: 12px; top: 52px; display: flex; flex-direction: column; background: var(--bg);
        border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.menu[hidden] { display: none; }
.menu button { border: 0; text-align: left; }

#layout { display: flex; height: calc(100% - 53px); }
#side { width: 270px; flex: none; overflow: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 10px; }
.sideActions { display: flex; gap: 8px; margin-bottom: 10px; }
.sideActions button { flex: 1; }
#tree ul { list-style: none; margin: 0; padding-left: 14px; }
#tree > ul { padding-left: 0; }
.node { display: flex; align-items: center; border-radius: 6px; }
.node:hover, .node.current { background: var(--hover); }
.node a { flex: 1; min-width: 0; padding: 5px 8px; color: inherit; text-decoration: none; white-space: nowrap;
          overflow: hidden; text-overflow: ellipsis; }
.node button { border: 0; padding: 2px 8px; color: var(--muted); }
#main { flex: 1; min-width: 0; overflow: auto; padding: 24px clamp(14px, 5vw, 64px) 80px; }

.titleRow { display: flex; gap: 8px; align-items: center; }
.icon { width: 2.6em; text-align: center; font-size: 22px; border-color: transparent; padding: 4px; }
.title { flex: 1; min-width: 0; font-size: 28px; font-weight: 700; border-color: transparent; padding: 4px 6px; }
.icon:focus, .title:focus { border-color: var(--line); outline: none; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0 18px; }
.toolbar .status { color: var(--muted); font-size: 14px; }
textarea.editor { width: 100%; min-height: 55vh; font: 15px/1.5 ui-monospace, Consolas, monospace; resize: vertical; }

.prose { max-width: 820px; }
.prose h1 { font-size: 24px; } .prose h2 { font-size: 20px; } .prose h3 { font-size: 17px; }
.prose a { color: var(--accent); }
.prose code { background: var(--panel); padding: 1px 5px; border-radius: 5px; font-size: 14px; }
.prose pre { background: var(--panel); padding: 12px; border-radius: 8px; overflow: auto; }
.prose pre code { padding: 0; }
.prose blockquote { margin: 0; padding-left: 14px; border-left: 3px solid var(--line); color: var(--muted); }
.prose table { border-collapse: collapse; }
.prose th, .prose td { border: 1px solid var(--line); padding: 5px 10px; text-align: left; }

.tableWrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.grid { border-collapse: collapse; width: 100%; }
.grid th { background: var(--panel); text-align: left; font-weight: 600; padding: 0; white-space: nowrap; }
.grid th button { border: 0; width: 100%; text-align: left; border-radius: 0; font-weight: 600; }
.grid th, .grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
.grid tr:last-child td { border-bottom: 0; }
.grid td { padding: 0; min-width: 120px; }
.grid td.narrow, .grid th.narrow { min-width: 0; width: 1%; border-right: 0; text-align: center; }
.grid td input:not([type=checkbox]), .grid td select { width: 100%; border: 0; border-radius: 0; background: transparent; padding: 8px 10px; }
.grid td input[type=checkbox] { width: 18px; height: 18px; margin: 8px 10px; }
.grid td button { border: 0; color: var(--muted); }

.results a { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.results a:hover { background: var(--hover); }
.listRow { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); width: min(420px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h3 { margin: 0 0 10px; }
dialog label { display: block; margin-bottom: 10px; font-size: 14px; color: var(--muted); }
dialog label input, dialog label select { display: block; width: 100%; margin-top: 4px; color: var(--text); font-size: 16px; }
.dialogButtons { display: flex; gap: 8px; margin-top: 14px; }

body.login { display: flex; align-items: center; justify-content: center; background: var(--panel); }
.card { width: min(360px, 92vw); background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 26px;
        display: flex; flex-direction: column; gap: 10px; }
.card h1 { margin: 0 0 8px; font-size: 24px; }

@media (max-width: 760px) {
  #side { position: fixed; z-index: 4; top: 53px; bottom: 0; left: 0; width: min(86vw, 320px); transform: translateX(-100%);
          transition: transform .18s; box-shadow: 4px 0 24px rgba(0,0,0,.2); }
  body.sideOpen #side { transform: none; }
  .title { font-size: 22px; }
}
@media (min-width: 761px) { #toggle { display: none; } }
