:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --ink: #2f3a36;
  --muted: #7c8a83;
  --accent: #5b8a72;
  --accent-dark: #466b58;
  --line: #e4e0d7;
  --amber: #f3ecdc;
  --danger: #b4503f;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}
button { cursor: pointer; font: inherit; }
input, select, textarea { font: inherit; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--line); padding: 22px 18px; display: flex; flex-direction: column;
}
.brand { font-size: 22px; margin: 0 0 18px; color: var(--accent-dark); }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 6px; }
.boards-group { border: none; }
.boards-group > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center;
  justify-content: space-between; padding: 4px 6px; border-radius: 6px;
  margin-bottom: 4px;
}
.boards-group > summary::-webkit-details-marker { display: none; }
.boards-group > summary:hover { background: var(--bg); }
.boards-group > summary::after {
  content: '▾'; font-size: 14px; color: var(--ink); font-weight: bold;
}
.boards-group:not([open]) > summary::after { content: '▸'; }
.boards { display: flex; flex-direction: column; gap: 2px; }
.board-link, .todo-link {
  text-decoration: none; color: var(--ink); padding: 7px 10px; border-radius: 7px; font-size: 15px;
}
.board-link:hover, .todo-link:hover { background: var(--bg); }
.board-link.active, .todo-link.active { background: var(--accent); color: #fff; }
.add-board { margin: 8px 0 16px; }
.add-board input { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; }
.todo-link { margin-top: 6px; }
.logout { margin-top: auto; color: var(--muted); text-decoration: none; font-size: 13px; padding-top: 16px; }
.logout:hover { color: var(--danger); }

.content { flex: 1; padding: 28px 32px; overflow-x: auto; }

/* header */
.board-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.board-header h2 { margin: 0; font-size: 26px; }
.board-actions { display: flex; gap: 8px; }
.inline { display: inline; }
.board-actions input { padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; }

/* add bars */
.add-card-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.add-card-bar input[name="title"], .add-card-bar input[name="text"] { flex: 1 1 220px; }
.add-card-bar input, .add-card-bar select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.file-label { display: inline-flex; align-items: center; gap: 4px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 7px; font-size: 13px; color: var(--muted); }
.file-label input { display: none; }

button { background: var(--accent); color: #fff; border: none; padding: 8px 14px; border-radius: 7px; }
button:hover { background: var(--accent-dark); }
button.danger { background: transparent; color: var(--danger); padding: 4px 8px; }
button.danger:hover { background: #f7e9e6; }

/* columns */
.columns { display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); gap: 16px; }
.column { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.column h3 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.column .count { background: var(--bg); border-radius: 10px; padding: 1px 8px; font-size: 12px; margin-left: 4px; }

.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card-title { font-weight: 600; }
.card-done { padding: 7px 11px; opacity: .72; }
.card-done > summary { font-weight: 500; font-size: 13px; cursor: pointer; list-style: none; }
.card-done > summary::before { content: '▶ '; font-size: 10px; color: var(--muted); }
.card-done[open] > summary::before { content: '▼ '; }
.card-done[open] { opacity: 1; }
.card-notes { font-size: 13px; color: var(--muted); margin-top: 4px; white-space: pre-wrap; }
.card-img { max-width: 100%; border-radius: 6px; margin-top: 8px; }
.card-controls { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.card-controls select { padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; }
.edit summary { font-size: 12px; color: var(--accent-dark); cursor: pointer; list-style: none; }
.edit form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.edit input, .edit textarea { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.edit textarea { min-height: 60px; resize: vertical; }

/* todo */
.todo-list { list-style: none; padding: 0; max-width: 720px; }
.todo-item { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.todo-item.done .todo-text { text-decoration: line-through; color: var(--muted); }
.todo-text { flex: 1; }
.todo-note { color: var(--muted); font-style: italic; }
.check { background: transparent; color: var(--accent); border: 1px solid var(--line); border-radius: 50%; width: 30px; height: 30px; padding: 0; }
.todo-item.done .check { background: var(--accent); color: #fff; }
.empty { color: var(--muted); background: transparent; border: 1px dashed var(--line); }

/* open card button */
.card-open-btn {
  font-size: 12px; color: var(--accent-dark); background: transparent;
  padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px;
}
.card-open-btn:hover { background: var(--bg); }

/* card dialog / shadowbox */
.card-dialog {
  border: none; border-radius: 14px; padding: 0; width: min(680px, 95vw);
  max-height: 90vh; box-shadow: 0 12px 50px rgba(0,0,0,.18); overflow: hidden;
}
.card-dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg-inner { padding: 28px 30px; overflow-y: auto; max-height: 90vh; }
.dlg-close {
  position: absolute; top: 16px; right: 18px;
  background: transparent; color: var(--muted); border: none;
  font-size: 18px; padding: 4px 8px; line-height: 1;
}
.dlg-close:hover { color: var(--danger); background: transparent; }
.dlg-title { margin: 0 0 4px; font-size: 22px; padding-right: 32px; }

/* card detail page */
.card-detail { max-width: 680px; }
.back-link { color: var(--accent-dark); text-decoration: none; font-size: 14px; }
.back-link:hover { text-decoration: underline; }
.cd-header { display: flex; align-items: baseline; gap: 12px; margin: 12px 0 6px; flex-wrap: wrap; }
.cd-header h2 { margin: 0; font-size: 24px; }
.cd-col-badge { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 2px 10px; color: var(--muted); white-space: nowrap; }
.cd-notes { color: var(--ink); white-space: pre-wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 10px 0; }
.cd-image { max-width: 100%; border-radius: 8px; margin: 10px 0; }
.cd-row { display: flex; align-items: center; gap: 8px; margin: 14px 0; }
.cd-row label { font-size: 14px; color: var(--muted); }
.cd-row select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; }
.cd-edit { margin: 14px 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.cd-edit summary { font-size: 14px; color: var(--accent-dark); cursor: pointer; list-style: none; }
.cd-edit form { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.cd-edit label { font-size: 13px; color: var(--muted); }
.cd-edit input, .cd-edit textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; }
.cd-edit textarea { min-height: 80px; resize: vertical; }
.cd-comments { margin-top: 24px; }
.cd-comments h3 { margin: 0 0 14px; font-size: 16px; }
.comment { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.comment-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.comment-text { white-space: pre-wrap; }
.no-comments { color: var(--muted); font-size: 14px; }
.add-comment { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.add-comment textarea { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; min-height: 140px; resize: vertical; width: 100%; }
.add-comment button { align-self: flex-start; }

/* ── mobile ──────────────────────────────────────────────────────── */
.mobile-bar { display: none; }
.sidebar-overlay { display: none; }

@media (max-width: 720px) {
  /* mobile top bar */
  .mobile-bar {
    display: flex; align-items: center; gap: 12px;
    background: var(--panel); border-bottom: 1px solid var(--line);
    padding: 12px 16px; position: sticky; top: 0; z-index: 50;
  }
  .hamburger {
    background: transparent; color: var(--ink); border: 1px solid var(--line);
    border-radius: 8px; padding: 6px 12px; font-size: 18px; line-height: 1;
  }
  .mobile-brand { font-size: 18px; font-weight: 700; color: var(--accent-dark); }

  /* sidebar becomes a slide-in drawer */
  .layout { display: block; }
  .sidebar {
    position: fixed; top: 0; left: -260px; width: 260px; height: 100vh;
    z-index: 200; transition: left .22s ease; box-shadow: 4px 0 20px rgba(0,0,0,.12);
    overflow-y: auto;
  }
  body.sidebar-open .sidebar { left: 0; }
  body.sidebar-open .sidebar-overlay {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 199;
  }

  /* board links — bigger tap targets */
  .board-link, .todo-link { padding: 12px 14px; font-size: 17px; }
  .add-board input { padding: 11px 12px; font-size: 16px; }

  /* content */
  .content { padding: 16px; }
  .board-header h2 { font-size: 20px; }
  .board-header { margin-bottom: 14px; }

  /* add card bar stacks */
  .add-card-bar { flex-direction: column; }
  .add-card-bar input, .add-card-bar select { width: 100%; font-size: 16px; padding: 12px; }
  .add-card-bar button { width: 100%; padding: 13px; font-size: 16px; }

  /* columns scroll horizontally */
  .columns {
    display: flex; overflow-x: auto; gap: 12px;
    padding-bottom: 12px; scroll-snap-type: x mandatory;
  }
  .column { min-width: 280px; scroll-snap-align: start; flex-shrink: 0; }

  /* bigger card controls */
  .card-controls select { padding: 8px 10px; font-size: 15px; }
  .card-open-btn { padding: 8px 14px; font-size: 14px; }
  button.danger { padding: 8px 12px; font-size: 16px; }

  /* dialog full screen on mobile */
  .card-dialog {
    width: 100%; max-width: 100%; height: 100%; max-height: 100%;
    border-radius: 0; margin: 0;
  }
  .dlg-inner { max-height: 100vh; }
  .add-comment textarea { font-size: 16px; }
}

/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 36px 32px; width: 320px; text-align: center; box-shadow: 0 8px 30px rgba(0,0,0,.06); }
.login-card h1 { margin: 0 0 18px; color: var(--accent-dark); }
.login-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; }
.login-card button { width: 100%; padding: 11px; }
.error { color: var(--danger); font-size: 14px; margin: 0 0 12px; }
