:root {
  color-scheme: light;
  --bg: #f7f3ed;
  --surface: #fffdf8;
  --text: #26211d;
  --muted: #766f67;
  --line: #ddd4c8;
  --primary: #7b4e2d;
  --primary-dark: #5f371d;
  --soft: #efe2d3;
  --warn: #6f3d30;
  --warn-bg: #f7e3dd;
  --danger: #b3261e;
  --shadow: 0 8px 20px rgba(78, 55, 35, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
  letter-spacing: 0;
}

html,
body {
  overflow-x: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.page {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 10px 28px;
}

.privacy {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
}

header {
  margin-bottom: 14px;
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 7.8vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.lead {
  margin: 0;
  color: var(--text);
  font-size: 1.08rem;
  line-height: 1.75;
  font-weight: 600;
}

main {
  display: grid;
  gap: 14px;
}

.panel {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.step {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
}

.purpose-step {
  margin-top: 14px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: 1.02rem;
  font-weight: 700;
}

textarea {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 72px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffefa;
  color: var(--text);
  outline: none;
}

textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(123, 78, 45, 0.14);
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.purpose-grid {
  display: grid;
  width: 100%;
  min-width: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.adjust-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.purpose-button,
.adjust-button {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffefa;
  color: var(--text);
  font-weight: 700;
}

.purpose-button {
  min-height: 40px;
  min-width: 0;
  padding: 6px 4px;
  font-size: 0.95rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-all;
  white-space: normal;
}

.purpose-button[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--soft);
  color: var(--primary-dark);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.actions {
  display: grid;
  gap: 10px;
}

.primary-button,
.copy-button {
  min-height: 58px;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
  font-size: 1.06rem;
  font-weight: 800;
}

.primary-button:hover,
.copy-button:hover {
  background: var(--primary-dark);
}

.copy-button {
  width: 100%;
  margin-top: 14px;
}

.status {
  min-height: 28px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.result {
  display: none;
}

.result.is-visible {
  display: block;
}

.draft {
  min-height: 180px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffefa;
  white-space: pre-wrap;
  line-height: 1.85;
}

.adjustments {
  display: none;
  margin-top: 16px;
}

.adjustments.is-visible {
  display: block;
}

.adjust-grid {
  margin-top: 10px;
}

.adjust-button {
  min-height: 46px;
  background: #fff8ef;
  font-size: 0.95rem;
}

.ad-slot {
  margin: 30px 0 16px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--muted);
}

.ad-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.76rem;
}

.ad-placeholder {
  display: grid;
  min-height: 72px;
  place-items: center;
  border: 1px solid rgba(221, 212, 200, 0.75);
  border-radius: 4px;
  background: #fbf5ee;
  color: var(--muted);
  font-size: 0.88rem;
}

.footer {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.legal-note {
  margin: 0;
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 0.86rem;
}

.copyright {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

@media (min-width: 680px) {
  .page {
    padding: 34px 16px 28px;
  }

  .panel {
    padding: 24px;
  }

  textarea {
    min-height: 168px;
  }

  .purpose-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
  }

  .purpose-button {
    min-height: 52px;
    font-size: 1rem;
  }

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