/*
 * components.css — every reusable UI component + charts.
 */

/* ============================= 5.1 Buttons ============================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  font: 600 14px/1 var(--font-sans);
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: box-shadow var(--dur-fast), transform var(--dur-fast),
    background-color var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
  user-select: none;
  position: relative;
}
.btn-sm { height: 32px; padding: 0 var(--space-3); font-size: 13px; }
.btn-lg { height: 48px; padding: 0 var(--space-5); font-size: 15px; }
.btn-icon { width: 40px; height: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; height: 32px; }

.btn-primary {
  position: relative;
  isolation: isolate;
  color: #fff;
  background: var(--grad-primary);
  border-color: var(--blue-700);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, .16);
}
.btn-primary::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: inherit;
  background: var(--grad-primary-hover);
  opacity: 0;
  transition: opacity var(--dur-fast);
}
.btn-primary:hover::before { opacity: 1; }
.btn-primary:hover { box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .16); }
.btn-primary:active { transform: translateY(1px); box-shadow: var(--shadow-xs); }

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--neutral-700);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--neutral-50); border-color: var(--neutral-400); }
.btn-secondary:active { background: var(--neutral-100); transform: translateY(1px); }

.btn-ghost {
  background: transparent;
  color: var(--blue-600);
}
.btn-ghost:hover { background: var(--blue-50); }
.btn-ghost:active { transform: translateY(1px); }

.btn-danger {
  background: var(--error-600);
  color: #fff;
  border-color: var(--error-700);
}
.btn-danger:hover { background: var(--error-700); }
.btn-danger:active { transform: translateY(1px); }

.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:disabled {
  background: var(--neutral-100);
  color: var(--neutral-400);
  border-color: var(--neutral-200);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}
.btn-primary:disabled::before { display: none; }

.btn.is-loading { color: transparent; pointer-events: none; }
.btn.is-loading .btn-label { visibility: hidden; }
.btn-spinner {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}
.btn.is-loading .btn-spinner { display: flex; }

/* Copy success state */
.btn-copy.is-copied {
  color: var(--green-700);
  border-color: var(--green-200);
  background: var(--green-50);
}
.btn-copy.is-copied .icon { animation: copy-pulse var(--dur-slow) var(--ease-spring); }
@keyframes copy-pulse {
  0% { transform: scale(.8); }
  100% { transform: scale(1); }
}

/* ============================= 5.2 Inputs =============================== */
.field { display: block; }
.field + .field { margin-top: var(--space-4); }
.field-label {
  display: block;
  font: 600 13px/1.4 var(--font-sans);
  color: var(--neutral-700);
  margin-bottom: 6px;
}
.field-label .required-mark { color: var(--error-600); margin-left: 2px; }
.field-help { margin-top: 6px; font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.field-error {
  margin-top: 6px;
  font-size: 12px;
  color: var(--error-600);
  display: flex;
  align-items: center;
  gap: 4px;
}
.field-error .icon { width: 14px; height: 14px; flex: none; }

.input, .select, .textarea {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 var(--space-3);
  font: 400 14px var(--font-sans);
  color: var(--text-primary);
  background: #fff;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.textarea { height: auto; min-height: 120px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--neutral-400); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--neutral-400); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--blue-500);
  box-shadow: var(--shadow-xs), var(--shadow-focus);
  outline: none;
}
.input.is-invalid, .select.is-invalid, .textarea.is-invalid,
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--error-500);
}
.input.is-invalid:focus, .select.is-invalid:focus, .textarea.is-invalid:focus,
.input[aria-invalid="true"]:focus, .select[aria-invalid="true"]:focus, .textarea[aria-invalid="true"]:focus {
  box-shadow: var(--shadow-xs), var(--shadow-focus-error);
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--neutral-50);
  color: var(--text-disabled);
  cursor: not-allowed;
}

.select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2363718A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}

.input-group {
  display: flex;
  align-items: stretch;
}
.input-group .input { border-radius: 0; }
.input-group > :first-child { border-top-left-radius: var(--radius-md); border-bottom-left-radius: var(--radius-md); }
.input-group > :last-child { border-top-right-radius: var(--radius-md); border-bottom-right-radius: var(--radius-md); }
.input-affix {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--space-3);
  background: var(--neutral-50);
  border: 1px solid var(--neutral-300);
  color: var(--text-muted);
  font-size: 14px;
  border-right: 0;
}
.input-btn-group { display: flex; align-items: stretch; }
.input-btn-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-btn-group .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0; }

/* ============================= 5.3 Cards ================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: var(--space-6);
}
@media (max-width: 639px) {
  .card { padding: var(--space-4); }
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.card-header-title { font-size: 16px; font-weight: 600; }

.tool-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: var(--space-4);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--blue-300);
}
.tool-card:hover .tool-card-icon { background: var(--blue-100); }
.tool-card:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.tool-card:active { transform: translateY(0); }
.tool-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--blue-50);
  color: var(--blue-600);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.tool-card-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.tool-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tool-card .badge { margin-top: auto; }

/* ============================= 5.4 Tables ================================= */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
  -webkit-overflow-scrolling: touch;
}
.table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 14px; }
.table thead th {
  font: 600 13px/1.4 var(--font-sans);
  color: var(--neutral-600);
  background: var(--neutral-50);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table thead th.is-numeric, .table td.is-numeric { text-align: right; }
.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--neutral-100);
  color: var(--text-primary);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--neutral-25); }
.table td.is-url { overflow-wrap: anywhere; color: var(--text-link); }

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  height: 100%;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: inherit;
}
.th-sort:hover { color: var(--neutral-900); }
.th-sort:focus-visible { outline: 2px solid var(--blue-500); outline-offset: -2px; }
.th-sort .icon { opacity: .4; }
th[aria-sort="ascending"] .th-sort .icon,
th[aria-sort="descending"] .th-sort .icon {
  opacity: 1;
  color: var(--blue-600);
}

.table-compact th, .table-compact td { padding: var(--space-2) var(--space-3); }

/* ============================= 5.5 Tabs =================================== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  padding: 10px 14px;
  font: 500 14px/1.4 var(--font-sans);
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--neutral-800); }
.tab[aria-selected="true"] {
  color: var(--blue-600);
  border-bottom-color: var(--blue-600);
  font-weight: 600;
}
.tab:focus-visible { outline: 2px solid var(--blue-500); outline-offset: -2px; }
.tabpanel { padding-top: var(--space-4); }
.tabpanel[hidden] { display: none; }

/* ============================= 5.6 Tooltips ================================ */
.tooltip-wrap { position: relative; display: inline-flex; }
.tooltip {
  /* display:none when hidden so an off-trigger tooltip never adds to page width
     (a visibility:hidden absolutely-positioned tooltip still causes horizontal scroll). */
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--neutral-800);
  color: #fff;
  font: 400 12px/1.45 var(--font-sans);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  max-width: min(240px, calc(100vw - 24px));
  width: max-content;
  z-index: 80;
  pointer-events: none;
  text-align: center;
}
.tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  margin-top: -4px;
  background: var(--neutral-800);
  transform: rotate(45deg);
}
.tooltip-wrap:hover .tooltip,
.tooltip-wrap:focus-within .tooltip,
.tooltip-wrap:focus-visible .tooltip {
  display: block;
  animation: mt-tooltip-in var(--dur-fast) ease 300ms both;
}
@keyframes mt-tooltip-in { from { opacity: 0; transform: translateX(-50%) translateY(4px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.tooltip.is-hidden { display: none !important; }

/* ============================= 5.7 Toasts =================================== */
#toast-root {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 380px;
}
@media (max-width: 639px) {
  #toast-root { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); max-width: none; }
}
.toast {
  position: relative;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3) var(--space-4) var(--space-3) 20px;
  min-width: 280px;
  max-width: 380px;
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font: 500 14px/1.4 var(--font-sans);
  color: var(--text-primary);
  animation: toast-in var(--dur-base) var(--ease-out);
}
@media (max-width: 639px) { .toast { min-width: 0; width: 100%; max-width: none; } }
.toast::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  background: var(--blue-500);
}
.toast-ok::before { background: var(--green-500); }
.toast-err::before { background: var(--error-600); }
.toast-icon { flex: none; margin-top: 1px; }
.toast-ok .toast-icon { color: var(--green-600); }
.toast-err .toast-icon { color: var(--error-600); }
.toast-msg { flex: 1 1 auto; }
.toast-close { flex: none; }
.toast.is-leaving { animation: toast-out var(--dur-fast) ease forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ============================= 5.8 Badges ==================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font: 500 12px/18px var(--font-sans);
  white-space: nowrap;
}
.badge-blue { background: var(--blue-100); color: var(--blue-800); }
.badge-green { background: var(--green-100); color: var(--green-800); }
.badge-amber { background: var(--warning-300); color: var(--warning-700); }
.badge-red { background: var(--error-300); color: var(--error-700); }
.badge-neutral { background: var(--neutral-100); color: var(--neutral-600); }
.badge-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* ============================= 5.9 Empty states / loading ==================== */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-4);
}
.empty-state-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--blue-50);
  color: var(--blue-500);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
}
.empty-state-title { font-size: 16px; font-weight: 600; margin-bottom: var(--space-2); }
.empty-state-body { font-size: 14px; color: var(--text-muted); max-width: 40ch; margin: 0 auto var(--space-4); }

.skeleton {
  border-radius: var(--radius-xs);
  background: linear-gradient(90deg, var(--neutral-100) 25%, var(--neutral-50) 50%, var(--neutral-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  display: block;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  animation: spin .8s linear infinite;
  stroke: currentColor;
}
.spinner-lg { width: 20px; height: 20px; }
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-row { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-muted); font-size: 14px; }

/* ============================= 5.10 Copy-to-clipboard ========================== */
.btn-copy-icon {
  position: relative;
}
.copy-live-region { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ============================= 5.11 Stat cards ================================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}
@media (max-width: 1023px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 639px) {
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}
.stat-card-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font: 500 13px var(--font-sans);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.stat-card-value {
  font-size: 30px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--text-primary);
}
.stat-card-meta {
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================= 5.12 Modal ========================================= */
.modal {
  border: 0;
  padding: 0;
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  animation: modal-in var(--dur-base) var(--ease-out);
}
.modal-lg { width: min(640px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(15, 27, 45, .5); }
@keyframes modal-in {
  from { opacity: 0; transform: scale(.97); }
  to { opacity: 1; transform: scale(1); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 18px; font-weight: 600; }
.modal-body { padding: var(--space-6); overflow-y: auto; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  background: var(--neutral-25);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ============================= 5.13 FAQ accordion ================================= */
.faq {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}
.faq + .faq { margin-top: var(--space-3); }
.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font: 600 15px/1.4 var(--font-sans);
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "";
  flex: none;
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2363718A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  transition: transform var(--dur-base) var(--ease-out);
}
.faq[open] summary::after { transform: rotate(180deg); }
.faq-body {
  margin-top: var(--space-3);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-secondary);
}

/* ============================= Breadcrumb, lang-switch already in layout.css ======= */

/* ============================= Lang switcher ======================================= */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--neutral-100);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 2px;
  height: 32px;
  flex: none;
}
.lang-switch a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0 12px;
  border-radius: var(--radius-full);
  font: 600 13px/1 var(--font-sans);
  color: var(--neutral-500);
  transition: background-color var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
}
.lang-switch a:hover { color: var(--neutral-800); }
.lang-switch a[aria-current="true"] {
  background: #fff;
  color: var(--neutral-900);
  box-shadow: var(--shadow-xs);
}

/* ============================= Chip / pill ========================================== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  font: 500 13px var(--font-sans);
  color: var(--text-secondary);
  transition: background-color var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.chip:hover { background: var(--blue-50); border-color: var(--blue-200); color: var(--blue-700); }

/* ============================= 6. Charts ============================================= */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.chart-card + .chart-card { margin-top: var(--space-4); }
.chart-title { font: 600 15px/1.4 var(--font-sans); color: var(--text-primary); margin-bottom: var(--space-4); }

.chart-daily { width: 100%; }
.chart-daily svg { width: 100%; height: auto; display: block; }
.chart-bar { fill: var(--blue-500); transition: fill var(--dur-fast); cursor: pointer; }
.chart-bar:hover, .chart-bar:focus-visible { fill: var(--blue-600); outline: none; }
.chart-gridline { stroke: var(--neutral-300); stroke-width: 1; }
.chart-axis-label { fill: var(--neutral-500); font-size: 11px; font-family: var(--font-sans); }
.chart-sr-table { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.hbar-list { display: flex; flex-direction: column; gap: 2px; }
.hbar, .hbar-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2fr auto auto;
  gap: var(--space-3);
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
}
.hbar-label {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hbar-track {
  height: 8px;
  background: var(--neutral-100);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.hbar-fill {
  display: block;
  width: 0; /* JS sets the fill % via CSSOM; 0 default replaces inline style="width:0%" */
  height: 100%;
  background: var(--blue-500);
  border-radius: inherit;
}
.hbar-value { color: var(--text-primary); font-weight: 600; }
.hbar-pct { color: var(--text-muted); font-size: 12px; min-width: 40px; text-align: right; }

.bot-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

/* ============================= Prose (SEO content) ==================================== */
.prose { max-width: 760px; }
.prose h2 {
  font-size: var(--text-2xl-size);
  line-height: var(--text-2xl-line);
  margin-bottom: var(--space-4);
}
.prose h2 + * { margin-top: 0; }
.prose p { margin-bottom: var(--space-4); color: var(--text-secondary); }
.prose ol, .prose ul { margin-bottom: var(--space-4); padding-left: var(--space-6); }
.prose ol { list-style: decimal; }
.prose ul { list-style: disc; }
.prose li { margin-bottom: var(--space-2); color: var(--text-secondary); }
.prose li::marker { color: var(--text-muted); }

/* ============================= Tool-view extensions ===================================
 * Reusable patterns needed by individual tool views (url-shortener and others):
 * alerts, result panels, QR box, stats page chrome, manage/report panels.
 * All reference semantic tokens only, per §1 dark-mode seam rule. */

.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  font-size: 14px;
}
.alert .icon { flex: none; margin-top: 2px; }
.alert-warning { background: var(--warning-50); border-color: var(--warning-300); color: var(--warning-700); }
.alert-warning .icon { color: var(--warning-500); }
.alert-error { background: var(--error-50); border-color: var(--error-300); color: var(--error-700); }
.alert-info { background: var(--info-50); border-color: var(--blue-200); color: var(--blue-700); }

.req { color: var(--error-600); margin-left: 2px; }
.field-optional { font-weight: 400; color: var(--text-muted); }
.field-checkbox label { display: flex; align-items: center; gap: var(--space-2); font: 600 13px var(--font-sans); color: var(--neutral-700); }
.field-checkbox input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--blue-600); }

.tool-options { margin-top: var(--space-4); border-top: 1px solid var(--border); padding-top: var(--space-4); }
.tool-options summary { cursor: pointer; font: 600 13px var(--font-sans); color: var(--text-secondary); list-style: none; }
.tool-options summary::-webkit-details-marker { display: none; }
.tool-options-grid { display: flex; flex-direction: column; gap: var(--space-4); margin-top: var(--space-4); }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }

.qr-box {
  width: 160px;
  height: 160px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
}
.qr-box svg, .qr-box img { width: 100%; height: 100%; }

.tool-result { margin-top: var(--space-6); }
.result-hero { margin-bottom: var(--space-4); }
.result-url {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  font: 600 18px var(--font-sans);
}
.result-url a { color: var(--text-link); overflow-wrap: anywhere; }
.result-target {
  margin-top: var(--space-2);
  font-size: 14px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}
.result-line { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; font-size: 14px; }
.result-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-6); margin-top: var(--space-6); }
@media (max-width: 639px) {
  .result-grid { grid-template-columns: 1fr; }
}
.result-block h3 { font-size: 15px; font-weight: 600; margin-bottom: var(--space-3); }

/* empty-state alias names used by tool views */
.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--blue-50);
  color: var(--blue-500);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
}
.empty-title { font-size: 16px; font-weight: 600; text-align: center; margin-bottom: var(--space-2); }
.empty-hint { font-size: 14px; color: var(--text-muted); text-align: center; max-width: 40ch; margin: 0 auto; }

/* stat-card alias names (label/value without the -card- infix) */
.stat-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font: 500 13px var(--font-sans);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.stat-value { font-size: 30px; line-height: 1.2; font-weight: 700; color: var(--text-primary); }
.stat-value-sm { font-size: 16px; font-weight: 600; }

/* Stats page (/l/{code}+) chrome */
.stats-page { padding-bottom: var(--space-16); }
.stats-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}
.stats-header-main h1 { margin-bottom: var(--space-2); }
.stats-target { display: flex; align-items: center; gap: var(--space-1); font-size: 14px; margin-top: var(--space-2); }
.stats-target a { color: var(--text-link); overflow-wrap: anywhere; }
.stats-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); font-size: 13px; color: var(--text-muted); margin-top: var(--space-2); }
.stats-header-qr { flex: none; text-align: center; }
.stats-short-url { font: 600 16px var(--font-sans); color: var(--text-link); overflow-wrap: anywhere; }

.stats-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.export-menu { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.export-label { font-size: 13px; color: var(--text-muted); margin-right: 4px; }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-4);
}
@media (max-width: 767px) {
  .chart-grid { grid-template-columns: 1fr; }
}
.daily-chart { width: 100%; height: auto; display: block; }
.chart-axis { stroke: var(--neutral-300); stroke-width: 1; }
.chart-range { display: flex; justify-content: space-between; font-size: 11px; color: var(--neutral-500); margin-top: var(--space-2); }

.manage-panel, .report-panel { margin-top: var(--space-6); }
.manage-panel summary, .report-link {
  cursor: pointer;
  font: 600 14px var(--font-sans);
  color: var(--text-secondary);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.manage-panel summary::-webkit-details-marker,
.report-panel summary::-webkit-details-marker { display: none; }
.manage-body, .report-body {
  margin-top: var(--space-4);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
}
.report-row { margin-top: var(--space-6); }

/* =========================================================================
   Shared component classes added during the UX audit.
   These were referenced by multiple tools but previously undefined.
   ========================================================================= */

/* Compact stat grid: auto-fit so 3-card rows never leave an empty column. */
.stat-grid-compact { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--space-3); }

/* Active/highlighted stat card (ads-metrics-calculator marks the computed metric). */
.stat-card.is-active { border-color: var(--blue-300); background: var(--blue-25); box-shadow: 0 0 0 1px var(--blue-200) inset; }

/* Header row for a result block: title left, action buttons right. */
.result-block-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3);
}
.result-block-head h2, .result-block-head h3 { margin: 0; }

/* Monospace code block (JSON-LD output, generated snippets). Scrolls, never overflows the page. */
.code-block {
  font-family: var(--font-mono); font-size: 13px; line-height: 1.6;
  background: var(--neutral-50); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-3) var(--space-4);
  overflow-x: auto; white-space: pre; color: var(--text-primary); margin: 0;
}

/* Line-numbered code table (robots.txt viewer). */
.code-table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 13px; }
.code-table .code-line-num {
  width: 1%; white-space: nowrap; text-align: right; padding: 1px var(--space-3) 1px 0;
  color: var(--text-muted); user-select: none; border-right: 1px solid var(--border);
}
.code-table .code-line { padding: 1px 0 1px var(--space-3); white-space: pre-wrap; overflow-wrap: anywhere; }

/* Preset / chip row: wraps with a consistent gap. */
.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* Compact empty state inside a tab panel / small area. */
.empty-state-sm { padding: var(--space-6) var(--space-4); }

/* Static group label (legend/heading above a control group). */
.field-label-static { display: block; font: 600 13px var(--font-sans); color: var(--text-secondary); margin-bottom: var(--space-2); }

/* Field group wrapper (fieldset) — reset native chrome. */
.field-group { border: 0; margin: 0; padding: 0; min-width: 0; }

/* Inline icon inside a help note should sit on the text line, not break to its own line. */
.field-help .icon { display: inline-block; vertical-align: -2px; margin-right: 4px; flex: none; }

/* Meter fill turns red when a value is over its limit. */
.hbar-fill.is-over { background: var(--error-500); }

/* Small utility lists (hints, links, invalid/skipped lines). */
.hint-list, .link-list { margin: var(--space-1) 0 0; padding-left: var(--space-4); }
.hint-list li, .link-list li { margin-bottom: var(--space-1); font-size: 13px; }
.link-list a { overflow-wrap: anywhere; }

/* Native range input theming. */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px; background: var(--neutral-200); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--blue-600); cursor: pointer; border: 2px solid #fff; box-shadow: var(--shadow-xs); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--blue-600); cursor: pointer; border: 2px solid #fff; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--blue-200); }

/* Fieldset used as a plain form group should carry no native border/margin. */
fieldset.field, fieldset.field-group { border: 0; margin: 0; padding: 0; min-width: 0; }

/* Danger card variant (CSP-clean replacement for inline border-color). */
.card-danger { border-color: var(--error-300); }

/* Link-styled button (CSP-safe inline actions in tables/forms). */
.btn-link { background: none; border: 0; padding: 0; margin: 0; color: var(--text-link); cursor: pointer; font: inherit; text-decoration: none; }
.btn-link:hover { text-decoration: underline; }
.btn-link.text-error { color: var(--error-600); }
