.hero {
  grid-template-columns: minmax(0, 1.28fr) minmax(280px, 0.72fr);
  gap: 40px;
}

.hero > div:first-child {
  min-width: 0;
}

.hero h1 {
  max-width: 100%;
  font-size: clamp(2.6rem, 7vw, 5.7rem);
  overflow-wrap: normal;
}

.writer-sidebar-tools {
  display: grid;
  gap: 10px;
  margin: 12px 0 16px;
  padding-bottom: 14px;
  border-bottom: 3px dotted rgba(23, 23, 23, 0.25);
}

/* Enhancements add rows dynamically, so the editor panel must not assign the
   flexible editor track to whichever child happens to be third. */
.editor-panel {
  display: flex;
  flex-direction: column;
}

.writer-editor {
  flex: 1 1 360px;
}

.secondary-toolbar {
  flex: 0 0 auto;
}

.secondary-toolbar button {
  height: auto;
  align-self: flex-start;
}

.compact-label {
  gap: 5px;
  font-size: 0.82rem;
}

.compact-label input,
.compact-label select {
  min-height: 38px;
}

.compact-button {
  width: 100%;
}

.secondary-toolbar {
  margin-top: -4px;
  padding-top: 8px;
  border-top: 2px dotted rgba(23, 23, 23, 0.22);
}

.secondary-toolbar button {
  min-height: 36px;
  font-size: 0.86rem;
}

.writer-workbench,
.text-analysis-workbench {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: #fffdf6;
  border: 2px solid var(--line);
}

.writer-stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.writer-stat-strip div {
  padding: 10px;
  background: #fff;
  border: 2px solid var(--line);
}

.writer-stat-strip strong,
.writer-stat-strip span {
  display: block;
}

.writer-stat-strip strong {
  font-size: 1.35rem;
}

.writer-stat-strip span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.writer-goal-row {
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.writer-goal-row label {
  font-size: 0.85rem;
}

.writer-goal-row input {
  min-height: 38px;
}

.goal-meter {
  height: 18px;
  overflow: hidden;
  background: #eee7d7;
  border: 2px solid var(--line);
}

.goal-meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--gold);
  transition: width 140ms ease;
}

.writer-goal-row > strong {
  padding-bottom: 2px;
  font-size: 0.86rem;
  white-space: nowrap;
}

.writer-find-panel {
  padding: 10px 12px;
  background: #f8f2e5;
  border: 2px solid var(--line);
}

.writer-find-panel summary {
  cursor: pointer;
  font-weight: 900;
}

.find-replace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.find-replace-grid input {
  min-height: 40px;
}

.writer-utility-actions,
.transform-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.inline-status {
  min-height: 1.2em;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 900;
}

.metric-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.text-analysis-workbench {
  background: transparent;
  border: 0;
  padding: 0;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.analysis-grid article,
.transform-panel {
  padding: 16px;
  background: var(--white);
  border: 2px solid var(--line);
  box-shadow: 3px 3px 0 var(--soft-shadow);
}

.analysis-grid h2,
.transform-panel h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
  text-transform: uppercase;
}

.analysis-grid p {
  margin-bottom: 0;
}

.keyword-list {
  display: grid;
  gap: 7px;
}

.keyword-list div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 5px;
  border-bottom: 1px dotted rgba(23, 23, 23, 0.3);
}

.keyword-list span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
}

.big-analysis-number {
  margin: 0 !important;
  font: 900 3rem "Courier New", monospace;
}

.analysis-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.transform-panel {
  display: grid;
  gap: 12px;
}

.counter-find-replace {
  margin-top: 2px;
  padding-top: 12px;
  border-top: 2px dotted rgba(23, 23, 23, 0.24);
}

@media (max-width: 1100px) {
  .hero {
    grid-template-columns: minmax(0, 1.18fr) minmax(260px, 0.82fr);
    gap: 28px;
  }

  .hero h1 {
    font-size: clamp(2.6rem, 6.3vw, 5rem);
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  .hero h1 {
    font-size: clamp(2.6rem, 10vw, 5.4rem);
  }

  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .writer-goal-row,
  .find-replace-grid {
    grid-template-columns: 1fr;
  }

  .writer-goal-row > strong {
    white-space: normal;
  }
}

@media (max-width: 640px) {
  .writer-stat-strip,
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .writer-utility-actions,
  .transform-actions {
    display: grid;
  }
}
