html {
  font-size: 14px;
  min-height: 100%;
  position: relative;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  background: #f6f7f9;
  color: #17202a;
  margin-bottom: 60px;
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.generation-overlay {
  align-items: center;
  background: rgba(15, 23, 42, 0.62);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  right: 0;
  top: 0;
  transition: opacity 0.18s ease;
  visibility: hidden;
  z-index: 1100;
}

.generation-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.generation-overlay-panel {
  align-items: center;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 22px 48px rgba(15, 23, 42, 0.24);
  display: grid;
  gap: 0.85rem;
  justify-items: center;
  max-width: 360px;
  padding: 1.5rem 1.6rem;
  text-align: center;
  width: min(360px, calc(100vw - 2rem));
}

.generation-overlay-panel span {
  color: #64748b;
  font-size: 0.95rem;
}

.workspace-header {
  align-items: flex-end;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin: 1.2rem 0 1.5rem;
}

.workspace-header h1 {
  font-size: 2rem;
  margin: 0.25rem 0;
}

.workspace-header p {
  color: #5d6978;
  margin: 0;
}

.eyebrow {
  color: #2f6f75;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-pill {
  border-radius: 999px;
  font-size: 0.88rem;
  padding: 0.5rem 0.85rem;
  white-space: nowrap;
}

.status-pill.ok {
  background: #e1f3ea;
  color: #14623b;
}

.status-pill.warn {
  background: #fff1d6;
  color: #7a4c00;
}

.quick-actions {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 1rem;
}

.action-card {
  background: #fff;
  border: 1px solid #dfe4ea;
  border-radius: 8px;
  color: #17202a;
  display: grid;
  gap: 0.35rem;
  padding: 1rem;
  text-decoration: none;
}

.action-card:hover {
  border-color: #8bb6bd;
  color: #17202a;
}

.action-card strong {
  font-size: 1.05rem;
}

.action-card span {
  color: #637083;
}

.dashboard-grid,
.content-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 420px minmax(0, 1fr);
}

.content-grid {
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 1fr);
}

.sidebar-stack {
  display: grid;
  gap: 1rem;
}

.panel {
  background: #fff;
  border: 1px solid #dfe4ea;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(24, 31, 42, 0.05);
  padding: 1.25rem;
}

.panel-title {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.panel-title h2 {
  font-size: 1.05rem;
  margin: 0;
}

.panel-title span {
  color: #718096;
  font-size: 0.9rem;
}

.textarea-xl {
  min-height: 220px;
}

.textarea-lg {
  min-height: 160px;
}

.textarea-sm {
  min-height: 96px;
}

.context-switches {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.reference-preview-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-top: 0.75rem;
  padding: 0.85rem;
}

.reference-preview-header {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.reference-preview-header span {
  color: #64748b;
  font-size: 0.88rem;
}

.reference-preview-list {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
}

.reference-preview-card {
  background: #fff;
  border: 1px solid #dbe3eb;
  border-radius: 8px;
  cursor: grab;
  display: grid;
  gap: 0.45rem;
  min-width: 0;
  padding: 0.55rem;
  position: relative;
}

.reference-preview-card:active {
  cursor: grabbing;
}

.reference-preview-card.is-dragging {
  opacity: 0.55;
}

.reference-preview-card img {
  aspect-ratio: 1 / 1;
  background: #eef2f6;
  border-radius: 6px;
  display: block;
  object-fit: cover;
  width: 100%;
}

.reference-preview-order {
  align-items: center;
  background: #0f172a;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 0.82rem;
  font-weight: 700;
  height: 1.7rem;
  justify-content: center;
  left: 0.75rem;
  position: absolute;
  top: 0.75rem;
  width: 1.7rem;
}

.reference-preview-name {
  color: #475569;
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-preview-remove {
  justify-self: stretch;
}

.project-form {
  display: grid;
  gap: 0.55rem;
}

.project-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.management-summary {
  color: #64748b;
  font-size: 0.9rem;
}

.management-list {
  min-height: 9rem;
}

.mini-card {
  border: 1px solid #e4e9ef;
  border-radius: 8px;
  padding: 0.8rem;
}

.mini-card-heading {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
}

.mini-card-heading span {
  background: #f1f5f9;
  border-radius: 999px;
  color: #475569;
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
  white-space: nowrap;
}

.mini-card.is-active {
  border-color: #8bb6bd;
  box-shadow: inset 0 0 0 1px rgba(35, 140, 150, 0.12);
}

.mini-card strong,
.mini-card span {
  display: block;
}

.mini-card span {
  color: #6a7482;
  font-size: 0.9rem;
}

.mini-card-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

.mini-card-actions form {
  margin: 0;
}

.management-pagination {
  align-items: center;
  border-top: 1px solid #edf1f5;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  margin-top: 1rem;
  padding-top: 0.85rem;
}

.management-pagination span {
  color: #64748b;
  font-size: 0.88rem;
}

.management-modal .modal-content {
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 8px;
}

.management-modal .modal-body {
  background: #fbfcfd;
}

.artifact-filter-bar,
.artifact-toolbar,
.artifact-pagination {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.artifact-filter-bar {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  flex-wrap: wrap;
  padding: 0.75rem 0.85rem;
}

.artifact-filter-bar .form-label {
  margin-bottom: 0;
}

.artifact-filter-bar .form-select {
  min-width: 180px;
}

.artifact-toolbar {
  justify-content: flex-end;
}

.artifact-list {
  display: grid;
  gap: 1rem;
}

.artifact-item {
  border-top: 1px solid #e6ebf0;
  padding-top: 1rem;
}

.artifact-meta {
  display: grid;
  gap: 0.2rem;
  margin-bottom: 0.75rem;
}

.artifact-meta span {
  color: #6a7482;
  font-size: 0.88rem;
}

.artifact-item pre,
.doc-panel pre {
  background: #f7f9fb;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: #1f2937;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
  overflow-x: auto;
  padding: 1rem;
  white-space: pre-wrap;
}

.artifact-text {
  margin: 0;
  max-height: 200rem;
  overflow: hidden;
  transition: max-height 0.2s ease;
}

.artifact-text.is-collapsed {
  max-height: 14rem;
}

.artifact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.artifact-pagination {
  justify-content: space-between;
  margin-top: 1rem;
}

.artifact-reader-dialog {
  margin: 3vh auto;
  max-width: min(1040px, calc(100vw - 2rem));
  min-height: 94vh;
}

.artifact-reader-dialog .modal-content {
  background: #fbfcfd;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 8px;
  min-height: 94vh;
}

.artifact-reader-header {
  align-items: flex-start;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 1rem 1.25rem;
}

.artifact-reader-title {
  display: grid;
  gap: 0.2rem;
}

.artifact-reader-actions {
  align-items: center;
  display: flex;
  gap: 0.75rem;
}

.artifact-reader {
  padding: clamp(1.25rem, 3vw, 2.75rem);
}

.artifact-markdown {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06);
  color: #17202a;
  line-height: 1.85;
  margin: 0 auto;
  max-width: 820px;
  min-height: 65vh;
  padding: clamp(1.25rem, 3vw, 2.4rem);
}

.artifact-markdown h2,
.artifact-markdown h3,
.artifact-markdown h4,
.artifact-markdown h5,
.artifact-markdown h6 {
  color: #0f172a;
  font-weight: 700;
  line-height: 1.35;
  margin: 1.45rem 0 0.75rem;
}

.artifact-markdown h2 {
  border-bottom: 1px solid #e2e8f0;
  font-size: 1.35rem;
  padding-bottom: 0.45rem;
}

.artifact-markdown h3 {
  font-size: 1.16rem;
}

.artifact-markdown h4,
.artifact-markdown h5,
.artifact-markdown h6 {
  font-size: 1.02rem;
}

.artifact-markdown h2:first-child,
.artifact-markdown h3:first-child,
.artifact-markdown h4:first-child {
  margin-top: 0;
}

.artifact-markdown p {
  margin: 0 0 1rem;
}

.artifact-markdown ul,
.artifact-markdown ol {
  margin: 0 0 1rem 1.35rem;
  padding: 0;
}

.artifact-markdown li {
  margin-bottom: 0.4rem;
  padding-left: 0.15rem;
}

.artifact-markdown .task-list-item {
  list-style: none;
  margin-left: -1.15rem;
}

.artifact-markdown .task-list-item input {
  margin-right: 0.45rem;
}

.artifact-markdown blockquote {
  background: #f5f8fa;
  border-left: 4px solid #8bb6bd;
  border-radius: 8px;
  color: #415161;
  margin: 1rem 0;
  padding: 0.85rem 1rem;
}

.artifact-markdown blockquote > :last-child {
  margin-bottom: 0;
}

.artifact-markdown hr {
  border: 0;
  border-top: 1px solid #e2e8f0;
  margin: 1.5rem 0;
  opacity: 1;
}

.artifact-table-wrap {
  border: 1px solid #dfe7ee;
  border-radius: 8px;
  margin: 1rem 0;
  overflow-x: auto;
}

.artifact-markdown table {
  border-collapse: collapse;
  min-width: 100%;
}

.artifact-markdown th,
.artifact-markdown td {
  border-bottom: 1px solid #e6edf3;
  padding: 0.7rem 0.85rem;
  text-align: left;
  vertical-align: top;
}

.artifact-markdown th {
  background: #f4f8fb;
  color: #0f172a;
  font-weight: 700;
}

.artifact-markdown tr:last-child td {
  border-bottom: 0;
}

.artifact-markdown a {
  color: #1d6f9f;
  text-decoration: none;
}

.artifact-markdown a:hover {
  text-decoration: underline;
}

.artifact-markdown code {
  background: #eef4f8;
  border-radius: 6px;
  color: #0f4c5c;
  font-size: 0.9em;
  padding: 0.12rem 0.32rem;
}

.artifact-markdown pre {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 8px;
  color: #e2e8f0;
  margin: 1rem 0;
  overflow-x: auto;
  padding: 1rem;
  white-space: pre-wrap;
}

.artifact-markdown pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.artifact-edit-textarea {
  min-height: 260px;
}

.artifact-modal .modal-content {
  border-radius: 8px;
}

.artifact-image {
  border-radius: 8px;
  display: block;
  max-height: 360px;
  max-width: 100%;
  object-fit: contain;
  margin-bottom: 0.75rem;
}

.artifact-video {
  background: #0f172a;
  border-radius: 8px;
  display: block;
  margin-bottom: 0.75rem;
  max-height: 420px;
  max-width: 100%;
  width: 100%;
}

.empty-state {
  color: #718096;
  margin: 0;
}

.auth-shell {
  display: grid;
  min-height: 68vh;
  place-items: center;
}

.auth-panel {
  background: #fff;
  border: 1px solid #dfe4ea;
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(24, 31, 42, 0.08);
  max-width: 380px;
  padding: 1.5rem;
  width: 100%;
}

.auth-panel h1 {
  font-size: 1.6rem;
}

.auth-panel p {
  color: #637083;
}

.doc-panel h1 {
  font-size: 1.7rem;
  margin-bottom: 1rem;
}

.doc-panel h2 {
  font-size: 1.15rem;
  margin-top: 1.4rem;
}

@media (max-width: 992px) {
  .dashboard-grid,
  .content-grid,
  .quick-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel {
    padding: 1rem;
  }

  .artifact-filter-bar,
  .artifact-pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .artifact-filter-bar .form-select {
    min-width: 0;
    width: 100%;
  }
}
