/* styles.css — HomeDesign Web Client — Dark theme, responsive */

:root {
  --bg: #1a1a2e;
  --bg2: #16213e;
  --bg3: #0f3460;
  --fg: #e0e0e0;
  --fg2: #a0a0b0;
  --accent: #3b82f6;
  --accent2: #6366f1;
  --danger: #ef4444;
  --success: #22c55e;
  --border: #2a2a4a;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
}

/* --- Layout --- */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#app-header h1 {
  font-size: 16px;
  color: var(--accent);
}

#app-home-link:hover {
  color: #60a5fa;
  text-decoration: underline;
}

/* --- Clickable names --- */

.project-name-link {
  cursor: pointer;
  transition: color 0.15s;
}
.project-name-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.task-title-link {
  cursor: pointer;
  transition: color 0.15s;
}
.task-title-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* --- Breadcrumb Navigation --- */

.breadcrumb-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--fg2);
  width: 100%;
  max-width: 900px;
}

.breadcrumb-link {
  cursor: pointer;
  color: var(--accent);
  transition: color 0.15s;
}
.breadcrumb-link:hover {
  color: #60a5fa;
  text-decoration: underline;
}

.breadcrumb-sep {
  color: var(--fg2);
  user-select: none;
}

.breadcrumb-current {
  color: var(--fg);
  font-weight: 500;
}

#app-header .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#user-info {
  font-size: 13px;
  color: var(--fg2);
}

#app-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
}

/* --- Screens --- */

.screen {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 24px;
}

/* --- Login --- */

#screen-login {
  justify-content: center;
}

.login-box {
  background: var(--bg2);
  padding: 32px;
  border-radius: var(--radius);
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--border);
}

.login-box h2 {
  margin-bottom: 20px;
  text-align: center;
  color: var(--accent);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--fg2);
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent);
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

/* --- Projects --- */

#screen-projects {
  align-items: stretch;
}

#screen-projects h2 {
  margin-bottom: 16px;
  color: var(--accent);
}

#project-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  width: 100%;
}

.project-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.project-card h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.project-card p {
  font-size: 13px;
  color: var(--fg2);
  margin-bottom: 12px;
}

.loading, .error {
  text-align: center;
  color: var(--fg2);
  padding: 40px;
}

.error { color: var(--danger); }

/* --- Buttons --- */

.cr-btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--fg);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.cr-btn:hover { background: var(--bg3); }

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

.cr-btn-secondary {
  background: var(--bg3);
  border-color: var(--bg3);
}

.cr-btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.cr-btn-sm {
  padding: 4px 10px;
  font-size: 14px;
}

/* --- Camera Room --- */

#screen-camera {
  padding: 0;
  align-items: stretch;
}

#camera-room {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.cr-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
}

.cr-status {
  font-size: 13px;
  color: var(--fg2);
}
.cr-status.cr-ok { color: var(--success); }
.cr-status.cr-ok::before { content: '● '; }
.cr-status.cr-err { color: var(--danger); }
.cr-status.cr-err::before { content: '● '; }

.cr-viewers {
  font-size: 12px;
  color: var(--fg2);
  margin-left: auto;
}

.cr-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Select screen (host/viewer buttons) - centered layout */
#cr-select.cr-screen {
  align-items: center;
  justify-content: center;
  gap: 16px;
}

/* Stream screen - stretch to fill, no centering */
#cr-stream.cr-screen {
  align-items: stretch;
}

.cr-select-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* --- Video Container --- */

.cr-video-container {
  flex: 1;
  position: relative;
  background: #000;
  overflow: hidden;
  min-height: 0;
  width: 100%;
  max-width: 900px;
  align-self: center;
}

.cr-video-container video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cr-annotation-overlay {
  position: absolute;
  z-index: 10;
  /* Positioned dynamically by annotation-canvas.js to match video content area */
}

.annotation-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* --- Toolbar --- */

.cr-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  z-index: 20;
}

.cr-tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cr-tool-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.cr-color-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.cr-color-btn.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent);
}

.cr-toolbar select {
  padding: 4px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-size: 12px;
}

/* --- Responsive --- */

@media (max-width: 600px) {
  .cr-toolbar {
    padding: 6px 8px;
    gap: 4px;
  }
  .cr-btn-sm {
    padding: 4px 6px;
    font-size: 12px;
  }
  .cr-color-btn {
    width: 20px;
    height: 20px;
  }
  .login-box {
    padding: 20px;
    margin: 0 12px;
  }
  #project-list {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   NEW STYLES - Projects, Tasks, Media
   ============================================ */

/* --- Projects Screen --- */

.projects-container {
  width: 100%;
  max-width: 1200px;
}

.projects-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.projects-header h2 {
  font-size: 24px;
  color: var(--fg);
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.project-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
}

.project-card:hover {
  border-color: var(--accent);
}

.project-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.project-card-header h3 {
  font-size: 18px;
  color: var(--fg);
}

.project-card-actions {
  display: flex;
  gap: 4px;
}

.project-desc {
  color: var(--fg2);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.4;
}

.project-card-footer {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.project-stat {
  font-size: 13px;
  color: var(--fg2);
}

.project-card-buttons {
  display: flex;
  gap: 10px;
}

/* --- Tasks Screen --- */

.tasks-container {
  width: 100%;
  max-width: 1200px;
}

.tasks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.tasks-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tasks-header h2 {
  font-size: 20px;
}

.tasks-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.task-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.2s;
}

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

.task-card-main {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}

.task-card-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-card-content {
  flex: 1;
}

.task-title {
  font-size: 16px;
  margin-bottom: 4px;
}

.task-desc {
  font-size: 13px;
  color: var(--fg2);
  line-height: 1.4;
}

.task-card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 12px;
  color: var(--fg2);
}

.task-card-actions {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.task-status, .task-priority {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
}

.status-todo { background: #374151; color: #9ca3af; }
.status-in_progress { background: #1e40af; color: #93c5fd; }
.status-review { background: #7c3aed; color: #c4b5fd; }
.status-done { background: #166534; color: #86efac; }

.priority-low { background: #374151; color: #9ca3af; }
.priority-medium { background: #854d0e; color: #fde047; }
.priority-high { background: #991b1b; color: #fca5a5; }

/* --- Task Detail Screen --- */

.task-detail-container {
  width: 100%;
  max-width: 1200px;
}

.task-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.task-detail-content {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.task-detail-title {
  font-size: 24px;
  margin-bottom: 12px;
}

.task-detail-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.task-detail-desc {
  color: var(--fg2);
  line-height: 1.6;
  margin-bottom: 24px;
}

.task-detail-hint {
  color: var(--fg2);
  font-size: 14px;
  margin-bottom: 16px;
}

.task-detail-status {
  margin-top: 12px;
  font-size: 14px;
  color: var(--accent);
}

.task-detail-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.task-detail-section h3 {
  margin-bottom: 16px;
  font-size: 16px;
}

.task-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.task-detail-action-btn,
.task-detail-action-btn .btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.task-detail-action-btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--fg);
  cursor: pointer;
  font-size: 14px;
}

.task-detail-action-btn:hover {
  background: var(--bg2);
  border-color: var(--accent);
}

.upload-label {
  cursor: pointer;
  margin: 0;
}

.task-detail-attachments h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.task-detail-attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.task-detail-attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.task-detail-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
}

.task-detail-thumb-placeholder {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: var(--bg3);
  border-radius: 4px;
}

.task-detail-att-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-detail-empty {
  color: var(--fg2);
  font-style: italic;
}

.task-detail-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.task-detail-modal-inner {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 100%;
}

.task-detail-modal-inner h3 {
  margin-bottom: 12px;
}

.task-detail-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

/* --- Media Gallery (task detail) --- */

.task-detail-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.task-detail-gallery-item {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
}

.task-detail-gallery-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

.task-detail-gallery-placeholder {
  width: 100%;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  background: rgba(255,255,255,0.05);
}

.task-detail-gallery-name {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 4px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-detail-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
  font-size: 14px;
  line-height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
}

.task-detail-gallery-item:hover .task-detail-delete-btn {
  opacity: 1;
}

.task-detail-no-media {
  color: var(--text-secondary);
  text-align: center;
  padding: 20px;
  font-style: italic;
}

/* --- Upload Zone --- */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  margin-bottom: 20px;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
}

.upload-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.upload-icon {
  font-size: 40px;
}

.upload-browse {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

.upload-progress {
  text-align: center;
}

.upload-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.upload-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}

/* --- Image Gallery --- */

.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg3);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}

.gallery-item:hover img {
  transform: scale(1.05);
}

.gallery-item-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gallery-item-name {
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.gallery-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.gallery-delete-btn:hover {
  opacity: 1;
}

/* --- Lightbox --- */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  display: flex;
  flex-direction: column;
  z-index: 1000;
}

.lightbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(0,0,0,0.5);
}

.lightbox-title {
  color: #fff;
  font-size: 14px;
}

.lightbox-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  padding: 0 8px;
}

.lightbox-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* --- Modal --- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h3 {
  font-size: 18px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--fg2);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-body {
  padding: 20px;
}

/* --- Buttons --- */

.btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--fg);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover {
  background: var(--border);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

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

.btn-primary:hover {
  background: var(--accent2);
  border-color: var(--accent2);
}

.btn-secondary {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-icon {
  padding: 4px 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.btn-icon:hover {
  opacity: 1;
}

/* --- Form Elements --- */

.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
}

.input-sm {
  padding: 6px 10px;
  font-size: 13px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* --- Badges --- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--border);
  color: var(--fg2);
}

.badge-blue { background: #1e40af; color: #93c5fd; }
.badge-green { background: #166534; color: #86efac; }
.badge-red { background: #991b1b; color: #fca5a5; }

/* --- Utility --- */

.loading {
  color: var(--fg2);
  text-align: center;
  padding: 40px;
}

.error {
  color: var(--danger);
  text-align: center;
  padding: 20px;
}

.no-data {
  color: var(--fg2);
  text-align: center;
  padding: 40px;
  font-style: italic;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state p {
  color: var(--fg2);
  margin-bottom: 20px;
  font-size: 18px;
}

/* --- Members List --- */

.members-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.member-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 6px;
}

.member-name {
  font-size: 14px;
}

/* --- Responsive --- */

@media (max-width: 768px) {
  .projects-grid {
    grid-template-columns: 1fr;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .task-card-main {
    flex-direction: column;
  }
  
  .task-card-right {
    align-items: flex-start;
    flex-direction: row;
    gap: 12px;
  }
}

/* Project Files Card */
.project-files-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px 24px;
  border-radius: 12px;
  margin-bottom: 24px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.project-files-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

.project-files-card.project-files-empty {
  background: #f5f5f5;
  color: #666;
  border: 2px dashed #ccc;
}

.project-files-card.project-files-empty:hover {
  border-color: #667eea;
  box-shadow: none;
}

.project-files-icon {
  font-size: 36px;
}

.project-files-info {
  flex: 1;
}

.project-files-info h3 {
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: 600;
}

.project-files-info p {
  margin: 0;
  font-size: 14px;
  opacity: 0.9;
}

.project-files-count {
  background: rgba(255,255,255,0.2);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
}

.tasks-section h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Image Editor */
.image-editor-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.95);
  z-index: 10000;
  display: flex;
  flex-direction: column;
}

.image-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #1a1a1a;
  border-bottom: 1px solid #333;
}

.image-editor-title {
  color: white;
  font-size: 16px;
  font-weight: 500;
}

.image-editor-actions {
  display: flex;
  gap: 10px;
}

.image-editor-actions button {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.image-editor-actions .btn-close {
  background: #444;
  color: white;
}

.image-editor-actions .btn-save {
  background: #4CAF50;
  color: white;
}

.image-editor-actions .btn-close:hover { background: #555; }
.image-editor-actions .btn-save:hover { background: #45a049; }

.image-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: #222;
  border-bottom: 1px solid #333;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-right: 1px solid #444;
}

.toolbar-group:last-child {
  border-right: none;
}

.toolbar-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  background: #333;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.toolbar-btn:hover { background: #444; }
.toolbar-btn.active { background: #667eea; }

.toolbar-label {
  color: #888;
  font-size: 12px;
  margin-right: 6px;
}

.color-picker {
  width: 36px;
  height: 36px;
  border: 2px solid #444;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
}

.stroke-width-input {
  width: 60px;
  height: 32px;
  background: #333;
  border: 1px solid #444;
  border-radius: 4px;
  color: white;
  padding: 0 8px;
  font-size: 14px;
}

.image-editor-canvas-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.image-editor-canvas {
  max-width: 100%;
  max-height: 100%;
  cursor: crosshair;
}

/* Image Editor AI toolbar & modals */
.toolbar-ai {
  border-left: 1px solid #444;
  padding-left: 12px;
}

.ai-toolbar-btn {
  background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
  color: #fff !important;
  font-size: 18px !important;
}

.ai-toolbar-btn:hover {
  background: linear-gradient(135deg, #4f46e5, #7c3aed) !important;
}

.editor-ai-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  padding: 20px;
}

.editor-ai-modal-inner {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 420px;
  width: 100%;
}

.editor-ai-modal-inner h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
  color: var(--fg);
}

.editor-ai-modal-desc {
  font-size: 13px;
  color: var(--fg2);
  margin-bottom: 12px;
}

.editor-ai-modal-preview {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 12px;
  background: #000;
}

.editor-ai-modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  resize: none;
  margin-bottom: 12px;
  box-sizing: border-box;
}

.editor-ai-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.editor-ai-result-img {
  max-width: 100%;
  max-height: 50vh;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 12px;
  background: #000;
}

.editor-ai-result-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.gallery-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #f5f5f5;
  transition: transform 0.2s;
}

.gallery-item:hover {
  transform: translateY(-2px);
}

.gallery-thumbnail {
  width: 100%;
  padding-top: 100%;
  position: relative;
  cursor: pointer;
  background: #e0e0e0;
}

.gallery-thumbnail img,
.gallery-thumbnail video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-thumbnail.gallery-video {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-thumbnail .video-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-thumbnail.gallery-file {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-thumbnail .file-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
}

.annotation-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #667eea;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
}

.gallery-item-info {
  padding: 8px 12px;
}

.gallery-filename {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* Old gallery-item-actions - overridden by Phase 1 styles below */

.btn-xs {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
}

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.95);
  z-index: 9999;
  display: flex;
  flex-direction: column;
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #111;
}

.lightbox-title {
  color: white;
  font-size: 14px;
}

.lightbox-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
}

.lightbox-close:hover {
  color: #ff5555;
}

.lightbox-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-media {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Upload Zone */
.upload-zone {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  margin-bottom: 16px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.05);
}

.upload-zone-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.upload-zone-text {
  color: #666;
  font-size: 14px;
}

.upload-zone-text strong {
  color: #667eea;
}

.upload-zone.uploading {
  pointer-events: none;
  opacity: 0.7;
}

/* ============ AI Panel Styles ============ */

.ai-panel {
  position: absolute;
  right: -400px;
  top: 0;
  bottom: 0;
  width: 380px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  box-shadow: -4px 0 20px rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: right 0.3s ease;
  border-left: 1px solid rgba(99,102,241,0.3);
}

.ai-panel.open {
  right: 0;
}

.ai-panel-header {
  display: flex;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  gap: 12px;
}

.ai-panel-header h3 {
  flex: 1;
  margin: 0;
  color: #fff;
  font-size: 16px;
}

.ai-provider-toggle {
  display: flex;
  gap: 4px;
  background: rgba(0,0,0,0.3);
  padding: 4px;
  border-radius: 8px;
}

.ai-provider-btn {
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  border-radius: 6px;
  font-size: 12px;
  transition: all 0.2s;
}

.ai-provider-btn.active {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
}

.ai-panel-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.2s;
}

.ai-panel-close:hover {
  background: rgba(239,68,68,0.5);
}

.ai-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Tools Grid */
.ai-tools-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.ai-tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-tool-btn:hover {
  background: rgba(99,102,241,0.2);
  border-color: rgba(99,102,241,0.5);
  transform: translateY(-2px);
}

.ai-tool-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.ai-tool-label {
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}

.ai-tool-desc {
  color: rgba(255,255,255,0.5);
  font-size: 11px;
  text-align: center;
}

/* Tool Interface */
.ai-tool-interface {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ai-tool-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-back-btn {
  padding: 8px 12px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.ai-back-btn:hover {
  background: rgba(255,255,255,0.2);
}

.ai-tool-title {
  color: #fff;
  font-weight: 600;
  font-size: 15px;
}

/* Image Preview */
.ai-image-preview {
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16/9;
}

.ai-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ai-capture-btn {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border: none;
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
}

.ai-capture-btn:hover {
  transform: translateX(-50%) scale(1.05);
}

/* Prompt Section */
.ai-prompt-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-prompt-section label {
  color: rgba(255,255,255,0.7);
  font-size: 13px;
}

#ai-prompt-input {
  width: 100%;
  padding: 12px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  resize: none;
}

#ai-prompt-input:focus {
  outline: none;
  border-color: rgba(99,102,241,0.5);
}

.ai-quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ai-quick-prompt {
  padding: 6px 10px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: rgba(255,255,255,0.8);
  border-radius: 16px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s;
}

.ai-quick-prompt:hover {
  background: rgba(99,102,241,0.3);
}

/* Action Button */
.ai-action-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  border: none;
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.2s;
}

.ai-action-btn:hover:not(:disabled) {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(34,197,94,0.4);
}

.ai-action-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Results Gallery */
.ai-results {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.ai-results h4 {
  color: #fff;
  margin: 0 0 12px 0;
  font-size: 14px;
}

.ai-results-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.ai-result-item {
  position: relative;
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
  overflow: hidden;
}

.ai-result-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.ai-result-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 4px;
  padding: 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
}

.ai-result-save,
.ai-result-view {
  flex: 1;
  padding: 6px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.ai-result-save:hover,
.ai-result-view:hover {
  background: rgba(99,102,241,0.5);
}

.ai-result-text {
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.ai-result-text pre {
  margin: 0;
  white-space: pre-wrap;
  font-size: 11px;
  color: rgba(255,255,255,0.8);
}

/* Chat Interface */
.ai-chat-interface {
  display: flex;
  flex-direction: column;
  height: 400px;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-chat-message {
  display: flex;
  gap: 10px;
  max-width: 90%;
}

.ai-chat-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-chat-assistant {
  align-self: flex-start;
}

.ai-chat-avatar {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  font-size: 16px;
  flex-shrink: 0;
}

.ai-chat-content {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.ai-chat-user .ai-chat-content {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
}

.ai-chat-assistant .ai-chat-content {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.9);
}

.ai-chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

#ai-chat-input {
  flex: 1;
  padding: 10px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  resize: none;
}

.ai-chat-send {
  padding: 10px 16px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border: none;
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.ai-chat-send:hover {
  opacity: 0.9;
}

.ai-chat-generate {
  padding: 10px 14px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border: none;
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: opacity 0.2s;
}

.ai-chat-generate:hover {
  opacity: 0.9;
}

/* AI Button in Toolbar */
.ai-toolbar-btn {
  position: relative;
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%) !important;
}

.ai-toolbar-btn::after {
  content: '✨';
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 12px;
}

/* Enhanced AI toolbar button visibility */
.ai-toolbar-btn {
  font-size: 20px !important;
  padding: 8px 14px !important;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.5) !important;
  animation: ai-pulse 2s ease-in-out infinite !important;
}

@keyframes ai-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(139, 92, 246, 0.4); }
  50% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.8); }
}

.ai-toolbar-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 25px rgba(139, 92, 246, 1) !important;
}

/* ============ Gallery Enhancements - Phase 1 ============ */

/* Sort controls */
.gallery-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 0 4px;
}

.gallery-sort label {
  font-size: 13px;
  color: #666;
}

.gallery-sort .input-sm {
  padding: 4px 8px;
  font-size: 13px;
  max-width: 150px;
}

/* Gallery badges */
.gallery-badge {
  position: absolute;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
}

.annotation-badge {
  top: 8px;
  right: 8px;
  background: #667eea;
}

.ai-badge {
  top: 8px;
  left: 8px;
  background: #f59e0b;
  color: #000;
}

.history-badge {
  bottom: 8px;
  right: 8px;
  background: #8b5cf6;
  color: #fff;
}

/* Notes preview */
.gallery-notes-preview {
  font-size: 11px;
  color: #999;
  display: block;
  margin-top: 2px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Restructured gallery actions */
.gallery-item-actions {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  opacity: 0;
  transition: opacity 0.2s;
}

.gallery-item:hover .gallery-item-actions {
  opacity: 1;
}

.gallery-vote-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  background: rgba(255,255,255,0.9);
  border-radius: 6px;
  padding: 2px 4px;
}

.gallery-tool-actions {
  display: flex;
  gap: 3px;
  justify-content: flex-end;
}

.vote-btn {
  background: rgba(255,255,255,0.8) !important;
  border: 1px solid #ddd !important;
  cursor: pointer;
  font-size: 11px !important;
  padding: 2px 5px !important;
}

.vote-btn:hover {
  background: #e3f2fd !important;
}

.vote-count {
  font-size: 12px;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
}

.vote-positive { color: #22c55e; }
.vote-negative { color: #ef4444; }
.vote-neutral { color: #999; }

/* Image Info Modal */
.image-info-modal {
  max-height: 70vh;
  overflow-y: auto;
}

.image-info-preview {
  position: relative;
  text-align: center;
  margin-bottom: 16px;
}

.ai-generated-tag {
  display: inline-block;
  background: #f59e0b;
  color: #000;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
}

.image-info-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.image-info-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  font-size: 13px;
}

.image-info-meta div {
  color: #555;
}

.image-info-history {
  border-top: 1px solid #eee;
  padding-top: 12px;
}

.image-info-history h4 {
  margin-bottom: 8px;
  font-size: 14px;
}

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

.history-entry {
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}

.history-type {
  display: inline-block;
  background: #e3f2fd;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.history-desc {
  color: #333;
}

.history-meta {
  color: #999;
  font-size: 12px;
}

.image-info-votes {
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 6px;
  font-size: 13px;
}

/* Analysis result cards */
.analysis-grid {
  display: grid;
  gap: 12px;
}

.analysis-card {
  background: #f8f9fa;
  padding: 14px;
  border-radius: 8px;
  border-left: 4px solid #667eea;
}

.analysis-card h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
}

.analysis-summary {
  margin-top: 8px;
  font-style: italic;
  color: #555;
}

.analysis-ranking ol {
  padding-left: 24px;
}

.analysis-ranking li {
  margin-bottom: 4px;
}

.analysis-tips ul {
  padding-left: 20px;
}

/* Match result styles */
.match-reference {
  background: #f0f4ff;
  padding: 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.match-results h4 {
  margin-bottom: 12px;
}

.match-item {
  display: flex;
  gap: 14px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 8px;
}

.match-score {
  font-size: 24px;
  font-weight: 700;
  color: #667eea;
  min-width: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.match-tip {
  margin-top: 6px;
  font-size: 13px;
  color: #666;
}

.match-best {
  background: #f0fdf4;
  padding: 14px;
  border-radius: 8px;
  margin-top: 16px;
  border-left: 4px solid #22c55e;
}

/* ============ Version History - Phase 2 ============ */

.version-history-container {
  max-height: 70vh;
  overflow-y: auto;
}

.version-history-header {
  display: flex;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #eee;
  margin-bottom: 16px;
}

.version-current-info h4 { margin: 0 0 8px 0; }

.version-meta {
  font-size: 13px;
  color: #666;
  margin-bottom: 2px;
}

.version-timeline h4 {
  margin-bottom: 12px;
}

.version-entries {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.version-entry {
  padding: 10px 14px;
  border-left: 4px solid #667eea;
  background: #f8f9fa;
  border-radius: 0 8px 8px 0;
}

.version-entry-origin {
  opacity: 0.7;
}

.version-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.version-entry-icon { font-size: 16px; }

.version-entry-type {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  background: #e3f2fd;
  padding: 2px 8px;
  border-radius: 4px;
}

.version-entry-name {
  font-weight: 600;
  font-size: 13px;
}

.version-entry-num {
  font-size: 11px;
  color: #999;
  background: #f0f0f0;
  padding: 1px 6px;
  border-radius: 4px;
}

.version-entry-desc {
  font-size: 13px;
  color: #333;
  margin-bottom: 4px;
}

.version-entry-meta {
  font-size: 12px;
  color: #999;
}

.version-entry-annotations {
  font-size: 12px;
  color: #667eea;
  margin-top: 4px;
}

.version-entry-result {
  margin-top: 6px;
}

/* ============ Image Comments - Phase 4 ============ */

.image-comments-container {
  display: flex;
  gap: 16px;
  max-height: 70vh;
}

.image-comments-canvas {
  flex: 1;
  position: relative;
  min-width: 0;
}

.comment-pins-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.comment-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
}

.comment-pin-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.image-comments-sidebar {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  overflow-y: auto;
}

.comments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
  margin-bottom: 12px;
}

.comments-header h4 { margin: 0; font-size: 14px; }

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comment-card {
  padding: 10px 12px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #eee;
}

.comment-resolved {
  opacity: 0.6;
}

.comment-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.comment-pin-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
}

.comment-priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.comment-author {
  font-weight: 600;
  font-size: 13px;
}

.comment-date {
  font-size: 11px;
  color: #999;
  margin-left: auto;
}

.comment-text {
  font-size: 13px;
  color: #333;
  margin-bottom: 6px;
}

.comment-replies {
  padding-left: 12px;
  border-left: 2px solid #ddd;
  margin: 8px 0;
}

.comment-reply {
  font-size: 12px;
  color: #555;
  margin-bottom: 4px;
}

.comment-reply-author {
  font-weight: 600;
}

.comment-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.reply-input {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  align-items: flex-start;
}

.reply-input textarea {
  flex: 1;
  font-size: 12px;
}

.comments-resolved-divider {
  padding: 8px 0;
  font-size: 12px;
  color: #999;
  text-align: center;
  border-top: 1px solid #eee;
  margin-top: 8px;
}

.new-comment-form .form-row {
  display: flex;
  gap: 12px;
}

@media (max-width: 768px) {
  .image-comments-container {
    flex-direction: column;
  }
  .image-comments-sidebar {
    width: 100%;
  }
}

/* ============ Drag-and-Drop Reordering - Phase 5 ============ */

.gallery-item[draggable="true"] {
  cursor: grab;
}

.gallery-item[draggable="true"]:active {
  cursor: grabbing;
}

.gallery-dragging {
  opacity: 0.4;
  transform: scale(0.95);
}

.gallery-dragover {
  border: 2px dashed #667eea;
  border-radius: 8px;
}

/* ============ AI Chat Modal (Task Detail) ============ */

.ai-chat-modal {
  display: flex;
  flex-direction: column;
  height: 60vh;
  min-height: 400px;
}

.ai-chat-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
  margin-bottom: 8px;
}

.ai-chat-provider-select {
  display: flex;
  gap: 4px;
  align-items: center;
}

.ai-select {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  max-width: 130px;
}

.ai-select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.3);
}

.ai-select option {
  background: #1e1e2e;
  color: #fff;
}

.ai-provider-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-backend {
  background: rgba(16,185,129,0.25);
  color: #6ee7b7;
}

.badge-opus {
  background: rgba(139,92,246,0.25);
  color: #c4b5fd;
}

.ai-chat-quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  margin-bottom: 8px;
}

.ai-chat-quick:hover {
  background: #667eea;
  color: white;
}

.ai-chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-chat-msg {
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
}

.ai-chat-msg-user {
  background: #f0f4ff;
}

.ai-chat-msg-assistant {
  background: #f8f9fa;
}

.ai-chat-msg-avatar {
  font-size: 18px;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}

.ai-chat-msg-content {
  flex: 1;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.ai-chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding-top: 8px;
  border-top: 1px solid #eee;
}

.ai-chat-input-row textarea {
  flex: 1;
  resize: none;
}

.ai-chat-input-row .btn-primary {
  height: 42px;
  min-width: 70px;
}

/* ============ Compose Images Picker ============ */

.compose-picker {
  max-height: 60vh;
  overflow-y: auto;
}

.compose-objects-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.compose-object-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 8px;
  cursor: pointer;
}

.compose-object-item:hover {
  background: #e8ecf4;
}

.compose-object-item input[type="radio"] {
  margin: 0;
}

.compose-object-item label {
  cursor: pointer;
  font-size: 14px;
}

/* ============ Task Detail AI Chat Modal ============ */

.task-detail-ai-btn {
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%) !important;
  color: #fff !important;
  border-color: #8b5cf6 !important;
  animation: ai-btn-glow 2s ease-in-out infinite;
}

.task-detail-ai-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.5);
}

@keyframes ai-btn-glow {
  0%, 100% { box-shadow: 0 0 4px rgba(139, 92, 246, 0.3); }
  50% { box-shadow: 0 0 12px rgba(139, 92, 246, 0.6); }
}

.ai-chat-modal-inner {
  width: 100%;
  max-width: 700px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  overflow: hidden;
}

.ai-chat-modal-header-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
  flex-shrink: 0;
}

.ai-chat-modal-header-bar h3 {
  flex: 1;
  margin: 0;
  font-size: 16px;
  color: var(--fg);
}

.ai-chat-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255,255,255,0.1);
  color: var(--fg);
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  transition: background 0.2s;
}

.ai-chat-close-btn:hover {
  background: var(--danger);
  color: #fff;
}

.ai-chat-msg-meta {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-style: italic;
}

.ai-chat-quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ai-chat-quick {
  padding: 4px 10px !important;
  font-size: 12px !important;
  border-radius: 16px;
  transition: all 0.2s;
}

.ai-chat-quick:hover {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%) !important;
  color: white !important;
  border-color: #6366f1 !important;
}

/* AI Image Selector */
.ai-image-selector {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ai-image-selector-label {
  font-size: 12px;
  color: var(--fg2);
  margin-bottom: 8px;
}

.ai-image-selector-grid {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.ai-img-select-item {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  flex-shrink: 0;
  transition: border-color 0.2s;
}

.ai-img-select-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-img-select-item:hover {
  border-color: var(--accent);
}

.ai-img-select-item.selected {
  border-color: #22c55e;
}

.ai-img-check {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  background: #22c55e;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
}

/* AI Chat Messages Area */
.ai-chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 400px;
}

.ai-chat-welcome {
  text-align: center;
  padding: 40px 20px;
  color: var(--fg2);
}

.ai-chat-welcome p {
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.ai-chat-msg {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  max-width: 95%;
}

.ai-chat-msg-user {
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.15));
  align-self: flex-end;
}

.ai-chat-msg-assistant {
  background: rgba(255,255,255,0.05);
  align-self: flex-start;
}

.ai-chat-msg-avatar {
  font-size: 20px;
  flex-shrink: 0;
  width: 30px;
  text-align: center;
}

.ai-chat-msg-content {
  flex: 1;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  color: var(--fg);
}

.ai-chat-msg-content pre {
  background: rgba(0,0,0,0.3);
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 13px;
  margin: 8px 0;
}

.ai-chat-msg-content code {
  background: rgba(0,0,0,0.2);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 13px;
}

.ai-chat-gen-images {
  margin-top: 8px;
}

.ai-chat-gen-image {
  margin-bottom: 8px;
}

.ai-chat-gen-image img {
  max-width: 100%;
  border-radius: 8px;
  margin: 4px 0;
}

.ai-chat-img-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

/* AI Chat Input Row */
.ai-chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ai-chat-input-row textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
}

.ai-chat-input-row .btn {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#ai-chat-generate-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  border-color: #f59e0b !important;
  color: #fff !important;
  font-size: 13px;
}

#ai-chat-generate-btn:hover {
  background: linear-gradient(135deg, #d97706, #b45309) !important;
}

/* ============ Order Items ============ */

.order-items-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.order-items-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.order-items-header h3 {
  margin: 0;
  font-size: 16px;
  color: var(--fg);
}

.order-saving-indicator {
  font-size: 13px;
  color: #f59e0b;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.order-saved-indicator {
  font-size: 13px;
  color: var(--success);
}

.order-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.order-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.2s;
}

.order-item:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(99,102,241,0.3);
}

.order-item-checked {
  opacity: 0.6;
  background: rgba(34,197,94,0.05);
}

.order-item-checkbox {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  min-width: 28px;
  transition: transform 0.15s;
}

.order-item-checkbox:hover {
  transform: scale(1.2);
}

.order-item-qty {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
}

.order-item-text {
  flex: 1;
  font-size: 14px;
  color: var(--fg);
}

.order-text-checked {
  text-decoration: line-through;
  color: var(--fg2);
}

.order-item-votes {
  display: flex;
  gap: 4px;
}

.order-vote-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--fg);
  transition: all 0.2s;
}

.order-vote-btn:hover {
  background: rgba(99,102,241,0.2);
  border-color: rgba(99,102,241,0.4);
}

.order-vote-up:hover {
  background: rgba(34,197,94,0.15);
  border-color: rgba(34,197,94,0.4);
}

.order-vote-down:hover {
  background: rgba(239,68,68,0.15);
  border-color: rgba(239,68,68,0.4);
}

.order-item-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.order-item:hover .order-item-actions {
  opacity: 1;
}

.order-item-actions .btn-icon {
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.2s;
}

.order-item-actions .btn-icon:hover {
  background: rgba(255,255,255,0.1);
}

/* Order Item Edit Mode */
.order-item-edit {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.order-item-edit .input-sm {
  padding: 6px 10px;
}

.order-items-empty {
  text-align: center;
  color: var(--fg2);
  padding: 20px;
  font-style: italic;
}

/* Order Items Add Form */
.order-items-add {
  margin-top: 12px;
}

.order-add-toggle {
  width: 100%;
  padding: 10px;
  font-size: 14px;
}

.order-add-form {
  margin-top: 12px;
}

.order-add-form textarea {
  margin-bottom: 12px;
  font-family: monospace;
  font-size: 13px;
}

.order-add-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ============ Attachments section header + Analyze ============ */

.task-detail-attachments-section {
  margin-top: 20px;
}

.task-detail-attachments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.task-detail-attachments-title {
  margin: 0;
  font-size: 16px;
  color: var(--fg);
}

/* ============ Analyze Design modal ============ */

.task-detail-analyze-modal-inner {
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.task-detail-analyze-desc {
  font-size: 14px;
  color: var(--fg2);
  margin-bottom: 16px;
}

.analyze-select-hint {
  font-size: 14px;
  color: var(--fg2);
  margin-bottom: 12px;
}

.analyze-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.analyze-image-pick {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
  aspect-ratio: 1;
  background: var(--bg3);
}

.analyze-image-pick:hover {
  border-color: var(--accent);
}

.analyze-image-pick.selected {
  border-color: var(--success);
  box-shadow: 0 0 0 2px var(--success);
}

.analyze-image-pick img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.analyze-image-check {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

.analyze-selected-count {
  font-size: 13px;
  color: var(--fg2);
  margin-bottom: 16px;
}

.analyze-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.analyze-results h4 {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: var(--fg);
}

.analyze-rankings {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.analyze-rank-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.analyze-rank-first {
  background: rgba(34,197,94,0.1);
  border-color: var(--success);
  border-width: 2px;
}

.analyze-rank-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.analyze-rank-first .analyze-rank-badge {
  background: var(--success);
  color: #fff;
}

.analyze-rank-img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.analyze-rank-body {
  flex: 1;
  min-width: 0;
}

.analyze-rank-score {
  font-weight: 600;
  font-size: 14px;
  color: var(--fg);
  margin-bottom: 4px;
}

.analyze-rank-text {
  font-size: 13px;
  color: var(--fg2);
  line-height: 1.4;
  margin-bottom: 4px;
}

.analyze-rank-strengths {
  font-size: 12px;
  color: var(--success);
}

.analyze-overall-summary {
  padding: 12px;
  background: rgba(59,130,246,0.1);
  border-radius: 8px;
  border-left: 4px solid var(--accent);
  margin-bottom: 16px;
}

.analyze-overall-summary strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--accent);
}

.analyze-overall-summary p {
  margin: 0;
  font-size: 13px;
  color: var(--fg);
  line-height: 1.5;
}

/* ============ AI History Panel ============ */

.ai-header-btn {
  padding: 4px 8px !important;
  font-size: 14px !important;
  background: rgba(255,255,255,0.08) !important;
  border: 1px solid rgba(255,255,255,0.15) !important;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.ai-header-btn:hover {
  background: rgba(99,102,241,0.3) !important;
  border-color: rgba(99,102,241,0.5) !important;
}

.ai-history-panel {
  max-height: 280px;
  overflow-y: auto;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding: 8px 16px;
}

.ai-history-empty {
  text-align: center;
  color: var(--fg2);
  font-size: 13px;
  padding: 16px;
}

.ai-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent;
}

.ai-history-item:hover {
  background: rgba(255,255,255,0.1);
}

.ai-history-item.active {
  background: rgba(99,102,241,0.15);
  border-color: rgba(99,102,241,0.3);
}

.ai-history-item-main {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.ai-history-preview {
  font-size: 13px;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.ai-history-meta {
  font-size: 10px;
  color: var(--fg2);
  opacity: 0.7;
}

.ai-history-delete {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  opacity: 0.3;
  transition: opacity 0.15s;
  padding: 4px;
  flex-shrink: 0;
}

.ai-history-delete:hover {
  opacity: 1;
}

/* ============ AI Attachment System ============ */

.ai-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.15);
}

.ai-attach-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-attach-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  width: 34px;
  height: 30px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.ai-attach-btn:hover {
  background: rgba(99,102,241,0.3);
  border-color: rgba(99,102,241,0.5);
}

.ai-action-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-action-btn {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border: none;
  border-radius: 8px;
  width: 38px;
  height: 30px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  box-shadow: 0 2px 6px rgba(99,102,241,0.3);
}

.ai-action-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(99,102,241,0.5);
}

.ai-action-btn:active {
  transform: scale(0.95);
}

.ai-send-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-attached-preview {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  overflow-x: auto;
  background: rgba(0,0,0,0.1);
  border-top: 1px solid rgba(255,255,255,0.05);
  flex-wrap: wrap;
}

.ai-attached-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  min-width: 60px;
  max-width: 80px;
}

.ai-attached-item img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
}

.ai-attached-name {
  font-size: 9px;
  color: var(--fg2);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70px;
}

.ai-attached-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  border: none;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.ai-file-icon {
  font-size: 28px;
  padding: 8px;
}

/* Image Picker Modal */
.ai-picker-modal {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 12px;
}

.ai-picker-inner {
  background: var(--bg2, #1e1e2e);
  border-radius: 12px;
  padding: 16px;
  max-width: 90%;
  max-height: 70vh;
  overflow-y: auto;
  min-width: 300px;
}

.ai-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.ai-picker-header h4 {
  margin: 0;
  color: var(--fg);
}

.ai-picker-close {
  background: none;
  border: none;
  color: var(--fg2);
  font-size: 18px;
  cursor: pointer;
}

.ai-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.ai-picker-item {
  position: relative;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  transition: all 0.15s;
}

.ai-picker-item.selected {
  border-color: #6366f1;
}

.ai-picker-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.ai-picker-name {
  display: block;
  font-size: 9px;
  color: var(--fg2);
  text-align: center;
  padding: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Message attachment thumbnails */
.ai-msg-attachments {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.ai-msg-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.2);
}

.ai-msg-file-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.1);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--fg2);
}

/* ============ AI Chat in Task Detail - Responsive ============ */

@media (max-width: 600px) {
  .ai-chat-modal-inner {
    max-width: 100%;
    max-height: 95vh;
    border-radius: 0;
  }

  .ai-chat-modal-header-bar {
    padding: 10px 12px;
    flex-wrap: wrap;
  }

  .ai-chat-quick-prompts {
    padding: 8px 12px;
  }

  .ai-chat-messages-area {
    padding: 12px;
  }

  .ai-chat-input-row {
    padding: 10px 12px;
  }

  .ai-attach-bar {
    flex-direction: row;
  }

  .order-item {
    flex-wrap: wrap;
  }

  .order-item-votes,
  .order-item-actions {
    opacity: 1;
  }
}
