:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-2: #eef1ed;
  --text: #181c1f;
  --muted: #68716d;
  --border: #d9ddd6;
  --accent: #2f7d6d;
  --accent-strong: #226457;
  --danger: #b84e4e;
  --danger-strong: #983d3d;
  --shadow: 0 16px 48px rgba(21, 28, 25, 0.12);
  --urgent: #b7372f;
  --high: #a46a13;
  --medium: #2f6f9f;
  --low: #617061;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101312;
  --surface: #171b1a;
  --surface-2: #202624;
  --text: #ecf1ee;
  --muted: #9ba6a2;
  --border: #303835;
  --accent: #64b6a5;
  --accent-strong: #8ecfc2;
  --danger: #d36b6b;
  --danger-strong: #ee8585;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  --urgent: #f07167;
  --high: #d79a3d;
  --medium: #74a7d7;
  --low: #94a391;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.hidden {
  display: none !important;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  color: var(--muted);
  font-weight: 700;
}

.logo-mark {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--accent);
  display: inline-block;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form h1 {
  margin: 0 0 6px;
  font-size: 26px;
  line-height: 1.15;
}

.auth-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.telegram-link {
  color: var(--accent-strong);
  font-size: 14px;
  text-decoration: none;
}

.telegram-link:hover {
  text-decoration: underline;
}

.auth-form input,
.task-form input,
.task-form textarea,
.task-form select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}

.auth-form input:focus,
.task-form input:focus,
.task-form textarea:focus,
.task-form select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.primary-button,
.secondary-button,
.danger-button,
.file-button,
.icon-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.primary-button {
  color: #ffffff;
  background: var(--accent);
}

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

.secondary-button,
.file-button,
.icon-button {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}

.secondary-button:hover,
.file-button:hover,
.icon-button:hover {
  background: var(--surface-2);
}

.danger-button {
  color: #ffffff;
  background: var(--danger);
}

.danger-button:hover {
  background: var(--danger-strong);
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

.app-view {
  min-height: 100vh;
  padding: 20px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto minmax(240px, 320px);
  gap: 16px;
  align-items: start;
  margin-bottom: 20px;
}

.topbar-main {
  display: flex;
  align-items: center;
  gap: 18px;
  justify-content: space-between;
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.presence-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  display: grid;
  gap: 12px;
}

.presence-title {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}

.presence-list,
.editing-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.user-pill,
.editing-pill {
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  max-width: 100%;
}

.user-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
}

.editing-pill {
  color: var(--accent-strong);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.muted-text {
  color: var(--muted);
  font-size: 13px;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(250px, 1fr));
  gap: 14px;
  align-items: stretch;
}

.column {
  min-width: 0;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 78%, var(--bg));
  display: flex;
  flex-direction: column;
  transition: border-color 140ms ease, background 140ms ease;
}

.column.drag-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}

.column-head {
  min-height: 58px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.column-title-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.column-title {
  margin: 0;
  font-size: 16px;
}

.count-pill {
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 13px;
}

.column-add-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font-size: 20px;
  line-height: 1;
}

.column-add-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--surface-2);
}

.task-list {
  min-height: 320px;
  flex: 1;
  padding: 10px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.task-card {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  display: grid;
  gap: 7px;
  align-items: start;
  color: var(--text);
  background: var(--surface);
  text-align: left;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
  cursor: pointer;
  overflow: hidden;
}

.task-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.task-card:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: 2px;
}

.task-card.dragging {
  opacity: 0.5;
}

.task-card-top {
  min-width: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.task-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: normal;
}

.user-line {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.task-creator {
  margin-top: -1px;
}

.task-description {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
  overflow-wrap: anywhere;
}

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

.badge {
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  display: inline-flex;
  align-items: center;
  color: var(--text);
  background: var(--surface-2);
  font-size: 12px;
}

.priority-urgent {
  color: var(--urgent);
  border: 1px solid color-mix(in srgb, var(--urgent) 45%, transparent);
}

.priority-high {
  color: var(--high);
  border: 1px solid color-mix(in srgb, var(--high) 45%, transparent);
}

.priority-medium {
  color: var(--medium);
  border: 1px solid color-mix(in srgb, var(--medium) 45%, transparent);
}

.priority-low {
  color: var(--low);
  border: 1px solid color-mix(in srgb, var(--low) 45%, transparent);
}

.priority-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.priority-dot {
  width: 10px;
  height: 10px;
  border: 0;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 14%, transparent);
}

.priority-dot.priority-urgent {
  color: var(--urgent);
  background: var(--urgent);
}

.priority-dot.priority-high {
  color: var(--high);
  background: var(--high);
}

.priority-dot.priority-medium {
  color: var(--medium);
  background: var(--medium);
}

.priority-dot.priority-low {
  color: var(--low);
  background: var(--low);
}

.task-card-actions {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  flex: 0 0 auto;
}

.card-action-button {
  width: 24px;
  height: 24px;
  border: 1px solid transparent;
  border-radius: 6px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}

.card-action-button:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border);
  background: var(--surface-2);
}

.card-image {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.empty-column {
  min-height: 290px;
  height: 100%;
  display: grid;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
}

.typing-indicator {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.typing-avatar {
  width: 16px;
  height: 16px;
}

.task-card > .typing-indicator {
  width: 100%;
  min-width: 0;
}

.typing-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.typing-dots {
  display: inline-flex;
  width: 16px;
  justify-content: flex-start;
}

.typing-dots span {
  display: inline-block;
  animation: typing-dot 1.05s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.14s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes typing-dot {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-3px);
  }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(10, 13, 12, 0.56);
}

.modal-panel {
  width: min(660px, 100%);
  max-height: min(860px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 0;
  font-size: 22px;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.warning {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--high);
  background: color-mix(in srgb, var(--high) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--high) 30%, transparent);
}

.task-form {
  display: grid;
  gap: 14px;
}

.task-view {
  display: grid;
  gap: 15px;
}

.view-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.view-description {
  margin: 0;
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.view-image {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.view-details {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(130px, 0.55fr) minmax(0, 1fr);
  gap: 8px 14px;
}

.view-details dt {
  color: var(--muted);
  font-size: 13px;
}

.view-details dd {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.task-form label,
.image-control {
  display: grid;
  gap: 7px;
}

.task-form label span,
.image-control > span {
  color: var(--muted);
  font-size: 13px;
}

.task-form textarea {
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.file-button input {
  display: none;
}

.image-preview {
  width: 100%;
}

.image-preview img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-action-spacer {
  flex: 1;
}

@media (max-width: 1100px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .presence-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .board {
    grid-template-columns: 1fr;
  }

  .app-view {
    padding: 14px;
  }
}

@media (max-width: 640px) {
  .topbar-main,
  .modal-actions,
  .presence-panel {
    grid-template-columns: 1fr;
  }

  .topbar-main {
    display: grid;
  }

  .primary-button,
  .secondary-button,
  .danger-button,
  .file-button {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    display: grid;
  }

  .modal-action-spacer {
    display: none;
  }
}
