/* Weekly Dev Dashboard — tasks-v2 */
:root {
  color-scheme: dark;
  --bg: #0c0d10;
  --bg-elevated: #12141a;
  --panel: #16181f;
  --surface: #1a1f26;
  --panel-hover: #1c1f28;
  --border: #2a2e38;
  --border-subtle: #22252d;
  --text: #eef0f4;
  --text-muted: #8b93a3;
  --text-subtle: #5c6474;
  --accent: #6c8cff;
  --accent-dim: rgba(108, 140, 255, 0.15);
  --accent-glow: rgba(108, 140, 255, 0.35);
  --success: #3dd68c;
  --success-dim: rgba(61, 214, 140, 0.12);
  --warning: #f0b429;
  --warning-dim: rgba(240, 180, 41, 0.12);
  --danger: #f07178;
  --danger-dim: rgba(240, 113, 120, 0.12);
  --testing: #c792ea;
  --testing-dim: rgba(199, 146, 234, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 220px;
  --sidebar-w-collapsed: 56px;
  --sidebar-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  /* Chat / task detail */
  --chat-glass: rgba(18, 20, 26, 0.72);
  --chat-glass-border: rgba(255, 255, 255, 0.06);
  --chat-thread-bg: #0a0b0e;
  --bubble-user: linear-gradient(145deg, rgba(108, 140, 255, 0.22) 0%, rgba(30, 36, 51, 0.95) 55%);
  --bubble-user-border: rgba(108, 140, 255, 0.32);
  --bubble-context: linear-gradient(145deg, rgba(108, 140, 255, 0.14) 0%, rgba(22, 26, 38, 0.9) 100%);
  --bubble-context-border: rgba(108, 140, 255, 0.22);
  --bubble-system: rgba(42, 46, 56, 0.35);
  --bubble-system-border: rgba(255, 255, 255, 0.06);
  --bubble-attachment: rgba(12, 13, 16, 0.5);
  --chat-radius-bubble: 18px;
  --chat-radius-bubble-tail: 5px;
  --chat-composer-pill: rgba(22, 24, 31, 0.85);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns var(--sidebar-transition);
}

html[data-sidebar-collapsed="true"] .app,
.app.sidebar-collapsed {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-subtle);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  transition: padding var(--sidebar-transition), width var(--sidebar-transition);
}

html[data-sidebar-collapsed="true"] .sidebar,
.app.sidebar-collapsed .sidebar {
  padding: 16px 8px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
  transition: padding var(--sidebar-transition), justify-content var(--sidebar-transition);
}

html[data-sidebar-collapsed="true"] .sidebar-brand,
.app.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 4px 0 16px;
}

html[data-sidebar-collapsed="true"] .sidebar-brand > div,
.app.sidebar-collapsed .sidebar-brand > div {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity var(--sidebar-transition), width var(--sidebar-transition);
}

.brand-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), #9b7dff);
  border-radius: 8px;
  font-size: 14px;
  color: #fff;
}

.sidebar-brand strong {
  display: block;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-subtle);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  transition: background 0.12s, color 0.12s, padding var(--sidebar-transition), justify-content var(--sidebar-transition);
}

html[data-sidebar-collapsed="true"] .nav-item,
.app.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 10px 8px;
  font-size: 0;
  gap: 0;
}

html[data-sidebar-collapsed="true"] .nav-icon,
.app.sidebar-collapsed .nav-icon {
  font-size: 14px;
  width: auto;
}

.nav-item:hover {
  background: var(--panel);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.nav-icon {
  opacity: 0.7;
  font-size: 12px;
  width: 16px;
  text-align: center;
}

.sidebar-section {
  margin-top: 24px;
  flex: 1;
  overflow: hidden;
  transition: opacity var(--sidebar-transition), max-height var(--sidebar-transition), margin var(--sidebar-transition);
}

html[data-sidebar-collapsed="true"] .sidebar-section,
.app.sidebar-collapsed .sidebar-section {
  opacity: 0;
  max-height: 0;
  margin-top: 0;
  pointer-events: none;
}

.sidebar-heading {
  margin: 0 0 10px 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.project-list li {
  margin: 0;
}

.project-link {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.project-link:hover,
.project-link.active {
  background: var(--panel);
  color: var(--text);
}

.project-link.active {
  border-left: 2px solid var(--accent);
  padding-left: 8px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 16px;
  margin-top: auto;
  font-size: 11px;
  color: var(--text-subtle);
  border-top: 1px solid var(--border-subtle);
  transition: justify-content var(--sidebar-transition);
}

html[data-sidebar-collapsed="true"] .sidebar-footer,
.app.sidebar-collapsed .sidebar-footer {
  justify-content: center;
  padding-top: 12px;
}

html[data-sidebar-collapsed="true"] #connection-label,
.app.sidebar-collapsed #connection-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity var(--sidebar-transition), width var(--sidebar-transition);
}

/* Sidebar toggle */
.sidebar-toggle {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.1s;
}

.sidebar-toggle:hover {
  background: var(--panel-hover);
  color: var(--text);
  border-color: var(--accent);
}

.sidebar-toggle:active {
  transform: scale(0.96);
}

.sidebar-toggle-icon {
  font-size: 16px;
  line-height: 1;
  transition: transform var(--sidebar-transition);
}

html[data-sidebar-collapsed="true"] .sidebar-toggle-icon,
.app.sidebar-collapsed .sidebar-toggle-icon {
  transform: rotate(0deg);
}

html:not([data-sidebar-collapsed="true"]) .app:not(.sidebar-collapsed) .sidebar-toggle-icon,
.app:not(.sidebar-collapsed) .sidebar-toggle-icon {
  transform: rotate(180deg);
}

.sidebar-backdrop {
  display: none;
}

.header-leading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-subtle);
  flex-shrink: 0;
}

.connection-dot.ok {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.connection-dot.reconnecting {
  background: var(--warning);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.pwa-install-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.pwa-install-btn:hover {
  background: var(--panel-hover);
  color: var(--text);
  border-color: var(--accent);
}

.pwa-install-icon {
  color: var(--accent);
  font-size: 12px;
}

html[data-sidebar-collapsed="true"] .pwa-install-label,
.app.sidebar-collapsed .pwa-install-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}

html[data-sidebar-collapsed="true"] .pwa-install-btn,
.app.sidebar-collapsed .pwa-install-btn {
  justify-content: center;
  padding: 8px;
}

.connection-dot.err {
  background: var(--danger);
}

/* Live sync indicator */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--success-dim);
  border: 1px solid rgba(61, 214, 140, 0.25);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--success);
  flex-shrink: 0;
}

.live-indicator[hidden] {
  display: none;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: live-pulse 2s ease-in-out infinite;
}

.live-indicator.reconnecting .live-dot {
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
  animation: live-pulse 0.8s ease-in-out infinite;
}

.live-indicator.reconnecting {
  color: var(--warning);
  background: var(--warning-dim);
  border-color: rgba(240, 180, 41, 0.25);
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.65; transform: scale(0.92); }
}

.live-indicator-sidebar {
  margin-left: auto;
}

html[data-sidebar-collapsed="true"] .live-indicator-sidebar .live-label,
.app.sidebar-collapsed .live-indicator-sidebar .live-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}

/* User session chip */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.user-chip:hover {
  border-color: var(--accent);
  background: var(--panel-hover);
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #9b7dff);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}

.user-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-wrap {
  position: relative;
  opacity: 1;
  z-index: 200;
  isolation: isolate;
}

.user-chip[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--panel-hover);
}

.user-menu-popover,
#user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  padding: 6px;
  opacity: 1;
  background-color: #1a1f26;
  background-color: var(--surface, var(--bg-elevated, #1a1f26));
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 4px 16px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  z-index: 201;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.user-menu-popover[hidden],
#user-menu[hidden] {
  display: none !important;
}

.user-menu-popover:not([hidden]),
#user-menu:not([hidden]) {
  display: block;
}

.user-menu-heading {
  padding: 8px 12px 6px;
}

.user-menu-heading-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.user-menu-heading-name {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  max-width: 196px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--border);
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  text-align: left;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}

.user-menu-item:hover {
  background: var(--panel-hover);
}

.user-menu-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.user-menu-item-link.user-menu-item-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.user-menu-item-icon {
  width: 16px;
  flex-shrink: 0;
  text-align: center;
  font-size: 14px;
  opacity: 0.85;
}

.user-menu-item-muted {
  color: var(--text-muted);
}

.user-menu-item-muted:hover {
  color: var(--text);
}

/* Auth modal */
.modal-auth .auth-hint {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

.modal-auth .auth-footer {
  justify-content: space-between;
}

.modal-auth .auth-footer .btn-primary {
  margin-left: auto;
}

.settings-section {
  max-width: 560px;
  padding: 8px 0 48px;
}

.settings-header {
  margin-bottom: 24px;
}

.settings-header h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.settings-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
}

.settings-card-title {
  margin: 0 0 14px;
  font-size: 15px;
}

.settings-dl {
  margin: 0;
  display: grid;
  gap: 12px;
}

.settings-dl dt {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.settings-dl dd {
  margin: 0;
  font-weight: 600;
}

.settings-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
}

.settings-form input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.settings-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.settings-desktop-sub {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

.settings-desktop-detected {
  margin: -8px 0 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.settings-desktop-meta {
  margin-bottom: 16px;
}

.settings-desktop-downloads {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.settings-desktop-unavailable {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--text-muted) 8%, var(--bg));
  border: 1px solid var(--border);
}

.settings-desktop-pwa-promo {
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
}

.settings-desktop-pwa-title {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text);
}

.settings-desktop-pwa-lead {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
}

.settings-desktop-pwa-btn {
  margin-bottom: 10px;
}

.settings-desktop-pwa-safari {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.settings-desktop-pwa-safari kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: inherit;
  font-size: 12px;
}

.settings-desktop-loading {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

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

.settings-desktop-instructions summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 8px;
}

.settings-desktop-instruction-block {
  margin: 12px 0;
}

.settings-desktop-instruction-block h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text);
}

.settings-desktop-instruction-block ol {
  margin: 0;
  padding-left: 20px;
  line-height: 1.6;
}

.settings-desktop-note {
  margin: 12px 0 0;
  font-size: 12px;
}

.settings-desktop-electron-hint {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  font-size: 13px;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.btn-download:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
}

.btn-download-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-download-primary:hover {
  filter: brightness(1.05);
}

.header-controls.settings-hidden .search-wrap,
.header-controls.settings-hidden .control-select,
.header-controls.settings-hidden .view-mode-tabs,
.header-controls.settings-hidden #week-span-selector,
.header-controls.settings-hidden #btn-carry-forward,
.header-controls.settings-hidden #live-indicator,
.header-controls.settings-hidden #btn-new-task {
  display: none;
}

/* Main */
.main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100vh;
  padding: 24px 28px 32px;
  overflow-x: auto;
  min-width: 0;
  transition: padding var(--sidebar-transition);
}

.top-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.header-titles h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.03em;
}

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

.header-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-subtle);
  font-size: 14px;
  pointer-events: none;
}

.search-input {
  width: 200px;
  padding: 9px 12px 9px 34px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.control-select {
  padding: 9px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.view-mode-tabs {
  display: inline-flex;
  align-items: stretch;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--border);
  gap: 2px;
}

.view-mode-tab {
  padding: 7px 14px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}

.view-mode-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.view-mode-tab.active {
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(108, 140, 255, 0.25);
}

.view-mode-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: transform 0.1s, opacity 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #7b6cff);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(240, 113, 120, 0.35);
}

.btn-danger:hover {
  background: rgba(240, 113, 120, 0.22);
  filter: brightness(1.05);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

/* Board */
.board-section {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 0;
  margin-top: 0;
}

.board-drag-hint {
  margin: 0 0 10px;
  font-size: 11px;
  color: var(--text-subtle);
  flex-shrink: 0;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(140px, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 12px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
  align-content: stretch;
}

.board-grid.week-span-5:not(.day-view) {
  grid-template-columns: repeat(5, minmax(140px, 1fr));
}

.board-grid.compact .day-column {
  font-size: 12px;
}

.board-grid.day-view {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  max-width: 960px;
}

.board-grid.day-view .day-column {
  min-width: 0;
  height: 100%;
}

.board-grid.day-view .day-sections {
  flex-direction: column;
  gap: 18px;
  max-height: none;
  padding: 12px 16px 16px;
}

.board-grid.day-view .status-section {
  min-height: 52px;
  padding-bottom: 6px;
}

.board-grid.day-view .status-section + .status-section {
  padding-top: 12px;
}

.board-grid.day-view .status-heading {
  font-size: 10px;
  margin-bottom: 6px;
}

.board-grid.day-view .task-cards {
  gap: 7px;
  min-height: 32px;
  max-height: none;
}

.board-grid.day-view .task-card-title {
  font-size: 13px;
}

.day-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 16px;
  text-align: left;
}

.day-view-header .day-add-task {
  position: static;
  opacity: 0.7;
  width: 32px;
  height: 32px;
  font-size: 20px;
  line-height: 30px;
}

.day-column:hover .day-view-header .day-add-task,
.day-view-header .day-add-task:focus-visible {
  opacity: 1;
}

.day-view-title {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.day-view-title .day-name {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  margin-bottom: 4px;
}

.day-column.is-today .day-view-title .day-name {
  color: var(--accent);
}

.day-num-large {
  display: block;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.day-date-full {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.day-view-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.day-nav-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text-muted);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.day-nav-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.day-today-btn {
  padding: 7px 12px;
  font-size: 12px;
}

.board-grid.day-view .day-footer {
  padding: 6px 16px;
}

.day-column {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.day-column.is-today {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim);
}

.day-header,
.day-view-header {
  flex-shrink: 0;
}

.day-header {
  position: relative;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: center;
}

.day-add-task {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-subtle);
  font-size: 16px;
  font-weight: 400;
  line-height: 20px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s, border-color 0.12s, background 0.12s;
}

.day-column:hover .day-add-task,
.day-add-task:focus-visible {
  opacity: 1;
}

.day-add-task:hover {
  color: var(--accent);
  border-color: var(--border-subtle);
  background: var(--accent-dim);
}

.day-column.is-today .day-add-task:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.day-name {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
}

.day-column.is-today .day-name {
  color: var(--accent);
}

.day-num {
  font-size: 18px;
  font-weight: 650;
  margin-top: 2px;
}

.day-sections {
  flex: 1 1 auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  min-height: 0;
}

.status-section {
  min-height: 36px;
  padding: 4px 0 6px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.status-section + .status-section {
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.board-grid:not(.day-view) .status-section .task-cards {
  overflow-x: hidden;
}

.status-section.drop-target {
  background: var(--accent-dim);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-glow), 0 0 12px var(--accent-dim);
}

.status-section.drop-target[data-status='in_progress'] {
  background: var(--warning-dim);
  border-color: var(--warning);
  box-shadow: inset 0 0 0 1px rgba(240, 180, 41, 0.35), 0 0 10px var(--warning-dim);
}

.status-section.drop-target[data-status='testing'] {
  background: var(--testing-dim);
  border-color: var(--testing);
  box-shadow: inset 0 0 0 1px rgba(199, 146, 234, 0.35), 0 0 10px var(--testing-dim);
}

.status-section.drop-target[data-status='done'],
.status-section-completed.drop-target {
  background: var(--success-dim);
  border-color: var(--success);
  box-shadow: inset 0 0 0 1px rgba(61, 214, 140, 0.35), 0 0 10px var(--success-dim);
}

.status-heading {
  margin: 0 0 6px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 0 2px;
}

.status-heading.todo { color: var(--text-muted); }
.status-heading.in_progress { color: var(--warning); }
.status-heading.testing { color: var(--testing); }
.status-heading.done {
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-icon {
  font-size: 8px;
  opacity: 0.85;
}

.status-section-completed {
  opacity: 0.92;
}

.status-section-completed .status-heading {
  margin-bottom: 3px;
}

.status-section-completed .task-cards {
  gap: 6px;
}

.day-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 8px;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  flex-shrink: 0;
}

.day-add-task-footer {
  position: static;
  width: 20px;
  height: 20px;
  font-size: 14px;
  line-height: 18px;
  opacity: 0.45;
  flex-shrink: 0;
}

.day-column:hover .day-add-task-footer,
.day-add-task-footer:focus-visible {
  opacity: 1;
}

.day-task-count {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
  text-transform: uppercase;
  line-height: 1.2;
}

.task-cards {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 24px;
}

.task-cards > .task-card,
.task-cards > .empty-slot {
  flex-shrink: 0;
}

.task-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex-shrink: 0;
  gap: 0;
  min-height: 56px;
  background: var(--panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: default;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
  overflow: hidden;
}

.task-drag-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  width: 100%;
  height: 20px;
  min-height: 20px;
  margin: 0;
  padding: 0 6px;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-subtle);
  cursor: grab;
  user-select: none;
  -webkit-user-drag: element;
  touch-action: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.task-drag-bar:hover,
.task-drag-bar:focus-visible {
  background: var(--accent-dim);
  border-bottom-color: rgba(108, 140, 255, 0.25);
  color: var(--accent);
  outline: none;
}

.task-drag-bar.is-dragging,
body.is-task-dragging .task-drag-bar {
  cursor: grabbing;
}

.task-drag-grip {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity 0.12s;
}

.task-drag-id {
  margin-left: auto;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.task-drag-grip i {
  display: block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
}

.task-drag-bar:hover .task-drag-grip,
.task-drag-bar:focus-visible .task-drag-grip,
.task-drag-bar.is-dragging .task-drag-grip {
  opacity: 1;
}

.task-card-body {
  flex: 0 0 auto;
  min-width: 0;
  min-height: 36px;
  padding: 8px 10px;
  cursor: pointer;
  overflow: visible;
}

.task-card:hover {
  background: var(--panel-hover);
  border-color: var(--border);
}

.task-card:hover .task-drag-bar {
  background: rgba(255, 255, 255, 0.04);
}

.task-card-title {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  display: block;
  max-width: 100%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-card-meta {
  margin-top: 3px;
  font-size: 9px;
  color: var(--text-subtle);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex-shrink: 0;
  overflow: visible;
}

.task-card-meta > span:not(.tag):not(.carried-badge-inline) {
  flex-shrink: 0;
  white-space: nowrap;
}

.task-card-meta .tag,
.task-card-meta .carried-badge-inline {
  flex-shrink: 0;
  white-space: nowrap;
}

.task-card-meta .tag {
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 8px;
  line-height: 1.3;
  background: var(--accent-dim);
  color: var(--accent);
}

.task-card.blocked {
  border-left: 3px solid var(--danger);
}

.task-card.is-done {
  opacity: 0.72;
  background: var(--success-dim);
  border-color: rgba(61, 214, 140, 0.2);
}

.task-card.is-done:hover {
  opacity: 0.88;
  background: rgba(61, 214, 140, 0.16);
  border-color: rgba(61, 214, 140, 0.35);
}

.task-card.is-done .task-card-title {
  text-decoration: line-through;
  text-decoration-color: rgba(61, 214, 140, 0.45);
  color: var(--text-muted);
}

.task-card.is-done .task-card-meta {
  opacity: 0.85;
}

.task-card.is-carried {
  border-left: 3px solid var(--warning);
}

.task-card.is-dragging {
  opacity: 0.45;
  pointer-events: none;
}

.task-card.is-dragging .task-drag-bar {
  pointer-events: auto;
}

.carried-badge {
  display: none;
  align-items: center;
  gap: 2px;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--warning);
  margin: 0;
}

.carried-badge-inline {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
}

.task-card.is-carried .carried-badge-inline {
  display: inline-flex;
}

.day-column .task-card-actions {
  display: none;
}

.task-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-top: 5px;
  cursor: default;
}

.task-move-btns {
  display: flex;
  gap: 2px;
}

.task-move-btn,
.task-day-select {
  font: inherit;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1.2;
}

.task-move-btn:hover,
.task-day-select:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.task-day-select {
  max-width: 72px;
  padding: 2px 2px;
}

.unscheduled-section {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  flex-shrink: 0;
}

.unscheduled-section.drag-over {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-dim);
}

.unscheduled-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.unscheduled-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.unscheduled-add-task {
  position: static;
  opacity: 0.55;
  flex-shrink: 0;
}

.unscheduled-section:hover .unscheduled-add-task,
.unscheduled-add-task:focus-visible {
  opacity: 1;
}

.unscheduled-header h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.unscheduled-hint {
  font-size: 11px;
  color: var(--text-subtle);
}

.unscheduled-cards {
  flex-direction: row;
  flex-wrap: wrap;
}

.unscheduled-cards .task-card {
  flex: 0 1 200px;
}

.empty-slot {
  padding: 8px;
  text-align: center;
  font-size: 11px;
  color: var(--text-subtle);
  opacity: 0.5;
}

.empty-slot-completed {
  padding: 4px;
  font-size: 10px;
  opacity: 0.35;
}

/* Modal — native <dialog>; do not set display on closed dialogs (hides ::backdrop only) */
dialog.modal:not([open]) {
  display: none;
}

.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  background: var(--bg-elevated);
  color: var(--text);
  max-width: 420px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.modal-form label {
  display: block;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.modal-form input,
.modal-form select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
}

.modal-header,
.modal-body,
.modal-footer {
  padding: 16px 20px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
  margin: 0;
  font-size: 17px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border-subtle);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Task detail — chat-style modal */
.modal-chat {
  width: min(90vw, 1100px);
  max-width: 1100px;
  height: 85vh;
  max-height: min(90vh, 900px);
  min-height: min(600px, 85vh);
  margin: auto;
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.55),
    0 0 0 1px var(--chat-glass-border);
}

.modal-chat[open] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-chat::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.chat-modal-form {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  --chat-header-height: 76px;
}

.chat-modal-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.chat-modal-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Right-side media gallery panel */
.chat-media-panel {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--chat-glass-border);
  background: rgba(12, 13, 17, 0.92);
}

.chat-media-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--chat-glass-border);
  flex-shrink: 0;
}

.chat-media-panel-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}

.chat-media-panel-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--chat-glass-border);
}

.chat-media-panel-close {
  display: none;
}

.chat-media-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
}

.chat-media-panel-body::-webkit-scrollbar {
  width: 6px;
}

.chat-media-panel-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.chat-media-panel-empty {
  margin: 24px 8px;
  text-align: center;
  font-size: 12px;
  color: var(--text-subtle);
}

.chat-media-panel-empty[hidden],
.chat-media-panel-grid[hidden] {
  display: none !important;
}

.chat-media-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.chat-media-panel-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.chat-media-panel-item .chat-media-thumb {
  width: 100%;
}

.chat-media-panel-item .chat-media-thumb--image,
.chat-media-panel-item .chat-media-thumb--video {
  width: 100%;
  height: 92px;
}

.chat-media-panel-item .chat-media-thumb .chat-attachment-img,
.chat-media-panel-item .chat-media-thumb .chat-attachment-video {
  width: 100%;
  height: 92px;
}

.chat-media-panel-item .chat-media-thumb--pdf {
  width: 100%;
  min-height: 92px;
  padding: 8px;
}

.chat-media-panel-item .chat-media-expand-text,
.chat-media-panel-item .chat-attachment-pdf-action {
  display: none;
}

.chat-media-panel-filename {
  display: block;
  font-size: 10px;
  line-height: 1.3;
  color: var(--text-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
}

.chat-media-panel-item:hover .chat-media-panel-filename,
.chat-media-panel-item:focus-within .chat-media-panel-filename {
  color: var(--text-muted);
}

.chat-media-panel-toggle {
  position: relative;
  display: none;
}

.chat-media-panel-toggle-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--chat-glass);
}

.chat-media-panel-toggle-badge[hidden] {
  display: none !important;
}

.chat-media-panel-backdrop {
  display: none;
}

@media (max-width: 768px) {
  .chat-media-panel-toggle {
    display: inline-flex;
  }

  .chat-media-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    width: min(280px, 88vw);
    border-left: 1px solid var(--chat-glass-border);
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
    transform: translateX(100%);
    transition: transform 0.22s ease;
  }

  .chat-modal-form.chat-media-panel-open .chat-media-panel {
    transform: translateX(0);
  }

  .chat-media-panel-close {
    display: inline-flex;
  }

  .chat-media-panel-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 34;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  .chat-media-panel-backdrop:not([hidden]) {
    opacity: 1;
    pointer-events: auto;
  }
}

.chat-header {
  position: relative;
  z-index: 31;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--chat-glass-border);
  flex-shrink: 0;
  background: var(--chat-glass);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
}

.chat-header-main {
  flex: 1;
  min-width: 0;
}

.chat-header-title {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0 0 8px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  transition: box-shadow 0.2s ease;
}

.chat-header-title:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-dim), 0 2px 0 var(--accent);
}

.chat-header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.chat-id-pill {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-subtle);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--chat-glass-border);
}

.chat-status-pill {
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--chat-glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.chat-status-pill.status-in_progress {
  color: var(--warning);
  background: var(--warning-dim);
  border-color: rgba(240, 180, 41, 0.25);
}

.chat-status-pill.status-testing {
  color: var(--testing);
  background: var(--testing-dim);
  border-color: rgba(199, 146, 234, 0.25);
}

.chat-status-pill.status-done {
  color: var(--success);
  background: var(--success-dim);
  border-color: rgba(61, 214, 140, 0.25);
}

.chat-status-pill.status-blocked {
  color: var(--danger);
  background: var(--danger-dim);
  border-color: rgba(240, 113, 120, 0.25);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.chat-menu-wrap {
  position: relative;
}

.chat-menu-btn,
.chat-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.chat-menu-btn:hover,
.chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chat-menu-btn:active,
.chat-close-btn:active {
  transform: scale(0.94);
}

.chat-menu-btn-icon {
  display: block;
  font-size: 18px;
  line-height: 1;
  letter-spacing: 0.12em;
  margin-top: -2px;
}

.chat-menu-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 156px;
  padding: 6px;
  background: var(--chat-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--chat-glass-border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  z-index: 10;
}

.chat-menu-popover[hidden] {
  display: none;
}

.chat-menu-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  text-align: left;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.chat-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.chat-menu-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.chat-menu-item-danger {
  color: var(--danger);
}

.chat-delete-confirm {
  position: absolute;
  top: var(--chat-header-height);
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 9, 12, 0.82);
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  pointer-events: none;
}

.chat-delete-confirm[hidden] {
  display: none;
}

.chat-delete-confirm-panel {
  pointer-events: auto;
  width: 100%;
  max-width: 328px;
  padding: 22px 20px 18px;
  background: var(--chat-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(240, 113, 120, 0.35);
  border-radius: 14px;
  box-shadow:
    0 20px 48px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(240, 113, 120, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: chat-panel-in 0.22s ease-out;
}

@keyframes chat-panel-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
  }
}

.chat-delete-confirm-eyebrow {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--danger);
}

.chat-delete-confirm-title {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.chat-delete-confirm-desc {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.chat-delete-confirm-task-name {
  display: inline;
  color: var(--text);
  font-weight: 600;
}

.chat-delete-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.chat-delete-confirm-btn {
  background: var(--danger);
  color: #1a0c0e;
  border-color: transparent;
  font-weight: 600;
}

.chat-delete-confirm-btn:hover {
  background: #ff8a90;
  filter: none;
}

.chat-delete-confirm-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-details-strip {
  flex-shrink: 0;
  border-bottom: 1px solid var(--chat-glass-border);
  background: rgba(16, 18, 24, 0.55);
}

.chat-details-summary {
  padding: 9px 16px;
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.chat-details-summary:hover {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
}

.chat-details-summary::-webkit-details-marker {
  display: none;
}

.chat-details-summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform 0.15s ease;
}

.chat-details-strip[open] .chat-details-summary::before {
  transform: rotate(90deg);
}

.chat-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 16px 12px;
}

.chat-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--chat-glass-border);
  border-radius: 999px;
  font-size: 11px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.chat-chip:focus-within {
  border-color: rgba(108, 140, 255, 0.35);
  background: rgba(108, 140, 255, 0.06);
}

.chat-chip-readonly {
  border-style: dashed;
  opacity: 0.92;
}

.chat-chip-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
}

.chat-chip-control {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  min-width: 72px;
  max-width: 140px;
}

.chat-chip-control:focus {
  outline: none;
}

.chat-chip-control:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.chat-chip-value {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.chat-details-timestamps {
  margin: 0;
  padding: 0 16px 12px;
  font-size: 10px;
  color: var(--text-subtle);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  opacity: 0.85;
}

.chat-thread {
  flex: 1 1 auto;
  flex-grow: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(108, 140, 255, 0.06), transparent 70%),
    var(--chat-thread-bg);
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chat-thread::-webkit-scrollbar {
  width: 6px;
}

.chat-thread::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.chat-thread-empty {
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-subtle);
  max-width: 220px;
}

.chat-thread-empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: 18px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--chat-glass-border);
}

.chat-bubble {
  max-width: 88%;
  display: flex;
  animation: chat-bubble-in 0.32s ease-out backwards;
}

@keyframes chat-bubble-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.chat-bubble-inner {
  width: 100%;
  padding: 10px 13px 11px;
  border-radius: var(--chat-radius-bubble);
  border: 1px solid transparent;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.chat-bubble-system {
  align-self: center;
  max-width: 96%;
}

.chat-bubble-system .chat-bubble-inner {
  background: var(--bubble-system);
  border-color: var(--bubble-system-border);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-align: center;
  box-shadow: none;
}

.chat-bubble-system .chat-bubble-body {
  font-size: 12px;
  color: var(--text-muted);
}

.chat-bubble-context {
  align-self: flex-start;
}

.chat-bubble-context .chat-bubble-inner {
  background: var(--bubble-context);
  border-color: var(--bubble-context-border);
  border-bottom-left-radius: var(--chat-radius-bubble-tail);
}

.chat-bubble-title {
  align-self: stretch;
  max-width: 100%;
}

.chat-bubble-title .chat-bubble-inner {
  background: linear-gradient(
    145deg,
    rgba(108, 140, 255, 0.2) 0%,
    rgba(22, 26, 38, 0.94) 100%
  );
  border-color: rgba(108, 140, 255, 0.3);
  border-radius: var(--chat-radius-bubble);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.chat-bubble-title .chat-bubble-author {
  color: var(--accent);
}

.chat-bubble-title .chat-bubble-body {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.45;
  color: var(--text);
}

.chat-bubble-user {
  align-self: flex-end;
}

.chat-bubble-user .chat-bubble-inner {
  background: var(--bubble-user);
  border-color: var(--bubble-user-border);
  border-bottom-right-radius: var(--chat-radius-bubble-tail);
}

.chat-bubble-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 5px;
  font-size: 9px;
  color: var(--text-subtle);
  opacity: 0.9;
}

.chat-bubble-system .chat-bubble-meta {
  justify-content: center;
}

.chat-bubble-author {
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 9px;
}

.chat-bubble-user .chat-bubble-author {
  color: var(--accent);
}

.chat-bubble-meta time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 9px;
  opacity: 0.75;
}

.chat-bubble-body {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-composer {
  position: relative;
  flex-shrink: 0;
  padding: 10px 12px 14px;
  border-top: 1px solid var(--chat-glass-border);
  background: var(--chat-glass);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.chat-composer--drag-over .chat-composer-shell {
  background: var(--accent-dim);
  box-shadow:
    inset 0 0 0 2px var(--accent),
    0 0 24px var(--accent-glow);
}

.chat-thread--drag-over {
  outline: 2px dashed rgba(108, 140, 255, 0.55);
  outline-offset: -6px;
  background-color: rgba(108, 140, 255, 0.06);
}

.chat-composer-shell {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 6px 6px 6px 4px;
  border-radius: 22px;
  background: var(--chat-composer-pill);
  border: 1px solid var(--chat-glass-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 4px 20px rgba(0, 0, 0, 0.2);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.chat-composer-shell:focus-within {
  border-color: rgba(108, 140, 255, 0.4);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 0 3px var(--accent-dim),
    0 4px 20px rgba(0, 0, 0, 0.25);
}

.chat-composer-leading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  padding: 2px 0 2px 4px;
}

.chat-composer-input {
  flex: 1;
  min-height: 36px;
  max-height: 120px;
  margin: 0;
  padding: 8px 10px;
  overflow-y: auto;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
}

.chat-composer-input:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

.chat-composer-input:focus {
  outline: none;
}

.chat-send-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin: 2px 2px 2px 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: linear-gradient(145deg, #7b9aff, var(--accent));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 2px 8px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: filter 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}

.chat-send-btn:hover {
  filter: brightness(1.1);
  box-shadow:
    0 4px 14px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.chat-send-btn:active {
  transform: scale(0.92);
}

.chat-send-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chat-send-icon {
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  margin-top: -2px;
}

.chat-attach-input {
  display: none;
}

.chat-media-btn,
.chat-attach-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.chat-media-btn {
  font-size: 20px;
  font-weight: 650;
  line-height: 1;
  color: var(--accent);
}

.chat-media-btn:hover:not(:disabled),
.chat-attach-btn:hover:not(:disabled) {
  color: var(--accent);
  background: var(--accent-dim);
}

.chat-media-btn:active:not(:disabled),
.chat-attach-btn:active:not(:disabled) {
  transform: scale(0.9);
}

.chat-media-btn:disabled,
.chat-attach-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-media-btn:focus-visible,
.chat-attach-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.chat-media-icon {
  line-height: 1;
  margin-top: -1px;
}

.chat-attach-icon {
  font-size: 16px;
  line-height: 1;
  opacity: 0.9;
}

.composer-pending-files {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 4px 2px 2px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  -webkit-overflow-scrolling: touch;
}

.composer-pending-files[hidden] {
  display: none !important;
}

.composer-pending-item {
  position: relative;
  flex: 0 0 auto;
  width: 64px;
}

.composer-pending-thumb-wrap {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  border: 1px solid var(--chat-glass-border);
  background: rgba(0, 0, 0, 0.25);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.composer-pending-item:hover .composer-pending-thumb-wrap {
  border-color: rgba(108, 140, 255, 0.35);
  transform: translateY(-1px);
}

.composer-pending-thumb-wrap img,
.composer-pending-thumb-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.composer-pending-icon {
  font-size: 28px;
  line-height: 1;
}

.composer-pending-label {
  display: block;
  margin-top: 4px;
  font-size: 9px;
  line-height: 1.2;
  color: var(--text-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 64px;
}

.composer-pending-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  z-index: 2;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  background: rgba(12, 13, 16, 0.88);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.12s ease;
}

.composer-pending-remove:hover {
  background: var(--danger);
  border-color: transparent;
}

.composer-pending-remove:active {
  transform: scale(0.9);
}

.chat-composer-main--files-pending .chat-composer-input:empty::before {
  content: 'Add a caption (optional)…';
}

.chat-composer-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 0;
}

.chat-composer-main--image-pending {
  gap: 4px;
}

.composer-image-preview {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  display: flex;
  align-items: stretch;
}

.composer-image-preview[hidden] {
  display: none !important;
}

.composer-image-preview-inner {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--chat-glass-border);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
}

.composer-image-preview-thumb {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 40px;
  max-height: 120px;
  object-fit: cover;
  cursor: zoom-in;
}

.composer-image-preview-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

.composer-image-preview-remove:hover {
  background: rgba(0, 0, 0, 0.85);
}

.composer-image-preview-remove:active {
  transform: scale(0.94);
}

.chat-composer-main--image-pending .chat-composer-input {
  flex: 0 1 auto;
  min-height: 32px;
  max-height: 72px;
}

.chat-composer-main--image-pending .chat-composer-input:empty::before {
  content: 'Add a caption (optional)…';
}

.composer-thumb-hover-popup {
  position: fixed;
  z-index: 12000;
  pointer-events: none;
  padding: 10px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  max-width: min(400px, calc(100vw - 24px));
  max-height: min(400px, calc(100vh - 24px));
}

.composer-thumb-hover-popup[hidden] {
  display: none !important;
}

.composer-thumb-hover-popup img {
  display: block;
  max-width: min(380px, calc(100vw - 44px));
  max-height: min(380px, calc(100vh - 44px));
  width: auto;
  height: auto;
  border-radius: 8px;
  object-fit: contain;
}

.chat-composer-uploading {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 6px 0;
}

.chat-composer-uploading[hidden] {
  display: none !important;
}

.chat-upload-label {
  font-size: 10px;
  letter-spacing: 0.02em;
  opacity: 0.85;
}

.chat-upload-progress {
  width: 100%;
}

.chat-upload-progress-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.chat-upload-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #8eb4ff, var(--accent));
  background-size: 200% 100%;
  transition: width 0.12s ease-out;
  box-shadow: 0 0 12px var(--accent-glow);
}

.chat-bubble-attachments {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

/* Collapsed chat media thumbnails */
.chat-media-thumb {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.18s ease;
}

.chat-media-thumb:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chat-media-thumb--image,
.chat-media-thumb--video {
  width: 140px;
  height: 140px;
  flex-shrink: 0;
}

.chat-media-thumb--image:hover,
.chat-media-thumb--video:hover,
.chat-media-thumb--pdf:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.chat-bubble-attachments .chat-media-thumb .chat-attachment-img,
.chat-bubble-attachments .chat-media-thumb .chat-attachment-video {
  width: 140px;
  height: 140px;
  max-width: none;
  max-height: none;
  object-fit: cover;
  display: block;
  border-radius: 12px;
  border: 1px solid var(--bubble-attachment);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.chat-bubble-attachments .chat-media-thumb .chat-attachment-video {
  background: #000;
}

.chat-media-expand-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

.chat-media-thumb:hover .chat-media-expand-hint,
.chat-media-thumb:focus-visible .chat-media-expand-hint {
  opacity: 1;
}

.chat-media-expand-text {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.chat-media-expand-icon {
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
}

.chat-media-expand-hint--video {
  background: rgba(0, 0, 0, 0.35);
}

.chat-media-thumb--pdf {
  gap: 10px;
  max-width: 220px;
  padding: 8px 12px;
  background: var(--bubble-attachment);
  border: 1px solid var(--chat-glass-border);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.chat-media-thumb--pdf:hover {
  border-color: rgba(108, 140, 255, 0.45);
  background: rgba(108, 140, 255, 0.08);
}

.chat-attachment-img {
  max-width: 100%;
  max-height: 280px;
  border-radius: 12px;
  display: block;
  border: 1px solid var(--bubble-attachment);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.chat-attachment-video {
  max-width: 100%;
  max-height: 280px;
  border-radius: 12px;
  background: #000;
  border: 1px solid var(--bubble-attachment);
}

.chat-attachment-pdf {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bubble-attachment);
  border: 1px solid var(--chat-glass-border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.15s ease;
}

.chat-attachment-pdf:hover {
  border-color: rgba(108, 140, 255, 0.45);
  background: rgba(108, 140, 255, 0.08);
  transform: translateY(-1px);
}

.chat-attachment-pdf:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chat-attachment-pdf-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.chat-attachment-pdf-meta {
  min-width: 0;
}

.chat-attachment-pdf-name {
  font-size: 12px;
  font-weight: 500;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chat-attachment-pdf-action {
  font-size: 10px;
  color: var(--text-muted);
}

/* Lightbox overlay for expanded media — native dialog stacks above task-detail modal top layer */
#chat-media-lightbox.chat-media-lightbox:not([open]) {
  display: none;
}

#chat-media-lightbox.chat-media-lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 24px;
  border: none;
  background: transparent;
  color: inherit;
  overflow: visible;
}

#chat-media-lightbox.chat-media-lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

#chat-media-lightbox.chat-media-lightbox::backdrop {
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.chat-media-lightbox-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: min(960px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  width: 100%;
}

.chat-media-lightbox-close {
  position: absolute;
  top: -12px;
  right: -12px;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: rgba(20, 22, 28, 0.9);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.chat-media-lightbox-close:hover {
  background: rgba(40, 44, 56, 0.95);
  transform: scale(1.05);
}

.chat-media-lightbox-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chat-media-lightbox-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.chat-media-expanded {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 96px);
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}

.chat-media-expanded--image {
  width: auto;
  height: auto;
  object-fit: contain;
}

.chat-media-expanded--video {
  width: 100%;
  background: #000;
}

.chat-media-expanded--pdf {
  width: min(900px, 100%);
  height: min(80vh, 720px);
  border: none;
  background: #fff;
  border-radius: 8px;
}

.chat-media-lightbox-pdf-link {
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-media-lightbox-pdf-link:hover {
  color: #fff;
}

body.chat-media-lightbox-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .chat-bubble,
  .chat-delete-confirm-panel {
    animation: none;
  }

  .chat-thread {
    scroll-behavior: auto;
  }

  .chat-media-panel,
  .chat-media-panel-backdrop {
    transition: none;
  }

  .chat-send-btn,
  .chat-media-btn,
  .chat-attach-btn,
  .composer-pending-remove,
  .chat-media-thumb,
  .chat-attachment-pdf {
    transition: none;
  }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 100;
  transition: opacity 0.2s, transform 0.2s;
}

.toast[hidden] {
  display: none;
}

.toast.visible {
  display: block;
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Loading */
.app.loading .board-grid {
  opacity: 0.5;
  pointer-events: none;
}

/* Responsive */
@media (max-width: 1200px) {
  .board-grid {
    grid-template-columns: repeat(4, minmax(140px, 1fr));
  }
  .board-grid.week-span-5:not(.day-view) {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }
}

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

  html[data-sidebar-collapsed="true"] .app,
  .app.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(var(--sidebar-w), 85vw);
    height: 100vh;
    transform: translateX(0);
    transition: transform var(--sidebar-transition), box-shadow var(--sidebar-transition);
    box-shadow: var(--shadow);
  }

  html[data-sidebar-collapsed="true"] .sidebar,
  .app.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
    pointer-events: none;
  }

  html[data-sidebar-collapsed="true"] .sidebar-brand > div,
  .app.sidebar-collapsed .sidebar-brand > div,
  html[data-sidebar-collapsed="true"] .nav-item,
  .app.sidebar-collapsed .nav-item,
  html[data-sidebar-collapsed="true"] .sidebar-section,
  .app.sidebar-collapsed .sidebar-section,
  html[data-sidebar-collapsed="true"] #connection-label,
  .app.sidebar-collapsed #connection-label {
    opacity: 1;
    width: auto;
    max-height: none;
    margin-top: 24px;
    font-size: 13px;
    pointer-events: auto;
  }

  html[data-sidebar-collapsed="true"] .nav-item,
  .app.sidebar-collapsed .nav-item {
    justify-content: flex-start;
    padding: 8px 10px;
    gap: 10px;
    font-size: 13px;
  }

  html[data-sidebar-collapsed="true"] .sidebar-brand,
  .app.sidebar-collapsed .sidebar-brand {
    justify-content: flex-start;
    padding: 4px 8px 20px;
  }

  html[data-sidebar-collapsed="true"] .sidebar,
  .app.sidebar-collapsed .sidebar {
    padding: 20px 14px;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--sidebar-transition);
  }

  .sidebar-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .board-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .board-grid.week-span-5:not(.day-view) {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .main {
    padding: 16px;
  }
  .board-grid {
    grid-template-columns: 1fr;
  }

  .modal-chat {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: none;
    min-height: 0;
    margin: 0;
    border-radius: 0;
  }
}

/* Active users — bottom-right presence panel */
.active-users-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 28;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: min(280px, calc(100vw - 32px));
  pointer-events: none;
}

.active-users-panel:not([hidden]) {
  pointer-events: auto;
}

.active-users-panel[hidden] {
  display: none !important;
}

.active-users-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.active-users-toggle:hover {
  background: var(--panel-hover);
  border-color: var(--accent);
}

.active-users-toggle[aria-expanded="true"] .active-users-chevron {
  transform: rotate(180deg);
}

.active-users-chevron {
  display: inline-block;
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.active-users-avatars {
  display: inline-flex;
  align-items: center;
  flex-direction: row-reverse;
}

.active-users-avatars:empty {
  display: none;
}

.active-users-avatar-mini {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--accent-dim);
  color: var(--accent);
  border: 2px solid var(--bg-elevated);
  margin-left: -6px;
}

.active-users-avatar-mini:first-child {
  margin-left: 0;
}

.active-users-count {
  white-space: nowrap;
}

.active-users-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  min-width: 180px;
  max-height: 240px;
  overflow-y: auto;
}

.active-users-list[hidden] {
  display: none !important;
}

.active-users-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.active-users-item.is-self {
  background: var(--accent-dim);
}

.active-users-item-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  background: var(--panel);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.active-users-item.is-self .active-users-item-avatar {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

.active-users-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-users-item-you {
  font-size: 10px;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
