:root {
  --teal-dark:  #0F6E56;
  --teal-mid:   #1D9E75;
  --teal-light: #E1F5EE;
  --teal-pale:  #f0faf6;
  --gold:       #BA7517;
  --gold-light: #FAEEDA;
  --rose:       #A8463A;
  --rose-light: #F8E6E2;
  --charcoal:   #2C2C2A;
  --mid-gray:   #5F5E5A;
  --soft-gray:  #8A8984;
  --light-gray: #F1EFE8;
  --white:      #ffffff;
  --border: rgba(15, 110, 86, 0.15);
  --border-strong: rgba(15, 110, 86, 0.35);
  --shadow: 0 1px 2px rgba(44, 44, 42, 0.06), 0 2px 8px rgba(44, 44, 42, 0.04);
  --shadow-lift: 0 8px 24px rgba(44, 44, 42, 0.14);
  --overlay: rgba(44, 44, 42, 0.35);
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans:  'DM Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-weight: 400;
  color: var(--charcoal);
  background: var(--teal-pale);
  font-size: 14px;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Buttons & inputs ---------- */
.btn {
  border: 1.5px solid transparent;
  border-radius: 100px;
  padding: 0.5rem 1.1rem;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary { background: var(--teal-dark); color: var(--white); }
.btn-primary:hover { background: var(--teal-mid); }
.btn-ghost { background: transparent; border-color: var(--teal-dark); color: var(--teal-dark); }
.btn-ghost:hover { background: var(--teal-light); }
.btn-quiet { background: transparent; color: var(--mid-gray); padding: 0.4rem 0.8rem; }
.btn-quiet:hover { background: var(--light-gray); color: var(--charcoal); }
.btn-danger { background: transparent; border-color: var(--rose); color: var(--rose); }
.btn-danger:hover { background: var(--rose-light); }
.btn-sm { padding: 0.3rem 0.8rem; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: default; }

.input, select.input, textarea.input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  background: var(--white);
  outline: none;
}
.input:focus { border-color: var(--teal-dark); box-shadow: 0 0 0 3px var(--teal-light); }
textarea.input { resize: vertical; min-height: 90px; line-height: 1.5; }
label.field { display: block; margin-bottom: 0.9rem; }
label.field > span {
  display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--mid-gray); margin-bottom: 0.3rem; font-weight: 500;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.9rem; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.25rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: inherit; }
.brand img { height: 30px; width: auto; }
.brand-title { font-family: var(--font-serif); font-size: 1.45rem; font-weight: 500; }
.brand-title em { color: var(--teal-dark); font-style: italic; }
.toolbar { display: flex; align-items: center; gap: 0.5rem; flex: 1; flex-wrap: wrap; }
.toolbar .search { max-width: 240px; border-radius: 100px; padding-left: 0.9rem; }
.toolbar select.input { width: auto; border-radius: 100px; padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 100px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 0.38rem 0.8rem; cursor: pointer; font-size: 0.85rem; color: var(--mid-gray); }
.seg button.on { background: var(--teal-dark); color: var(--white); }
.user-menu { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--teal-light); color: var(--teal-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 500; flex-shrink: 0;
}
.avatar.empty { background: var(--light-gray); color: var(--soft-gray); }

/* ---------- Board ---------- */
.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(270px, 1fr);
  gap: 1rem;
  padding: 1.25rem;
  overflow-x: auto;
  height: calc(100vh - 58px);
  align-items: start;
}
.column {
  background: var(--light-gray);
  border-radius: 16px;
  display: flex; flex-direction: column;
  max-height: 100%;
  min-height: 160px;
}
.column[data-status="triage"] { background: var(--gold-light); }
.col-head { padding: 0.85rem 1rem 0.5rem; display: flex; align-items: baseline; gap: 0.5rem; }
.col-title { font-family: var(--font-serif); font-size: 1.25rem; font-weight: 500; }
.col-count { color: var(--soft-gray); font-size: 0.8rem; }
.col-hint { padding: 0 1rem 0.5rem; font-size: 0.78rem; color: var(--mid-gray); margin-top: -0.3rem; }
.col-add { margin-left: auto; border: 0; background: transparent; color: var(--mid-gray); cursor: pointer; font-size: 1.2rem; line-height: 1; padding: 0 0.3rem; border-radius: 6px; }
.col-add:hover { background: var(--white); color: var(--teal-dark); }
.cards { padding: 0.25rem 0.6rem 0.8rem; overflow-y: auto; flex: 1; min-height: 60px; }
.cards.drop-target { outline: 2px dashed var(--teal-mid); outline-offset: -4px; border-radius: 12px; }
.col-foot { padding: 0 1rem 0.8rem; }
.col-foot button { font-size: 0.8rem; }

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow);
  cursor: grab;
  border-left: 3px solid transparent;
  transition: box-shadow 0.15s, transform 0.15s;
}
.card:hover { box-shadow: var(--shadow-lift); }
.card.dragging { opacity: 0.4; }
.card.p0 { border-left-color: var(--rose); }
.card.p1 { border-left-color: var(--gold); }
.card-top { display: flex; align-items: center; gap: 0.35rem; margin-bottom: 0.3rem; font-size: 0.72rem; color: var(--soft-gray); }
.card-title { font-weight: 500; font-size: 0.92rem; word-wrap: break-word; }
.card-meta { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.5rem; font-size: 0.75rem; color: var(--mid-gray); flex-wrap: wrap; }
.card-meta .spacer { flex: 1; }
.placeholder { height: 52px; border: 2px dashed var(--teal-mid); border-radius: 12px; margin-bottom: 0.5rem; background: var(--teal-light); }

.badge { display: inline-flex; align-items: center; border-radius: 100px; padding: 0.05rem 0.5rem; font-size: 0.7rem; font-weight: 500; }
.kind-bug { background: var(--rose-light); color: var(--rose); }
.kind-request { background: var(--teal-light); color: var(--teal-dark); }
.kind-task { background: var(--light-gray); color: var(--mid-gray); }
.prio { font-weight: 500; }
.prio-0 { background: var(--rose); color: var(--white); }
.prio-1 { background: var(--gold-light); color: var(--gold); }
.prio-2 { background: var(--teal-light); color: var(--teal-dark); }
.prio-3 { background: var(--light-gray); color: var(--soft-gray); }
.label { background: var(--light-gray); color: var(--mid-gray); }
.due.overdue { color: var(--rose); font-weight: 500; }
.icon-mail::before { content: "✉"; }
.icon-comment::before { content: "💬"; filter: grayscale(1); font-size: 0.7rem; }

.empty-col { text-align: center; color: var(--soft-gray); font-size: 0.8rem; padding: 1rem 0.5rem; }

/* ---------- Drawer & modal ---------- */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(560px, 100vw);
  background: var(--white);
  box-shadow: var(--shadow-lift);
  display: flex; flex-direction: column;
}
.drawer-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 0.6rem; }
.drawer-head .id { color: var(--soft-gray); font-size: 0.85rem; }
.drawer-head .close { margin-left: auto; }
.drawer-body { padding: 1.25rem; overflow-y: auto; flex: 1; }
.title-input {
  width: 100%; border: 1px solid transparent; border-radius: 10px; padding: 0.3rem 0.5rem; margin: 0 -0.5rem 0.8rem;
  font-family: var(--font-serif); font-size: 1.6rem; font-weight: 500; line-height: 1.2; resize: none; background: transparent;
}
.title-input:hover { border-color: var(--border); }
.title-input:focus { border-color: var(--teal-dark); outline: none; background: var(--white); }
.section-label {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--teal-dark);
  margin: 1.5rem 0 0.7rem; font-weight: 500;
}
.section-label::before { content: ""; width: 24px; height: 1px; background: var(--teal-dark); }
.email-box { border: 1px solid var(--border); border-radius: 12px; background: var(--teal-pale); padding: 0.8rem 0.9rem; font-size: 0.85rem; }
.email-box .from { color: var(--mid-gray); }
.email-box .subject { font-weight: 500; margin: 0.2rem 0 0.5rem; }
.email-box pre { white-space: pre-wrap; font-family: inherit; margin: 0; max-height: 260px; overflow-y: auto; color: var(--mid-gray); }
.comment { padding: 0.6rem 0; border-bottom: 1px solid var(--light-gray); }
.comment-head { font-size: 0.78rem; color: var(--soft-gray); margin-bottom: 0.2rem; }
.comment-head b { color: var(--charcoal); font-weight: 500; }
.comment-body { white-space: pre-wrap; word-wrap: break-word; }
.activity { font-size: 0.78rem; color: var(--soft-gray); padding: 0.2rem 0; }
.drawer-foot { padding: 0.9rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: 0.5rem; align-items: center; }
.saved-note { font-size: 0.8rem; color: var(--teal-mid); margin-left: auto; opacity: 0; transition: opacity 0.2s; }
.saved-note.show { opacity: 1; }

.modal {
  position: fixed; z-index: 50; left: 50%; top: 8vh; transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px)); max-height: 84vh; overflow-y: auto;
  background: var(--white); border-radius: 20px; box-shadow: var(--shadow-lift); padding: 1.5rem;
}
.modal h2 { font-family: var(--font-serif); font-weight: 400; font-size: 1.8rem; margin: 0 0 1rem; }
.modal h2 em { color: var(--teal-dark); }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; }
.form-error { color: var(--rose); font-size: 0.85rem; min-height: 1.2em; margin: 0.2rem 0 0.5rem; }

.team-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0; border-bottom: 1px solid var(--light-gray); flex-wrap: wrap; }
.team-row .who { flex: 1; min-width: 180px; }
.team-row .who small { color: var(--soft-gray); display: block; }
.link-box { background: var(--teal-pale); border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem; font-size: 0.78rem; word-break: break-all; margin: 0.5rem 0; }

.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--charcoal); color: var(--white); padding: 0.6rem 1.1rem; border-radius: 100px; font-size: 0.85rem;
  box-shadow: var(--shadow-lift);
}
.toast.error { background: var(--rose); }

/* ---------- Login ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--white); border: 1px solid var(--border);
  border-radius: 20px; padding: 2.25rem 2rem; box-shadow: var(--shadow);
}
.auth-card img { height: 40px; display: block; margin: 0 auto 1rem; }
.auth-card h1 { font-family: var(--font-serif); font-weight: 400; text-align: center; font-size: 2rem; margin: 0 0 0.3rem; }
.auth-card h1 em { color: var(--teal-dark); }
.auth-card p.lead { text-align: center; color: var(--mid-gray); margin: 0 0 1.5rem; font-weight: 300; }
.auth-card .btn { width: 100%; padding: 0.7rem; margin-top: 0.4rem; }

@media (max-width: 900px) {
  .toolbar .search { max-width: 160px; }
}
@media (max-width: 600px) {
  .topbar { padding: 0.6rem 1rem; }
  .board { padding: 1rem; grid-auto-columns: 82vw; height: auto; min-height: calc(100vh - 110px); }
  .field-row { grid-template-columns: 1fr; }
  .brand-title { font-size: 1.2rem; }
}

.comment-new { margin-top: 0.7rem; }
label.field.check { display: flex; gap: 0.5rem; align-items: center; }
.btn-block { display: block; width: 100%; text-align: center; text-decoration: none; padding: 0.7rem; margin-top: 0.4rem; }
