/* Natural Rewriter. Kept separate from the media tools because this is a text
   tool with a server model behind it, and the states and gate report have
   nowhere else in the plugin to live. */

.sk-rewrite-wrap {
  --sk-ink: #22303a;
  --sk-muted: #5f7180;
  --sk-line: #dce4ea;
  --sk-pale: #f6f9fb;
  --sk-accent: #2c6e8f;
  --sk-warn: #8a5a00;
  --sk-warn-bg: #fff6e3;
  --sk-err: #a03030;
  --sk-ok: #1f6b3f;
  max-width: 900px;
  margin: 0 auto;
  padding: 8px 4px 56px;
  color: var(--sk-ink);
  line-height: 1.6;
}

.sk-rewrite-wrap h1 { margin: 0 0 8px; }
.sk-rewrite-lede { color: var(--sk-muted); margin: 0 0 18px; }
.sk-rewrite-lede strong { color: var(--sk-ink); }

.sk-rewrite-privacy {
  border: 1px solid var(--sk-line);
  border-left: 4px solid var(--sk-accent);
  background: var(--sk-pale);
  padding: 12px 14px;
  border-radius: 6px;
  margin: 0 0 22px;
  font-size: 0.94rem;
}
.sk-rewrite-privacy strong { color: var(--sk-accent); }

.sk-rewrite-panel {
  border: 1px solid var(--sk-line);
  border-radius: 8px;
  padding: 18px 18px 20px;
  margin: 0 0 20px;
  background: #fff;
}
.sk-rewrite-panel h2 { margin: 0 0 12px; font-size: 1.15rem; }
.sk-rewrite-hint { color: var(--sk-muted); font-size: 0.9rem; margin: 0 0 8px; }

.sk-rewrite-modes { display: grid; gap: 10px; margin: 0 0 14px; }
.sk-rewrite-mode {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--sk-line); border-radius: 6px;
  padding: 10px 12px; cursor: pointer; background: var(--sk-pale);
}
.sk-rewrite-mode:has(input:checked) { border-color: var(--sk-accent); background: #eef5f9; }
.sk-rewrite-mode input { margin-top: 4px; }
.sk-rewrite-mode strong { display: block; }
.sk-rewrite-mode small { color: var(--sk-muted); display: block; }

.sk-rewrite-field { display: block; margin: 0 0 12px; }
.sk-rewrite-field > span { display: block; font-size: 0.9rem; color: var(--sk-muted); margin-bottom: 4px; }
.sk-rewrite-field select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--sk-line);
  border-radius: 6px; font: inherit; background: #fff; color: inherit;
}

/* The paste box is the first thing on the tool now, so it is sized like the
   main event rather than a form field: tall enough to hold a paragraph you can
   read at a glance, and wide enough that 1.6 line-height does not leave the
   right third of the panel empty. */
#sk-rewrite-input, #sk-rewrite-output {
  width: 100%; box-sizing: border-box;
  border: 1px solid var(--sk-line); border-radius: 6px;
  padding: 16px 18px; font: inherit; line-height: 1.7; color: inherit;
  background: #fff; resize: vertical;
}

#sk-rewrite-input {
  min-height: 320px;
  font-size: 1.02rem;
}

#sk-rewrite-input:focus-visible {
  outline: 2px solid var(--sk-accent);
  outline-offset: 2px;
}

#sk-rewrite-output { background: var(--sk-pale); min-height: 240px; }

.sk-rewrite-counts { display: flex; gap: 16px; margin: 8px 0 0; font-size: 0.85rem; color: var(--sk-muted); }
.sk-rewrite-counts b { color: var(--sk-ink); }
.sk-rewrite-counts span { margin-left: 4px; }

.sk-rewrite-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0 0; }

/* Ink, not accent. The rest of the site's primary buttons are near-black with
   white text; a violet fill here made the rewriter look like a different site.
   The border matches the fill so the button keeps a defined edge on the pale
   panel behind it. */
.sk-rewrite-button {
  border: 1px solid var(--sk-ink); background: var(--sk-ink); color: var(--sk-surface, #fff);
  padding: 11px 22px; border-radius: 4px; font: inherit; font-weight: 500;
  cursor: pointer; transition: opacity 0.15s ease;
}
.sk-rewrite-button:hover:not(:disabled) { opacity: 0.86; }
.sk-rewrite-button:disabled { opacity: 0.4; cursor: not-allowed; }
.sk-rewrite-button:focus-visible { outline: 2px solid var(--sk-accent); outline-offset: 2px; }
.sk-rewrite-ghost {
  background: transparent; color: var(--sk-ink); border-color: var(--sk-line);
}

/* The two mode cards and the length select sit under the paste box as one
   quiet row, so the box is what you see first. */
.sk-rewrite-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 220px);
  gap: 16px;
  align-items: start;
  margin: 20px 0 0;
}

@media (max-width: 720px) {
  .sk-rewrite-options { grid-template-columns: 1fr; }
  #sk-rewrite-input { min-height: 240px; }
}

/* The explicit states. data-active marks the stage currently in progress. */
.sk-rewrite-stages { display: flex; gap: 14px; list-style: none; margin: 16px 0 6px; padding: 0; flex-wrap: wrap; }
.sk-rewrite-stages li { display: flex; align-items: center; gap: 6px; color: var(--sk-muted); font-size: 0.88rem; }
.sk-rewrite-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--sk-line); display: inline-block; }
body[data-sk-rewrite-state="working"] .sk-rewrite-stages li[data-stage="working"] .sk-rewrite-dot { background: var(--sk-accent); }
body[data-sk-rewrite-state="ready"] .sk-rewrite-stages li[data-stage="ready"] .sk-rewrite-dot { background: var(--sk-ok); }
body[data-sk-rewrite-state="failed"] .sk-rewrite-stages li[data-stage="failed"] .sk-rewrite-dot { background: var(--sk-err); }
body[data-sk-rewrite-state="cancelled"] .sk-rewrite-stages li[data-stage="cancelled"] .sk-rewrite-dot { background: var(--sk-muted); }
.sk-rewrite-stages li[data-active="yes"] { color: var(--sk-ink); font-weight: 600; }

.sk-rewrite-status { margin: 6px 0 0; font-size: 0.95rem; }
.sk-rewrite-status[data-state="busy"] { color: var(--sk-accent); }
.sk-rewrite-status[data-state="ok"] { color: var(--sk-ok); }
.sk-rewrite-status[data-state="warn"] { color: var(--sk-warn); }
.sk-rewrite-status[data-state="error"] { color: var(--sk-err); }

/* The gate report. Shown on every result, pass or fail. */
.sk-rewrite-gates { margin: 18px 0 0; }
.sk-rewrite-gates-ok { color: var(--sk-ok); font-weight: 600; margin: 0 0 8px; }
.sk-rewrite-gates-fail { background: var(--sk-warn-bg); border: 1px solid #e8d49a; border-radius: 6px; padding: 12px 14px; margin: 0 0 10px; }
.sk-rewrite-gates-fail strong { color: var(--sk-warn); }
.sk-rewrite-gate-failures { margin: 8px 0 0 18px; color: var(--sk-warn); font-size: 0.92rem; }
.sk-rewrite-gate-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.sk-rewrite-gate-list li { display: flex; gap: 10px; font-size: 0.85rem; align-items: baseline; }
.sk-rewrite-gate-list li[data-pass="no"] .sk-rewrite-gate-name { color: var(--sk-warn); font-weight: 600; }
.sk-rewrite-gate-list li[data-pass="yes"] .sk-rewrite-gate-name { color: var(--sk-ok); }
.sk-rewrite-gate-name { min-width: 150px; text-transform: capitalize; }
.sk-rewrite-gate-detail { color: var(--sk-muted); }

.sk-rewrite-original {
  white-space: pre-wrap; word-break: break-word;
  background: var(--sk-pale); border: 1px solid var(--sk-line); border-radius: 6px;
  padding: 12px; font: inherit; line-height: 1.6; margin: 0; max-height: 320px; overflow: auto;
}

.sk-rewrite-guide { border-top: 1px solid var(--sk-line); margin-top: 8px; padding-top: 18px; }
.sk-rewrite-guide h2 { font-size: 1.1rem; }
.sk-rewrite-guide h3 { font-size: 1rem; margin: 20px 0 6px; }
.sk-rewrite-guide ul { padding-left: 20px; }
.sk-rewrite-guide li { margin-bottom: 6px; }

/* Dark values keyed off the site's own toggle.
 *
 * This block was originally @media (prefers-color-scheme: dark), which only
 * reflects the operating system and ignores the Light / Dark control in the
 * header. A visitor who chose Dark on a machine set to Light got a white panel,
 * a white textarea and a white privacy callout. Every other tool stylesheet
 * keys off html[data-sk-scheme="dark"], which is what the toggle writes, so this
 * is aligned to the same convention rather than being a one-off.
 *
 * The attribute selector also outranks the light rules above it on specificity,
 * so load order cannot decide the outcome.
 */
html[data-sk-scheme="dark"] .sk-rewrite-wrap {
  --sk-ink: #e6edf3;
  --sk-muted: #9fb0be;
  --sk-line: #33414d;
  --sk-pale: #1b242c;
  --sk-accent: #6cb6d8;
  --sk-warn: #e0b64a;
  --sk-warn-bg: #2b2413;
  --sk-err: #e08080;
  --sk-ok: #6cce9a;
}

html[data-sk-scheme="dark"] .sk-rewrite-panel {
  background: #131a20;
}

html[data-sk-scheme="dark"] .sk-rewrite-mode {
  background: var(--sk-pale);
}

html[data-sk-scheme="dark"] .sk-rewrite-mode:has(input:checked) {
  background: #16242c;
}

/* The privacy callout and the text area both hardcode a light surface in the
   rules above, so they need their own value here rather than inheriting the
   dark --sk-pale. */
html[data-sk-scheme="dark"] .sk-rewrite-privacy {
  background: var(--sk-pale);
}

html[data-sk-scheme="dark"] .sk-rewrite-privacy strong {
  color: var(--sk-accent);
}

/* The rewrite text area and the mode select hardcode #fff above. The generic
   dark rule in color-scheme.css targets bare textarea/select at specificity
   (0,0,1), and the id selector used here is (1,0,0), so the light value wins
   unless it is overridden at the same or higher specificity. */
html[data-sk-scheme="dark"] #sk-rewrite-input,
html[data-sk-scheme="dark"] #sk-rewrite-output,
html[data-sk-scheme="dark"] .sk-rewrite-field select {
  background: #0e1418;
  color: var(--sk-ink);
  border-color: var(--sk-line);
}

html[data-sk-scheme="dark"] #sk-rewrite-output {
  background: var(--sk-pale);
}

/* In dark mode the ink fill becomes a near-white fill, so the label has to go
   dark. The outline-only button keeps the page's text colour instead of the
   near-white one -- it has no fill to read against. */
html[data-sk-scheme="dark"] .sk-rewrite-button:not(.sk-rewrite-ghost) {
  background: var(--sk-ink);
  border-color: var(--sk-ink);
  color: #0e1519;
}

html[data-sk-scheme="dark"] .sk-rewrite-ghost {
  background: transparent;
  color: var(--sk-ink);
  border-color: var(--sk-line);
}

html[data-sk-scheme="dark"] .sk-rewrite-ghost {
  color: var(--sk-accent);
}
