/* =========================================================================
   Prompt Rewriter — dark / lab tool aesthetic
   --------------------------------------------------------------------------
   Deliberately the visual opposite of the Tool Wall (light pinboard). This
   site reads like a focused dev tool: dark green near-black background,
   subtle scanlines, mono typography, score-bars, streaming token reveal.
   Same brand colours, opposite mood.
   ========================================================================= */

:root {
  --green-dark:    #1f4040;
  --green-deep:    #0c1d1d;     /* near-black green, the canvas */
  --green-mid:     #163030;     /* panels */
  --green-line:    rgba(199, 219, 92, 0.16);
  --green-hero:    #c7db5c;
  --green-pale:    #dfe99a;
  --plum:          #a85b8b;
  --cranberry:     #d92d4b;
  --grey-mute:     #7a8c8c;

  --serif: Georgia, "Fields", "Times New Roman", serif;
  --sans:  Tahoma, "Noto Sans", Verdana, sans-serif;
  --mono:  ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas,
           "Liberation Mono", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--green-deep);
  color: var(--green-pale);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* Scanlines + a faint top-down gradient for atmosphere. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 3px,
      rgba(199, 219, 92, 0.025) 3px,
      rgba(199, 219, 92, 0.025) 4px
    ),
    radial-gradient(ellipse at 50% -20%, rgba(199, 219, 92, 0.08), transparent 60%);
}

main.app {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px 40px;
}

/* ---------- topbar ---------- */

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--green-line);
  margin-bottom: 24px;
}

.back {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--green-pale);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--green-line);
  border-radius: 4px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.back:hover {
  color: var(--green-deep);
  background: var(--green-hero);
  border-color: var(--green-hero);
}

.title-block { text-align: left; }

.site-tag {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--green-hero);
  margin-bottom: 4px;
}

.site-tag em {
  color: var(--plum);
  font-style: italic;
  text-transform: none;
  letter-spacing: 0.04em;
  font-family: var(--serif);
}

.site-title {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(20px, 3vw, 30px);
  letter-spacing: -0.01em;
  color: var(--green-pale);
  text-transform: lowercase;
}

.model-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--green-hero);
  padding: 6px 12px;
  border: 1px solid var(--green-line);
  border-radius: 999px;
  background: rgba(31, 64, 64, 0.4);
}

.model-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-hero);
  animation: pulse 2.4s ease-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(199, 219, 92, 0.7); }
  70%      { box-shadow: 0 0 0 9px rgba(199, 219, 92, 0); }
}

@media (max-width: 640px) {
  .topbar { grid-template-columns: 1fr; gap: 12px; }
  .model-pill { justify-self: start; }
}

/* ---------- lede + examples ---------- */

.lede {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.5;
  color: var(--green-pale);
  max-width: 720px;
  margin-bottom: 24px;
  opacity: 0.92;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
}

.examples-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--grey-mute);
  margin-right: 4px;
}

.example {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--green-pale);
  background: transparent;
  border: 1px dashed var(--green-line);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.example:hover, .example:focus-visible {
  border-color: var(--green-hero);
  border-style: solid;
  color: var(--green-hero);
  outline: none;
}

.example::before {
  content: "→ ";
  color: var(--plum);
}

/* ---------- editor: two-pane ---------- */

.editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 32px;
}

@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; }
}

.pane {
  background: var(--green-mid);
  border: 1px solid var(--green-line);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  min-height: 460px;
  overflow: hidden;
}

.pane-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--green-line);
  background: rgba(0, 0, 0, 0.18);
  font-size: 11px;
  letter-spacing: 0.1em;
}

.pane-num {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--green-deep);
  background: var(--green-hero);
  padding: 2px 8px;
  border-radius: 3px;
}

.pane-name {
  font-family: var(--mono);
  text-transform: uppercase;
  color: var(--green-pale);
  letter-spacing: 0.16em;
}

.pane-meta {
  margin-left: auto;
  font-family: var(--mono);
  color: var(--grey-mute);
  font-size: 11px;
  letter-spacing: 0;
}

.pane-meta.thinking {
  color: var(--green-hero);
}

/* ---------- input pane ---------- */

.prompt-input {
  flex: 1;
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  padding: 18px 20px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.65;
  color: var(--green-pale);
  caret-color: var(--green-hero);
}

.prompt-input::placeholder {
  color: var(--grey-mute);
  font-style: italic;
}

.pane-foot {
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--green-line);
  background: rgba(0, 0, 0, 0.14);
}

.rewrite-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--green-hero);
  color: var(--green-deep);
  border: none;
  padding: 12px 22px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 0 0 rgba(199, 219, 92, 0);
}

.rewrite-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 0 0 4px rgba(199, 219, 92, 0.18);
}

.rewrite-btn:disabled {
  background: var(--green-line);
  color: var(--grey-mute);
  cursor: wait;
}

.rewrite-arrow {
  font-size: 16px;
  transition: transform 0.15s;
}

.rewrite-btn:hover:not(:disabled) .rewrite-arrow {
  transform: translateX(3px);
}

/* ---------- output pane: scores + rewrite ---------- */

.scores {
  padding: 14px 18px 4px;
  border-bottom: 1px solid var(--green-line);
}

.score-row {
  display: grid;
  grid-template-columns: 110px 1fr 36px;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}

.score-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--green-pale);
  text-transform: uppercase;
}

.score-bar {
  position: relative;
  height: 6px;
  background: rgba(199, 219, 92, 0.12);
  border-radius: 3px;
  overflow: hidden;
}

.score-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(to right, var(--plum), var(--green-hero));
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.score-row[data-score="1"] .score-bar-fill { width: 20%; }
.score-row[data-score="2"] .score-bar-fill { width: 40%; }
.score-row[data-score="3"] .score-bar-fill { width: 60%; }
.score-row[data-score="4"] .score-bar-fill { width: 80%; }
.score-row[data-score="5"] .score-bar-fill { width: 100%; }

.score-value {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--green-hero);
  text-align: right;
}

.score-reason {
  grid-column: 2 / -1;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  line-height: 1.4;
  color: var(--grey-mute);
  margin-top: 2px;
  min-height: 1.4em;
}

/* Soft fade-in when scores arrive */
.score-row.populated .score-reason { color: var(--green-pale); }
.score-row.populated .score-value  { color: var(--green-hero); }

.rewrite-block {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.rewrite-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px dashed var(--green-line);
  font-size: 11px;
}

.rewrite-tag {
  font-family: var(--mono);
  color: var(--plum);
  font-style: italic;
  margin-right: auto;
}

.use-btn, .copy-btn {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  background: transparent;
  color: var(--green-pale);
  border: 1px solid var(--green-line);
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.use-btn:hover:not(:disabled),
.copy-btn:hover:not(:disabled) {
  background: var(--green-hero);
  color: var(--green-deep);
  border-color: var(--green-hero);
}

.use-btn:disabled,
.copy-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.copy-btn.copied {
  background: var(--green-hero);
  color: var(--green-deep);
}

.rewrite-output {
  flex: 1;
  padding: 18px 20px 22px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.7;
  color: #ffffff;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
}

.rewrite-output .placeholder {
  color: var(--grey-mute);
  font-style: italic;
}

/* Streaming cursor */
.rewrite-output.streaming::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 14px;
  background: var(--green-hero);
  margin-left: 2px;
  vertical-align: -2px;
  animation: caret 1s steps(2) infinite;
}

@keyframes caret { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .model-pill .dot { animation: none; }
  .rewrite-output.streaming::after { animation: none; opacity: 1; }
  .score-bar-fill { transition: none; }
}

/* ---------- footer ---------- */

.page-foot {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px dashed var(--green-line);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  color: var(--grey-mute);
  font-family: var(--mono);
}

.page-foot a {
  color: var(--green-pale);
  text-decoration: underline;
  text-decoration-color: var(--green-hero);
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;
}

.page-foot a:hover {
  color: var(--green-hero);
}

.accreditation {
  font-size: 10px;
  letter-spacing: 0.06em;
}

/* ---------- shake on error ---------- */

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

.pane.error {
  animation: shake 0.4s ease-in-out;
  border-color: var(--cranberry);
}
