:root {
  --text: #172b4d;
  --muted: #5e6c84;
  --list-bg: #f1f2f4;
  --card-bg: #ffffff;
  --accent: #0c66e4;
  --danger: #c9372c;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.4; color: var(--text);
  background: #0079bf; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
input, textarea, select { border: 2px solid #dfe1e6; border-radius: 4px; padding: 6px 8px; background: #fff; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; width: 100%; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
#app { height: 100%; display: flex; flex-direction: column; }

/* ---------- buttons */
.btn { padding: 6px 12px; border-radius: 4px; background: rgba(255,255,255,.2); color: #fff; font-weight: 500; white-space: nowrap; }
.btn:hover { background: rgba(255,255,255,.3); }
.primary { background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 4px; font-weight: 600; }
.primary:hover { background: #0055cc; }
.subtle { background: #e2e4e9; color: var(--text); padding: 8px 12px; border-radius: 4px; font-weight: 500; }
.subtle:hover { background: #d5d8de; }
.danger { color: var(--danger); }
.danger.subtle:hover { background: #ffd5d2; }
.icon-btn { width: 28px; height: 28px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; color: inherit; opacity: .7; }
.icon-btn:hover { background: rgba(0,0,0,.1); opacity: 1; }

/* ---------- top bar */
.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: rgba(0,0,0,.28); color: #fff; flex: none; min-height: 48px; backdrop-filter: blur(6px); }
.topbar .spacer { flex: 1; }
.topbar .board-title { font-weight: 700; font-size: 18px; padding: 4px 8px; border-radius: 4px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw; }
.topbar .board-title:hover { background: rgba(255,255,255,.2); }
.topbar input.inline-edit { font-weight: 700; font-size: 18px; color: var(--text); max-width: 45vw; }
.topbar .filter { width: 200px; border-color: transparent; background: rgba(255,255,255,.2); color: #fff; }
.topbar .filter::placeholder { color: rgba(255,255,255,.75); }
.topbar .filter:focus { background: #fff; color: var(--text); }
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 4px; }
.brand:hover { background: rgba(255,255,255,.2); }
.brand-mark { width: 20px; height: 20px; border-radius: 4px; background: #fff; position: relative; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; top: 4px; width: 5px; border-radius: 1px; background: #0079bf; }
.brand-mark::before { left: 4px; height: 12px; }
.brand-mark::after { left: 11px; height: 8px; }

/* ---------- login */
.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { background: #fff; padding: 36px 32px; border-radius: 10px; width: 100%; max-width: 360px; box-shadow: 0 12px 32px rgba(0,0,0,.3); text-align: center; }
.login h1 { margin: 12px 0 4px; font-size: 22px; }
.login p { margin: 0 0 20px; }
.login input { width: 100%; padding: 10px; margin-bottom: 12px; font-size: 15px; }
.login .primary { width: 100%; padding: 10px; font-size: 15px; }
.login .error { color: var(--danger); min-height: 20px; margin-bottom: 8px; font-size: 13px; }
.login .brand-mark { width: 48px; height: 48px; border-radius: 10px; background: #0079bf; margin: 0 auto; }
.login .brand-mark::before, .login .brand-mark::after { background: #fff; top: 10px; width: 11px; }
.login .brand-mark::before { left: 9px; height: 28px; }
.login .brand-mark::after { left: 27px; height: 18px; }

/* ---------- home */
.home { flex: 1; overflow: auto; padding: 24px; max-width: 1100px; width: 100%; margin: 0 auto; }
.home h2 { color: #fff; margin: 0 0 14px; font-size: 18px; }
.boards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.board-tile { display: flex; flex-direction: column; justify-content: space-between; height: 104px; border-radius: 8px; color: #fff; padding: 10px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: filter .15s; }
.board-tile:hover { filter: brightness(1.1); }
.tile-title { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile-meta { font-size: 12px; opacity: .85; }
.board-tile.new { background: rgba(255,255,255,.18); align-items: center; justify-content: center; cursor: pointer; border: 2px dashed rgba(255,255,255,.4); font-weight: 600; }
.board-tile.new:hover { background: rgba(255,255,255,.28); }
.new-board-form { background: #fff; border-radius: 8px; padding: 12px; color: var(--text); grid-column: span 2; max-width: 400px; }
.new-board-form input { width: 100%; margin-bottom: 10px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.swatch { width: 36px; height: 28px; border-radius: 4px; border: 2px solid transparent; }
.swatch.on { border-color: #172b4d; box-shadow: inset 0 0 0 2px #fff; }
.form-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- board */
.board { flex: 1; display: flex; overflow-x: auto; overflow-y: hidden; padding: 12px; gap: 12px; align-items: flex-start; -webkit-overflow-scrolling: touch; }
.list { background: var(--list-bg); border-radius: 12px; width: 272px; flex: none; max-height: 100%; display: flex; flex-direction: column; box-shadow: 0 1px 1px rgba(9,30,66,.25); }
.list-header { padding: 8px 8px 4px 12px; display: flex; align-items: center; gap: 4px; cursor: grab; }
.list-title { font-weight: 600; flex: 1; padding: 4px 6px; border-radius: 4px; cursor: text; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-header input.inline-edit { flex: 1; font-weight: 600; min-width: 0; }
.list-header .count { font-size: 12px; color: var(--muted); padding: 0 4px; }
.cards { flex: 1; overflow-y: auto; padding: 4px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 10px; }
.card { background: var(--card-bg); border-radius: 8px; padding: 8px 10px; box-shadow: 0 1px 1px rgba(9,30,66,.25); cursor: pointer; border: 2px solid transparent; }
.card:hover { border-color: #388bff; }
.card-title { word-wrap: break-word; }
.card-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.label { height: 8px; min-width: 40px; border-radius: 4px; font-size: 12px; font-weight: 600; line-height: 16px; }
.label.named { height: 16px; padding: 0 8px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--muted); }
.badge { padding: 1px 6px; border-radius: 4px; background: #f1f2f4; }
.badge.due.soon { background: #f5cd47; color: #172b4d; }
.badge.due.today { background: #f5cd47; color: #172b4d; }
.badge.due.overdue { background: #eb5a46; color: #fff; }
.badge.complete { background: #4bce97; color: #fff; }
.ghost { opacity: .35; }
.dragging { transform: rotate(3deg); }
.composer { padding: 6px 8px 8px; }
.add-card-btn { width: 100%; text-align: left; padding: 6px 8px; border-radius: 6px; color: var(--muted); }
.add-card-btn:hover { background: #dcdfe4; color: var(--text); }
.composer textarea { display: block; margin-bottom: 8px; box-shadow: 0 1px 1px rgba(9,30,66,.25); border-color: transparent; }
.composer-actions { display: flex; gap: 4px; align-items: center; }
.add-list { width: 272px; flex: none; background: rgba(255,255,255,.22); border-radius: 12px; padding: 10px 12px; color: #fff; cursor: pointer; font-weight: 500; }
.add-list:hover { background: rgba(255,255,255,.3); }
.add-list-form { width: 272px; flex: none; background: var(--list-bg); border-radius: 12px; padding: 8px; }
.add-list-form input { width: 100%; margin-bottom: 8px; }

/* ---------- popover / menu */
.popover { position: fixed; z-index: 40; background: #fff; border-radius: 8px; box-shadow: 0 8px 24px rgba(9,30,66,.3); min-width: 200px; padding: 6px; color: var(--text); }
.menu-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 4px; }
.menu-item:hover { background: #f1f2f4; }
.menu-item.danger:hover { background: #ffd5d2; }
.menu-section { padding: 6px 10px; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.menu-swatches { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 10px 8px; }

/* ---------- modal */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-start; justify-content: center; padding: 48px 12px; overflow-y: auto; z-index: 50; }
.modal { background: #f4f5f7; border-radius: 12px; width: 100%; max-width: 760px; padding: 20px 24px 24px; position: relative; box-shadow: 0 16px 40px rgba(0,0,0,.4); }
.modal .close { position: absolute; top: 12px; right: 12px; font-size: 18px; }
.modal h2 { margin: 0 32px 4px 0; font-size: 20px; padding: 4px 6px; border-radius: 4px; cursor: text; word-break: break-word; }
.modal h2:hover { background: #e2e4e9; }
.modal input.inline-edit.title { font-size: 20px; font-weight: 700; width: calc(100% - 32px); }
.modal .in-list { margin: 0 6px 20px; font-size: 13px; }
.modal-grid { display: grid; grid-template-columns: minmax(0, 1fr) 170px; gap: 20px; }
.section { margin-bottom: 22px; }
.section h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.section h4 .link { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-width: 52px; height: 32px; border-radius: 4px; padding: 0 12px; font-weight: 600; opacity: .45; border: 2px solid transparent; }
.chip.on { opacity: 1; border-color: #172b4d; }
.chip:hover { opacity: .85; }
.label-names { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.label-names label { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.label-names input { flex: 1; min-width: 0; padding: 4px 6px; }
.label-dot { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.due-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.desc textarea { min-height: 96px; background: #fff; }
.desc .save-row { margin-top: 8px; display: flex; gap: 8px; align-items: center; }
.progress-row { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.progress { flex: 1; height: 8px; background: #dfe1e6; border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .2s; }
.progress.full > div { background: #4bce97; }
.check-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 4px; }
.check-item:hover { background: #e9ebef; }
.check-item input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.check-item .text { flex: 1; word-break: break-word; }
.check-item.done .text { text-decoration: line-through; color: var(--muted); }
.check-item .icon-btn { visibility: hidden; }
.check-item:hover .icon-btn { visibility: visible; }
.check-add { display: flex; gap: 6px; margin-top: 6px; }
.check-add input { flex: 1; }
.side h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; }
.side .subtle, .side select { display: block; width: 100%; text-align: left; margin-bottom: 8px; }
.meta { font-size: 12px; color: var(--muted); margin-top: 12px; }

/* ---------- archived list */
.archived-item { display: flex; align-items: center; gap: 8px; padding: 8px; background: #fff; border-radius: 6px; margin-bottom: 6px; }
.archived-item .t { flex: 1; }

/* ---------- toast */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: #172b4d; color: #fff; padding: 10px 16px; border-radius: 6px; opacity: 0; transition: all .2s; z-index: 100; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- mobile */
@media (max-width: 640px) {
  .topbar { padding: 8px; gap: 6px; }
  .topbar .filter { width: 110px; }
  .topbar .board-title { max-width: 38vw; font-size: 16px; }
  .board { padding: 8px; gap: 8px; scroll-snap-type: x mandatory; }
  .list, .add-list, .add-list-form { width: 84vw; scroll-snap-align: start; }
  .modal-grid { grid-template-columns: 1fr; }
  .modal { padding: 16px; }
  .overlay { padding: 16px 8px; }
  .new-board-form { grid-column: span 1; }
  .home { padding: 16px; }
}
