/* SERP Snippet Preview — tool-specific styles (loaded on this tool only). */

.sp-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ti-border);
}

.sp-save {
  margin: 0;
}

.sp-jump {
  display: none;
  font-weight: var(--ti-fw-semi);
  text-decoration: none;
}

.sp-import {
  margin-bottom: 24px;
  padding: 20px;
  border: 1px solid rgba(79, 70, 229, 0.25);
  border-radius: var(--ti-radius-lg);
  background: rgba(79, 70, 229, 0.04);
}

.sp-import .ti-actions {
  margin: 12px 0;
}

.sp-form__title {
  margin-bottom: 4px;
}

.sp-form__intro {
  margin: 0 0 16px;
}

/* Sections */
.sp-sec {
  margin-bottom: 12px;
  border: 1px solid var(--ti-border);
  border-radius: var(--ti-radius-lg);
  background: var(--ti-white);
}

.sp-sec[hidden] {
  display: none;
}

.sp-sec > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  border-radius: var(--ti-radius-lg);
}

.sp-sec > summary::-webkit-details-marker {
  display: none;
}

.sp-sec > summary::before {
  content: "";
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--ti-primary);
  border-bottom: 2px solid var(--ti-primary);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.sp-sec[open] > summary::before {
  transform: rotate(45deg);
}

.sp-sec > summary:hover {
  background: var(--ti-bg);
}

.sp-sec > summary:focus-visible {
  outline: none;
  box-shadow: var(--ti-focus);
}

.sp-sec__title {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: var(--ti-fw-bold);
  letter-spacing: -0.01em;
}

.sp-sec__tag {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(220, 38, 38, 0.1);
  font-size: 16px;
  font-weight: var(--ti-fw-semi);
  color: #B91C1C;
}

.sp-sec__tag--rec {
  background: var(--ti-primary-tint);
  color: var(--ti-primary);
}

.sp-sec__tag--opt {
  background: var(--ti-bg);
  color: var(--ti-muted-color);
}

.sp-sec__body {
  padding: 4px 18px 18px;
}

.sp-textarea-sm {
  min-height: 96px;
}

.sp-help-tight {
  margin: -6px 0 16px;
}

.sp-help-top {
  margin: 0 0 14px;
}

.sp-link-btn {
  display: inline-block;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--ti-font);
  font-size: 16px;
  font-weight: var(--ti-fw-semi);
  color: var(--ti-primary);
  cursor: pointer;
}

.sp-link-btn:hover {
  text-decoration: underline;
}

.sp-link-btn[hidden] {
  display: none;
}

/* Output */
.sp-output {
  min-height: 220px;
  max-height: 56vh;
}

.sp-out__actions {
  margin: 14px 0 20px;
}

.sp-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 12px;
}

.sp-summary p {
  margin: 0;
  font-size: 16px;
}

.ti-issue--error { border-left: 4px solid #DC2626; }
.ti-issue--warn  { border-left: 4px solid #D97706; }
.ti-issue--ok    { border-left: 4px solid #16A34A; }
.ti-issue--info  { border-left: 4px solid var(--ti-primary); }

.sp-issue-link {
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--ti-font);
  font-size: 16px;
  font-weight: var(--ti-fw-semi);
  color: var(--ti-text-color);
  text-align: left;
  text-decoration: underline;
  text-decoration-color: var(--ti-border-strong);
  text-underline-offset: 3px;
  cursor: pointer;
}

.sp-issue-link:hover {
  color: var(--ti-primary);
}

.sp-note {
  margin-top: 14px;
}

@media (max-width: 980px) {
  .sp-jump {
    display: inline-block;
  }
}

@media (max-width: 640px) {
  .sp-output {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .sp-sec__body {
    padding: 4px 14px 16px;
  }

  .sp-sec > summary {
    padding: 14px;
  }
}

.sp-empty {
  margin: 0;
  padding: 14px 16px;
  border: 1px dashed var(--ti-border-strong);
  border-radius: var(--ti-radius-md);
  color: var(--ti-muted-color);
}

/* SERP preview-specific */
.sp-ta-title { min-height: 72px; }
.sp-ta-desc { min-height: 116px; }
.sp-ta-alts { min-height: 104px; }
.sp-count { min-height: 24px; }
.sp-help-top { margin: -6px 0 16px; }
.sp-indent { margin: 8px 0 12px 32px; }
.sp-layout { margin-top: 24px; }
.sp-out__title { margin: 24px 0 12px; }
.sp-output { min-height: 96px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Preview panel */
.sp-preview {
  padding: 20px;
  border: 1px solid var(--ti-border);
  border-radius: var(--ti-radius-lg);
  background: var(--ti-white);
}

.sp-preview__head { flex-wrap: wrap; gap: 10px 16px; }

.sp-preview__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
}

.sp-dark { margin: 0; }

/* The frame scrolls sideways if the preview is wider than the screen; the page never does. */
.sp-frame {
  --g: 1.142857; /* 16 / 14: Google's 14px text shows at 16px, every width scales by the same factor */
  overflow-x: auto;
  padding: calc(20px * var(--g)) calc(16px * var(--g));
  border: 1px solid var(--ti-border);
  border-radius: var(--ti-radius-md);
  background: #FFFFFF;
}

.sp-frame:focus-visible { outline: none; box-shadow: var(--ti-focus); }

.sp-serp {
  --sp-title: #1A0DAB;
  --sp-text: #4D5156;
  --sp-name: #202124;
  --sp-fav-bg: #F1F3F4;
  width: calc(600px * var(--g));
  font-family: Arial, "Liberation Sans", Arimo, Helvetica, sans-serif;
  color: var(--sp-text);
}

.sp-serp[data-device="mobile"] {
  width: calc(360px * var(--g));
  padding: calc(14px * var(--g)) calc(16px * var(--g));
  border-radius: calc(16px * var(--g));
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.18);
}

.sp-serp[data-device="mobile"] .sp-serp__title,
.sp-serp[data-device="mobile"] .sp-serp__desc { width: calc(328px * var(--g)); }

.sp-frame--dark { background: #1F1F1F; }
.sp-frame--dark .sp-serp { --sp-title: #99C3FF; --sp-text: #BFBFBF; --sp-name: #DADCE0; --sp-fav-bg: #3C4043; }
.sp-frame--dark .sp-serp[data-device="mobile"] { background: #303134; box-shadow: none; }

.sp-serp__site {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  min-width: 0;
}

.sp-serp__fav {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: calc(28px * var(--g));
  height: calc(28px * var(--g));
  overflow: hidden;
  border-radius: 50%;
  background: var(--sp-fav-bg);
  font-size: 16px;
  font-weight: 700;
  color: var(--sp-name);
}

.sp-serp__fav img { width: calc(18px * var(--g)); height: calc(18px * var(--g)); object-fit: contain; }

.sp-serp__meta { display: grid; min-width: 0; line-height: 1.35; }
.sp-serp__name { overflow: hidden; font-size: 16px; color: var(--sp-name); text-overflow: ellipsis; white-space: nowrap; }
.sp-serp__url { overflow: hidden; font-size: 16px; color: var(--sp-text); text-overflow: ellipsis; white-space: nowrap; }

.sp-serp__title {
  margin: 0 0 4px;
  font-size: calc(20px * var(--g));
  font-weight: 400;
  line-height: calc(26px * var(--g));
  color: var(--sp-title);
  white-space: nowrap;
}

.sp-serp[data-device="mobile"] .sp-serp__title { white-space: normal; }

.sp-serp__desc {
  font-size: calc(14px * var(--g));
  line-height: calc(22px * var(--g));
  color: var(--sp-text);
  overflow-wrap: anywhere;
}

.sp-serp__desc b { font-weight: 700; color: var(--sp-text); }
.sp-serp__date { color: var(--sp-text); opacity: 0.85; }
.sp-serp__ph { font-style: italic; opacity: 0.8; }

.sp-scroll-hint { display: none; margin: 8px 0 0; }

/* Meters */
.sp-meters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 24px;
  margin-top: 18px;
}

.sp-meter__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  margin-bottom: 6px;
}

.sp-meter__label { font-weight: var(--ti-fw-semi); }
.sp-meter__value { color: var(--ti-muted-color); }

.sp-meter__bar {
  position: relative;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--ti-bg);
  box-shadow: inset 0 0 0 1px var(--ti-border);
}

.sp-meter__fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: #16A34A;
  transition: width 0.15s ease;
}

.sp-meter[data-state="close"] .sp-meter__fill { background: #D97706; }
.sp-meter[data-state="cut"] .sp-meter__fill { background: #DC2626; }
.sp-meter[data-state="cut"] .sp-meter__value { color: #991B1B; font-weight: var(--ti-fw-semi); }
.sp-note { margin: 14px 0 0; }

.sp-limits { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }
.sp-limits .ti-field { margin-bottom: 8px; }
@media (max-width: 560px) { .sp-limits { grid-template-columns: minmax(0, 1fr); } }

/* Title ideas */
.sp-alts { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.sp-alts[hidden] { display: none; }

.sp-alt {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px 12px;
  align-items: center;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--ti-border);
  border-left: 4px solid #16A34A;
  border-radius: var(--ti-radius-sm);
  background: var(--ti-white);
}

.sp-alt--close { border-left-color: #D97706; }
.sp-alt--cut { border-left-color: #DC2626; }
.sp-alt__text { overflow-wrap: anywhere; }
.sp-alt__meta { white-space: nowrap; color: var(--ti-muted-color); }

@media (max-width: 760px) {
  .sp-scroll-hint { display: block; }
  .sp-meters { grid-template-columns: minmax(0, 1fr); }
  .sp-preview { padding: 14px; }
  .sp-alt { grid-template-columns: minmax(0, 1fr) auto; }
  .sp-alt__text { grid-column: 1 / -1; }
  .sp-indent { margin-left: 0; }
}

/* The preview sits above the form, so the checks column scrolls with the page
   instead of being a sticky panel with its own scrollbar. */
.sp .sp-out.ti-app-panel--output,
.admin-bar .sp .sp-out.ti-app-panel--output {
  position: static;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}