:root {
  font-family: system-ui, Inter, "Segoe UI", sans-serif;
  color: #17233c;
  background: #fff;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #17233c;
  --muted: #66758d;
  --line: #dfe7f2;
  --paper: #fff;
  --blue: #3478ef;
  --blue-dark: #245bc2;
  --shadow: 0 8px 22px rgba(20, 33, 58, .05);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  background: #fff;
  color: var(--ink);
}
.layout {
  position: relative;
  max-width: 1100px;
  margin: 8px auto 28px;
  padding: 12px;
}
.intro { margin: 10px 0 18px; }
.intro h1 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.35;
  font-weight: 650;
  letter-spacing: -.25px;
}
.lead { margin: 3px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.workspace { display: grid; grid-template-columns: 1fr; gap: 12px; }
.card {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.editor { padding: 16px; display: flex; flex-direction: column; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-heading label, .section-heading h2 { margin: 0; color: var(--ink); font-size: 14px; font-weight: 650; }
.section-heading h2 { font-size: 14px; }
.counter { color: var(--muted); font-size: 12px; }
.counter #charCount { color: var(--blue-dark); font-weight: 700; }
textarea {
  width: 100%; height: 88px; min-height: 88px; resize: none; overflow: hidden;
  padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fbfcff; color: var(--ink); font: 15px/1.6 system-ui, Inter, "Segoe UI", sans-serif;
}
textarea:focus, input:focus-visible {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(52, 120, 239, .13); outline: none;
}
textarea::placeholder { color: #8b98ad; }
.editor-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 9px; color: var(--muted); font-size: 12px; }
.text-button { padding: 6px; border: 0; background: transparent; color: var(--blue-dark); font: 600 12px system-ui, sans-serif; cursor: pointer; }
.text-button:hover { text-decoration: underline; }
.controls { padding: 16px; }
.settings { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.field label { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 7px; color: #44536d; font-size: 12px; font-weight: 600; }
.field output { color: var(--blue-dark); font-weight: 650; }
.field input[type="range"] { width: 100%; height: 5px; margin: 8px 0 2px; accent-color: var(--blue); cursor: pointer; }
.range-ends { display: flex; justify-content: space-between; color: #7e8ba0; font-size: 11px; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.button {
  min-height: 44px; padding: 0 15px; border: 0; border-radius: 10px;
  display: inline-flex; justify-content: center; align-items: center; gap: 8px;
  font: 600 13px system-ui, sans-serif; cursor: pointer; transition: transform .15s, filter .15s;
}
.button:not(:disabled):hover { transform: translateY(-1px); }
.button:focus-visible, .text-button:focus-visible { outline: 3px solid rgba(52, 120, 239, .3); outline-offset: 2px; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button-primary { flex: 1; color: white; background: linear-gradient(115deg, #3478ef, #245bc2); box-shadow: 0 4px 10px rgba(36, 91, 194, .16); }
.button-secondary { color: #31415d; background: #eef3f9; }
.button-secondary:hover:not(:disabled) { filter: brightness(.97); }
.status { min-height: 16px; margin: 11px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.status.error { color: #b54343; }
dialog { width: min(420px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); box-shadow: 0 20px 60px rgba(20, 33, 58, .2); }
dialog::backdrop { background: rgba(23, 35, 60, .42); backdrop-filter: blur(2px); }
.dialog-content { padding: 26px; text-align: center; }
.dialog-icon { display: grid; place-items: center; width: 38px; height: 38px; margin: 0 auto 13px; border-radius: 50%; background: #fff3dc; color: #a16b17; font-weight: 700; }
.dialog-content h2 { margin: 0 0 9px; font-size: 19px; font-weight: 650; }
.dialog-content p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.dialog-actions { display: flex; justify-content: center; gap: 9px; margin-top: 22px; }
.button-danger { color: #fff; background: #b64b46; }
.button-danger:hover { background: #9f3c38; }
@media (max-width: 600px) {
  .layout { margin: 8px auto 22px; padding: 12px 8px; }
  .intro { margin: 9px 0 14px; }
  .lead { font-size: 14px; }
  .workspace { gap: 10px; }
  .settings { grid-template-columns: 1fr; }
  .editor, .controls { padding: 13px; }
  textarea { height: 88px; min-height: 88px; padding: 11px; font-size: 16px; }
  .action-row { gap: 7px; }
  .button { min-height: 44px; padding: 0 11px; }
}
@media (max-width: 390px) {
  .settings { gap: 12px 10px; }
  .action-row { display: grid; grid-template-columns: 1fr 1fr; }
  .button-primary { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }


@media screen {
  body.pde-resource-ui { --ink:#17324d; --muted:#71839b; --line:#e4edf5; --blue:#0798b3; --blue-dark:#078ca6; --shadow:0 6px 24px #17324d05; }
  body.pde-resource-ui textarea:focus { border-color:#0798b3; box-shadow:0 0 0 3px #0798b318; }
  body.pde-resource-ui .text-button { color:#0798b3; }
}
