textarea {
  width: 100%;
  min-height: 280px;
  max-height: 480px;
  overflow-y: auto;
  border: 0;
  outline: none;
  resize: vertical;
  padding: 20px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}

.editor-footer {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  gap: 12px;
}

.actions,
.panel-actions {
  display: flex;
  gap: 8px;
}

.analysis,
.history,
.issues {
  margin-top: 20px;
}

.analysis-body,
.issues-panel {
  padding: 20px;
  line-height: 1.8;
  font-size: 14px;
  color: #353a40;
}

.result {
  padding: 22px;
}

.score {
  text-align: center;
  padding: 12px 0 24px;
}

.score-circle {
  width: 150px;
  height: 150px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 12px solid #eee;
  display: grid;
  place-items: center;
}

.score-circle-neutral {
  border-top-color: #d8dce2;
  border-right-color: #d8dce2;
}

.score-circle-good {
  border-top-color: var(--green);
  border-right-color: var(--green);
}

.score-circle-warn {
  border-top-color: var(--orange);
  border-right-color: var(--orange);
}

.score-circle-bad {
  border-top-color: var(--red);
  border-right-color: var(--red);
}

.score-number {
  font-size: 36px;
  font-weight: 750;
}

.score-label {
  font-weight: 650;
  font-size: 14px;
}

.score-label-neutral {
  color: var(--muted);
}

.score-label-good {
  color: var(--green);
}

.score-label-warn {
  color: var(--orange);
}

.score-label-bad {
  color: var(--red);
}

.confidence {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.metric {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.progress {
  height: 7px;
  background: #eceef1;
  border-radius: 20px;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width 0.35s ease;
}

/* Shown while AI analysis is pending (see detector.js) — a fixed-width segment sliding
   back and forth instead of a static bar, so a several-minute wait for a large model
   reads as "working" rather than "stuck". */
.progress.pending span {
  width: 30% !important;
  transition: none;
  animation: progress-pending 1.1s ease-in-out infinite alternate;
}

@keyframes progress-pending {
  from { margin-left: 0%; }
  to   { margin-left: 70%; }
}

.red {
  background: var(--red);
}

.green {
  background: var(--green);
}

.orange {
  background: var(--orange);
}

.card.analysis {
  position: relative;
}

.ai-suggestions {
  margin-top: 10px;
  padding: 12px 14px;
  background: #fff9e8;
  border: 1px solid #f2df9d;
  border-radius: 10px;
}

.ai-suggestions ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.segment-breakdown {
  margin-top: 10px;
  padding: 12px 14px;
  background: #f7f8fa;
  border: 1px solid #e1e4e9;
  border-radius: 10px;
}

.segment-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.segment-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.segment-list .chip {
  flex-shrink: 0;
}

.scan-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 4px;
}

.scan-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.scan-step-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.scan-step[data-status="running"] .scan-step-dot {
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(91, 76, 255, 0.15);
  animation: pulse-dot 1s ease-in-out infinite;
}

.scan-step[data-status="running"] .scan-step-label {
  color: var(--text);
  font-weight: 600;
}

.scan-step[data-status="done"] .scan-step-dot {
  background: var(--green);
}

.scan-step[data-status="skipped"] .scan-step-label {
  text-decoration: line-through;
  opacity: 0.6;
}

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

.api-toggle {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.api-toggle input {
  margin-top: 2px;
}

.api-toggle:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

.ai-contributions {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f2df9d;
}

.ai-suggestions li {
  margin-bottom: 4px;
}

.analysis-fragment {
  display: inline;
  padding: 2px 3px;
  border-radius: 3px;
  cursor: pointer;
}

.issue-popover {
  position: absolute;
  z-index: 5;
  width: 260px;
  max-width: calc(100% - 12px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  box-shadow: var(--shadow);
  animation: modal-in 0.15s ease both;
}

.analysis-fragment.issue-grammar,
.analysis-fragment.issue-spelling {
  background: #ffe0e0;
  border-bottom: 2px solid var(--red);
}

.analysis-fragment.issue-punctuation,
.analysis-fragment.issue-style,
.analysis-fragment.issue-clarity,
.analysis-fragment.issue-readability {
  background: #fff1d4;
  border-bottom: 2px solid var(--orange);
}

.analysis-fragment.issue-consistency,
.analysis-fragment.issue-ai_signal {
  background: #e1edff;
  border-bottom: 2px solid var(--blue);
}

.issue-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.issue-item.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 76, 255, 0.08);
}

.issue-item:hover {
  transform: translateY(-1px);
}

.issue-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  align-items: center;
}

.issue-title {
  font-weight: 650;
}

.issue-meta,
.suggestion-list,
.history-list,
.provider-status-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.provider-status-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.provider-status-list li:last-child {
  border-bottom: 0;
}

.provider-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.provider-row-controls {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.provider-key-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: #fbfcfe;
}

.issue-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.issue-text,
.issue-explanation {
  margin: 10px 0 0;
}

.issue-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  background: #f1f2f4;
  border-radius: 999px;
  padding: 4px 8px;
}

.history-item {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.history-item:last-child {
  border-bottom: 0;
}

.history-score {
  color: var(--red);
  font-weight: 650;
}
