*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  background-color: #f8fafc;
  color: #0f172a;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

/* Sign-in Screen */
.signin-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f6 100%);
}

.signin-grid {
  max-width: 920px;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 32px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 36px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

@media (max-width: 768px) {
  .signin-grid {
    grid-template-columns: 1fr;
  }
}

.signin-form-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.signin-guide-col {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.version-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

/* Main App Shell */
.desk-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: #ffffff;
}

.desk-header {
  height: 54px;
  min-height: 54px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: #ffffff;
  gap: 16px;
}

.desk-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* Left Project Rail */
.project-rail {
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e2e8f0;
  background: #fbfcfd;
  position: relative;
  user-select: none;
  min-height: 0;
}

.project-rail-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
}

.project-rail-resizer:hover,
.project-rail-resizer.dragging {
  background: rgba(37, 99, 235, 0.35);
}

.project-card {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  margin-bottom: 6px;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.project-card:hover {
  background: #f1f5f9;
}

.project-card.active {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.project-initial-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-bottom: 8px;
}

.project-initial-btn.active {
  background: #1e3a8a;
  color: #ffffff;
  border-color: #1e3a8a;
}

/* Center Chat Workspace */
.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #ffffff;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.prompt-bubble {
  align-self: flex-end;
  max-width: 78%;
  background: #eef4ff;
  border: 1px solid #dbeafe;
  color: #0f172a;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.reply-bubble {
  align-self: flex-start;
  max-width: 82%;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.waiting-card {
  align-self: flex-start;
  max-width: 78%;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #78350f;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
}

/* Right Documents & Stages Panel */
.docs-pane {
  width: 340px;
  min-width: 280px;
  max-width: 420px;
  border-left: 1px solid #e2e8f0;
  background: #fbfcfd;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.docs-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.status-not_started {
  background: #f1f5f9;
  color: #475569;
}

.status-in_progress {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-done {
  background: #dcfce7;
  color: #15803d;
}

.status-blocked {
  background: #fee2e2;
  color: #b91c1c;
}

/* Scrollable Modal / Drawer (guaranteed scrollable at 1280x800) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-panel {
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  width: 100%;
  max-width: 680px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.18);
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  flex-shrink: 0;
}

.modal-scroll-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: #f8fafc;
  flex-shrink: 0;
}

.mobile-tab-bar {
  display: none;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  padding: 6px 12px;
  gap: 8px;
}

@media (max-width: 768px) {
  .desk-header {
    height: auto;
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .mobile-tab-bar {
    display: flex;
  }
  .project-rail,
  .docs-pane,
  .chat-pane {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
  }
  .mobile-hidden {
    display: none !important;
  }
  .prompt-bubble,
  .reply-bubble,
  .waiting-card {
    max-width: 92%;
  }
}
