:root {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #171a29;
  background: #f3f3ee;
  font-synthesis: none;
  --blue: #344de0;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, textarea, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid #7385ff;
  outline-offset: 3px;
}
button { -webkit-tap-highlight-color: transparent; }
.editor {
  max-width: 830px;
  margin-inline: auto;
  padding: max(38px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right))
    max(26px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
}
.editor-header {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-block: 0 28px;
}
h1 { font-size: clamp(28px, 5vw, 39px); letter-spacing: -.06em; margin: 0; }
.brand-mark {
  display: grid;
  place-content: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--blue);
}
.brand-mark i { background: white; width: 18px; height: 2px; border-radius: 2px; }
.brand-mark i:last-child { width: 11px; }
.editor-card {
  background: #fff;
  border: 1px solid #dedfd8;
  border-radius: 21px;
  box-shadow: 0 12px 36px #2226190b;
}
.editor-bar, .editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 17px 20px;
}
.editor-bar { border-bottom: 1px solid #ebebe6; }
.editor-bar label { font-weight: 700; }
#word-count, #save-status { color: #5b6070; font-size: 13px; }
#draft {
  display: block;
  width: 100%;
  min-height: 170px;
  height: 53vh;
  height: clamp(170px, 53svh, 620px);
  padding: 20px;
  resize: vertical;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 18px;
  line-height: 1.6;
}
#draft:focus-visible { outline-offset: -4px; }
#draft::placeholder { color: #686e7d; }
.editor-footer { border-top: 1px solid #ebebe6; }
.primary {
  min-height: 46px;
  background: var(--blue);
  color: white;
  border: 1px solid transparent;
  border-radius: 12px;
  padding-inline: 15px;
  font-weight: 700;
}
.primary span { font-size: 12px; margin-right: 5px; }
.primary:disabled { background: #e6e8f0; color: #555a70; cursor: default; }

.reader { position: fixed; inset: 0; background: #08090b; color: #fff; }
.viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.viewport.dragging { cursor: grabbing; }
.script {
  max-width: 1040px;
  margin-inline: auto;
  padding: 35vh max(8vw, env(safe-area-inset-right)) 72vh max(8vw, env(safe-area-inset-left));
  padding-block: 35dvh 72dvh;
  font-size: var(--script-size, 44px);
  font-weight: 650;
  line-height: 1.32;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.script.mirrored { transform: scaleX(-1); }
.reader-header, .reader-footer {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 1;
  pointer-events: none;
}
.reader-header {
  top: 0;
  display: flex;
  justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    0 max(12px, env(safe-area-inset-left));
}
.reader-header button, .reader-actions button {
  min-height: 44px;
  border-radius: 10px;
  padding-inline: 11px;
  font-size: 14px;
}
.reader-header button, .reader-actions button:not(.primary) {
  color: #fff;
  background: #242731;
  border: 1px solid #4a4e5e;
}
.reader-header button { pointer-events: auto; }
.reader-header button[aria-expanded="false"] { opacity: .62; }
.reader-footer {
  bottom: 0;
  padding: 0 max(12px, env(safe-area-inset-right))
    max(9px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.controls {
  pointer-events: auto;
  max-width: 610px;
  margin: 0 auto 9px;
  padding: 12px;
  background: #161820;
  border: 1px solid #3d4150;
  border-radius: 16px;
}
.sliders {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.setting { display: grid; gap: 2px; }
.setting label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
  font-size: 13px;
  font-weight: 650;
}
.setting output { font-size: 12px; color: #bfc9ff; white-space: nowrap; }
.setting input { width: 100%; height: 36px; margin: 0; accent-color: #889bff; }
.reader-actions {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}
.reader-actions button[aria-pressed="true"] { background: #2b3565; border-color: #768dff; }
.progress {
  height: 2px;
  max-width: 610px;
  margin-inline: auto;
  background: #fff2;
  border-radius: 2px;
}
.progress span { display: block; height: 100%; width: 0; background: #a5b4ff; border-radius: 2px; }
@media (max-width: 370px) {
  .editor { padding-inline: 14px; }
  .editor-bar, .editor-footer, #draft { padding-inline: 12px; }
  .setting label { flex-wrap: wrap; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .editor { padding-top: max(16px, env(safe-area-inset-top)); }
  .editor-header { margin-bottom: 14px; }
  .controls { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px; }
}
@media (orientation: landscape) and (max-height: 500px) and (max-width: 620px) {
  .controls { display: block; }
}
.editor-label { display: grid; gap: 4px; }
.editor-label #save-status:empty { display: none; }
.secondary {
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid #d8dcee;
  border-radius: 10px;
  background: #f6f7fd;
  color: #2536aa;
  font-size: 14px;
  font-weight: 700;
}
.secondary:disabled { opacity: .65; cursor: default; }
.import-feedback {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 20px;
  background: #f6f7fb;
  color: #454b64;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.import-feedback:has(#import-status:empty) { padding-block: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.projects-card {
  margin-bottom: 16px;
  padding: 13px 16px;
  background: #fff;
  border: 1px solid #dedfd8;
  border-radius: 17px;
}
.projects-header, .project-feedback {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.projects-header { margin-bottom: 6px; }
.projects-header h2 { font-size: 16px; margin: 0; }
.project-row {
  display: flex;
  gap: 6px;
  margin-block: 8px;
}
.project-row input, .project-row select {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 9px;
  border: 1px solid #d8dcee;
  border-radius: 10px;
  background: white;
  color: inherit;
  font: inherit;
  font-size: 16px;
}
.project-row button { flex: 0 0 auto; }
.project-feedback { color: #535b6d; font-size: 13px; line-height: 1.35; }
#project-copy { margin-block: 0 8px; }
@media (max-width: 420px) {
  .projects-card { padding-inline: 11px; }
  .project-row .secondary { padding-inline: 9px; }
}
