:root {
  --aw-blue: #075cff;
  --aw-blue-dark: #0646c8;
  --aw-ink: #111827;
  --aw-muted: #6b7280;
  --aw-line: #dfe5ef;
  --aw-soft: #f4f7fb;
  --aw-panel: #ffffff;
  --aw-mint: #12b886;
  --aw-coral: #ff7a59;
  --shadow: 0 20px 60px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--aw-soft);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--aw-ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 16px;
  letter-spacing: 0;
  background:
    linear-gradient(180deg, rgba(7, 92, 255, 0.06), rgba(255, 255, 255, 0) 360px),
    var(--aw-soft);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: var(--aw-blue);
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(7, 92, 255, 0.28);
}

.brand strong,
.brand span span {
  display: block;
}

.brand strong {
  font-size: 1rem;
  line-height: 1.1;
}

.brand span span {
  margin-top: 2px;
  color: var(--aw-muted);
  font-size: 0.875rem;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--aw-line);
  border-radius: 10px;
  color: var(--aw-muted);
  background: #fff;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(350px, 0.78fr) minmax(0, 1.22fr);
  gap: 28px;
  align-items: start;
  min-height: calc(100vh - 155px);
}

.generator-panel {
  border: 1px solid var(--aw-line);
  border-radius: 8px;
  background: var(--aw-panel);
  box-shadow: var(--shadow);
}

.generator-panel.is-premium > [data-aw-usage-meter] {
  display: none;
}

.section-heading,
.topic-form,
.quota,
.generator-panel > [data-aw-usage-meter] {
  padding-inline: 28px;
}

.section-heading {
  padding-top: 28px;
  padding-bottom: 8px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--aw-muted);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  margin-bottom: 0;
  line-height: 1.08;
}

h1 {
  font-size: 2.5rem;
  letter-spacing: 0;
}

h2 {
  font-size: 2.25rem;
}

.topic-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 16px;
  padding-top: 14px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

.field span {
  color: var(--aw-ink);
  font-size: 0.9375rem;
  font-weight: 750;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--aw-line);
  border-radius: 12px;
  color: var(--aw-ink);
  background: #fff;
  padding: 12px 14px;
  outline: none;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.field textarea {
  resize: vertical;
}

.optional-fields {
  grid-column: 1 / -1;
  border-top: 1px solid var(--aw-line);
  border-bottom: 1px solid var(--aw-line);
}

.optional-fields summary {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--aw-ink);
  font-weight: 750;
  cursor: pointer;
  list-style: none;
  transition: background-color 150ms ease;
}

.optional-fields summary:hover {
  background: #f8faff;
}

.optional-fields summary::-webkit-details-marker {
  display: none;
}

.optional-fields summary::after {
  width: 9px;
  height: 9px;
  margin-left: auto;
  border-right: 2px solid var(--aw-blue);
  border-bottom: 2px solid var(--aw-blue);
  content: "";
  transform: rotate(45deg) translateY(-2px);
  transition: transform 150ms ease;
}

.optional-fields[open] summary::after {
  transform: rotate(225deg) translate(-2px, -2px);
}

.optional-summary-copy {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 8px;
}

.optional-summary-copy strong {
  font: inherit;
}

.optional-summary-copy small {
  color: var(--aw-muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.optional-fields-grid {
  display: grid;
  gap: 14px;
  padding: 4px 0 18px;
}

.field select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--aw-muted) 50%),
    linear-gradient(135deg, var(--aw-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) 21px,
    calc(100% - 15px) 21px;
  background-repeat: no-repeat;
  background-size: 5px 5px;
  padding-right: 42px;
  cursor: pointer;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--aw-blue);
  box-shadow: 0 0 0 4px rgba(7, 92, 255, 0.14);
}

.field input::placeholder,
.field textarea::placeholder {
  color: #8a9099;
}

.form-actions {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 4px;
}

.form-actions:has(.form-hint[hidden]) {
  justify-content: flex-end;
}

.form-hint {
  margin: 0;
  color: var(--aw-muted);
  font-size: 0.9375rem;
  line-height: 1.45;
}

.primary-button,
.secondary-button,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 12px;
  border: 0;
  font-weight: 800;
  line-height: 1;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.primary-button {
  min-height: 52px;
  padding: 0 20px;
  color: #fff;
  background: var(--aw-blue);
  box-shadow: 0 16px 28px rgba(7, 92, 255, 0.25);
  white-space: nowrap;
}

.secondary-button {
  min-height: 50px;
  padding: 0 18px;
  color: var(--aw-blue);
  background: #eef4ff;
  border: 1px solid rgba(7, 92, 255, 0.18);
}

.copy-button {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  width: 42px;
  height: 42px;
  color: var(--aw-muted);
  background: #f8fafc;
  border: 1px solid var(--aw-line);
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.copy-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary-button:hover:not(:disabled) {
  background: var(--aw-blue-dark);
  box-shadow: 0 18px 34px rgba(7, 92, 255, 0.32);
}

.primary-button:disabled,
.secondary-button:disabled {
  color: #8d96a5;
  background: #edf0f4;
  box-shadow: none;
}

.primary-button svg,
.secondary-button svg,
.copy-button svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
  flex: 0 0 auto;
}

.quota {
  margin-top: 24px;
  padding-top: 18px;
  padding-bottom: 24px;
  border-top: 1px solid var(--aw-line);
}

.quota-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--aw-muted);
}

.quota-line strong {
  color: var(--aw-ink);
  font-size: 1.125rem;
}

.progress-track {
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf0f4;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--aw-blue), var(--aw-mint));
  transition: width 220ms ease;
}

.results-area {
  min-width: 0;
}

.results-heading {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) auto minmax(110px, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 42px;
  margin-bottom: 10px;
}

.results-heading h2 {
  grid-column: 2;
  font-size: 1.4rem;
  text-align: center;
}

.proposal-nav-button {
  min-height: 38px;
  border: 0;
  padding: 0;
  color: var(--aw-blue);
  background: transparent;
  font-weight: 750;
}

.proposal-nav-button:first-child {
  justify-self: start;
}

.proposal-nav-button:last-child {
  justify-self: end;
}

.empty-state {
  display: grid;
  gap: 8px;
  min-height: 180px;
  align-content: center;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 24px;
  color: var(--aw-muted);
  background: rgba(255, 255, 255, 0.62);
}

.empty-state p {
  margin: 0;
  color: var(--aw-ink);
  font-size: 1.125rem;
  font-weight: 800;
}

.empty-state span {
  line-height: 1.5;
}

.result-list {
  display: block;
}

.topic-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--aw-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(17, 24, 39, 0.07);
}

.topic-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  content: "";
  background: var(--accent, var(--aw-blue));
}

.topic-card-inner {
  padding: 16px 18px 6px 22px;
}

.topic-card-top {
  height: 0;
  margin: 0;
}

.topic-card h3 {
  margin: 0 0 6px;
  padding-right: 46px;
  font-size: 1.1rem;
  line-height: 1.3;
}

.topic-title-label {
  color: var(--aw-blue);
}

.topic-description {
  margin: 0 0 10px;
  color: var(--aw-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.free-result {
  display: grid;
  gap: 4px;
  margin: 14px 0 10px;
}

.free-result > span {
  color: var(--aw-muted);
  font-size: 0.8125rem;
  font-weight: 800;
  text-transform: uppercase;
}

.free-result p {
  margin: 0;
  color: #273244;
  font-size: 0.9rem;
  line-height: 1.4;
}

.topic-scores {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 0 7px;
  border-top: 1px solid var(--aw-line);
  border-bottom: 1px solid var(--aw-line);
}

.score-item {
  display: grid;
  min-width: 0;
  justify-items: center;
  gap: 1px;
  text-align: center;
}

.score-ring {
  --ring-color: #d64848;
  position: relative;
  display: grid;
  width: 43px;
  height: 43px;
  margin-bottom: 2px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--ring-color) calc(var(--score) * 1%), #e5eaf2 0);
}

.score-ring::before {
  position: absolute;
  inset: 4px;
  border-radius: inherit;
  background: #fff;
  content: "";
}

.score-ring.is-medium {
  --ring-color: #d88916;
}

.score-ring.is-good {
  --ring-color: #45a56b;
}

.score-ring.is-very-good {
  --ring-color: #13865a;
}

.score-ring strong {
  position: relative;
  z-index: 1;
  color: var(--aw-ink);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.score-ring strong span {
  color: inherit;
  font-size: 0.62rem;
}

.score-item > span {
  color: var(--aw-muted);
  font-size: 0.68rem;
  line-height: 1.2;
}

.score-item small {
  color: var(--aw-ink);
  font-size: 0.67rem;
  font-weight: 800;
}

.topic-premium {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--aw-line);
}

.topic-premium-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.topic-premium-heading strong {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--aw-ink);
}

.premium-title-badge {
  display: inline-flex;
  min-height: 20px;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(7, 92, 255, 0.2);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--aw-blue);
  background: #eef4ff;
  font-size: 0.65rem;
  font-weight: 800;
}

.premium-title-badge svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
}

.premium-title-badge.is-active {
  border-color: rgba(18, 184, 134, 0.24);
  color: #08775b;
  background: #eaf9f4;
}

.premium-state {
  display: block;
  margin-top: 2px;
  color: var(--aw-blue);
  font-size: 0.75rem;
  font-weight: 700;
}

.premium-intro {
  display: block;
  max-width: 440px;
  margin-top: 3px;
  color: var(--aw-muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.premium-detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  column-gap: 18px;
}

.premium-detail {
  position: relative;
  min-width: 0;
  min-height: 47px;
  padding: 5px 0 6px;
  overflow: hidden;
  border-top: 1px solid #edf0f4;
}

.premium-detail dt {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  color: var(--aw-ink);
  font-size: 0.74rem;
  font-weight: 800;
}

.premium-detail dt svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  fill: var(--aw-blue);
}

.premium-detail dd {
  margin: 0;
  color: #4f5e73;
  font-size: 0.71rem;
  line-height: 1.35;
}

.premium-preview {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.premium-preview-blur {
  display: inline;
  filter: blur(4px);
  opacity: 0.82;
  user-select: none;
}

.blur-lines {
  position: absolute;
  right: 0;
  bottom: 3px;
  display: block;
  width: 42%;
  margin: 0;
  filter: blur(3px);
  opacity: 0.72;
}

.blur-lines i {
  display: block;
  width: 100%;
  height: 3px;
  border-radius: 4px;
  background: #cfd8e6;
}

.blur-lines i:last-child {
  display: none;
}

.topic-premium-cta {
  display: grid;
  max-width: 225px;
  gap: 3px;
  text-align: center;
}

.topic-premium-cta a {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 14px;
  color: #fff;
  background: var(--aw-blue);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.topic-premium-cta small {
  color: var(--aw-muted);
  font-size: 0.66rem;
  line-height: 1.25;
}

@media (min-width: 901px) and (max-height: 850px) {
  .free-result {
    margin-top: 8px;
  }

  .premium-intro {
    display: none;
  }

  .premium-detail {
    min-height: 30px;
    padding: 2px 0 3px;
  }

  .premium-detail dt {
    margin-bottom: 0;
    font-size: 0.72rem;
  }

  .premium-detail dd {
    font-size: 0.69rem;
    line-height: 1.25;
  }

  .premium-preview {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.result-actions {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(320px, calc(100vw - 44px));
  border-radius: 12px;
  padding: 12px 14px;
  color: #fff;
  background: #111827;
  box-shadow: 0 16px 40px rgba(17, 24, 39, 0.24);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

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

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 24px, 1180px);
    padding-top: 16px;
  }

  .topic-form {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2.25rem;
  }

  h2 {
    font-size: 1.7rem;
  }

  .section-heading,
  .topic-form,
  .quota,
  .generator-panel > [data-aw-usage-meter] {
    padding-inline: 18px;
  }

  .section-heading {
    padding-top: 20px;
  }

  .form-actions {
    display: grid;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .results-heading {
    grid-template-columns: minmax(82px, 1fr) auto minmax(82px, 1fr);
    align-items: center;
  }

  .topic-card-top {
    align-items: center;
  }

  .premium-detail-list {
    grid-template-columns: 1fr;
  }

  .topic-premium-heading {
    display: grid;
  }

  .topic-premium-cta {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

@media (min-width: 980px) and (min-height: 680px) {
  .app-shell {
    height: calc(100vh - 115px);
    padding-top: 14px;
    padding-bottom: 0;
  }

  .topbar {
    margin-bottom: 14px;
  }

  .workspace {
    gap: 20px;
    min-height: 0;
  }

  .generator-panel {
    position: sticky;
    top: 132px;
    max-height: none;
    overflow: visible;
  }

  .section-heading,
  .topic-form,
  .quota,
  .generator-panel > [data-aw-usage-meter] {
    padding-inline: 22px;
  }

  .section-heading {
    padding-top: 17px;
    padding-bottom: 2px;
  }

  h1 {
    font-size: 2rem;
  }

  .topic-form {
    gap: 9px 12px;
    padding-top: 8px;
  }

  .topic-form > .aw-free-signup {
    margin-bottom: 0;
    padding: 7px 0 9px;
    font-size: 12px;
  }

  .field {
    gap: 5px;
  }

  .field span {
    font-size: 0.84rem;
  }

  .field input,
  .field select,
  .field textarea {
    min-height: 38px;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 0.88rem;
  }

  #ideas {
    height: 70px;
    min-height: 70px;
  }

  .field textarea:not(#ideas) {
    min-height: 54px;
  }

  .optional-fields summary {
    min-height: 39px;
    font-size: 0.86rem;
  }

  .form-actions {
    padding-top: 0;
  }

  .form-actions .primary-button {
    min-height: 42px;
    border-radius: 8px;
  }

  .generator-panel > [data-aw-usage-meter] .aw-free-usage-note {
    margin-top: 12px;
    padding-top: 10px;
    padding-bottom: 13px;
  }

  .copy-button {
    width: 34px;
    height: 34px;
    border-radius: 8px;
  }

  .secondary-button {
    min-height: 40px;
    border-radius: 8px;
  }

  .result-actions {
    display: none;
  }

  html.topic-refinement-open,
  html.topic-refinement-open body {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
  }

  html.topic-refinement-open .app-shell {
    height: auto;
    min-height: calc(100vh - 115px);
    overflow: visible;
  }
}
