@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
  color-scheme: light;
  background: #f6f7f9;
  color: #172033;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Arial,
    Helvetica,
    sans-serif;
}

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

button,
.download-link {
  border: 1px solid #172033;
  background: #172033;
  color: #ffffff;
  cursor: pointer;
  border-radius: 6px;
  min-height: 2.25rem;
  padding: 0.45rem 0.8rem;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
}

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

.secondary-button {
  background: #ffffff;
  border-color: #cbd3df;
  color: #172033;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd3df;
  border-radius: 6px;
  background: #ffffff;
  color: #172033;
  padding: 0.65rem 0.7rem;
}

textarea {
  min-height: 5rem;
  resize: vertical;
}

label {
  display: grid;
  gap: 0.35rem;
}

label span,
.field-label,
h3 {
  color: #586174;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.field-group {
  display: grid;
  gap: 0.5rem;
}

.app-shell {
  display: grid;
  gap: 1rem;
  min-height: 100vh;
  padding: 1rem;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  border-bottom: 1px solid #dce2eb;
  padding-bottom: 1rem;
}

.topbar h1 {
  margin: 0;
  color: #172033;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  line-height: 1.1;
}

.topbar p {
  margin: 0.3rem 0 0;
  color: #586174;
}

.api-key-field {
  min-width: min(16rem, 100%);
}

.workflow-grid {
  align-items: start;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(22rem, 0.86fr) minmax(0, 1.14fr);
}

.panel {
  border: 1px solid #dce2eb;
  border-radius: 8px;
  background: #ffffff;
  min-height: 18rem;
  padding: 1rem;
}

.compact-panel {
  min-height: auto;
  padding: 0.85rem;
}

.input-panel {
  grid-row: span 2;
}

.fact-card-panel {
  gap: 0.7rem;
}

.stack {
  display: grid;
  align-content: start;
  gap: 0.9rem;
}

.empty-panel {
  color: #8992a3;
}

.panel-heading,
.qa-title-row {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
}

.panel-heading {
  color: #172033;
  font-size: 1rem;
  font-weight: 800;
}

.panel-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.body-input {
  min-height: 20rem;
}

.two-col {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.status-text {
  margin: 0;
  font-weight: 700;
}

.uncertain-list {
  display: grid;
  gap: 0.65rem;
}

.uncertain-row {
  border-top: 1px solid #e5e9f0;
  display: grid;
  gap: 0.5rem;
  padding-top: 0.65rem;
}

.uncertain-row p {
  margin: 0;
}

.uncertain-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.status-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  padding: 0.35rem 0.5rem;
  text-transform: uppercase;
}

.pass {
  background: #e6f6ec;
  color: #116438;
}

.warn {
  background: #fff5d6;
  color: #805a00;
}

.fail {
  background: #fde7e7;
  color: #9f1d21;
}

.preview {
  border-left: 3px solid #2f6fdd;
  padding-left: 1rem;
}

.preview h2 {
  margin: 0;
  font-size: 1.25rem;
}

.preview p {
  color: #586174;
}

.preview pre {
  background: #f6f7f9;
  border-radius: 6px;
  overflow: auto;
  padding: 0.8rem;
  white-space: pre-wrap;
}

.tag-row,
.export-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  border: 1px solid #cbd3df;
  border-radius: 999px;
  color: #586174;
  padding: 0.25rem 0.55rem;
}

.warn-tag {
  background: #fff7e6;
  border-color: #f0c978;
  color: #7b560b;
}

.fact-summary-grid {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.fact-summary-grid div {
  background: #f4faf8;
  border: 1px solid #d9ebe6;
  border-radius: 6px;
  display: grid;
  gap: 0.22rem;
  min-width: 0;
  padding: 0.55rem;
}

.fact-summary-grid span {
  color: #667085;
  font-size: 0.72rem;
  font-weight: 700;
}

.fact-summary-grid strong {
  color: #172033;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.fact-compact-list,
.fact-edit-grid {
  display: grid;
  gap: 0.55rem;
}

.fact-edit-grid {
  border-top: 1px solid #e5e9f0;
  padding-top: 0.7rem;
}

.optimized-panel {
  min-height: 24rem;
  overflow: hidden;
  position: relative;
}

.optimized-panel.is-streaming {
  border-color: #91cdbf;
  box-shadow: 0 0 0 3px rgba(38, 138, 116, 0.08);
}

.stream-status {
  align-items: center;
  color: #0d6b58;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  gap: 0.45rem;
}

.stream-cursor {
  animation: stream-spin 0.8s linear infinite;
  border: 2px solid #b7ddd5;
  border-radius: 999px;
  border-top-color: #0d6b58;
  display: inline-block;
  height: 1rem;
  width: 1rem;
}

.streaming-preview {
  border-left-color: #20846d;
}

.streaming-preview pre {
  animation: preview-breathe 1.8s ease-in-out infinite;
  background: #f4fbf8;
  border: 1px solid #d6eee8;
}

.stream-placeholder {
  display: grid;
  gap: 0.7rem;
}

.preview-pulse-line,
.preview-pulse-block {
  animation: preview-breathe 1.6s ease-in-out infinite;
  background: linear-gradient(90deg, #edf5f2, #dceee8, #edf5f2);
  border-radius: 6px;
}

.preview-pulse-line {
  height: 1rem;
  width: 82%;
}

.preview-pulse-line.title-line {
  height: 1.5rem;
  width: 54%;
}

.preview-pulse-line.short-line {
  width: 66%;
}

.preview-pulse-block {
  height: 12rem;
  width: 100%;
}

.stream-word-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-height: 1.8rem;
}

.stream-word {
  animation: word-pop 0.46s ease both;
  background: #e9f6f2;
  border: 1px solid #b7ddd5;
  border-radius: 999px;
  color: #0d6b58;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.22rem 0.5rem;
}

.qa-list {
  display: grid;
  gap: 0.7rem;
}

.qa-item {
  border: 1px solid #e5e9f0;
  border-radius: 8px;
  display: grid;
  gap: 0.45rem;
  padding: 0.75rem;
}

.qa-item p,
.qa-item em,
.qa-item small {
  margin: 0;
}

.qa-item small {
  color: #586174;
}

.qa-item code {
  color: #2f6fdd;
}

.progress-panel {
  border: 1px solid #dce2eb;
  border-radius: 8px;
  background: #ffffff;
  display: grid;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
}

.progress-summary {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
}

.progress-summary strong {
  color: #172033;
}

.progress-summary span,
.progress-panel p {
  color: #586174;
}

.progress-panel p {
  margin: 0;
}

.progress-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.progress-steps li {
  border: 1px solid #cbd3df;
  border-radius: 999px;
  color: #586174;
  padding: 0.25rem 0.55rem;
}

.calibration-metrics {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.calibration-observations {
  border: 1px solid #e5e9f0;
  border-radius: 8px;
  color: #586174;
  display: grid;
  gap: 0.45rem;
  margin: 0;
  padding: 0.75rem 0.75rem 0.75rem 1.4rem;
}

@media (max-width: 900px) {
  .workflow-grid,
  .two-col,
  .fact-summary-grid,
  .calibration-metrics {
    grid-template-columns: 1fr;
  }

  .input-panel {
    grid-row: auto;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}

@keyframes stream-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes preview-breathe {
  0%,
  100% {
    opacity: 0.72;
  }

  50% {
    opacity: 1;
  }
}

@keyframes word-pop {
  0% {
    opacity: 0;
    transform: translateY(0.4rem) scale(0.9);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
