/* Shared chrome — header tools, server badge, settings sheet, job panel */

.server-badge {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 500;
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  color: var(--text-tertiary);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.server-badge[data-state="on"] {
  color: var(--spot-slate);
  border-color: rgba(120, 180, 170, 0.35);
}

.server-badge[data-state="warn"] {
  color: var(--spot-gold);
  border-color: rgba(232, 192, 74, 0.35);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.btn-icon:hover {
  border-color: var(--spot-slate);
  color: var(--text);
  background: var(--surface-hover);
}

.job-panel {
  position: fixed;
  bottom: var(--s-5);
  right: var(--s-5);
  width: min(22rem, calc(100vw - 2rem));
  padding: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--spot-gold);
  border-radius: var(--radius);
  z-index: 90;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.job-panel[data-state="failed"] {
  border-left-color: #c45;
}

.job-panel-head {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  margin-bottom: var(--s-2);
}

.job-panel-title-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.job-panel-dismiss {
  margin-left: auto;
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1.2;
  color: var(--text-tertiary);
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  cursor: pointer;
}

.job-panel-cancel:not([hidden]) + .job-panel-dismiss {
  margin-left: 0;
}

.job-panel-dismiss:hover {
  color: var(--text);
  border-color: var(--spot-slate);
}

.job-panel-cancel {
  margin-left: auto;
  flex-shrink: 0;
  padding: 0.15rem 0.45rem;
  font-size: var(--text-xs);
  line-height: 1.3;
  color: var(--spot-rust);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--spot-rust) 45%, var(--border-subtle));
  border-radius: var(--radius);
  cursor: pointer;
}

.job-panel-cancel:hover {
  border-color: var(--spot-rust);
}

.job-panel-cancel[hidden],
.job-panel-dismiss[hidden] {
  display: none !important;
}

.job-panel-spinner {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 2px solid var(--text-tertiary);
  border-top-color: var(--spot-gold);
  border-radius: 50%;
  animation: sm-spin 0.7s linear infinite;
}

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

.sm-btn-spinner,
.sm-spinner {
  flex-shrink: 0;
  width: 13px;
  height: 13px;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: sm-spin 0.65s linear infinite;
}

button.is-loading,
.inbox-btn.is-loading,
.note-toolbar-btn.is-loading {
  display: inline-flex;
  align-items: center;
  cursor: wait;
  opacity: 0.88;
}

button.is-loading::before,
.inbox-btn.is-loading::before,
.note-toolbar-btn.is-loading::before {
  content: "";
  flex-shrink: 0;
  width: 13px;
  height: 13px;
  margin-right: 0.45rem;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: sm-spin 0.65s linear infinite;
}

button.is-loading:disabled,
.inbox-btn.is-loading:disabled,
.note-toolbar-btn.is-loading:disabled {
  opacity: 0.88;
}

.job-panel-title {
  font-family: var(--mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--spot-gold);
  text-transform: capitalize;
}

.job-panel-status {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.4;
}

body.sm-busy .click-card {
  pointer-events: none;
  opacity: 0.55;
}

body.sm-busy button:disabled,
body.sm-busy .inbox-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.job-panel-log {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-tertiary);
  line-height: 1.45;
  max-height: 7.5rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  white-space: pre-wrap;
  margin: 0;
  padding-right: 0.15rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}

.copy-toast {
  position: fixed;
  bottom: var(--s-5);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--s-2) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  z-index: 250;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.copy-toast.show {
  opacity: 1;
}

.copy-toast.is-error {
  color: var(--text);
  border-color: color-mix(in srgb, var(--spot-rust) 55%, var(--border-subtle));
  border-left: 3px solid var(--spot-rust);
  max-width: min(36rem, calc(100vw - 2rem));
  text-align: left;
  line-height: 1.45;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg, rgba(0, 0, 0, 0.55));
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.settings-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.settings-sheet {
  position: fixed;
  top: 0;
  right: 0;
  width: min(26rem, 100vw);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border-subtle);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.settings-sheet.open {
  transform: translateX(0);
}

.settings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-5) var(--s-5) var(--s-3);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-subtle);
}

.settings-head h2 {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--spot-slate);
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-4) var(--s-5) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.settings-body .capture-field input {
  background: var(--bg);
}

.field-hint {
  display: block;
  margin-top: var(--s-1);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  line-height: 1.45;
}

.field-hint code {
  font-family: var(--mono);
  font-size: 0.92em;
}

.llm-status {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--bg);
}

.llm-status-dot {
  width: 10px;
  height: 10px;
  margin-top: 0.2rem;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-tertiary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-tertiary) 25%, transparent);
}

.llm-status[data-state="connected"] .llm-status-dot {
  background: var(--spot-slate);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--spot-slate) 30%, transparent);
}

.llm-status[data-state="offline"] .llm-status-dot,
.llm-status[data-state="error"] .llm-status-dot,
.llm-status[data-state="model-missing"] .llm-status-dot {
  background: var(--spot-rust);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--spot-rust) 25%, transparent);
}

.llm-status[data-state="needs-model"] .llm-status-dot {
  background: var(--spot-gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--spot-gold) 25%, transparent);
}

.llm-status[data-state="testing"] .llm-status-dot {
  background: var(--spot-gold);
  animation: llm-pulse 1s ease-in-out infinite;
}

@keyframes llm-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.llm-status-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.llm-status-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.llm-status-detail {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  line-height: 1.45;
}

.settings-section-label,
.settings-presets-label {
  display: block;
  font-size: 0.68rem;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--s-2);
}

.settings-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0;
}

.theme-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-2);
}

.theme-swatch {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  font-family: var(--sans);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition:
    border-color 0.12s ease,
    color 0.12s ease,
    background 0.12s ease;
}

.theme-swatch:hover {
  border-color: var(--spot-slate);
  color: var(--text);
  background: var(--surface);
}

.theme-swatch.is-active {
  border-color: var(--spot-gold);
  color: var(--text);
  background: var(--spot-gold-soft);
}

.theme-swatch-chip {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.theme-swatch-chip--warm {
  background: linear-gradient(
    145deg,
    #0a0a09 42%,
    #e8c04a 42%,
    #e8c04a 58%,
    #5eb8a8 58%
  );
}

.theme-swatch-chip--light {
  background: linear-gradient(
    145deg,
    #f6f5f2 42%,
    #b8860b 42%,
    #b8860b 58%,
    #2a7a68 58%
  );
}

.theme-swatch-chip--pink {
  background: linear-gradient(
    145deg,
    #0c080a 42%,
    #ff9ec4 42%,
    #ff9ec4 52%,
    #e8b050 52%,
    #e8b050 62%,
    #88b0e0 62%
  );
}

.theme-swatch-name {
  font-weight: 500;
  line-height: 1.2;
}

.settings-model-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.settings-model-row input {
  flex: 1;
  min-width: 0;
}

.settings-model-refresh {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  cursor: pointer;
}

.settings-model-refresh:hover {
  color: var(--spot-gold);
  border-color: var(--spot-slate);
  background: var(--surface);
}

.settings-preset-grid {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.settings-preset-group {
  min-width: 0;
}

.settings-preset-group-label {
  display: block;
  font-size: 0.62rem;
  font-family: var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--s-1);
}

.settings-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.settings-preset {
  padding: 0.4rem 0.7rem;
  font-size: var(--text-xs);
  font-family: var(--mono);
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}

.settings-preset:hover {
  color: var(--text);
  border-color: var(--spot-slate);
}

.settings-preset.is-active {
  color: var(--spot-gold);
  border-color: color-mix(in srgb, var(--spot-gold) 55%, var(--border-subtle));
  background: color-mix(in srgb, var(--spot-gold) 8%, var(--bg));
}

.settings-actions {
  display: flex;
  gap: var(--s-2);
  margin-top: var(--s-1);
}

.settings-btn {
  flex: 1;
  padding: 0.6rem 0.75rem;
  font-family: var(--sans);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid var(--border-subtle);
}

.settings-btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.settings-btn-primary:hover {
  background: var(--text-secondary);
}

.settings-btn-secondary {
  background: transparent;
  color: var(--text-secondary);
}

.settings-btn-secondary:hover {
  color: var(--text);
  border-color: var(--spot-slate);
}

.settings-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.settings-foot {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  line-height: 1.45;
  margin-top: var(--s-1);
}

@media (max-width: 640px) {
  .settings-sheet {
    width: 100%;
  }
}
