:root {
  --bg: #f6f7f9;
  --surface: #eef0f3;
  --card: #ffffff;
  --border: #e3e6ea;
  --text: #1b1f23;
  --muted: #6a7480;
  --primary: #2f6fed;
  --primary-d: #245ad0;
  --shadow: 0 1px 2px rgba(16, 22, 33, .06), 0 1px 3px rgba(16, 22, 33, .08);
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
.hidden { display: none !important; }

/* ---- buttons / inputs ---- */
.btn {
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  cursor: pointer; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: #f3f5f8; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: rgba(0,0,0,.05); }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn-danger { color: #c0392b; border-color: #f0c4bd; background: #fdecea; }
input, select, textarea { font: inherit; }
input[type=text], input:not([type]), input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47,111,237,.25); border-color: var(--primary); }

/* ---- login screen ---- */
.login-screen {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #e9eefb, var(--bg));
}
.login-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); padding: 36px 40px; text-align: center; min-width: 320px;
}
.login-mark, .brand-mark {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  background: var(--primary); color: #fff; font-weight: 800; border-radius: 12px; font-size: 20px;
}
.login-card h1 { margin: 16px 0 4px; font-size: 22px; }
.login-sub { color: var(--muted); margin: 0 0 22px; }
.login-card #gbtn { display: flex; justify-content: center; min-height: 44px; }
.login-error { color: #c0392b; min-height: 18px; margin: 12px 0 0; font-size: 13px; }

/* ---- app shell ---- */
.app { max-width: 1500px; margin: 0 auto; padding: 14px 18px 32px; }
#topbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.brand .brand-mark { width: 30px; height: 30px; font-size: 15px; border-radius: 8px; }
#topbar .select { width: auto; min-width: 160px; }
#topbar .search { width: auto; min-width: 200px; }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 12px; }
.tabs { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.tabs .tab { border: none; background: transparent; padding: 5px 12px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px; color: var(--muted); }
.tabs .tab.active { background: #fff; color: var(--text); box-shadow: var(--shadow); font-weight: 600; }

/* ---- capacity ---- */
.cap { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.cap .agent { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #e7f0ff; color: #234; border: 1px solid #d4e2fb; }
.cap .agent.fail { background: #fdecea; border-color: #f3c8c2; }
.cap .agent.cool { background: #fef3df; border-color: #f5dcab; }

/* ---- board ---- */
.board-grid { display: grid; grid-template-columns: repeat(7, minmax(180px, 1fr)); gap: 12px; }
.col { background: var(--surface); border-radius: var(--radius); padding: 10px; min-height: 140px; }
.col h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin: 2px 4px 10px;
  color: var(--muted); display: flex; justify-content: space-between;
}
.col h3 .count { background: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--border);
  border-radius: 8px; padding: 10px; margin-bottom: 10px; box-shadow: var(--shadow); cursor: pointer;
  transition: transform .08s, box-shadow .12s;
}
.card:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(16,22,33,.10); }
.card.t-bug { border-left-color: #e5534b; }
.card.t-idea { border-left-color: #d99a2b; }
.card.t-story { border-left-color: #2f6fed; }
.card.t-epic { border-left-color: #7a5af5; }
.card.humanonly { border-left-color: #b0379a; }
.card .id { color: var(--muted); font-size: 12px; font-weight: 600; }
.card .title { font-weight: 600; margin: 2px 0 6px; }
.card .summary { color: var(--muted); font-size: 12.5px; margin: 0 0 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .pills { display: flex; gap: 4px; flex-wrap: wrap; }
.card .thumb-row { display: flex; gap: 4px; margin-top: 8px; }
.card .thumb-row img { width: 34px; height: 34px; object-fit: cover; border-radius: 5px; border: 1px solid var(--border); }
.card .foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.card .moves { margin-top: 8px; display: flex; gap: 4px; flex-wrap: wrap; }

.pill { display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: #eef0f3; color: #44505c; }
.pill.idea { background: #fbeccf; color: #7a5310; }
.pill.bug { background: #fbdcd9; color: #8a2b22; }
.pill.pts { background: #dde9ff; color: #1f49a6; }
.pill.hardstop { background: #f7c5c0; color: #8a2b22; }
.pill.blocked { background: #fbe3c0; color: #7a4d10; }
.pill.ver { background: #e6e0fb; color: #4b3a9a; }
.pill.epic { background: #ede7ff; color: #5b3ee0; }

/* ---- dialogs ---- */
.dlg { border: none; border-radius: 14px; padding: 0; box-shadow: 0 24px 60px rgba(10,15,25,.28); width: 560px; max-width: 94vw; }
.dlg-wide { width: 760px; }
.dlg::backdrop { background: rgba(15, 20, 30, .45); backdrop-filter: blur(2px); }
.dlg form, .dlg > .dlg-head, .dlg > .d-meta, .dlg > .d-summary, .dlg > .d-section { padding-left: 22px; padding-right: 22px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding-top: 18px; padding-bottom: 6px; }
.dlg-title { margin: 0; font-size: 18px; font-weight: 700; }
.dlg-head-actions { display: flex; gap: 6px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin: 18px 0 0; padding: 14px 0 20px; border-top: 1px solid var(--border); }
.fld { display: block; margin: 12px 0 0; font-weight: 600; font-size: 13px; }
.fld input, .fld select, .fld textarea, .fld .EasyMDEContainer { font-weight: 400; margin-top: 5px; }
.fld .hint, .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row .fld { flex: 1; min-width: 150px; }
.chk { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; }
.chk input { width: auto; }

/* ---- markdown body ---- */
.md-body { line-height: 1.6; }
.md-body h1, .md-body h2, .md-body h3 { line-height: 1.3; margin: 1em 0 .4em; }
.md-body h1 { font-size: 20px; } .md-body h2 { font-size: 17px; } .md-body h3 { font-size: 15px; }
.md-body ul, .md-body ol { padding-left: 1.4em; margin: .4em 0; }
.md-body li { margin: .2em 0; }
.md-body code { background: #f0f2f5; padding: .1em .35em; border-radius: 4px; font-size: 90%; }
.md-body pre { background: #0d1117; color: #e6edf3; padding: 12px; border-radius: 8px; overflow: auto; }
.md-body pre code { background: none; padding: 0; }
.md-body blockquote { margin: .5em 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.md-body img, .md-img { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.md-body table { border-collapse: collapse; } .md-body td, .md-body th { border: 1px solid var(--border); padding: 4px 8px; }

/* ---- detail view ---- */
.d-meta { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 4px; padding-bottom: 6px; }
.d-summary { background: #f3f7ff; border: 1px solid #d9e6ff; border-radius: 10px; padding: 12px 14px; margin: 8px 22px 0; font-size: 14px; }
.d-summary:empty { display: none; }
.d-section { margin-top: 18px; }
.d-section h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.rel-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; margin: 0 6px 6px 0; font-size: 12.5px; cursor: pointer; }
.rel-chip b { color: var(--muted); }
.review-note { border-left: 3px solid var(--border); padding: 4px 0 4px 12px; margin: 8px 0; }
.review-note .rn-head { font-size: 12px; color: var(--muted); }
.review-note.approve { border-left-color: #2faa54; }
.review-note.request-changes { border-left-color: #e5534b; }

/* ---- attachments ---- */
.att-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 13px; }
.att-add { cursor: pointer; }
.att-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.att-grid:empty::after { content: "No attachments yet."; color: var(--muted); font-weight: 400; font-size: 12.5px; }
.att-item { position: relative; width: 96px; }
.att-item img { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; background: #f0f2f5; }
.att-item .att-name { font-size: 10.5px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-item .att-del {
  position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 999px;
  border: 1px solid var(--border); background: #fff; color: #c0392b; cursor: pointer; font-size: 12px; line-height: 1;
  box-shadow: var(--shadow); display: none;
}
.att-item:hover .att-del { display: block; }

/* ---- relation picker ---- */
.relpick { position: relative; }
.relpick .chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.relpick .chip { display: inline-flex; align-items: center; gap: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px 4px 2px 9px; font-size: 12px; font-weight: 400; }
.relpick .chip button { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 13px; line-height: 1; padding: 0 2px; }
.relpick .drop {
  position: absolute; z-index: 30; left: 0; right: 0; margin-top: 3px; background: #fff;
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); max-height: 220px; overflow: auto;
}
.relpick .drop button {
  display: block; width: 100%; text-align: left; border: none; background: none; padding: 7px 10px;
  cursor: pointer; font-size: 13px; font-weight: 400;
}
.relpick .drop button:hover, .relpick .drop button.active { background: #eef3ff; }
.relpick .drop .ri-id { color: var(--muted); font-weight: 600; margin-right: 6px; }

/* ---- EasyMDE: custom glyph toolbar (no Font Awesome dependency) ---- */
.EasyMDEContainer .editor-toolbar button { color: #44505c; }
.editor-toolbar button.mde-bold::after { content: "B"; font-weight: 800; }
.editor-toolbar button.mde-italic::after { content: "I"; font-style: italic; font-weight: 600; }
.editor-toolbar button.mde-heading::after { content: "H"; font-weight: 700; }
.editor-toolbar button.mde-ul::after { content: "• ─"; font-size: 12px; }
.editor-toolbar button.mde-ol::after { content: "1."; font-weight: 700; font-size: 12px; }
.editor-toolbar button.mde-quote::after { content: "❝"; }
.editor-toolbar button.mde-code::after { content: "</>"; font-size: 11px; font-weight: 700; }
.editor-toolbar button.mde-link::after { content: "🔗"; }
.editor-toolbar button.mde-image::after { content: "🖼"; }
.editor-toolbar button.mde-preview::after { content: "👁"; }
.editor-toolbar button[class*="mde-"] { min-width: 30px; }
.EasyMDEContainer .CodeMirror { border-radius: 0 0 8px 8px; min-height: 120px; }
.EasyMDEContainer .editor-toolbar { border-radius: 8px 8px 0 0; }

/* ---- empty state ---- */
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty h2 { margin: 0 0 6px; color: var(--text); font-size: 18px; }
.empty p { margin: 0 auto; max-width: 420px; }

/* ---- admin console ---- */
.admin-users { padding: 8px 22px 22px; display: flex; flex-direction: column; gap: 10px; }
.admin-user { border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.admin-user .au-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.admin-user .au-name { font-weight: 600; }
.admin-user .au-email { color: var(--muted); font-size: 12.5px; }
.admin-user .au-row { display: flex; gap: 12px; align-items: flex-start; margin-top: 10px; flex-wrap: wrap; }
.admin-user .au-row > label { font-size: 12px; font-weight: 600; color: var(--muted); }
.admin-user select { width: auto; min-width: 130px; }
.au-projects { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.au-projects label { display: inline-flex; align-items: center; gap: 5px; font-weight: 400; font-size: 13px; }
.au-projects input { width: auto; }
.admin-user .au-save { margin-left: auto; }
.admin-user.saved { border-color: #b6e3c4; background: #f4fbf6; }

@media (max-width: 1100px) { .board-grid { grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); grid-template-columns: none; overflow-x: auto; } }
