/* HMI colors and Segoe UI are required by the product brief. */
:root {
  color-scheme: dark;
  --bg: #202428;
  --surface: #2b3035;
  --strong: #363c42;
  --text: #edf0f2;
  --muted: #bcc2c8;
  --border: #858e97;
  --primary: #c4cbd2;
  --primary-hover: #e0e5e9;
  --on-primary: #202428;
  --success: #8bd5a3;
  --blue: #9ecbff;
  --danger: #ff9696;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 100%;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #d4d6d8;
  --surface: #eceeef;
  --strong: #dfe2e4;
  --text: #202428;
  --muted: #50565c;
  --border: #777e85;
  --primary: #41484f;
  --primary-hover: #30363c;
  --on-primary: #fff;
  --success: #24633d;
  --blue: #245b91;
  --danger: #b22222;
}

* { box-sizing: border-box; }
body { margin: 0; font-size: .875rem; }
button, input, select, textarea { font: inherit; }
button, input, select, textarea {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text);
}
button { cursor: pointer; }
button:hover { background: var(--strong); }
button:active { background: var(--bg); }
button:disabled { cursor: default; opacity: .45; }
button.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 600; }
button.primary:hover { background: var(--primary-hover); }
button.danger { color: var(--danger); }
input, select, textarea { max-width: 100%; min-width: 0; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.75rem; margin-bottom: 4px; }
h2 { font-size: 1.125rem; }
p { max-width: 80ch; }
.muted { color: var(--muted); }
.text-button { background: transparent; border-color: transparent; }

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 24px;
  min-height: 65px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); font-size: 1.125rem; font-weight: 600; text-decoration: none; }
.brand svg { flex-shrink: 0; }
.header-actions { display: flex; flex-wrap: wrap; gap: 8px; max-width: 100%; }
.header-actions button { background: transparent; }
.header-actions button:hover { background: var(--strong); }
.count { margin-left: 6px; color: var(--muted); font-weight: 400; font-size: .8125rem; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; min-height: calc(100dvh - 65px); }
.board-workspace { min-width: 0; display: flex; flex-direction: column; padding: 24px; }
.board-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; margin-bottom: 24px; }
.board-heading p { margin: 0; font-size: .8125rem; }
.board-heading > button { flex-shrink: 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar > label { min-width: 0; }
.toolbar select { width: 10rem; }
.search-field { display: flex; align-items: center; flex: 1 1 14rem; background: var(--surface); border: 1px solid var(--border); border-radius: 2px; padding-left: 12px; }
.search-field svg { flex-shrink: 0; color: var(--muted); }
.search-field input { width: 100%; border: 0; background: transparent; }
.board-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 4px; font-size: .75rem; }
.board {
  display: flex;
  align-items: stretch;
  gap: 20px;
  overflow-x: auto;
  min-height: 26rem;
  flex: 1;
  padding: 4px 4px 24px;
  scrollbar-width: thin;
  position: relative;
}
.column { flex: 1 0 17rem; min-width: 0; max-width: 25rem; display: flex; flex-direction: column; }
.column-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 4px;
  border-bottom: 2px solid var(--border);
  min-height: 52px;
  padding: 0 0 4px;
  cursor: grab;
}
.column-header h2 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0; font-size: .9375rem; overflow-wrap: anywhere; }
.column-header .count { margin-left: 0; }
.column-marker { color: var(--muted); }
.completed-column .column-marker { color: var(--success); }
.column-controls { display: flex; margin-left: auto; }
.column-controls button { min-width: 30px; padding: 8px 6px; font-size: 1rem; }
.card-list { display: flex; flex-direction: column; gap: 12px; min-height: 10rem; padding: 14px 0 10px; }
.card { padding: 16px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); cursor: grab; overflow-wrap: anywhere; }
.card-title { display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 0; min-height: 28px; font-size: .9375rem; font-weight: 600; line-height: 1.5; }
.card-title:hover { background: transparent; text-decoration: underline; text-underline-offset: 4px; }
.card-description { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; color: var(--muted); font-size: .8125rem; margin: 8px 0 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { --tag-color: var(--blue); min-height: 32px; max-width: 100%; padding: 4px 8px; border-color: color-mix(in srgb, var(--tag-color) 65%, var(--border)); background: color-mix(in srgb, var(--tag-color) 14%, var(--surface)); color: var(--text); font-size: .75rem; overflow-wrap: anywhere; }
.tag::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; background: var(--tag-color); }
.card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.assignee { color: var(--muted); font-size: .75rem; }
.card-order { display: flex; }
.card-order button { min-width: 32px; padding: 6px 8px; }
.add-card { text-align: left; background: transparent; color: var(--muted); border: 1px dashed var(--border); padding: 10px 12px; margin-bottom: auto; }
.column-empty { text-align: left; padding: 24px 12px; color: var(--muted); }
.column-empty .empty-glyph { display: none; }
.column-empty p { font-size: .8125rem; margin-bottom: 6px; }
.column-empty p:first-of-type { color: var(--text); }
.column-empty p:last-of-type { font-size: .75rem; }
.board-empty { width: 100%; padding: 32px 16px; border: 1px dashed var(--border); border-radius: 4px; }
.board-empty .empty-glyph { display: none; }
.no-results { position: absolute; bottom: 0; margin: 0; padding: 8px 0; font-size: .8125rem; background: var(--bg); }
.board-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 20px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--muted); font-size: .75rem; }

.assistant { display: flex; flex-direction: column; gap: 16px; min-width: 0; border-left: 1px solid var(--border); background: var(--surface); padding: 24px 20px 16px; }
.assistant-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.assistant-heading h2 { margin: 0; font-size: 1rem; }
.assistant-heading button { font-size: .75rem; padding: 8px; }
.ai-connection { font-size: .75rem; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.ai-connection p { margin-bottom: 12px; }
.ai-connection button { width: 100%; }
.chat-log { flex: 1; min-height: 12rem; max-height: 55dvh; overflow-y: auto; scrollbar-width: thin; }
.chat-empty { color: var(--muted); padding: 4px 0; font-size: .8125rem; }
.chat-message { margin: 0 0 20px; padding: 0; overflow-wrap: anywhere; }
.chat-message.user { padding: 12px; border-radius: 2px; background: var(--strong); }
.chat-message strong { font-size: .75rem; font-weight: 600; }
.chat-message p { margin: 6px 0 0; white-space: pre-wrap; font-size: .8125rem; }
.chat-composer { margin-top: auto; }
.chat-composer textarea { width: 100%; min-height: 100px; background: var(--bg); }
.chat-composer > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: .6875rem; }
.privacy-note { font-size: .6875rem; color: var(--muted); margin: 0; }

dialog { width: min(600px, calc(100% - 32px)); max-height: calc(100dvh - 48px); padding: 24px; border: 2px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / .65); }
body:has(dialog[open]) { overflow: hidden; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.dialog-heading h2 { margin: 0; font-size: 1.375rem; }
.dialog-heading > button { background: transparent; border-color: transparent; }
form > label, .form-row label { display: block; font-size: .8125rem; font-weight: 600; margin: 16px 0 6px; }
form > input:not([type="hidden"]), form > textarea, .form-row input, .form-row select { width: 100%; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row > div { min-width: 0; }
fieldset { padding: 0; margin: 20px 0; border: 0; min-width: 0; }
legend { font-size: .8125rem; font-weight: 600; margin-bottom: 10px; }
.label-editor { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.editable-label { display: inline-flex; align-items: center; }
.remove-label { min-height: 32px; padding: 4px 8px; background: transparent; border: 0; }
.label-adder { display: flex; gap: 8px; }
.label-adder > input:first-of-type { flex: 1; min-width: 0; }
.label-adder input[type="color"] { padding: 4px; width: 44px; flex-shrink: 0; }
.label-adder button { white-space: nowrap; }
.inline-label-input { min-width: 60px; width: 130px; min-height: 32px; padding: 4px 8px; font-size: .75rem; }
.dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.dialog-footer > div { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.form-error { color: var(--danger); font-size: .8125rem; }
.check-label { display: flex; align-items: center; gap: 10px; }
.archive-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.archive-row > div { min-width: 0; }
.archive-row p { font-size: .8125rem; margin: 4px 0 0; }
.archive-row button { flex-shrink: 0; }
.archive-empty { padding: 24px 0; color: var(--muted); }
.error-banner { border: 2px solid var(--danger); padding: 16px; margin-bottom: 16px; color: var(--danger); background: var(--surface); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); padding: 12px 24px; border: 2px solid var(--primary); background: var(--surface); color: var(--text); border-radius: 4px; z-index: 20; max-width: calc(100% - 32px); }
/* Drop indicators mark the actual insertion position, not a decorative card accent. */
.drop-before, .drop-after { position: relative; }
.drop-before::before, .drop-after::after { content: ""; position: absolute; left: 0; right: 0; height: 3px; background: var(--blue); pointer-events: none; }
.drop-before::before { top: -6px; }
.drop-after::after { bottom: -6px; }
.column.drop-before::before { inset: 0 auto 0 -10px; width: 3px; height: auto; }
.column.drop-after::after { inset: 0 -10px 0 auto; width: 3px; height: auto; }
.drop-target { outline: 3px dashed var(--blue); outline-offset: -4px; }
.dragging { opacity: .5; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 18rem; }
  .board-workspace { padding: 20px; }
  .toolbar select { width: 9rem; }
}
@media (max-width: 800px) {
  .workspace { display: block; }
  .assistant { border-left: 0; border-top: 1px solid var(--border); min-height: 28rem; }
  .chat-log { max-height: 25rem; }
  .masthead { padding: 10px 16px; }
  .board-workspace { padding: 24px 16px 16px; }
  .board-heading { margin-bottom: 20px; }
  .board { min-height: 24rem; }
}
@media (max-width: 430px) {
  .brand { gap: 8px; }
  .brand svg { display: none; }
  .header-actions { gap: 4px; }
  .header-actions button { padding: 8px; }
  .search-field { flex-basis: 100%; }
  .toolbar > label:not(.search-field) { flex: 1; }
  .toolbar select { width: 100%; }
  .board-meta { font-size: .6875rem; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  dialog { padding: 16px; }
  .dialog-footer { flex-wrap: wrap; }
  .label-adder { flex-wrap: wrap; }
  .label-adder > input:first-of-type { flex-basis: 65%; }
}
