/* The card detail modal. */

/* A second copy of the action bar pinned to the top of the modal. */
.card-modal .modal-actions-top {
  margin-top: 0;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.card-modal .modal-title-input {
  width: 100%;
  font-size: 17px;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 7px 9px;
  margin-bottom: 14px;
  background: transparent;
}
.card-modal .modal-title-input:hover { background: var(--surface-sunk); }
/* Open / Done segmented switch under the title. */
.card-status-switch {
  display: inline-flex;
  margin: -6px 0 14px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.status-opt {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 0;
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.status-opt + .status-opt { border-left: 1px solid var(--line); }
.status-opt:hover:not(:disabled) { background: var(--surface-sunk); color: var(--ink); }
.status-opt.selected { background: var(--surface-alt); color: var(--ink); }
.status-opt.is-done.selected { background: var(--ok-tint); color: var(--ok-ink); }
.card-visibility .card-status-switch { margin: 0 0 6px; }
.card-visibility .hint { margin: 0; font-size: 12px; color: var(--ink-faint); }
.status-opt.is-private.selected { background: var(--warn-tint); color: var(--warn-ink); }
.status-opt:disabled { cursor: default; }
.status-opt:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.card-modal .modal-title-input:focus { outline: none; background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }

.card-grid { display: flex; gap: 20px; align-items: flex-start; }
.card-main { flex: 1; min-width: 0; }
/* The side panel scrolls on its own so long label/assignee lists don't push
   the modal past the viewport. */
.card-side {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  max-height: calc(100vh - 7vh - 120px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

/* Side accordion sections */
.card-acc { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); flex-shrink: 0; }
.card-acc[hidden] { display: none; }
.card-acc-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px;
  font-size: 12px; font-weight: 700; color: var(--ink-soft);
  cursor: pointer; list-style: none; user-select: none;
  border-radius: var(--r-md);
}
.card-acc-head::-webkit-details-marker { display: none; }
.card-acc-head:hover { background: var(--surface-sunk); color: var(--ink); }
.card-acc-head:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.card-acc-head svg { transition: transform var(--t-fast); flex-shrink: 0; }
.card-acc[open] > .card-acc-head svg { transform: rotate(90deg); }
.card-acc[open] > .card-acc-head { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.card-acc-body { padding: 4px 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.card-acc-body > .add-inline { align-self: flex-start; }
.card-side-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 6px 2px 2px; flex-shrink: 0; }

.card-section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.card-section-label .hint { font-weight: 400; text-transform: none; color: var(--ink-faint); }
.card-section + .card-section { margin-top: 18px; }

.desc-rendered {
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 10px;
  font-size: 13px;
  min-height: 42px;
  background: var(--surface-sunk);
  cursor: text;
}
.desc-rendered[role="button"]:hover { background: var(--surface-alt); }
.desc-rendered:not([role="button"]) { cursor: auto; }
.desc-rendered:focus-visible { outline: 2px solid var(--brand); }

/* Rendered Markdown — shared by the description view and the rich-text editor. */
.md-content { line-height: 1.5; overflow-wrap: anywhere; }
.md-content > :first-child { margin-top: 0; }
.md-content > :last-child { margin-bottom: 0; }
.md-content p { margin: 0 0 8px; }
.md-content h1, .md-content h2, .md-content h3,
.md-content h4, .md-content h5, .md-content h6 { margin: 12px 0 6px; font-size: 14px; }
.md-content h1 { font-size: 17px; }
.md-content h2 { font-size: 15px; }
.md-content ul, .md-content ol { margin: 0 0 8px; padding-left: 20px; }
.md-content blockquote { margin: 0 0 8px; padding: 2px 0 2px 10px; border-left: 3px solid var(--line-strong); color: var(--ink-soft); }
.md-content code { background: var(--surface-alt); border-radius: 3px; padding: 1px 4px; font-family: var(--font-mono); font-size: 12px; }
.md-content a { color: var(--brand); text-decoration: underline; }
.md-content img { max-width: 100%; height: auto; vertical-align: bottom; border-radius: var(--r-sm); }
.md-content a.md-img { display: inline-block; max-width: 100%; }
.rte-body img { cursor: default; }
.rte-uploading {
  display: inline-block;
  padding: 6px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--ink-faint);
  font-size: 12px;
  user-select: none;
}

/* Rich-text editor */
.rte {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.rte:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--ring); }
.rte-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 4px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-sunk);
  border-radius: var(--r-md) var(--r-md) 0 0;
}
.rte-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 28px;
  border: none; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-soft);
  cursor: pointer;
}
.rte-btn:hover { background: var(--surface-alt); color: var(--ink); }
.rte-btn[aria-pressed="true"] { background: var(--brand-tint); color: var(--brand); }
.rte-btn:focus-visible { outline: 2px solid var(--brand); }
.rte-sep { width: 1px; height: 18px; margin: 0 4px; background: var(--line); }
.rte-body {
  min-height: 110px; max-height: 50vh; overflow-y: auto;
  padding: 10px 11px;
  font-size: 13px;
  outline: none;
}
.rte-body.is-empty::before {
  content: attr(data-placeholder);
  color: var(--ink-faint);
  pointer-events: none;
  position: absolute;
}

/* Labels */
.label-rows { display: flex; flex-direction: column; gap: 6px; }
.label-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.label-swatch-btn { width: 22px; height: 22px; border: none; border-radius: 5px; flex-shrink: 0; cursor: pointer; }
.label-name {
  flex: 1; min-width: 0; min-height: 30px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 13px;
  background: var(--surface-sunk);
}
.label-name:focus { outline: none; background: var(--surface); border-color: var(--brand); }
.label-del { border: none; background: none; color: var(--ink-faint); cursor: pointer; display: inline-flex; align-items: center; font-size: 12px; padding: 3px 5px; border-radius: 4px; flex-shrink: 0; }
.label-del:hover { background: var(--danger-tint); color: var(--danger); }
.label-row .swatch-grid { flex-basis: 100%; background: var(--surface-sunk); border-radius: var(--r-sm); padding: 6px; }

/* Assignees */
.assignee-rows { display: flex; flex-direction: column; gap: 2px; }
.assignee-row { display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 5px; cursor: pointer; font-size: 13px; }
.assignee-row:hover { background: var(--surface-sunk); }
.assignee-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Cover */
.cover-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.cover-swatch {
  width: 34px; height: 22px;
  border: 2px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  background: var(--surface-alt);
  color: var(--ink-soft);
  font-size: 10px;
}
.cover-swatch.selected { border-color: var(--ink); }
.cover-swatch.cover-none { width: auto; padding: 0 8px; }

/* Dates */
.date-editor { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.date-field { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--ink-soft); width: 100%; }
.date-field .input { min-height: 34px; }
.date-inline { display: flex; gap: 6px; }
.date-inline .input { min-height: 34px; }

/* Move */
.move-editor { display: flex; flex-direction: column; gap: 6px; }
.move-editor select.input { min-height: 34px; }

.card-meta { font-size: 12px; color: var(--ink-soft); }

/* Checklists */
.checklist { margin-bottom: 16px; }
.checklist-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.checklist-title {
  flex: 1; min-width: 0; min-height: 30px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 3px 7px;
  background: var(--surface-sunk);
}
.checklist-title:focus { outline: none; background: var(--surface); border-color: var(--brand); }
.checklist-bar-track { height: 6px; background: var(--surface-alt); border-radius: 999px; overflow: hidden; }
.checklist-bar { height: 100%; background: var(--brand); transition: width var(--t); }
.checklist-pct { font-size: 11px; color: var(--ink-soft); }
.checklist-items { list-style: none; margin: 6px 0; }
.checklist-items li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.checklist-item-text {
  flex: 1; min-width: 0; min-height: 28px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 13px;
  background: transparent;
}
.checklist-item-text:hover { background: var(--surface-sunk); }
.checklist-item-text:focus { outline: none; background: var(--surface); border-color: var(--brand); }
.checklist-item-text.done { text-decoration: line-through; color: var(--ink-soft); }
.checklist-item-btn { border: none; background: none; color: var(--ink-faint); cursor: pointer; display: inline-flex; align-items: center; gap: 3px; font-size: 11px; padding: 3px 5px; border-radius: 4px; white-space: nowrap; }
.checklist-item-btn:hover { background: var(--surface-alt); color: var(--ink); }
.checklist-add .input { min-height: 32px; }

.card-modal.viewer .modal-actions,
.card-modal.viewer .add-inline { display: none; }
.card-modal.viewer input,
.card-modal.viewer textarea,
.card-modal.viewer select { pointer-events: none; background: var(--surface-sunk); }

@media (max-width: 640px) {
  .card-grid { flex-direction: column; }
  .card-side { width: 100%; position: static; max-height: none; overflow: visible; padding-right: 0; }
}

/* Custom fields */
.field-rows { display: flex; flex-direction: column; gap: 8px; }
.field-row { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--ink-soft); }
.field-row .field-input { display: flex; gap: 6px; align-items: center; }
.field-row .field-input .input { min-height: 34px; flex: 1; min-width: 0; }
.field-row.field-check { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.field-open { flex-shrink: 0; text-decoration: none; }

/* Comments — a separate panel to the right of the card modal; it stacks
   under the modal on narrower screens. */
.card-modal-wrap {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  width: min(1416px, 100%);
}
.card-modal-wrap > .card-modal { flex: 1 1 1040px; min-width: 0; }
.card-comments {
  width: 360px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  max-height: calc(100vh - 7vh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 18px;
  scrollbar-gutter: stable;
}
@media (max-width: 1180px) {
  .card-modal-wrap { flex-direction: column; align-items: stretch; width: min(1040px, 100%); }
  .card-modal-wrap > .card-modal { flex: none; }
  .card-comments { width: auto; position: static; max-height: none; overflow: visible; }
}
.comment-composer, .comment { display: flex; gap: 10px; align-items: flex-start; }
.comment-composer { margin-bottom: 14px; }
.comment-composer .avatar, .comment .avatar { width: 28px; height: 28px; font-size: 11px; margin-top: 2px; }
.comment-composer-body, .comment-main { flex: 1; min-width: 0; }
.comment-input { width: 100%; min-height: 0; }
.comment-composer-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.comment-composer-actions .hint { font-size: 11px; color: var(--ink-faint); }
.comment-list { display: flex; flex-direction: column; gap: 14px; }
.comment-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.comment-when { font-size: 11px; color: var(--ink-faint); }
.comment-body {
  margin-top: 4px;
  padding: 8px 10px;
  background: var(--surface-alt);
  border-radius: var(--r-sm);
  font-size: 13px;
}
.comment-main > .comment-input { margin-top: 4px; }
.comment-actions { display: flex; gap: 10px; margin-top: 4px; }
.comment-actions:empty { display: none; }
.link-btn {
  border: none;
  background: none;
  padding: 0;
  font-size: 11px;
  color: var(--ink-soft);
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: var(--ink); }
.comment-actions .btn { margin-right: 0; }
