/* Rapid UI tools — works with any theme. Brand colours can be overridden by the theme. */
.rt-tool,
.rt-ad {
  --rt-brand:      var(--ru-brand, #2563EB);
  --rt-brand-dark: var(--ru-brand-dark, #1d4ed8);
  --rt-mint:       var(--ru-cyan-light, #cffafe);
  --rt-lime:       var(--ru-brand-light, #dbeafe);
  --rt-bg:         var(--ru-surface, #ffffff);
  --rt-soft:       var(--ru-soft, #f1f5f9);
  --rt-text:       var(--ru-text, #0f172a);
  --rt-muted:      var(--ru-muted, #64748b);
  --rt-border:     var(--ru-border, #e2e8f0);
  --rt-error:      #dc2626;
  --rt-ok:         #16a34a;
  --rt-radius:     10px;
}

.rt-tool {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  margin: 0 0 28px;
  background: var(--rt-bg);
  border: 1px solid var(--rt-border);
  border-radius: var(--rt-radius);
  color: var(--rt-text);
  font-size: 15px;
  line-height: 1.5;
}
.rt-tool *,
.rt-tool *::before,
.rt-tool *::after {
  box-sizing: border-box;
}

/* Inputs */
.rt-field {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid var(--rt-border);
  border-radius: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea.rt-field {
  min-height: 140px;
  resize: vertical;
}
.rt-field--tall {
  min-height: 240px !important;
}
.rt-field--num {
  width: 90px;
}
.rt-field--auto {
  width: auto;
}
.rt-field:focus {
  outline: none;
  border-color: var(--rt-brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--rt-mint) 70%, transparent);
}
.rt-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
}
.rt-big {
  font-size: 20px;
  font-weight: 600;
}
.rt-color {
  width: 64px;
  height: 44px;
  padding: 2px;
  border: 1px solid var(--rt-border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

/* Layout */
.rt-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.rt-row--nowrap {
  flex-wrap: nowrap;
}
.rt-row--nowrap .rt-field {
  flex: 1;
}
.rt-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--rt-muted);
}
.rt-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}
.rt-cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.rt-align-end {
  align-items: end;
}
@media (min-width: 640px) {
  .rt-cols {
    grid-template-columns: 1fr 1fr;
  }
  .rt-cols--3 {
    grid-template-columns: repeat(3, 1fr);
  }
}
.rt-stack,
.rt-cards {
  display: grid;
  gap: 10px;
}
@media (min-width: 640px) {
  .rt-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Buttons */
.rt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--rt-text);
  background: #fff;
  border: 1.5px solid var(--rt-border);
  border-radius: var(--rt-radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.rt-btn:hover {
  border-color: var(--rt-brand);
  color: var(--rt-brand);
  background: #f8faff;
}
.rt-btn--primary,
.rt-btn.is-active {
  color: #fff;
  background: var(--rt-brand);
  border-color: var(--rt-brand);
}
.rt-btn--primary:hover {
  background: var(--rt-brand-dark);
  border-color: var(--rt-brand-dark);
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
  color: #fff;
}
.rt-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.rt-btn:focus-visible,
.rt-link:focus-visible {
  outline: 2px solid var(--rt-brand);
  outline-offset: 3px;
}
.rt-link {
  padding: 0;
  margin-left: auto;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--rt-brand);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
}

/* Output */
.rt-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}
.rt-stat {
  padding: 12px;
  text-align: center;
  background: var(--rt-soft);
  border-radius: 10px;
}
.rt-stat__v {
  font-size: 24px;
  font-weight: 800;
  color: var(--rt-brand);
  letter-spacing: -0.02em;
}
.rt-stat__k {
  font-size: 12.5px;
  color: var(--rt-muted);
}
.rt-out {
  display: block;
  min-height: 44px;
  padding: 12px 14px;
  background: var(--rt-soft);
  border-radius: 10px;
  word-break: break-word;
}
.rt-panel {
  border: 1px solid var(--rt-border);
  border-radius: 10px;
  overflow: hidden;
}
.rt-panel__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--rt-muted);
  background: var(--rt-soft);
}
.rt-pre {
  margin: 0;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}
.rt-break {
  word-break: break-all;
}
.rt-list {
  margin: 0;
  padding-left: 22px;
  max-height: 360px;
  overflow: auto;
}
.rt-list li {
  display: list-item;
  padding: 3px 0;
}
.rt-list li > .rt-link {
  margin-left: 10px;
}
.rt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.rt-table th,
.rt-table td {
  padding: 7px 10px;
  text-align: left;
  border-bottom: 1px solid var(--rt-border);
}
.rt-table thead th {
  font-size: 12.5px;
  color: var(--rt-muted);
}
.rt-tool mark {
  background: var(--rt-lime);
  color: inherit;
  border-radius: 3px;
}

/* Messages */
.rt-msg:empty {
  display: none;
}
.rt-msg {
  margin: 0;
  font-size: 14px;
}
.rt-muted {
  color: var(--rt-muted);
}
.rt-error {
  color: var(--rt-error);
}
.rt-ok {
  color: var(--rt-ok);
}
.rt-badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
}
.rt-badge--ok {
  color: var(--rt-ok);
  background: #e3f6ea;
}
.rt-badge--bad {
  color: var(--rt-error);
  background: #fde8e6;
}

/* Diff */
.rt-diff {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  border: 1px solid var(--rt-border);
  border-radius: 10px;
  overflow: auto;
  max-height: 480px;
}
.rt-diff:empty {
  display: none;
}
.rt-diff > div {
  padding: 2px 10px;
  white-space: pre-wrap;
}
.rt-diff__add {
  background: #e3f6ea;
}
.rt-diff__del {
  background: #fde8e6;
  text-decoration: line-through;
  text-decoration-color: rgba(180, 35, 24, 0.4);
}
.rt-diff__note {
  color: var(--rt-error);
}

/* Colour */
.rt-swatch {
  height: 72px;
  border: 1px solid var(--rt-border);
  border-radius: 10px;
}
.rt-palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 6px;
}
.rt-palette__chip {
  min-height: 84px;
  padding: 8px;
  font: 600 13px ui-monospace, Menlo, Consolas, monospace;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
}
.rt-preview {
  padding: 24px;
  border: 1px solid var(--rt-border);
  border-radius: 10px;
}
.rt-preview p {
  margin: 0 0 6px;
}
.rt-preview__big {
  font-size: 24px;
  font-weight: 700;
}

/* Upload */
.rt-drop {
  padding: 28px 16px;
  text-align: center;
  background: var(--rt-soft);
  border: 2px dashed var(--rt-border);
  border-radius: var(--rt-radius);
  transition: border-color 0.15s, background 0.15s;
}
.rt-drop.is-over {
  border-color: var(--rt-brand);
  background: color-mix(in srgb, var(--rt-lime) 40%, white);
}
.rt-drop p {
  margin: 4px 0;
}
.rt-drop__title {
  font-weight: 700;
  color: var(--rt-brand-dark);
}
.rt-drop__file {
  font-weight: 600;
}
.rt-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.rt-results {
  margin: 0;
  padding-left: 22px;
}
.rt-results li {
  margin-bottom: 12px;
}
.rt-results p {
  margin: 4px 0 0;
  font-size: 13.5px;
}

/* Ads */
.rt-ad {
  margin: 0 0 24px;
  min-height: 90px;
  text-align: center;
}
.rt-ad--sidebar {
  min-height: 250px;
}
