.tool-shell {
  --tool-accent: #0f766e;
  --tool-accent-soft: #ccfbf1;
  --tool-border: rgba(15, 118, 110, 0.25);
}

.tool-hero {
  position: relative;
  overflow: hidden;
}

.tool-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 82% 22%, rgba(20, 184, 166, 0.24), transparent 55%);
  pointer-events: none;
}

.tool-hero p {
  max-width: none;
}

.tool-hero a.page-subtitle {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  color: #4338ca;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;
  border-radius: 0.5rem;
  padding: 0.15rem 0.35rem;
  transition:
    color 0.15s ease,
    text-decoration-color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.05s ease;
}

.tool-hero a.page-subtitle:hover {
  color: #3730a3;
  text-decoration-color: #3730a3;
}

.tool-hero a.page-subtitle:visited {
  color: #5b21b6;
  text-decoration-color: #5b21b6;
}

.tool-hero a.page-subtitle::after {
  content: "↗";
  font-size: 0.9em;
  line-height: 1;
  opacity: 0.9;
}

.tool-hero a.page-subtitle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(67, 56, 202, 0.35);
  background: rgba(67, 56, 202, 0.06);
}

@media (max-width: 640px) {
  .tool-hero a.page-subtitle {
    padding: 0.35rem 0.5rem;
    border-radius: 0.65rem;
  }
}

.tool-grid {
  display: grid;
  gap: 1.5rem;
}

.tool-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tool-card-title {
  margin: 0;
  font-size: 1.125rem;
  line-height: 1.25;
  font-weight: 600;
  color: #0f172a;
}

.tool-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tool-input {
  width: 100%;
  min-height: 11rem;
  resize: vertical;
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: #ffffff;
  padding: 0.95rem 1rem;
  color: #0f172a;
  line-height: 1.45;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.tool-input:focus {
  border-color: var(--tool-accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.tool-actions {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.tool-btn {
  border: 0;
  border-radius: 0.9rem;
  padding: 0.6rem 0.95rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.tool-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.tool-btn--ghost {
  background: rgba(255, 255, 255, 0.66);
  color: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.tool-btn--danger {
  background: linear-gradient(145deg, #b91c1c, #dc2626);
  color: #ffffff;
  box-shadow: 0 8px 22px rgba(220, 38, 38, 0.24);
}

.tool-btn--primary,
.tool-btn--ready {
  background: linear-gradient(145deg, #15803d, #22c55e);
  color: #ffffff;
  border: 1px solid rgba(34, 197, 94, 0.28);
  box-shadow: 0 8px 22px rgba(34, 197, 94, 0.24);
}

.tool-result + .tool-actions .tool-btn {
  min-width: 14.5rem;
  justify-content: center;
  text-align: center;
}

.tool-result + .tool-actions .tool-btn:disabled {
  opacity: 1;
  cursor: default;
  background: rgba(255, 255, 255, 0.66);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: none;
}

/* Copy button keeps primary look even when disabled */
.tool-result + .tool-actions #copyBtn.tool-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  background: linear-gradient(145deg, #15803d, #22c55e);
  color: #ffffff;
  border: 1px solid rgba(34, 197, 94, 0.28);
  box-shadow: 0 8px 22px rgba(34, 197, 94, 0.24);
}

.tool-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.32rem 0.72rem;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 700;
}

.tool-status--idle {
  background: #e2e8f0;
  color: #334155;
}

.tool-status--loading {
  background: #dbeafe;
  color: #1e40af;
}

.tool-status--matched {
  background: #dcfce7;
  color: #166534;
}

.tool-status--partial {
  background: #fef3c7;
  color: #92400e;
}

.tool-status--error,
.tool-status--not_found {
  background: #fee2e2;
  color: #991b1b;
}

.tool-result {
  margin-top: 0.75rem;
  min-height: calc(1rem * 1.45 * 4 + 2rem);
  border-radius: 1rem;
  border: 1px solid var(--tool-border);
  background: linear-gradient(180deg, rgba(240, 253, 250, 0.7), rgba(255, 255, 255, 0.95));
  padding: 1rem;
}

.tool-result code {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Consolas", "Menlo", "Monaco", monospace;
  font-size: 0.92rem;
  color: #0f172a;
}

.tool-meta {
  margin-top: 0.75rem;
  color: #64748b;
  font-size: 0.8rem;
}

.tool-warning-list {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
  color: #7c2d12;
}

.tool-warning-list:empty {
  margin-top: 0;
}

.tool-table-wrap {
  overflow: auto;
}

.tool-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.tool-table th,
.tool-table td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.28);
  text-align: left;
  vertical-align: top;
  padding: 0.62rem 0.5rem;
}

.tool-table th {
  color: #334155;
  font-weight: 700;
}

.tool-empty-note {
  color: #64748b;
  font-size: 0.9rem;
}

.tool-admin-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

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

.tool-admin-card {
  display: grid;
  gap: 0.9rem;
}

.tool-admin-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.tool-admin-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.06);
  color: #334155;
}

.tool-admin-section {
  display: grid;
  gap: 0.4rem;
}

.tool-admin-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #334155;
}

.tool-admin-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(255, 255, 255, 0.88);
  padding: 0.85rem 0.95rem;
  color: #0f172a;
  font-family: "Consolas", "Menlo", "Monaco", monospace;
  font-size: 0.9rem;
  line-height: 1.45;
}

.tool-admin-warnings {
  margin: 0;
  padding-left: 1.1rem;
  color: #7c2d12;
}
