/* ---------- Fonts (self-hosted, no internet needed) ---------- */
@font-face { font-family: "Manrope"; font-weight: 400; font-display: swap; src: url(fonts/manrope-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Manrope"; font-weight: 400; font-display: swap; src: url(fonts/manrope-latin-ext-400-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Manrope"; font-weight: 500; font-display: swap; src: url(fonts/manrope-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Manrope"; font-weight: 500; font-display: swap; src: url(fonts/manrope-latin-ext-500-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Manrope"; font-weight: 600; font-display: swap; src: url(fonts/manrope-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Manrope"; font-weight: 600; font-display: swap; src: url(fonts/manrope-latin-ext-600-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Manrope"; font-weight: 700; font-display: swap; src: url(fonts/manrope-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Manrope"; font-weight: 700; font-display: swap; src: url(fonts/manrope-latin-ext-700-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Manrope"; font-weight: 800; font-display: swap; src: url(fonts/manrope-latin-800-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Manrope"; font-weight: 800; font-display: swap; src: url(fonts/manrope-latin-ext-800-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url(fonts/jetbrains-mono-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url(fonts/jetbrains-mono-latin-ext-500-normal.woff2) format("woff2"); unicode-range: U+0100-02AF; }

/* ---------- Theme ---------- */
:root {
  --bg: #F4F3EF;
  --surface: #FFFFFF;
  --surface-2: #ECEAE4;
  --ink: #17171C;
  --ink-2: #3F3F46;
  --muted: #7A7A85;
  --line: #E3E1DA;
  --accent: #0F6E66;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCEEEA;
  --danger: #D2463A;
  --warn: #C9831F;

  --st-backlog: #A1A1AA;
  --st-in_progress: #E39B2D;
  --st-done: #1F9D6B;
  --st-cancelled: #C9C9CE;

  --p-mihailo: #3367E8;
  --p-sofija: #DD4C78;
  --p-none: #B4B4BB;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-1: 0 1px 2px rgba(23, 23, 28, .05), 0 1px 1px rgba(23, 23, 28, .03);
  --shadow-2: 0 10px 30px rgba(23, 23, 28, .10), 0 2px 6px rgba(23, 23, 28, .06);
  --shadow-3: 0 24px 70px rgba(23, 23, 28, .22);
  --font: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1012;
    --surface: #18191C;
    --surface-2: #222429;
    --ink: #ECECEF;
    --ink-2: #C8C8CE;
    --muted: #8D8D97;
    --line: #2A2C31;
    --accent: #35C2B1;
    --accent-ink: #062A26;
    --accent-soft: #143430;
    --danger: #F06A5D;
    --warn: #F0B04D;
    --st-backlog: #7C7C86;
    --st-cancelled: #4A4B52;
    --p-mihailo: #5C8BFF;
    --p-sofija: #F0709A;
    --p-none: #5A5B63;
    --shadow-1: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 12px 34px rgba(0, 0, 0, .5);
    --shadow-3: 0 24px 80px rgba(0, 0, 0, .65);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 28px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -.02em; white-space: nowrap; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
}
.brand-mark svg { width: 17px; height: 17px; }
.spacer { flex: 1; }

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border-radius: 11px;
}
.segmented button {
  padding: 6px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: background .15s, color .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 11px;
  font-weight: 700; font-size: 14px; letter-spacing: -.005em;
  transition: transform .08s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn svg { width: 16px; height: 16px; }
.kbd { font-family: var(--mono); font-size: 11px; opacity: .65; padding: 1px 5px; border-radius: 5px; background: rgba(255,255,255,.18); }

.me-btn { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 99px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.me-btn:hover { background: var(--surface-2); }

/* ---------- Avatar ---------- */
.avatar {
  --c: var(--p-none);
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-grid; place-items: center; flex: none;
  font-size: 11.5px; font-weight: 800; letter-spacing: .02em;
  color: #fff; background: var(--c);
}
.avatar.sm { width: 22px; height: 22px; font-size: 10.5px; }
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }
.avatar.none { background: transparent; border: 1.5px dashed var(--p-none); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }

/* ---------- Mobile tabs ---------- */
.tabs { display: none; }

/* ---------- Board ---------- */
.board {
  display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr));
  gap: 18px; padding: 22px 28px 40px;
  align-items: start;
  max-width: 1500px; margin: 0 auto;
}
.column {
  border-radius: var(--radius);
  padding: 10px;
  min-height: 160px;
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
  transition: background .15s, box-shadow .15s;
}
.column.drop-target { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.col-head { display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 6px; margin-bottom: 8px; }
.col-head h2 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .01em; }
.col-head .count { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.col-head .add { margin-left: auto; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.col-head .add:hover { background: var(--surface); color: var(--ink); }
.col-head .add svg { width: 15px; height: 15px; }
.cards { display: flex; flex-direction: column; gap: 8px; }
.empty { padding: 22px 8px; text-align: center; font-size: 13px; color: var(--muted); }

.card {
  position: relative;
  background: var(--surface);
  border-radius: 12px;
  padding: 12px 13px 11px;
  box-shadow: var(--shadow-1);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: box-shadow .15s, transform .15s, border-color .15s;
  text-align: left; width: 100%;
  display: block;
}
.card:hover { box-shadow: var(--shadow-2); border-color: transparent; }
.card.dragging { opacity: .45; transform: rotate(-1.5deg); }
.card-title { font-weight: 650; font-size: 14.5px; letter-spacing: -.01em; line-height: 1.35; word-wrap: break-word; }
.card-desc {
  margin-top: 4px; font-size: 13px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-line;
}
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; min-height: 22px; }
.card-meta .avatar { margin-left: auto; }
.card.is-done .card-title { color: var(--muted); }
.card.is-cancelled .card-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--st-cancelled); }
.card.is-cancelled, .card.is-done { box-shadow: none; }

.due {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 11.5px; font-weight: 500;
  padding: 3px 7px; border-radius: 6px;
  background: var(--surface-2); color: var(--ink-2);
}
.due svg { width: 12px; height: 12px; }
.due.soon { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.due.overdue { background: color-mix(in srgb, var(--danger) 13%, transparent); color: var(--danger); }
.due.muted { background: transparent; color: var(--muted); padding-left: 0; }

.fab { display: none; }

/* ---------- Dialogs ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 15, 20, .38);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
  animation: fade .15s ease-out;
}
.sheet {
  width: min(560px, 100%);
  max-height: calc(100dvh - 40px); overflow: auto;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-3);
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.2);
}
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 4px; }
.sheet-head .eyebrow { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.icon-btn { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.sheet-body { padding: 4px 20px 8px; display: flex; flex-direction: column; gap: 18px; }

.title-input {
  width: 100%; border: 0; outline: 0; background: transparent;
  font-size: 22px; font-weight: 750; letter-spacing: -.02em; padding: 6px 0;
}
.title-input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.desc-input {
  width: 100%; min-height: 90px; resize: vertical;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); padding: 11px 13px; outline: 0;
  font-size: 14.5px; line-height: 1.5;
}
.desc-input:focus, .date-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.field-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 12px 0 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  transition: border-color .12s, background .12s;
}
.chip:hover { border-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--surface); }
.chip[aria-pressed="true"] .avatar.none { border-color: var(--surface); color: var(--surface); }
.chip.plain { padding: 0 12px; }

.date-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.date-input {
  height: 34px; padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); outline: 0;
  font-family: var(--mono); font-size: 13px;
}

.sheet-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px 18px; margin-top: 6px;
  border-top: 1px solid var(--line);
}
.sheet-foot .meta { font-size: 12px; color: var(--muted); margin-right: auto; }

/* Who-are-you picker */
.picker { text-align: center; padding: 30px 24px 28px; }
.picker h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.02em; }
.picker p { margin: 0 0 24px; color: var(--muted); }
.picker-options { display: flex; gap: 14px; justify-content: center; }
.picker-options button {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: 150px; padding: 22px 10px 18px; border-radius: 16px;
  border: 1px solid var(--line); font-weight: 700; font-size: 16px;
  transition: border-color .15s, transform .1s, box-shadow .15s;
}
.picker-options button:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.picker-options button:active { transform: scale(.97); }
.picker .logout { margin-top: 22px; font-size: 13px; color: var(--muted); text-decoration: underline; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 60;
  transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-2);
  animation: rise .2s ease-out;
}

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes slideup { from { transform: translateY(100%); } }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .topbar { padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); gap: 10px; flex-wrap: wrap; }
  .topbar .new-btn { display: none; }
  .me-btn .me-name { display: none; }
  .filter { order: 3; width: 100%; }
  .filter button { flex: 1; justify-content: center; }

  .tabs {
    display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
    padding: 10px 16px 4px;
    position: sticky; top: var(--topbar-h, 108px); z-index: 15;
    background: var(--bg);
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button {
    display: inline-flex; align-items: center; gap: 6px; flex: none;
    padding: 8px 10px; border-radius: 99px;
    font-size: 13px; font-weight: 650; color: var(--muted);
  }
  .tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
  .tabs .count { font-family: var(--mono); font-size: 11.5px; opacity: .8; }

  .board { display: block; padding: 10px 16px 110px; }
  .column { display: none; background: none; padding: 0; min-height: 0; }
  .column.active { display: block; }
  .col-head { display: none; }
  .card { padding: 14px 15px 13px; }
  .card-title { font-size: 15.5px; }

  .fab {
    display: grid; place-items: center;
    position: fixed; right: 18px; bottom: max(22px, calc(env(safe-area-inset-bottom) + 10px)); z-index: 30;
    width: 58px; height: 58px; border-radius: 18px;
    background: var(--accent); color: var(--accent-ink);
    box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 45%, transparent);
  }
  .fab svg { width: 24px; height: 24px; }
  .fab:active { transform: scale(.95); }

  .overlay { padding: 0; place-items: end stretch; }
  .sheet {
    width: 100%; border-radius: 22px 22px 0 0;
    max-height: 94dvh;
    padding-bottom: env(safe-area-inset-bottom);
    animation: slideup .24s cubic-bezier(.2, .9, .3, 1);
  }
  .sheet::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
  .title-input { font-size: 20px; }
  .desc-input, .date-input { font-size: 16px; } /* prevents iOS zoom on focus */
  .picker-options button { width: 46%; }
  .kbd { display: none; }
}
