:root {
  --bg: #191919; --bg2: #202020; --bg3: #2a2a2a; --hover: #ffffff10; --line: #ffffff17;
  --text: #ebebeb; --muted: #9b9b9b; --accent: #e03a3e; --link: #5ea2f5;
  --gray: #5a5a5a; --blue: #2e5f9e; --green: #2f7a55; --yellow: #8a6d1d; --orange: #a1571f; --red: #9b3434; --purple: #6b4a9e; --pink: #9a3f75; --brown: #6e4a37;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--link); }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: #ffffff1f; border-radius: 6px; }

#app { display: flex; height: 100vh; }
.sidebar { width: 248px; flex: none; background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 8px 6px; overflow: auto; }
.sidebar .ws { display: flex; align-items: center; gap: 8px; padding: 8px; font-weight: 600; }
.logo { width: 22px; height: 22px; border-radius: 5px; background: var(--accent); display: grid; place-items: center; font-size: 13px; color: #fff; font-weight: 700; }
.navitem { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; color: var(--muted); width: 100%; text-align: left; }
.navitem:hover { background: var(--hover); } .navitem.on { background: #ffffff14; color: var(--text); }
.navitem .ic { width: 20px; text-align: center; }
.navsec { font-size: 11px; color: var(--muted); padding: 14px 8px 4px; text-transform: uppercase; letter-spacing: .04em; }
.spacer { flex: 1; }
.main { flex: 1; min-width: 0; overflow: auto; position: relative; }
.page { max-width: 1180px; margin: 0 auto; padding: 36px 48px 120px; }
.topbar-m { display: none; }
h1.title { font-size: 38px; margin: 0 0 6px; font-weight: 700; outline: none; }
.icon-big { font-size: 56px; cursor: pointer; line-height: 1; margin-bottom: 8px; display: inline-block; }
.muted { color: var(--muted); }

.btn { padding: 4px 10px; border-radius: 6px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--hover); color: var(--text); }
.btn.primary { background: #2383e2; color: #fff; } .btn.primary:hover { background: #1b74cc; }
.btn.danger { color: #ff7b7b; }
.toolbar { display: flex; align-items: center; gap: 4px; margin: 14px 0 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.vtab { padding: 6px 10px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.vtab.on { color: var(--text); border-color: var(--text); } .vtab:hover { background: var(--hover); }
.tools { margin-left: auto; display: flex; gap: 2px; align-items: center; }
.search { background: var(--bg3); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; width: 160px; }

/* tags */
.tag { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 13px; line-height: 20px; background: var(--gray); margin: 1px 4px 1px 0; white-space: nowrap; }
.tag.blue { background: var(--blue); } .tag.green { background: var(--green); } .tag.yellow { background: var(--yellow); } .tag.orange { background: var(--orange); }
.tag.red { background: var(--red); } .tag.purple { background: var(--purple); } .tag.pink { background: var(--pink); } .tag.brown { background: var(--brown); }
.chip { display: inline-block; padding: 0 6px; margin: 1px 4px 1px 0; border-radius: 4px; background: var(--bg3); border: 1px solid var(--line); font-size: 13px; line-height: 20px; cursor: pointer; }

/* table */
.tablewrap { overflow: auto; }
table.tbl { border-collapse: collapse; min-width: 100%; }
.tbl th { text-align: left; font-weight: 400; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--bg); }
.tbl td { padding: 4px 8px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); vertical-align: top; height: 32px; overflow: hidden; text-overflow: ellipsis; }
.tbl td.t { font-weight: 500; }
.tbl tr:hover td { background: #ffffff07; }
.tbl td.cell { cursor: text; }
.cell .ph { color: #ffffff3a; }
.groupHead { padding: 12px 0 6px; display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.groupHead .cnt { color: var(--muted); }
.newrow { color: var(--muted); padding: 6px 8px; display: block; width: 100%; text-align: left; } .newrow:hover { background: var(--hover); }

/* board */
.board { display: flex; gap: 14px; overflow: auto; padding: 8px 0 24px; align-items: flex-start; }
.col { width: 280px; flex: none; background: #ffffff06; border-radius: 8px; padding: 8px; min-height: 60px; }
.col.over { outline: 2px dashed #2383e2; }
.col h4 { margin: 2px 4px 8px; font-weight: 400; display: flex; gap: 8px; align-items: center; }
.card { background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; box-shadow: 0 1px 2px #0004; }
.card:hover { background: #333; } .card.drag { opacity: .4; }
.card .ct { font-weight: 500; margin-bottom: 4px; } .card .cp { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* list */
.lrow { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-bottom: 1px solid var(--line); cursor: pointer; }
.lrow:hover { background: var(--hover); } .lrow .lt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal .dow { padding: 6px; color: var(--muted); font-size: 12px; text-align: right; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal .day { min-height: 110px; padding: 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); position: relative; min-width: 0; }
.cal .day.out { background: #ffffff05; color: var(--muted); }
.cal .day .dn { text-align: right; font-size: 12px; color: var(--muted); padding: 0 4px 2px; }
.cal .day.today .dn span { background: var(--accent); color: #fff; border-radius: 50%; display: inline-block; width: 22px; height: 22px; line-height: 22px; text-align: center; }
.cal .day .add { position: absolute; left: 4px; top: 2px; opacity: 0; color: var(--muted); } .cal .day:hover .add { opacity: 1; }
.ev { display: block; width: 100%; text-align: left; padding: 1px 6px; border-radius: 4px; margin-bottom: 2px; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--blue); color: #fff; }
.calhead { display: flex; align-items: center; gap: 8px; margin: 8px 0; } .calhead h3 { margin: 0 8px; font-weight: 600; min-width: 170px; text-align: center; } .calhead h3::first-letter { text-transform: uppercase; }

/* overlays */
.popover { position: fixed; z-index: 60; background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 28px #000a; padding: 6px; min-width: 220px; max-width: 360px; max-height: 420px; overflow: auto; }
.popover .opt { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 5px; width: 100%; text-align: left; } .popover .opt:hover, .popover .opt.on { background: var(--hover); }
.popover input[type=text], .popover input[type=search], .popover input:not([type]), .popover input[type=date], .popover input[type=number], .popover select { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 5px 8px; margin-bottom: 6px; }
.popover label.l { display: block; color: var(--muted); font-size: 12px; margin: 8px 4px 4px; }
.scrim { position: fixed; inset: 0; background: #0008; z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--bg); border-left: 1px solid var(--line); z-index: 50; overflow: auto; padding: 24px 40px 120px; box-shadow: -10px 0 40px #0008; }
.modal { position: fixed; z-index: 55; top: 8vh; left: 50%; transform: translateX(-50%); width: min(620px, 94vw); background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 20px; max-height: 84vh; overflow: auto; box-shadow: 0 20px 60px #000b; }
.modal h3 { margin: 0 0 12px; }
.modal input:not([type=checkbox]), .modal select, .modal textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; width: 100%; }
.frow { display: grid; grid-template-columns: 1fr 150px 1fr 32px; gap: 8px; margin-bottom: 8px; align-items: center; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #fff; color: #111; padding: 8px 14px; border-radius: 8px; z-index: 99; box-shadow: 0 6px 20px #0008; }

/* row page */
.props { margin: 16px 0 8px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.prow { display: grid; grid-template-columns: 170px 1fr; align-items: start; min-height: 32px; }
.prow .pn { color: var(--muted); padding: 6px 4px; }
.prow .pv { padding: 4px 6px; border-radius: 4px; min-height: 28px; cursor: text; } .prow .pv:hover { background: var(--hover); }
.cellinput { width: 100%; background: var(--bg3); border: 1px solid #2383e2; border-radius: 4px; padding: 3px 6px; outline: none; }
.titleinput { font-size: 36px; font-weight: 700; background: none; border: 0; outline: none; width: 100%; padding: 0; margin: 6px 0 0; }

/* blocks */
.blk { display: flex; gap: 6px; align-items: flex-start; padding: 2px 0; position: relative; }
.blk .tx { flex: 1; outline: none; min-height: 1.6em; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.blk .tx:empty::before { content: attr(data-ph); color: #ffffff30; }
.blk.h1 .tx { font-size: 30px; font-weight: 700; margin-top: 18px; } .blk.h2 .tx { font-size: 23px; font-weight: 600; margin-top: 14px; } .blk.h3 .tx { font-size: 18px; font-weight: 600; margin-top: 10px; }
.blk .mk { width: 22px; text-align: center; color: var(--muted); user-select: none; padding-top: 3px; flex: none; }
.blk.todo.done .tx { color: var(--muted); text-decoration: line-through; }
.blk.quote .tx { border-left: 3px solid var(--text); padding-left: 12px; }
.blk.callout { background: var(--bg3); border-radius: 6px; padding: 10px; } .blk.code .tx { font-family: ui-monospace, Menlo, monospace; background: var(--bg3); padding: 10px; border-radius: 6px; }
.blk hr { flex: 1; border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.slash .opt .ic { width: 28px; height: 28px; display: grid; place-items: center; background: var(--bg); border-radius: 5px; border: 1px solid var(--line); }

/* home */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin: 14px 0 28px; }
.dcard { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; text-align: left; } .dcard:hover { background: var(--bg3); }
.dcard .n { font-size: 26px; font-weight: 700; margin-top: 4px; }
.box { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } .two > div { min-width: 0; }
.login { margin: auto; width: 340px; padding: 28px; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; }
.login input { width: 100%; padding: 9px 12px; margin: 6px 0 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.login .btn { width: 100%; justify-content: center; padding: 9px; }
.err { color: #ff7b7b; margin-bottom: 8px; }
@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .2s; } .sidebar.open { transform: none; box-shadow: 10px 0 40px #000a; }
  .topbar-m { display: flex; padding: 8px 12px; border-bottom: 1px solid var(--line); gap: 8px; align-items: center; }
  .page { padding: 20px 16px 100px; } .two { grid-template-columns: 1fr; } h1.title { font-size: 28px; } .drawer { padding: 20px 16px 100px; }
  .cal .day { min-height: 70px; } .frow { grid-template-columns: 1fr 1fr; }
}
.tx code { background: #ffffff1a; padding: 1px 5px; border-radius: 4px; font-family: ui-monospace, Menlo, monospace; font-size: .92em; }
.tx a { color: var(--link); text-decoration: underline; cursor: pointer; }
