:root {
  --accent: #770000;
  --accent-hover: #aa0000;
  --border-color: #ccc;
  --header-bg: #eee;
  --header-fg: #333;
  --error-bg: #fdd;
  --error-fg: #a00;
  --column-bg: #f4f4f4;
  --card-bg: #fff;

  /* Chrome-only theming; columns/cards/modals stay light in both themes - see CODE_NOTES.md */
  --chrome-bg: rgba(0, 0, 0, 0.5);
  --chrome-fg: #fff;
  --chrome-border: rgba(255, 255, 255, 0.15);
  --canvas-bg: #525252;
  --tab-bg: rgba(255, 255, 255, 0.08);
  --tab-fg: #ddd;
  --tab-hover-bg: rgba(255, 255, 255, 0.16);
  --tab-border: rgba(255, 255, 255, 0.25);
}

[data-theme="light"] {
  --chrome-bg: var(--header-bg);
  --chrome-fg: var(--header-fg);
  --chrome-border: var(--border-color);
  --canvas-bg: #dcdcdc;
  --tab-bg: var(--column-bg);
  --tab-fg: #555;
  --tab-hover-bg: #e4e4e4;
  --tab-border: var(--border-color);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: Arial, Helvetica, sans-serif;
  background: #fff;
  color: #222;
}

/* No sidebar (toolbar+tabs+board layout); rotated-sidebar version tried & rejected - see CODE_NOTES.md */
#app-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--canvas-bg);
}

#toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 12px;
  background: var(--chrome-bg);
  color: var(--chrome-fg);
  border-bottom: 1px solid var(--chrome-border);
}

.toolbar-group {
  display: flex;
  gap: 6px;
}

#tab-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px 0;
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--chrome-border);
  overflow-x: auto;
}

#reopen-banner {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--chrome-bg);
  color: var(--chrome-fg);
  border-bottom: 1px solid var(--chrome-border);
  font-size: 13px;
}

#reopen-banner[hidden] {
  display: none;
}

#reopen-banner button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 3px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
}

#reopen-banner button:hover {
  background: var(--accent-hover);
}

#reopen-banner-dismiss-btn {
  background: #999;
}

#reopen-banner-dismiss-btn:hover {
  background: #888;
}

.tab {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 10px;
  border: 1px solid var(--tab-border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: var(--tab-bg);
  color: var(--tab-fg);
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  background: var(--tab-hover-bg);
}

.tab.active {
  background: #fff;
  color: #222;
  font-weight: bold;
}

.tab-close-btn {
  padding: 0 4px;
}

.add-tab-btn {
  flex: 0 0 auto;
  margin-bottom: 4px;
  padding: 4px 10px;
}

.toolbar-group-anchor {
  position: relative;
}

.dropdown-panel {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  background: #fff;
  color: #222;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dropdown-panel[hidden] {
  display: none;
}

.tag-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.dropdown-empty {
  font-size: 13px;
  color: #777;
}

.dropdown-clear-btn {
  align-self: flex-start;
  padding: 4px 8px;
  font-size: 12px;
}

#filter-tags-btn.filter-active {
  background: var(--accent-hover);
  font-weight: bold;
}

button {
  font: inherit;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--accent-hover);
}

button:disabled {
  background: #bbb;
  border-color: #bbb;
  cursor: not-allowed;
}

button:disabled:hover {
  background: #bbb;
}

.delete-btn {
  flex: 0 0 auto;
  padding: 2px 7px;
  background: transparent;
  color: var(--header-fg);
  border-color: transparent;
}

.delete-btn:hover {
  background: var(--error-bg);
  color: var(--error-fg);
  border-color: var(--error-fg);
}

.column-header {
  cursor: grab;
}

.card {
  cursor: grab;
}

.column-title,
.card-title {
  cursor: text;
}

.card-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dragging {
  opacity: 0.4;
}

.column.drag-over,
.card.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

/* No background of its own - the dark #app-shell canvas shows through here, so each column reads
   as a distinct raised panel rather than the whole board being one continuous white sheet. */
#board {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  overflow-x: auto;
}

.column {
  flex: 0 0 var(--column-width, 260px);
  min-width: 0; /* min-width:0 needed - flex items ignore --column-width otherwise, see CODE_NOTES.md */
  display: flex;
  flex-direction: column;
  background: var(--column-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  max-height: 100%;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
}

.column-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--border-color);
}

/* Frame (border/background) hidden until hover/focus - reads as plain bold text at rest instead
   of an always-visible form field, until you actually mean to rename it. */
.column-title,
.card-title {
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
}

.column-title:hover,
.column-title:focus,
.card-title:hover,
.card-title:focus {
  border-color: var(--border-color);
  background: #fff;
}

.column-title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: bold;
}

.column-cards {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 8px;
  transition: border-color 0.1s ease, box-shadow 0.1s ease;
}

/* The card itself (not just the title input/edit/delete buttons) opens the detail view on click -
   this is the only visual cue for that, since nothing about a plain bordered box otherwise says so. */
.card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.card-title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: bold;
}

/* Left of the title, a dedicated open-detail affordance - neutral/gray rather than the red
   .delete-btn convention, since it isn't a destructive action. */
.card-edit-btn {
  flex: 0 0 auto;
  padding: 2px 6px;
  background: transparent;
  color: var(--header-fg);
  border-color: transparent;
}

.card-edit-btn:hover {
  background: var(--column-bg);
  border-color: var(--border-color);
}

/* Clamped to 2 lines rather than a fixed height - short descriptions just take one line, long
   ones truncate with an ellipsis instead of stretching every card in the column to match. */
.card-description-preview {
  margin-top: 4px;
  font-size: 12px;
  color: #666;
  white-space: pre-line;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.add-card-btn {
  margin: 8px;
  align-self: flex-start;
}

.card .checklist-progress {
  margin-top: 6px;
}

.due-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 12px;
  background: #eee;
  color: #444;
}

.due-badge.due-overdue {
  background: var(--error-bg);
  color: var(--error-fg);
}

.due-badge.due-soon {
  background: #fff3cd;
  color: #8a6300;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2147483000;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  background: #fff;
  color: #222;
  padding: 20px;
  border-radius: 8px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.modal-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* [hidden] alone loses to .modal-row's display:flex (author beats user-agent rule) - see CODE_NOTES.md */
.modal-row[hidden] {
  display: none;
}

.modal-row label {
  font-size: 13px;
  color: #555;
}

.modal-row input,
.modal-row select,
.modal-row textarea {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.modal-row textarea {
  resize: vertical;
  min-height: 3.6em;
}

/* Card detail modal: viewport-ratio sizing with cap, description fills remaining space - see CODE_NOTES.md */
.card-modal-panel {
  width: min(90vw, 900px);
  height: min(85vh, 800px);
  overflow-y: auto;
}

.card-modal-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 0 0 auto;
}

.card-modal-title-input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 22px;
  font-weight: bold;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: inherit;
}

.card-modal-title-input:hover,
.card-modal-title-input:focus {
  border-color: var(--border-color);
  background: var(--column-bg);
}

.card-modal-close-btn {
  flex: 0 0 auto;
  padding: 4px 10px;
  background: transparent;
  color: var(--header-fg);
  border-color: transparent;
}

.card-modal-close-btn:hover {
  background: var(--column-bg);
  border-color: var(--border-color);
}

.card-modal-meta-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  flex: 0 0 auto;
}

.card-modal-due-date-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-modal-due-date-field label {
  font-size: 13px;
  color: #555;
}

/* Shared by Tag (dropdown) and Activity (panel above description) toggles - see CODE_NOTES.md */
.card-modal-toggle-btn {
  background: transparent;
  color: var(--header-fg);
  border-color: var(--border-color);
}

.card-modal-toggle-btn:hover {
  background: var(--column-bg);
}

/* The one row allowed to actually grow - everything above it (header, meta bar, tags, checklist,
   the activity panel when open) is fixed/natural height, and description absorbs whatever's left. */
.card-modal-description-row {
  flex: 1 1 auto;
  min-height: 0;
}

#card-modal-description {
  flex: 1 1 auto;
  min-height: 120px;
  resize: none;
}

#archive-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  min-width: 320px;
  overflow-y: auto;
}

.archive-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.archive-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.archive-row-title {
  font-weight: bold;
}

.timeline-all-boards-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

#timeline-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 400px;
  min-width: 360px;
  overflow-y: auto;
}

.timeline-group-header {
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  color: #888;
  margin-top: 8px;
}

.timeline-group-header:first-child {
  margin-top: 0;
}

.timeline-row {
  cursor: pointer;
}

.timeline-row:hover {
  background: var(--column-bg);
}

.archive-row-meta {
  font-size: 12px;
  color: #666;
}

.archive-row-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

#card-modal-activity {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 140px;
  overflow-y: auto;
  font-size: 12px;
  color: #555;
}

.activity-row {
  display: flex;
  gap: 8px;
}

.activity-row-time {
  flex: 0 0 auto;
  color: #888;
  font-family: monospace;
}

.activity-row-message {
  flex: 1 1 auto;
}

.checklist-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checklist-progress-bar {
  flex: 1 1 auto;
  height: 6px;
  border-radius: 3px;
  background: #e5e5e5;
  overflow: hidden;
}

.checklist-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
}

.checklist-progress-label {
  flex: 0 0 auto;
  font-size: 12px;
  color: #555;
}

.checklist-toggle-btn {
  flex: 0 0 auto;
  padding: 0 4px;
  background: transparent;
  color: var(--header-fg);
  border-color: transparent;
  font-size: 11px;
  line-height: 1.6;
}

.checklist-toggle-btn:hover {
  background: var(--column-bg);
  border-color: var(--border-color);
}

.card-checklist-items {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
}

.card-checklist-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
}

.card-checklist-item-text.card-checklist-item-done {
  text-decoration: line-through;
  color: #888;
}

#card-modal-checklist-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.checklist-item-text {
  flex: 1 1 auto;
  font: inherit;
  padding: 4px 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.checklist-item-text.checklist-item-done {
  text-decoration: line-through;
  color: #888;
}

.modal-field-with-button {
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-field-with-button input {
  flex: 1 1 auto;
}

.modal-field-with-button input[type="color"] {
  flex: 0 0 auto;
  width: 32px;
  padding: 2px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: bold;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

#card-modal-tags {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
}

.tag-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tag-row input[type="text"] {
  flex: 1 1 auto;
  font: inherit;
  padding: 4px 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.tag-row input[type="color"] {
  flex: 0 0 auto;
  width: 28px;
  padding: 2px;
}

.settings-version {
  margin: 4px 0 0;
  font-size: 11px;
  opacity: 0.55;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
}

#toast {
  position: fixed;
  bottom: 10px;
  right: 10px;
  z-index: 2147483647;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  padding: 8px 14px;
  border-radius: 5px;
  font-family: monospace;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#toast.visible {
  opacity: 1;
  transform: translateY(0);
}
