/* Mesita design system — premium SaaS: left sidebar + immersive full-bleed boards,
   rounded surfaces, frosted lists, rich gradient backgrounds, slate palette, Inter. */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --raised: #ffffff; --sunken: #eef1f5;
  --ink: #0f172a; --ink-2: #475569; --muted: #8a93a3; --faint: #aab2bf;
  --line: #e7eaef; --line-2: #eef1f5; --hover: #f2f4f8;
  --brand: #5b5bd6; --brand-2: #7c3aed; --brand-soft: rgba(91,91,214,.10); --brand-border: rgba(91,91,214,.22);
  --green:#15924b; --green-bg:#e4f6ec; --amber:#a76a13; --amber-bg:#fbf0d8; --red:#dc3a32; --red-bg:#fdeceb;
  --radius: 10px; --radius-sm: 7px; --radius-xs: 5px; --pill: 999px;
  --side-bg: #fbfbfd; --side-w: 252px;
  --shadow-xs: 0 1px 2px rgba(15,23,42,.05);
  --shadow: 0 2px 4px -1px rgba(15,23,42,.05), 0 6px 16px -10px rgba(15,23,42,.2);
  --shadow-md: 0 8px 24px -10px rgba(15,23,42,.22), 0 2px 6px -3px rgba(15,23,42,.12);
  --shadow-lg: 0 28px 60px -20px rgba(15,23,42,.36);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 14.5px; line-height: 1.55;
  letter-spacing: -.004em; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
a { color: var(--brand); text-decoration: none; }
h1,h2,h3 { letter-spacing: -.028em; line-height: 1.18; font-weight: 700; color: var(--ink); margin: 0; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .grow { flex: 1; }
.row { display: flex; gap: 12px; align-items: center; } .spread { justify-content: space-between; } .wrap-row { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
code { font-family: ui-monospace,'SF Mono',Menlo,monospace; font-size: .85em; background: var(--sunken); padding: .15em .45em; border-radius: 6px; }
.ico { display: inline-block; vertical-align: -.18em; flex: none; }

/* ============ LAYOUT ============ */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--side-w); flex: none; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--side-bg); border-right: 1px solid var(--line); padding: 12px 10px; gap: 4px; overflow: hidden; transition: width .16s ease; }
.side-brand { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 8px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px; letter-spacing: -.03em; color: var(--ink); }
.brand svg { border-radius: 8px; flex: none; }
.side-collapse { color: var(--faint); }
.side-search { display: flex; align-items: center; gap: 7px; background: var(--sunken); border: 1px solid transparent; border-radius: var(--pill); padding: 0 12px; margin-bottom: 6px; }
.side-search:focus-within { background: var(--surface); border-color: var(--brand-border); }
.side-search .ico { color: var(--muted); flex: none; }
.side-search input { border: 0; background: transparent; box-shadow: none; padding: 8px 0; font-size: 13.5px; min-width: 0; }
.side-search input:focus { box-shadow: none; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-item { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--ink-2);
  font-weight: 600; font-size: 13.5px; transition: background .1s, color .1s; }
.side-item .ico { color: var(--faint); flex: none; }
.side-item:hover { background: var(--hover); color: var(--ink); }
.side-item.active { background: var(--brand-soft); color: var(--brand); }
.side-item.active .ico { color: var(--brand); }
.side-item .count-pill { margin-left: auto; }
.side-boards { margin-top: 12px; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-sec { display: flex; align-items: center; justify-content: space-between; padding: 4px 10px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; font-weight: 700; color: var(--muted); }
.side-board-list { overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.side-board { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--ink-2); font-size: 13.5px; font-weight: 550; }
.side-board:hover { background: var(--hover); color: var(--ink); }
.side-board.active { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.side-board-sw { width: 22px; height: 18px; border-radius: 5px; flex: none; box-shadow: var(--shadow-xs); }
.side-board-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.side-board-star { color: var(--brand); display: inline-flex; }
.side-foot { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 6px; }
.usermenu { position: relative; flex: 1; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 6px 8px; border-radius: var(--radius-sm); }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--hover); }
.side-user-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.usermenu summary .ico:last-child { color: var(--muted); flex: none; }
.menu-pop { position: absolute; left: 0; bottom: calc(100% + 8px); width: 240px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; z-index: 60; }
.menu-id { display: flex; gap: 10px; align-items: center; padding: 8px; }
.menu-id span.muted { display: block; }
.menu-sep { height: 1px; background: var(--line-2); margin: 6px 0; }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 9px 10px; border-radius: var(--radius-xs);
  color: var(--ink-2); font-weight: 550; font-size: 13.5px; background: transparent; border: 0; cursor: pointer; font-family: var(--font); }
.menu-item:hover { background: var(--hover); color: var(--ink); }
.menu-item.active { color: var(--brand); background: var(--brand-soft); }
.menu-item.signout { color: var(--red); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--pill);
  border: 0; background: transparent; color: var(--ink-2); cursor: pointer; transition: .12s; position: relative; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.sm { width: 28px; height: 28px; }

.main { flex: 1; min-width: 0; }
.main-pad { max-width: 1120px; margin: 0 auto; padding: 32px 32px 80px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: 26px; letter-spacing: -.035em; }

/* collapsed sidebar (icons only) */
html.side-collapsed .sidebar { width: 64px; }
html.side-collapsed .side-label { display: none; }
html.side-collapsed .side-item, html.side-collapsed .side-board { justify-content: center; }
html.side-collapsed .side-search { justify-content: center; }
html.side-collapsed .usermenu summary { justify-content: center; }
.mobile-side-btn, .side-scrim { display: none; }

/* ============ BUTTONS ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-family: var(--font); font-size: 14px;
  font-weight: 600; padding: 9px 17px; border-radius: var(--pill); border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); cursor: pointer; transition: background .12s, border-color .12s, transform .04s, box-shadow .12s; box-shadow: var(--shadow-xs); white-space: nowrap; }
.btn:hover { border-color: #d4d9e2; background: #fbfcfd; }
.btn:active { transform: translateY(.5px); }
.btn .ico { opacity: .9; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); box-shadow: 0 6px 16px -8px rgba(15,23,42,.5); }
.btn.primary:hover { background: #1e293b; border-color: #1e293b; }
.btn.brand { background: linear-gradient(135deg,var(--brand),var(--brand-2)); color: #fff; border-color: transparent; box-shadow: 0 6px 16px -8px var(--brand); }
.btn.brand:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--red); border-color: var(--red-bg); }
.btn.danger:hover { background: var(--red-bg); }
.btn.sm { padding: 6px 13px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ============ CARDS / PANELS / FORMS ============ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card.welcome { background: linear-gradient(140deg, color-mix(in srgb, var(--brand) 9%, var(--surface)), color-mix(in srgb, var(--brand-2) 8%, var(--surface))); border-color: var(--brand-border); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-row { padding: 14px 18px; border-bottom: 1px solid var(--line-2); display: block; color: var(--ink); }
.panel-row:last-child { border-bottom: none; }
a.panel-row:hover { background: var(--hover); }
label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 7px; color: var(--ink-2); }
input[type=text], input[type=email], input[type=url], input[type=search], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; font-family: var(--font); font-size: 14px; color: var(--ink); padding: 10px 13px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.field { margin-bottom: 16px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* ============ CHIPS / FLASH / MISC ============ */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650; padding: 3px 11px; border-radius: var(--pill); background: var(--sunken); color: var(--ink-2); text-transform: capitalize; }
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 13.5px; font-weight: 550; border: 1px solid transparent; }
.flash.ok { background: var(--green-bg); color: var(--green); } .flash.err { background: var(--red-bg); color: var(--red); }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .serif { font-size: 22px; font-weight: 800; letter-spacing: -.03em; color: var(--ink); display: block; margin-bottom: 8px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.empty .btn { margin-top: 16px; }
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 700; font-size: 12.5px; flex: none; }
.count-pill { background: var(--brand); color: #fff; border-radius: var(--pill); padding: 1px 8px; font-size: 11px; font-weight: 700; }
.url-box { display: flex; align-items: center; gap: 8px; }
.url-box .u { flex: 1; min-width: 0; padding: 10px 13px; background: var(--sunken); border-radius: var(--radius-sm); font-family: ui-monospace,Menlo,monospace; font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Prominent click-anywhere-to-copy MCP endpoint */
.mcp-url { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer; font-family: var(--font);
  background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; margin: 4px 0 12px; transition: border-color .12s, background .12s; }
.mcp-url:hover { border-color: var(--brand-border); background: var(--brand-soft); }
.mcp-url-text { flex: 1; min-width: 0; font-family: ui-monospace,'SF Mono',Menlo,monospace; font-size: 15px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcp-url-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; color: var(--brand); flex: none; }

/* ============ BOARD TILES ============ */
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.board-tile { position: relative; height: 132px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .12s, box-shadow .16s; }
.board-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.board-tile-overlay { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.02), rgba(0,0,0,.5)); }
.board-tile-body { position: absolute; inset: auto 0 0 0; padding: 14px 16px; color: #fff; }
.board-tile-name { display: flex; align-items: center; gap: 5px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.board-tile-meta { display: block; font-size: 11.5px; opacity: .92; margin-top: 4px; text-transform: capitalize; }

/* ============ IMMERSIVE BOARD ============ */
body.board-page .main-pad { max-width: none; padding: 0; height: 100vh; display: flex; flex-direction: column; }
body.board-page .main { height: 100vh; }
.board-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; background-color: #5b5bd6; }
body.board-page.public .board-wrap { height: 100vh; }
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 22px; flex: none;
  background: rgba(0,0,0,.16); backdrop-filter: blur(8px); }
.board-title { font-size: 19px; color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,.3); }
.board-vis { font-size: 11.5px; font-weight: 650; text-transform: capitalize; color: #fff; background: rgba(255,255,255,.22); border-radius: var(--pill); padding: 3px 11px; }
.board-hbtn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 11px; border-radius: var(--radius-sm); border: 0;
  background: rgba(255,255,255,.18); color: #fff; font-weight: 600; font-size: 13px; font-family: var(--font); cursor: pointer; transition: .12s; }
.board-hbtn:hover { background: rgba(255,255,255,.3); }
.board-hbtn.on .ico { fill: #ffd96b; color: #ffd96b; }
.board-canvas { flex: 1; overflow: auto; padding: 16px 16px 8px; }
.board-toolbar { display: flex; gap: 8px; padding: 0 4px 12px; }
.board-toolbar .btn { background: rgba(255,255,255,.92); border-color: transparent; backdrop-filter: blur(4px); }
.kanban-scroll { display: flex; align-items: flex-start; gap: 14px; min-height: 60px; }

/* lists — frosted glass over any background */
.klist { flex: 0 0 288px; max-height: calc(100vh - 150px); display: flex; flex-direction: column;
  background: rgba(247,248,250,.86); backdrop-filter: blur(14px) saturate(160%); border: 1px solid rgba(255,255,255,.4);
  border-radius: var(--radius); box-shadow: 0 6px 20px -8px rgba(0,0,0,.3); }
.klist.dragging { opacity: .45; }
.klist-head { display: flex; align-items: center; gap: 8px; padding: 13px 12px 9px; }
.klist-name { font-weight: 700; font-size: 14px; letter-spacing: -.01em; flex: 1; cursor: text; color: var(--ink); }
.klist-name-edit { font-weight: 700; font-size: 14px; padding: 4px 7px; }
.klist-count { font-size: 11px; font-weight: 700; color: var(--muted); background: rgba(15,23,42,.06); border-radius: var(--pill); padding: 2px 9px; }
.klist-count.over { background: var(--red-bg); color: var(--red); }
.klist-menu { width: 28px; height: 28px; font-size: 17px; }
.klist-cards { overflow-y: auto; padding: 2px 9px 12px; display: flex; flex-direction: column; gap: 9px; min-height: 24px; }
.klist-foot { padding: 4px 9px 10px; }
.kadd { width: 100%; text-align: left; background: transparent; border: 0; color: var(--ink-2); font-size: 13.5px; font-weight: 600; padding: 8px 9px; border-radius: var(--radius-xs); cursor: pointer; }
.kadd:hover { background: rgba(15,23,42,.06); color: var(--ink); }
.list-add { flex: 0 0 288px; }
.list-add-btn { width: 100%; text-align: left; background: rgba(255,255,255,.28); backdrop-filter: blur(8px); border: 0; color: #fff; font-weight: 650; font-size: 14px; padding: 13px; border-radius: var(--radius); cursor: pointer; }
.list-add-btn:hover { background: rgba(255,255,255,.4); }

/* cards */
.kcard { background: var(--surface); border: 1px solid transparent; border-radius: var(--radius-sm); padding: 10px 12px; box-shadow: 0 1px 2px rgba(15,23,42,.12); cursor: pointer; transition: box-shadow .12s, transform .05s; }
.kcard:hover { box-shadow: 0 4px 14px -4px rgba(15,23,42,.3); transform: translateY(-1px); }
.kcard.dragging { opacity: .4; }
.kcard-cover { height: 36px; border-radius: var(--radius-xs); margin: -2px -3px 9px; }
.kcard-labels { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }
.klabel { height: 18px; min-width: 38px; border-radius: var(--pill); font-size: 10.5px; font-weight: 700; color: #14223b; display: inline-flex; align-items: center; padding: 0 9px; }
.kcard-title { font-size: 14px; line-height: 1.4; color: var(--ink); }
.kcard-badges { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 9px; }
.kbadge { font-size: 11px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; }
.kbadge.overdue { color: var(--red); font-weight: 700; } .kbadge.done { color: var(--green); }
.kcard-members { display: flex; gap: 4px; margin-top: 9px; justify-content: flex-end; }
.kavatar { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #2a3142; }
.kcompose { background: var(--surface); border: 1.5px solid var(--brand); border-radius: var(--radius-sm); padding: 9px; box-shadow: var(--shadow); }
.kcompose textarea, .kcompose input { width: 100%; border: 0; box-shadow: none; padding: 3px; font-size: 14px; resize: none; }
.kcompose textarea:focus, .kcompose input:focus { box-shadow: none; }

/* ============ POPOVER ============ */
.kpop { position: absolute; z-index: 90; width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; }
.kpop-h { font-weight: 700; font-size: 13px; padding: 4px 8px 8px; }
.kpop-sub { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 8px 8px 4px; }
.kpop-row { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: transparent; border-radius: var(--radius-xs); font-size: 13.5px; color: var(--ink-2); cursor: pointer; font-family: var(--font); text-transform: capitalize; }
.kpop-row:hover { background: var(--hover); color: var(--ink); }
.kpop-row.on { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.kpop-row.danger { color: var(--red); }
.kpop-sws { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 8px 8px; }
.kpop-sw, .cm-sw { width: 30px; height: 30px; border-radius: 7px; border: 0; cursor: pointer; box-shadow: var(--shadow-xs); background-size: cover; }
.kpop-sw:hover, .cm-sw:hover { transform: scale(1.08); }
.kpop-sw.wide { width: 100%; height: 30px; }
.kpop-input { width: calc(100% - 16px); margin: 4px 8px; }

/* ============ CARD MODAL ============ */
.cm-back { position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(3px); z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; }
.cm { width: 100%; max-width: 760px; background: var(--surface); border-radius: 13px; box-shadow: var(--shadow-lg); overflow: hidden; animation: cm-in .16s ease-out; }
@keyframes cm-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.cm-loading { padding: 48px; text-align: center; color: var(--muted); }
.cm-top { display: flex; align-items: flex-start; gap: 12px; padding: 22px 24px 8px; }
.cm-title { font-size: 20px; font-weight: 800; letter-spacing: -.025em; flex: 1; outline: none; border-radius: 8px; padding: 2px 6px; }
.cm-title[contenteditable]:focus { box-shadow: 0 0 0 3px var(--brand-soft); }
.cm-close { background: transparent; border: 0; font-size: 28px; line-height: 1; color: var(--muted); cursor: pointer; }
.cm-grid { display: grid; grid-template-columns: 1fr 156px; gap: 20px; padding: 10px 24px 28px; }
.cm-side { display: flex; flex-direction: column; gap: 7px; }
.cm-act { justify-content: flex-start; }
.cm-sec { margin-bottom: 18px; }
.cm-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.cm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cm-chip { border: 0; height: 30px; border-radius: var(--pill); padding: 0 13px; font-size: 12px; font-weight: 700; color: #14223b; cursor: pointer; opacity: .45; }
.cm-chip.on { opacity: 1; } .cm-chip.add { background: var(--sunken); color: var(--ink-2); opacity: 1; }
.cm-mem { border: 1px solid var(--line); background: var(--surface); border-radius: var(--pill); padding: 3px 9px 3px 3px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; opacity: .55; }
.cm-mem.on { opacity: 1; border-color: var(--brand); }
.cm-done { font-size: 13px; color: var(--ink-2); margin-left: 8px; }
.cm-fields { display: flex; flex-direction: column; gap: 10px; }
.cm-field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.cm-field input[type=checkbox] { width: auto; }
.cm-checklist { margin-bottom: 14px; }
.cm-chk-bar { height: 7px; background: var(--sunken); border-radius: var(--pill); overflow: hidden; margin: 5px 0 9px; }
.cm-chk-bar span { display: block; height: 100%; background: var(--green); border-radius: var(--pill); }
.cm-item { display: flex; align-items: center; gap: 6px; }
.cm-item label { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; margin: 0 0 4px; cursor: pointer; flex: 1; }
.cm-item .checked { text-decoration: line-through; color: var(--muted); }
.cm-item-convert { background: transparent; border: 0; color: var(--muted); cursor: pointer; }
.cm-comment { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.cm-comment-body { font-size: 14px; margin-top: 3px; }
.cm-addcomment textarea { margin-bottom: 6px; }
.cm-att { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 3px 0; }
.cm-x { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; }
.cm-acts { display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 640px){ .cm-grid { grid-template-columns: 1fr; } }

/* ============ CALENDAR ============ */
.cal-month { font-weight: 700; font-size: 15px; min-width: 130px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-dow { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--muted); text-align: center; padding-bottom: 4px; }
.cal-cell { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); min-height: 96px; padding: 7px; }
.cal-cell.empty { background: transparent; border: 0; }
.cal-cell.today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.cal-day { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.cal-card { display: block; font-size: 11.5px; font-weight: 600; padding: 3px 7px; border-radius: 6px; margin-bottom: 4px; background: var(--brand-soft); color: var(--brand); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-card.overdue { background: var(--red-bg); color: var(--red); } .cal-card.done { background: var(--green-bg); color: var(--green); }

/* ============ PLANS / DASHBOARD ============ */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(216px, 1fr)); gap: 16px; }
.plan-card { display: flex; flex-direction: column; }
.plan-card.current { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), var(--shadow); }
.plan-card h3 { font-size: 18px; }
.plan-price { font-size: 32px; font-weight: 800; letter-spacing: -.03em; margin: 12px 0; }
.plan-feats { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.plan-feats li { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.plan-feats .ico { color: var(--green); }
.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; margin-bottom: 22px; }
.dash-stat { text-align: center; padding: 20px 14px; }
.dash-n { font-size: 32px; font-weight: 800; letter-spacing: -.03em; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px){ .dash-grid { grid-template-columns: 1fr; } }
.dash-row { display: flex; align-items: center; gap: 12px; padding: 5px 0; }
.dash-lbl { width: 120px; font-size: 13px; color: var(--ink-2); flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-track { flex: 1; height: 10px; background: var(--sunken); border-radius: var(--pill); overflow: hidden; }
.dash-track span { display: block; height: 100%; border-radius: var(--pill); }
.dash-num { width: 28px; text-align: right; font-size: 13px; font-weight: 700; color: var(--muted); }

/* ============ TOASTS / MODAL ============ */
#toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; font-size: 13px; font-weight: 600; padding: 10px 18px; border-radius: var(--pill); box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: .2s; }
.toast.show { opacity: 1; transform: none; }
.bm-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 70; padding: 20px; }
.bm-backdrop[hidden] { display: none; }
.bm-modal { max-width: 440px; width: 100%; animation: cm-in .16s ease-out; }
.bm-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 860px) {
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 70; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  html.side-open .sidebar { transform: none; }
  .mobile-side-btn { display: inline-flex; position: fixed; top: 12px; left: 12px; z-index: 50; background: var(--surface); box-shadow: var(--shadow); }
  html.side-open .side-scrim { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 60; }
  .main-pad { padding: 60px 18px 60px; }
  body.board-page .main-pad { padding: 0; }
}

/* ============ THEME ============ */
:root { color-scheme: light; }
.theme-toggle .ico:nth-child(2) { display: none; }
[data-theme="dark"] .theme-toggle .ico:nth-child(1) { display: none; }
[data-theme="dark"] .theme-toggle .ico:nth-child(2) { display: inline-block; }
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0e13; --surface: #15181f; --raised: #1b1f28; --sunken: #1a1d25; --side-bg: #101319;
  --ink: #eef1f6; --ink-2: #b3bccb; --muted: #7b8494; --faint: #5e6675;
  --line: #262b35; --line-2: #1d212a; --hover: #1e222b;
  --green:#46c984; --green-bg:#10271c; --amber:#d6a142; --amber-bg:#2a2113; --red:#f0857c; --red-bg:#2c1715;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 2px 6px -2px rgba(0,0,0,.5); --shadow-md: 0 10px 28px -10px rgba(0,0,0,.65); --shadow-lg: 0 28px 60px -20px rgba(0,0,0,.75);
}
[data-theme="dark"] .btn.primary { background: #eef1f6; color: #0f172a; border-color: #eef1f6; }
[data-theme="dark"] .klist { background: rgba(21,24,31,.86); border-color: rgba(255,255,255,.06); }
[data-theme="dark"] .klabel, [data-theme="dark"] .kavatar { color: #0f172a; }

/* Editable table */
.tbl-row { display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line-2); }
.tbl-row:last-child { border-bottom: 0; }
.tbl-head { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--muted); }
.tbl-title { flex: 2; }
.tbl-due { flex: 1; }
.tbl-done { flex: none; width: 40px; text-align: center; }
.tbl-open { flex: none; }
input.tbl-edit { border: 1px solid transparent; background: transparent; box-shadow: none; border-radius: 8px; padding: 6px 8px; }
input.tbl-edit:hover { border-color: var(--line); }
input.tbl-edit:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-soft); }

/* Timeline / Gantt */
.tl { position: relative; }
.tl-head { position: relative; height: 24px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.tl-month { position: absolute; top: 0; font-size: 11px; font-weight: 700; color: var(--muted); transform: translateX(2px); }
.tl-rows { display: flex; flex-direction: column; gap: 6px; }
.tl-row { display: flex; align-items: center; gap: 12px; }
.tl-label { width: 200px; flex: none; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-track { position: relative; flex: 1; height: 26px; background: var(--sunken); border-radius: var(--radius-sm); }
.tl-bar { position: absolute; top: 4px; height: 18px; border-radius: var(--pill); background: linear-gradient(135deg,var(--brand),var(--brand-2)); min-width: 8px; }
.tl-bar.overdue { background: linear-gradient(135deg,#f87171,#dc3a32); }
.tl-bar.done { background: linear-gradient(135deg,#34d399,#15924b); }

/* @mention autocomplete + md toolbar */
.mention-pop { position: absolute; z-index: 95; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 5px; min-width: 200px; }
.mention-item { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.mention-item.active, .mention-item:hover { background: var(--brand-soft); color: var(--brand); }
.md-toolbar { display: flex; gap: 4px; margin-bottom: 6px; }
.md-toolbar button { width: 30px; height: 28px; border: 1px solid var(--line); background: var(--surface); border-radius: 7px; cursor: pointer; font-weight: 700; font-size: 13px; }
.md-toolbar button:hover { background: var(--hover); }
.md-toolbar .grow { flex: 1; }
.md-preview { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; font-size: 14px; min-height: 84px; background: var(--sunken); }
.md-preview h2 { font-size: 17px; margin: 10px 0 4px; } .md-preview h3 { font-size: 15px; margin: 8px 0 4px; }
.md-preview ul { padding-left: 18px; margin: 4px 0; }

/* ---------- View switcher (Board / List / Gallery) ---------- */
.view-seg { display: inline-flex; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--pill); padding: 2px; gap: 2px; }
.view-seg-btn { border: none; background: transparent; color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 600; padding: 5px 13px; border-radius: var(--pill); cursor: pointer; }
.view-seg-btn:hover { color: var(--ink); }
.view-seg-btn.on { background: var(--surface); color: var(--brand); box-shadow: 0 1px 3px rgba(15,23,42,.16); }

/* ---------- List view ---------- */
.list-view { display: flex; flex-direction: column; gap: 20px; padding: 4px 2px 40px; max-width: 1000px; }
.lv-group-head { display: flex; align-items: center; gap: 8px; margin: 0 2px 8px; }
.lv-group-name { font-weight: 700; letter-spacing: -.01em; }
.lv-group-count { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--sunken); border-radius: var(--pill); padding: 1px 9px; }
.lv-rows { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.lv-row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line-2); cursor: pointer; transition: background .1s; }
.lv-row:last-child { border-bottom: none; }
.lv-row:hover { background: var(--hover); }
.lv-labels { display: inline-flex; gap: 3px; flex: none; }
.lv-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.lv-title { flex: 1; font-weight: 550; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lv-meta { display: inline-flex; gap: 10px; flex: none; align-items: center; }
.lv-mem { display: inline-flex; gap: 3px; flex: none; }
.lv-mem .kavatar { width: 22px; height: 22px; font-size: 10px; }
.lv-empty { padding: 16px; }

/* ---------- Gallery view ---------- */
.gallery-view { display: flex; flex-direction: column; gap: 22px; padding: 4px 2px 40px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.gtile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: 0 1px 2px rgba(15,23,42,.12); cursor: pointer; overflow: hidden; transition: box-shadow .12s, transform .05s; }
.gtile:hover { box-shadow: 0 6px 18px -6px rgba(15,23,42,.32); transform: translateY(-1px); }
.gtile-cover { height: 96px; background-size: cover; background-position: center; }
.gtile-body { padding: 11px 13px; display: flex; flex-direction: column; gap: 7px; }
.gtile-title { font-weight: 600; line-height: 1.35; }

/* ---------- Card modal: open-as-page link ---------- */
.cm-page { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; color: var(--muted); font-size: 17px; text-decoration: none; flex: none; }
.cm-page:hover { background: var(--hover); color: var(--ink); }

/* ---------- Card-as-page (Notion-style doc) ---------- */
.doc { max-width: 820px; margin: 0 auto; padding-bottom: 60px; }
.doc-crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); margin-bottom: 18px; }
.doc-crumb a { color: var(--ink-2); font-weight: 600; } .doc-crumb a:hover { color: var(--brand); }
.doc-sep { color: var(--faint); }
.doc-board { margin-left: auto; }
.doc-cover { height: 180px; border-radius: var(--radius); margin-bottom: 20px; background-size: cover; background-position: center; }
.doc-title { font-size: 34px; font-weight: 800; letter-spacing: -.035em; line-height: 1.15; outline: none; border-radius: 8px; margin-bottom: 20px; }
.doc-title[contenteditable]:focus { background: var(--brand-soft); box-shadow: 0 0 0 2px var(--brand-border); }
.doc-props { display: flex; flex-direction: column; gap: 2px; margin-bottom: 26px; }
.doc-prop { display: flex; align-items: center; gap: 12px; padding: 5px 0; }
.doc-prop-k { width: 96px; flex: none; color: var(--muted); font-size: 13px; font-weight: 600; }
.doc-prop-v { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.doc-prop-v input[type=datetime-local] { font: inherit; font-size: 13px; border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 4px 8px; background: var(--surface); color: var(--ink); }
.doc-done { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--ink-2); }
.doc-labels { display: inline-flex; gap: 5px; flex-wrap: wrap; }
.doc-section { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 20px; }
.doc-h2 { font-size: 16px; font-weight: 700; margin-bottom: 12px; letter-spacing: -.01em; }
.doc-body { font-size: 15.5px; line-height: 1.7; color: var(--ink); }
.doc-body h2 { font-size: 21px; margin: 18px 0 6px; } .doc-body h3 { font-size: 17px; margin: 14px 0 4px; }
.doc-body ul, .doc-body ol { padding-left: 22px; margin: 6px 0; }
.doc-body p { margin: 8px 0; } .doc-body a { color: var(--brand); }
.doc-body code { background: var(--sunken); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.doc-edit textarea, .doc-desc { width: 100%; font-family: var(--font); font-size: 15px; line-height: 1.6; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; background: var(--surface); color: var(--ink); resize: vertical; }
.doc-edit-btn { margin-top: 10px; }
.doc-chk { margin-bottom: 16px; }
.doc-chk-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.doc-chk-bar { height: 6px; background: var(--sunken); border-radius: var(--pill); overflow: hidden; margin-bottom: 8px; }
.doc-chk-bar span { display: block; height: 100%; background: var(--brand); border-radius: var(--pill); transition: width .2s; }
.doc-chk-item { display: flex; align-items: center; gap: 9px; padding: 5px 2px; font-size: 14.5px; cursor: pointer; }
.doc-chk-item .checked { text-decoration: line-through; color: var(--muted); }
.doc-atts { display: flex; flex-direction: column; gap: 6px; }
.doc-att { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 14px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-xs); width: fit-content; }
.doc-att:hover { background: var(--hover); color: var(--brand); }
.doc-addcomment { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; margin-bottom: 18px; }
.doc-addcomment textarea { width: 100%; font-family: var(--font); font-size: 14.5px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface); color: var(--ink); resize: vertical; }
.doc-comments { display: flex; flex-direction: column; gap: 16px; }
.doc-comment { display: flex; gap: 10px; }
.doc-comment-head { margin-bottom: 2px; }
.doc-comment-body { font-size: 14.5px; line-height: 1.6; }
.doc-activity { margin-top: 26px; }
.doc-activity summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; }
.doc-act { padding: 4px 0; }
@media (max-width: 640px){ .doc-prop { align-items: flex-start; flex-direction: column; gap: 3px; } .doc-prop-k { width: auto; } .doc-title { font-size: 27px; } }

/* ---------- Read-view markdown (md_to_html output) ---------- */
.doc-body h1 { font-size: 25px; font-weight: 800; letter-spacing: -.02em; margin: 18px 0 8px; }
.doc-body blockquote { border-left: 3px solid var(--brand); padding-left: 13px; color: var(--ink-2); margin: 10px 0; }
.doc-body pre { background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 12px 14px; overflow: auto; margin: 10px 0; }
.doc-body pre code { background: none; padding: 0; font-size: 13px; }
.doc-body hr { border: none; border-top: 2px solid var(--line); margin: 16px 0; }
.doc-body img.md-img { max-width: 100%; border-radius: var(--radius-sm); margin: 8px 0; }
.doc-body ul.md-todo { list-style: none; padding-left: 2px; }
.doc-body li.md-task { display: flex; align-items: center; gap: 8px; }
.doc-body li.md-task .md-done { text-decoration: line-through; color: var(--muted); }

/* ---------- Block editor ---------- */
#be-save { font-size: 12px; color: var(--muted); text-align: right; height: 15px; margin-bottom: 2px; }
.be { margin-top: 2px; min-height: 40px; }
.be-block { display: flex; align-items: flex-start; gap: 4px; position: relative; padding: 1px 0; border-radius: 4px; }
.be-handle { opacity: 0; cursor: grab; color: var(--faint); width: 16px; flex: none; text-align: center; line-height: 1.8; user-select: none; font-size: 12px; }
.be-block:hover .be-handle { opacity: .55; }
.be-handle:active { cursor: grabbing; }
.be-ce { flex: 1; min-width: 0; outline: none; line-height: 1.7; padding: 2px 3px; border-radius: 4px; }
.be-ce:empty:before { content: attr(data-ph); color: var(--faint); pointer-events: none; }
.be-ce code { background: var(--sunken); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.be-ce a { color: var(--brand); }
.be-h1 .be-ce { font-size: 25px; font-weight: 800; letter-spacing: -.02em; line-height: 1.25; }
.be-h2 .be-ce { font-size: 20px; font-weight: 750; letter-spacing: -.015em; }
.be-h3 .be-ce { font-size: 17px; font-weight: 700; }
.be-marker { flex: none; min-width: 20px; text-align: right; color: var(--ink-2); line-height: 1.7; user-select: none; padding-top: 2px; }
.be-quote .be-ce { border-left: 3px solid var(--brand); padding-left: 12px; color: var(--ink-2); }
.be-check { flex: none; width: 16px; height: 16px; margin-top: 6px; }
.be-ce.be-checked { text-decoration: line-through; color: var(--muted); }
.be-codearea { flex: 1; font-family: ui-monospace,'SF Mono',Menlo,monospace; font-size: 13px; line-height: 1.55; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 10px 12px; resize: none; color: var(--ink); }
.be-hr { flex: 1; border: none; border-top: 2px solid var(--line); margin: 11px 0; }
.be-image-wrap { flex: 1; cursor: pointer; }
.be-image-wrap img { max-width: 100%; border-radius: var(--radius-sm); display: block; }
.be-img-add { width: 100%; color: var(--muted); background: var(--sunken); border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 14px; cursor: pointer; font: inherit; }
.be-block.be-drop { box-shadow: 0 -2px 0 var(--brand); }
.be-block.be-dragging { opacity: .4; }
.be-slash { position: absolute; z-index: 95; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 5px; width: 260px; max-height: 304px; overflow: auto; }
.be-slash-item { display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left; border: 0; background: transparent; border-radius: var(--radius-xs); padding: 7px 10px; cursor: pointer; font-family: var(--font); }
.be-slash-item.on, .be-slash-item:hover { background: var(--hover); }
.be-slash-l { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.be-slash-h { font-size: 11.5px; color: var(--muted); }
.be-slash-empty { padding: 8px 10px; color: var(--muted); font-size: 13px; }

/* ---------- Per-board custom CSS editor ---------- */
.css-back { position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(3px); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 5vh 16px; }
.css-modal { width: 100%; max-width: 680px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow-lg); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.css-head { display: flex; flex-direction: column; gap: 3px; }
.css-area { width: 100%; min-height: 280px; font-family: ui-monospace,'SF Mono',Menlo,monospace; font-size: 13px; line-height: 1.55; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--sunken); color: var(--ink); resize: vertical; }
.css-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Board theme picker (in board menu) ---------- */
.kpop-themes { display: flex; flex-wrap: wrap; gap: 5px; padding: 2px 4px 4px; }
.kpop-theme { flex: 1 1 calc(50% - 5px); border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 8px; border-radius: var(--radius-xs); cursor: pointer; }
.kpop-theme:hover { background: var(--hover); color: var(--ink); }
.kpop-theme.on { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
