:root {
  --bg: #e6ebf1;
  --ink: #1b2533;
  --ink-soft: #566376;
  --paper: #ffffff;
  --line: #c9d2dd;
  --cobalt: #2e57d9;
  --cobalt-dark: #2446b3;
  --high: #c8413a;
  --medium: #b57a0c;
  --low: #3b8c62;

  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }


body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-family: var(--display); margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }

/* ---------- Header ---------- */
.topbar {
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 24px 28px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}
.topbar h1 {
  font-size: clamp(30px, 4.4vw, 46px);
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.lede { margin: 10px 0 0; color: var(--ink-soft); max-width: 52ch; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--cobalt); color: #fff; }
.btn-primary:hover { background: var(--cobalt-dark); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: transparent; color: var(--high); border-color: color-mix(in srgb, var(--high) 40%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--high) 8%, transparent); }
.btn-small {
  padding: 5px 10px;
  font-size: 13px;
  border-radius: 6px;
  background: var(--bg);
  border-color: var(--line);
}
.btn-small:hover { border-color: var(--ink-soft); }
.topbar .btn-primary { padding: 13px 22px; font-size: 16px; }

/* ---------- Board ---------- */
.board {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px 64px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.column {
  border-top: 4px solid var(--col, var(--ink-soft));
  background: color-mix(in srgb, var(--paper) 45%, transparent);
  border-radius: 4px 4px 14px 14px;
  padding: 14px 14px 18px;
}
.column[data-status="todo"] { --col: var(--ink); }
.column[data-status="progress"] { --col: var(--cobalt); }
.column[data-status="done"] { --col: var(--low); }

.column-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 2px 4px 14px;
}
.column-head h2 { font-size: 19px; }
.count {
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  color: var(--col);
}

.dropzone {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 160px;
  border-radius: 10px;
  transition: background-color .15s, box-shadow .15s;
}
.dropzone.over {
  background: color-mix(in srgb, var(--col) 10%, transparent);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--col) 45%, transparent);
}

.empty {
  margin: 0;
  padding: 28px 12px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
}

/* ---------- Ticket (card shaped like a torn ticket stub) ---------- */
.ticket-wrap {
  filter: drop-shadow(0 1px 1px rgb(27 37 51 / .08)) drop-shadow(0 4px 10px rgb(27 37 51 / .06));
  cursor: grab;
}
.ticket-wrap.dragging { opacity: .45; cursor: grabbing; }

.ticket {
  --stub: 38px;
  --notch: 8px;
  background: var(--paper);
  border-radius: 10px;
  -webkit-mask:
    radial-gradient(circle var(--notch) at 0 var(--stub), #0000 97%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle var(--notch) at 100% var(--stub), #0000 97%, #000) right / 51% 100% no-repeat;
          mask:
    radial-gradient(circle var(--notch) at 0 var(--stub), #0000 97%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle var(--notch) at 100% var(--stub), #0000 97%, #000) right / 51% 100% no-repeat;
}

.ticket-stub {
  height: var(--stub);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background:
    linear-gradient(90deg, var(--line) 50%, transparent 0) left bottom / 8px 1.5px repeat-x;
}
.ticket-no {
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  color: var(--ink-soft);
}
.prio {
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.prio::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.prio-high { color: var(--high); }
.prio-medium { color: var(--medium); }
.prio-low { color: var(--low); }

.ticket-body { padding: 12px 16px 14px; }

.ticket-title {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  font-weight: 600;
  font-size: 15.5px;
  line-height: 1.35;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.ticket-title:hover { color: var(--cobalt); text-decoration: underline; text-underline-offset: 3px; }

.ticket-desc {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.ticket-meta {
  margin: 10px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 13px;
  color: var(--ink-soft);
}
.overdue { color: var(--high); font-weight: 600; }

.ticket-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.column[data-status="done"] .ticket-title { color: var(--ink-soft); }

/* ---------- Dialog ---------- */
dialog {
  width: min(560px, calc(100vw - 32px));
  border: 0;
  border-radius: 14px;
  padding: 0;
  color: var(--ink);
  box-shadow: 0 24px 60px rgb(27 37 51 / .25);
  margin: auto;
}
dialog::backdrop { background: rgb(27 37 51 / .45); }
dialog[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

dialog form { padding: 24px; }
dialog h2 { font-size: 24px; margin-bottom: 18px; }
.hint { margin: -8px 0 16px; color: var(--ink-soft); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; flex: 1; }
.field > span { font-weight: 600; font-size: 14px; }
.field small { font-weight: 400; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--cobalt);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cobalt) 20%, transparent);
}
.field-row { display: flex; gap: 12px; }

.form-error { color: var(--high); min-height: 1.5em; margin: 0 0 8px; font-size: 14px; }

.dialog-actions { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }

#ticketDialog:not(.editing) .edit-only { display: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--high); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; }
  .dropzone { min-height: 80px; }
}
@media (max-width: 560px) {
  .topbar { flex-direction: column; align-items: stretch; padding-top: 28px; }
  .field-row { flex-direction: column; gap: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
