/* Shipyard styles. Colours are tokens; dark mode follows the system setting. */
:root {
  --bg: #f5f6f8; --surface: #fff; --surface-2: #f0f2f5; --border: #e1e4ea;
  --text: #1c2230; --muted: #6a7385; --accent: #2f5bea; --accent-soft: #e6ecfd;
  --done: #1f9d61; --doing: #c98a06; --danger: #d0343a; --overdue: #d0343a;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --surface: #1a1f27; --surface-2: #222833; --border: #2d3441;
    --text: #e6e9ef; --muted: #8e97a8; --accent: #6b8cff; --accent-soft: #232d4a;
    --done: #3cc283; --doing: #e3a72a; --danger: #ff6b70; --overdue: #ff6b70;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 4px 0; display: flex; align-items: center; gap: 10px; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 6px; }
p { margin: 4px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; min-width: 0; }
.error { color: var(--danger); min-height: 1.2em; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* ---- controls */
button, .button {
  font: inherit; border: 1px solid transparent; border-radius: 7px; padding: 7px 12px;
  cursor: pointer; background: var(--surface-2); color: var(--text); display: inline-flex; align-items: center; gap: 6px;
}
.button:hover { text-decoration: none; }
button.primary { background: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.ghost, .ghost.button { background: transparent; border-color: var(--border); }
button.ghost:hover, .ghost.button:hover { background: var(--surface-2); }
button.small, .button.small { padding: 3px 8px; font-size: 12px; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); }
.danger { color: var(--danger) !important; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; padding: 7px 9px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type="checkbox"] { width: auto; accent-color: var(--done); }
textarea { resize: vertical; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); }
.pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); text-transform: capitalize; }
.pill.doing { background: color-mix(in srgb, var(--doing) 18%, transparent); color: var(--doing); }

/* ---- layout */
.topbar {
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { color: var(--muted); padding: 6px 10px; border-radius: 6px; font-weight: 500; }
.topbar nav a.active, .topbar nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.brand { font-weight: 800; letter-spacing: .5px; color: var(--text); font-size: 17px; }
.brand.big { font-size: 28px; color: var(--accent); text-align: center; margin-bottom: 16px; }
.who { display: flex; gap: 12px; align-items: center; color: var(--muted); }
main { max-width: 1180px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head-actions { display: flex; align-items: center; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card-actions { display: flex; gap: 8px; margin-top: 12px; }
.meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; margin-top: 8px; }
.project-card { color: var(--text); display: block; }
.project-card:hover { text-decoration: none; border-color: var(--accent); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.progress span { display: block; height: 100%; background: var(--done); border-radius: 99px; }
.progress.wide { width: 160px; margin: 0; }

/* ---- login */
.login-wrap { display: grid; place-items: center; min-height: 80vh; }
.login { width: min(360px, 100%); padding: 28px; }
.login button { width: 100%; justify-content: center; }

/* ---- rows (team, my tasks) */
.list-card { padding: 4px 0; }
.row, .row-link { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.row:last-child, .row-link:last-child { border-bottom: 0; }
.row-link:hover { background: var(--surface-2); text-decoration: none; }
.row.inactive { opacity: .55; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none;
}
.avatar.small { width: 22px; height: 22px; font-size: 10px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.status-dot.doing { background: var(--doing); }
.date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.overdue .date { color: var(--overdue); font-weight: 600; }

/* ---- project page */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.tabs { display: flex; background: var(--surface-2); border-radius: 8px; padding: 3px; }
.tabs a { padding: 5px 14px; border-radius: 6px; color: var(--muted); font-weight: 600; }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs a:hover { text-decoration: none; }
.lists { display: flex; flex-direction: column; gap: 14px; }
.task-list { padding: 0; }
.task-list > header { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.task-list.closed > header { border-bottom: 0; }
.task-list h2 { flex: 1; }
.count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 2px 8px; border-radius: 99px; }
.caret { background: none; padding: 0 4px; color: var(--muted); }
.task-rows { padding: 4px 0 8px; border-radius: 0 0 var(--radius) var(--radius); }
.task-rows.drop-target, .column.drop-target { background: var(--accent-soft); }
.task-row { display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-left: 3px solid transparent; }
.task-row:hover { background: var(--surface-2); }
.task-row.selected { border-left-color: var(--accent); background: var(--accent-soft); }
.task-row.dragging, .board-card.dragging { opacity: .4; }
.task-row.done .task-title { color: var(--muted); text-decoration: line-through; }
.task-title { background: none; padding: 2px 0; text-align: left; flex: 1; min-width: 0; color: var(--text); border-radius: 0; }
.assignee { font-size: 12px; color: var(--muted); background: var(--surface-2); padding: 1px 8px; border-radius: 99px; white-space: nowrap; }
.completed-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 10px 14px 4px; }
.add-task { border: 0; background: transparent; margin: 4px 14px 0; width: calc(100% - 28px); padding: 6px 2px; }
.add-task:focus { outline: 0; border-bottom: 1px solid var(--accent); border-radius: 0; }
.add-list { display: flex; gap: 8px; }
.add-list input { max-width: 340px; }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-items {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 170px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 4px;
  display: flex; flex-direction: column;
}
.menu-items button { background: none; text-align: left; padding: 7px 10px; }
.menu-items button:hover { background: var(--surface-2); }

/* ---- board */
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.column { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 200px; }
.column > header { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 10px; }
.column.doing > header h2 { color: var(--doing); }
.column.done > header h2 { color: var(--done); }
.cards { display: flex; flex-direction: column; gap: 8px; }
.board-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; cursor: grab; box-shadow: var(--shadow); }
.board-card:hover { border-color: var(--accent); }
.board-title { font-weight: 500; }
.board-card .date { margin-top: 6px; }

/* ---- drawer */
.drawer {
  position: fixed; top: 52px; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 15;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -6px 0 24px rgba(0, 0, 0, .08);
  padding: 16px 20px 24px; overflow-y: auto;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.drawer-title { font-size: 18px; font-weight: 600; border-color: transparent; padding: 4px 6px; margin-bottom: 10px; }
.drawer-title:hover { border-color: var(--border); }
.drawer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.drawer h3 { margin-top: 8px; }
.drawer-actions { display: flex; justify-content: space-between; margin-top: 10px; }
.comment { border-top: 1px solid var(--border); padding: 10px 0; }
.comment-head { display: flex; gap: 8px; align-items: baseline; }
.comment p { white-space: pre-wrap; overflow-wrap: anywhere; }
.comments { margin-bottom: 10px; }

/* On wide screens the page makes room for the drawer instead of sitting under it. */
@media (min-width: 900px) {
  main:has(.drawer) { max-width: none; margin-right: 440px; }
}

/* ---- dialog + toast */
.modal { border: 1px solid var(--border); border-radius: 12px; padding: 0; background: var(--surface); color: var(--text); width: min(440px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(10, 15, 25, .45); }
.dialog-form { padding: 20px; }
.dialog-form h2 { font-size: 17px; margin-bottom: 14px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; transition: .2s; z-index: 50; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: #fff; }

/* ---- phones */
@media (max-width: 720px) {
  main { padding: 16px; }
  .topbar { padding: 0 16px; gap: 12px; height: auto; min-height: 52px; flex-wrap: wrap; }
  .topbar nav { order: 3; flex-basis: 100%; overflow-x: auto; padding-bottom: 6px; }
  .who span { display: none; }
  .board { grid-template-columns: 1fr; }
  .task-row { flex-wrap: wrap; }
  .task-row .date { margin-left: 26px; }
  .progress.wide { width: 90px; }
  .drawer { top: 0; }
  .add-list { flex-direction: column; }
}
