/* Boards - house style: gold on near-black at night, ivory by day.
   Type: Cinzel for headings, Georgia for reading, DM Mono for labels. */
:root {
  --bg: #0f0e17; --dots: #24223a; --panel: #1a1924; --card: #1e1d2a; --card2: #262536;
  --line: #2f2d42; --text: #ece9f4; --muted: #a39cb8; --accent: #c9a96e; --accent2: #EAB85C;
  --wire: #8c84a8; --shadow: 0 2px 10px rgba(0,0,0,.45); --sel: #EAB85C;
  --f-head: "Cinzel", Georgia, serif; --f-body: Georgia, "Times New Roman", serif; --f-mono: "DM Mono", ui-monospace, monospace;
}
:root[data-theme="light"] {
  --bg: #efe9dc; --dots: #d8cfbd; --panel: #f7f2e8; --card: #fffdf8; --card2: #f4efe4;
  --line: #ddd3c0; --text: #1f1c2a; --muted: #6a6478; --accent: #9a7330; --accent2: #BE8C44;
  --wire: #7d7790; --shadow: 0 1px 6px rgba(60,40,10,.18); --sel: #BE8C44;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--f-body); }
button { font: inherit; color: inherit; cursor: pointer; }

/* gate */
#gate { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #1c1830 0%, #0b0a12 70%); }
.gate-box { text-align: center; width: min(360px, 88vw); }
.gate-mark { font-size: 34px; background: linear-gradient(135deg,#A87528,#EAB85C,#F5D27E); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 6px rgba(234,184,92,.55)); }
.gate-box h1 { font-family: var(--f-head); letter-spacing: .22em; font-weight: 500; color: #ece9f4; margin: 8px 0 26px; font-size: 26px; }
#gatePass { width: 100%; padding: 14px 16px; font-size: 21px; border-radius: 10px; border: 1px solid #3a3650; background: #15131f; color: #fff; text-align: center; }
#gateGo { margin-top: 14px; width: 100%; padding: 13px; border-radius: 10px; border: 1px solid #c9a96e; background: transparent; color: #EAB85C; font-family: var(--f-mono); letter-spacing: .2em; text-transform: uppercase; font-size: 14px; }
#gateErr { margin-top: 14px; color: #f2a08f; font-size: 17px; min-height: 22px; }

/* top bar */
#top { position: fixed; top: 0; left: 0; right: 0; height: 58px; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 0 14px 0 86px; background: color-mix(in srgb, var(--panel) 92%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
#crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; font-size: 19px; }
#crumbs a { color: var(--muted); text-decoration: none; cursor: pointer; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
#crumbs a:hover { color: var(--accent2); }
#crumbs .sep { color: var(--line); }
#crumbs .cur { color: var(--text); font-family: var(--f-head); letter-spacing: .06em; overflow: hidden; text-overflow: ellipsis; }
#topright { display: flex; align-items: center; gap: 10px; }
#searchwrap { position: relative; }
#search { width: 260px; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 17px; font-family: var(--f-body); }
#results { position: absolute; right: 0; top: 46px; width: min(520px, 92vw); max-height: 70vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; }
.res { padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.res:hover, .res.on { background: var(--card2); }
.res .rt { font-size: 18px; }
.res .rp { font-family: var(--f-mono); font-size: 13px; color: var(--muted); margin-top: 2px; }
.res .rs { font-size: 16px; color: var(--muted); margin-top: 4px; }
.res mark { background: color-mix(in srgb, var(--accent2) 45%, transparent); color: inherit; }
.tb { padding: 8px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); font-family: var(--f-mono); font-size: 14px; }
.tb:hover { border-color: var(--accent); }
.sync { font-family: var(--f-mono); font-size: 13px; color: var(--muted); min-width: 92px; text-align: right; }
.sync.s-err { color: #f2a08f; }
.sync.s-saving { color: var(--accent2); }

/* left rail */
#rail { position: fixed; left: 0; top: 0; bottom: 0; width: 74px; z-index: 21; padding: 66px 6px 10px; display: flex; flex-direction: column; gap: 4px;
  background: var(--panel); border-right: 1px solid var(--line); }
.tool { border: 0; background: transparent; border-radius: 10px; padding: 8px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; touch-action: none; }
.tool:hover, .tool.on { background: var(--card2); }
.tool .ti { font-size: 24px; line-height: 1; color: var(--accent2); }
.tool .tl { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }

/* canvas */
#canvas { position: fixed; left: 74px; top: 58px; right: 0; bottom: 0; overflow: hidden; touch-action: none; cursor: default;
  background-color: var(--bg); background-image: radial-gradient(var(--dots) 1.2px, transparent 1.2px); }
#canvas.panning { cursor: grabbing; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#lines { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
#lines path { fill: none; stroke: var(--wire); pointer-events: stroke; cursor: pointer; }
#lines path.sel { stroke: var(--sel); }
#lines text { fill: var(--text); font-family: var(--f-body); font-size: 17px; paint-order: stroke; stroke: var(--bg); stroke-width: 5px; }
#empty { position: absolute; left: 50%; top: 40%; transform: translate(-50%,-50%); color: var(--muted); font-size: 21px; font-style: italic; }

/* items */
.item { position: absolute; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); font-size: 21px; line-height: 1.5; }
.card.tinted { border-left: 6px solid var(--c); background: color-mix(in srgb, var(--c) 9%, var(--card)); }
.card .body { padding: 14px 18px; min-height: 52px; outline: none; overflow-wrap: anywhere; }
.card .body[contenteditable="true"] { cursor: text; box-shadow: inset 0 0 0 2px var(--sel); border-radius: 5px; }
.body p { margin: 0; }
.body h1, .body h2, .body h3, .body h4 { font-family: var(--f-head); font-weight: 600; letter-spacing: .03em; margin: .2em 0 .3em; line-height: 1.25; }
.body h1 { font-size: 1.5em; } .body h2 { font-size: 1.3em; } .body h3 { font-size: 1.15em; } .body h4 { font-size: 1.05em; }
.body ul, .body ol { margin: .2em 0; padding-left: 1.3em; }
.body li.check { list-style: none; position: relative; }
.body li.check::before { content: "☐"; position: absolute; left: -1.25em; color: var(--muted); }
.body li.check.done::before { content: "☑"; color: var(--accent2); }
.body li.check.done { text-decoration: line-through; color: var(--muted); }
.body blockquote { margin: .3em 0; padding-left: 12px; border-left: 3px solid var(--accent); color: var(--muted); }
.body pre, .body code { font-family: var(--f-mono); font-size: .8em; background: var(--card2); border-radius: 4px; padding: 1px 4px; white-space: pre-wrap; }
.body hr { border: 0; border-top: 1px solid var(--line); margin: .5em 0; }
.body a, .caption a { color: var(--accent2); }
.body mark { background: color-mix(in srgb, #EAB85C 40%, transparent); color: inherit; border-radius: 2px; }
.body mark.hl-blue { background: color-mix(in srgb, #6fb0f2 40%, transparent); }
.body mark.hl-green { background: color-mix(in srgb, #8fd16a 40%, transparent); }
.body mark.hl-orange { background: color-mix(in srgb, #ffa35c 45%, transparent); }
.body mark.hl-pink { background: color-mix(in srgb, #f29bc8 45%, transparent); }
.body mark.hl-grey { background: color-mix(in srgb, #b5b5b5 40%, transparent); }
.tc-red { color: #f2756a; } .tc-blue { color: #6fb0f2; } .tc-green { color: #8fd16a; } .tc-orange { color: #ffa35c; }
.caption { padding: 8px 18px 12px; font-size: 17px; color: var(--muted); border-top: 1px solid var(--line); }
.item.selected > .card, .item.selected > .tile .ticon, .item.selected > .colwrap { outline: 3px solid var(--sel); outline-offset: 2px; }
.item.hit > .card, .item.hit > .tile .ticon { box-shadow: 0 0 0 4px #EAB85C, 0 0 24px rgba(234,184,92,.6); }
.item.dragging { opacity: .25; }
.item.droptarget > .tile .ticon { outline: 4px dashed var(--accent2); outline-offset: 4px; }
.item.linkpick > .card, .item.linkpick > .tile .ticon { outline: 3px dashed var(--accent2); }
.more { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 6px; border: 0; background: var(--card2); color: var(--muted); font-size: 18px; line-height: 1; opacity: 0; z-index: 3; }
.item:hover > .more, .item.selected > .more { opacity: 1; }
.rsz { position: absolute; top: 0; right: -6px; width: 12px; bottom: 0; cursor: ew-resize; z-index: 2; }
.cmt { position: absolute; top: -10px; left: -10px; background: var(--accent); color: #111; border-radius: 12px; font-family: var(--f-mono); font-size: 12px; padding: 2px 7px; }

/* board tiles */
.tile { width: 100%; text-align: center; cursor: pointer; user-select: none; }
.ticon { width: 98px; height: 98px; margin: 0 auto; border-radius: 14px; background: var(--tc, #4a4560); display: flex; align-items: center; justify-content: center; overflow: hidden; box-shadow: var(--shadow); }
.ticon svg { width: 52px; height: 52px; }
.ticon svg path { fill: #fff; }
.ticon svg .fa-secondary { opacity: .45; }
.ticon img { width: 100%; height: 100%; object-fit: cover; }
.ticon .glyph { font-size: 44px; color: #fff; opacity: .9; }
.tname { margin-top: 8px; font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; outline: none; }
.tname[contenteditable="true"] { box-shadow: 0 0 0 2px var(--sel); border-radius: 4px; cursor: text; }
.tcount { font-family: var(--f-mono); font-size: 13px; color: var(--muted); margin-top: 2px; }

/* columns */
.colwrap { background: color-mix(in srgb, var(--panel) 85%, transparent); border: 1px solid var(--line); border-radius: 8px; padding: 0 10px 10px; }
.colwrap.tinted { border-top: 5px solid var(--c); }
.colhead { display: flex; align-items: baseline; gap: 8px; padding: 12px 4px 10px; cursor: grab; }
.coltitle { flex: 1; font-family: var(--f-head); font-size: 19px; letter-spacing: .04em; outline: none; overflow-wrap: anywhere; min-height: 24px; }
.coltitle[contenteditable="true"] { box-shadow: 0 0 0 2px var(--sel); border-radius: 4px; cursor: text; }
.colcount { font-family: var(--f-mono); font-size: 13px; color: var(--muted); }
.colfold { border: 0; background: transparent; color: var(--muted); font-size: 16px; padding: 0 4px; }
.colbody { display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.colbody > .item { position: relative; left: auto !important; top: auto !important; width: 100% !important; }
.colwrap.collapsed .colbody { display: none; }
.ph { height: 8px; border-radius: 4px; background: var(--accent2); box-shadow: 0 0 10px rgba(234,184,92,.6); }
.unsorted .colwrap { border-style: dashed; }

/* to-do */
.todo .ttitle { padding: 12px 18px 4px; font-family: var(--f-head); font-size: 19px; outline: none; }
.todo .tasks { padding: 6px 12px 10px; }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 3px 6px; border-radius: 5px; }
.task input { width: 22px; height: 22px; margin-top: 6px; accent-color: #c9a96e; flex: none; cursor: pointer; }
.task .tx { flex: 1; outline: none; min-height: 30px; overflow-wrap: anywhere; }
.task .tx p { margin: 0; }
.task.done .tx { text-decoration: line-through; color: var(--muted); }
.task .tx[contenteditable="true"] { box-shadow: 0 0 0 2px var(--sel); border-radius: 4px; cursor: text; }
.task .due { font-family: var(--f-mono); font-size: 12px; color: var(--muted); align-self: center; }
.addtask { margin: 2px 6px 4px; border: 0; background: transparent; color: var(--muted); font-size: 17px; padding: 4px 6px; }
.addtask:hover { color: var(--accent2); }
.tprog { font-family: var(--f-mono); font-size: 12px; color: var(--muted); padding: 0 18px 10px; }

/* link, image, file, table, draw */
.link .lprev { width: 100%; display: block; max-height: 300px; object-fit: cover; border-radius: 5px 5px 0 0; background: var(--card2); }
.link .lt { padding: 12px 18px 2px; font-weight: bold; overflow-wrap: anywhere; outline: none; }
.link .lt[contenteditable="true"] { box-shadow: inset 0 0 0 2px var(--sel); }
.link .ls { padding: 0 18px 12px; font-family: var(--f-mono); font-size: 13px; }
.link .ls a { color: var(--muted); text-decoration: none; }
.link .ls a:hover { color: var(--accent2); }
.link input.lin { margin: 14px 18px; width: calc(100% - 36px); font-size: 18px; padding: 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--card2); color: var(--text); }
.image img.pic { width: 100%; display: block; border-radius: 5px; background: var(--card2); min-height: 40px; }
.file .fbox { padding: 14px 18px; display: flex; gap: 14px; align-items: center; }
.file .fico { width: 54px; height: 64px; border-radius: 6px; background: var(--card2); display: flex; align-items: center; justify-content: center; font-family: var(--f-mono); font-size: 12px; color: var(--accent2); flex: none; overflow: hidden; }
.file .fico img { width: 100%; height: 100%; object-fit: cover; }
.file .fname { overflow-wrap: anywhere; font-size: 18px; }
.file .fmeta a { font-family: var(--f-mono); font-size: 13px; color: var(--accent2); }
.table .tt { padding: 12px 18px 0; font-family: var(--f-head); }
.table table { border-collapse: collapse; width: 100%; font-size: 17px; }
.table td { border: 1px solid var(--line); padding: 6px 8px; vertical-align: top; }
.table tr:first-child td { background: var(--card2); font-weight: bold; }
.table .tw { padding: 10px; overflow: auto; }
.draw { background: transparent; border: 0; box-shadow: none; }
.draw svg { width: 100%; height: auto; display: block; }
:root:not([data-theme="light"]) .draw svg path { stroke: #e8e4f2; }
.comment .body { font-size: 18px; }
.comment .cm { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.comment .cm:last-child { border: 0; }
.raw pre { font-size: 12px; max-height: 220px; overflow: auto; padding: 10px; margin: 0; }

/* drag layer, menus, panels */
#drag { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
#drag * { pointer-events: none !important; }
#drag > .item { position: fixed; transform-origin: 0 0; opacity: .92; }
#menu { position: fixed; z-index: 70; min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 8px; font-size: 18px; }
#menu .mi { padding: 9px 12px; border-radius: 8px; cursor: pointer; }
#menu .mi:hover { background: var(--card2); }
#menu .sw { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
#menu .sw span { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 2px solid var(--line); }
#menu .sw span.none { background: var(--card); position: relative; }
#menu .sw span.none::after { content: "∅"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--muted); }
#menu .ml { font-family: var(--f-mono); font-size: 12px; color: var(--muted); padding: 6px 12px 0; letter-spacing: .1em; text-transform: uppercase; }
#trash { position: fixed; right: 14px; top: 70px; z-index: 40; width: min(420px, 92vw); max-height: 75vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 12px; }
.tr-head { display: flex; justify-content: space-between; align-items: center; font-family: var(--f-head); font-size: 18px; margin-bottom: 8px; }
.tr-head button { border: 0; background: transparent; font-size: 24px; color: var(--muted); }
.tr-row { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 8px; font-size: 17px; }
.tr-row:hover { background: var(--card2); }
.tr-row .tx { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-row button { border: 1px solid var(--accent); background: transparent; color: var(--accent2); border-radius: 7px; padding: 4px 10px; font-family: var(--f-mono); font-size: 13px; }
#banner { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 80; background: #3a1d1d; color: #ffd7cf; border: 1px solid #7a3b33; border-radius: 12px; padding: 12px 18px; font-size: 18px; box-shadow: var(--shadow); }
#banner button { margin-left: 12px; border: 1px solid #ffd7cf; background: transparent; color: #ffd7cf; border-radius: 8px; padding: 4px 12px; }
#hint { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 80; background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 16px; font-size: 18px; box-shadow: var(--shadow); }
#zoom { position: fixed; right: 14px; bottom: 14px; z-index: 30; display: flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
#zoom button { border: 0; background: transparent; min-width: 34px; height: 32px; border-radius: 7px; font-size: 18px; }
#zoom button:hover { background: var(--card2); }
#zFit { font-family: var(--f-mono); font-size: 13px !important; }
#zPct { font-family: var(--f-mono); font-size: 13px; color: var(--muted); min-width: 46px; text-align: center; }

@media (max-width: 760px) {
  #top { padding-left: 12px; height: 54px; }
  #search { width: 140px; }
  #trashBtn .tl, .sync { display: none; }
  #rail { top: auto; bottom: 0; left: 0; right: 0; width: auto; height: 64px; flex-direction: row; padding: 4px 6px; border-right: 0; border-top: 1px solid var(--line); justify-content: space-around; }
  #canvas { left: 0; top: 54px; bottom: 64px; }
  #zoom { bottom: 76px; }
}
