:root {
  color-scheme: light;
  --ink: #132b40;
  --ink-soft: #506273;
  --paper: #fffdf8;
  --paper-deep: #f4eee2;
  --wash: #edf2f1;
  --line: #d8dedb;
  --navy: #163b59;
  --navy-deep: #0d2a42;
  --gold: #bd9251;
  --gold-pale: #f5ead6;
  --danger: #a43e3e;
  --shadow: 0 18px 50px rgba(17, 44, 65, 0.09);
  --serif: "Iowan Old Style", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --sans: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 6%, rgba(189, 146, 81, 0.08), transparent 30rem),
    linear-gradient(180deg, #f7f6f0 0%, var(--paper) 38rem, #f7f8f5 100%);
  font-family: var(--sans);
  line-height: 1.75;
  overflow-x: hidden;
}

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

button,
select,
input[type="radio"] {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(189, 146, 81, 0.6);
  outline-offset: 3px;
}

.shell {
  width: min(1120px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  width: min(1120px, calc(100% - 40px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  color: var(--navy-deep);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 29px;
  height: 24px;
  color: var(--paper);
  background: var(--navy);
  border-radius: 3px 3px 9px 3px;
  box-shadow: 4px 4px 0 var(--gold);
  font-family: var(--serif);
  font-size: 0.9rem;
  line-height: 1;
}

.brand-mark.small {
  width: 23px;
  height: 19px;
  font-size: 0.75rem;
  box-shadow: 3px 3px 0 var(--gold);
}

.header-note {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.hero {
  min-height: 465px;
  padding: 72px 0 76px;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(280px, 0.92fr);
  align-items: center;
  gap: clamp(30px, 7vw, 100px);
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

h1,
h2,
h3,
h4,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3,
h4 {
  margin-top: 0;
  color: var(--navy-deep);
  font-family: var(--serif);
  line-height: 1.35;
}

h1 {
  max-width: 650px;
  margin-bottom: 20px;
  font-size: clamp(2.25rem, 5vw, 4.6rem);
  font-weight: 500;
  letter-spacing: 0.04em;
}

h1 em {
  color: var(--navy);
  font-style: normal;
  text-decoration: underline;
  text-decoration-color: rgba(189, 146, 81, 0.56);
  text-decoration-thickness: 0.14em;
  text-underline-offset: 0.14em;
}

.hero-lead {
  max-width: 600px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.02rem;
}

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 28px;
}

.hero-chips span {
  padding: 5px 12px;
  color: var(--navy);
  border: 1px solid rgba(22, 59, 89, 0.16);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.66);
  font-size: 0.78rem;
}

.hero-art {
  position: relative;
  min-height: 330px;
  isolation: isolate;
  border-radius: 3px 52px 3px 52px;
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.64), rgba(229, 235, 231, 0.52)),
    url('/assets/hero-stationery.webp') center / cover no-repeat;
  box-shadow: 18px 18px 0 rgba(189, 146, 81, 0.2), var(--shadow);
  overflow: hidden;
}

.hero-art::before {
  content: "";
  position: absolute;
  inset: 24px;
  z-index: -1;
  border: 1px solid rgba(22, 59, 89, 0.2);
  border-radius: 2px 35px 2px 35px;
  background: rgba(255, 253, 248, 0.48);
}

.hero-art::after {
  content: "";
  position: absolute;
  width: 68%;
  height: 55%;
  right: 11%;
  bottom: 13%;
  z-index: -1;
  border: 1px solid rgba(22, 59, 89, 0.2);
  background: rgba(255, 253, 248, 0.75);
  box-shadow: -20px 20px 0 rgba(22, 59, 89, 0.08);
  transform: rotate(-5deg);
}

.workspace,
.results,
.save-area,
.guide {
  padding-top: 74px;
  padding-bottom: 74px;
}

.section-intro {
  max-width: 700px;
  margin-bottom: 30px;
}

.section-intro h2 {
  margin-bottom: 10px;
  font-size: clamp(1.8rem, 3.4vw, 2.7rem);
  font-weight: 500;
}

.section-intro > p:last-child {
  margin: 0;
  color: var(--ink-soft);
}

.letter-form {
  padding: clamp(20px, 4vw, 45px);
  border: 1px solid rgba(22, 59, 89, 0.1);
  border-radius: 3px 34px 3px 34px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.choice-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
  margin-bottom: 34px;
}

.choice-block {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice-label,
.tone-choice legend {
  display: block;
  padding: 0;
  color: var(--navy-deep);
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 700;
}

select,
input[type="text"],
textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 13px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
  font-size: 16px;
}

select {
  margin-top: 8px;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

select.has-error,
input.has-error,
textarea.has-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(164, 62, 62, 0.1);
}

.choice-help,
.field-help {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 0.75rem;
  line-height: 1.55;
}

.tone-choice {
  min-width: 0;
}

.tone-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.tone-option {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
  color: var(--navy);
  font-size: 0.9rem;
}

.tone-option:has(input:checked) {
  border-color: var(--navy);
  background: #eef3f4;
}

.tone-option input {
  accent-color: var(--gold);
}

.insert-panel {
  padding: 22px;
  border: 1px solid rgba(189, 146, 81, 0.34);
  border-radius: 2px 20px 2px 20px;
  background: linear-gradient(135deg, rgba(245, 234, 214, 0.45), rgba(255, 253, 248, 0.66));
}

.insert-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 19px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(189, 146, 81, 0.24);
}

.insert-heading .eyebrow {
  margin-bottom: 4px;
}

.insert-heading h3 {
  margin: 0;
  font-size: 1.35rem;
}

.insert-tip {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.75rem;
  text-align: right;
}

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

.field:first-child {
  grid-column: 1 / -1;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.field-label {
  color: var(--navy-deep);
  font-family: var(--serif);
  font-weight: 700;
}

.required-mark {
  padding: 1px 7px;
  color: var(--danger);
  border: 1px solid rgba(164, 62, 62, 0.26);
  border-radius: 999px;
  font-size: 0.68rem;
}

.field.has-error input,
.field.has-error textarea {
  border-color: var(--danger);
  background: #fff8f6;
}

.field-error {
  min-height: 1.45em;
  margin: 5px 0 0;
  color: var(--danger);
  font-size: 0.76rem;
  line-height: 1.45;
}

.status {
  min-height: 1.7em;
  margin-top: 18px;
  color: var(--ink-soft);
  font-size: 0.83rem;
}

.status[data-kind="error"] {
  color: var(--danger);
}

.status[data-kind="success"] {
  color: #2b6b52;
}

.form-actions,
.result-actions,
.save-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.form-actions {
  margin-top: 4px;
}

.button {
  min-height: 46px;
  padding: 9px 17px;
  border: 1px solid transparent;
  border-radius: 2px;
  font-size: 0.87rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  color: var(--paper);
  background: var(--navy);
  box-shadow: 4px 4px 0 rgba(189, 146, 81, 0.45);
}

.button-primary:hover {
  background: var(--navy-deep);
}

.button-secondary {
  color: var(--navy);
  border-color: rgba(22, 59, 89, 0.34);
  background: transparent;
}

.button-secondary:hover {
  background: #eef3f4;
}

.button-quiet {
  color: var(--ink-soft);
  border-color: var(--line);
  background: transparent;
}

.button-quiet:hover {
  background: rgba(216, 222, 219, 0.32);
}

.button-danger {
  color: var(--danger);
  border-color: rgba(164, 62, 62, 0.32);
  background: transparent;
}

.results {
  padding-top: 84px;
  border-top: 1px solid rgba(22, 59, 89, 0.09);
}

.primary-result {
  position: relative;
  margin-bottom: 54px;
  padding: 37px clamp(22px, 5vw, 58px) 32px;
  border: 1px solid rgba(22, 59, 89, 0.16);
  border-radius: 3px 36px 3px 36px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.result-ribbon {
  position: absolute;
  top: -14px;
  left: 30px;
  padding: 3px 13px;
  color: var(--paper);
  background: var(--gold);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
}

.preview-block + .preview-block {
  margin-top: 26px;
}

.preview-block h3,
.comparison-card h4 {
  margin-bottom: 7px;
  color: var(--gold);
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
}

.subject-preview {
  margin: 0;
  color: var(--navy-deep);
  font-family: var(--serif);
  font-size: clamp(1.06rem, 2.2vw, 1.35rem);
  font-weight: 700;
}

.body-preview,
.comparison-body {
  margin: 0;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 2;
}

.result-actions {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.comparison-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.comparison-heading h3 {
  margin: 0;
  font-size: 1.45rem;
}

.comparison-heading > p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

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

.comparison-card {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 2px 21px 2px 21px;
  background: rgba(255, 253, 248, 0.76);
}

.comparison-card.is-selected {
  border-color: rgba(189, 146, 81, 0.75);
  box-shadow: inset 0 0 0 2px rgba(189, 146, 81, 0.12);
}

.comparison-card h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 19px;
  font-size: 1.25rem;
}

.tone-badge {
  padding: 2px 8px;
  color: var(--gold);
  border: 1px solid rgba(189, 146, 81, 0.38);
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
}

.comparison-subject {
  margin: 0 0 19px;
  color: var(--navy);
  font-size: 0.91rem;
  font-weight: 700;
}

.comparison-body {
  font-size: 0.9rem;
  line-height: 1.85;
}

.save-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 0.88fr);
  gap: 45px;
  align-items: center;
  border-top: 1px solid rgba(22, 59, 89, 0.09);
}

.save-copy h2,
.guide h2 {
  margin-bottom: 9px;
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  font-weight: 500;
}

.save-copy p:last-child {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.save-actions {
  padding: 20px;
  border: 1px solid rgba(22, 59, 89, 0.12);
  border-radius: 3px 22px 3px 22px;
  background: rgba(237, 242, 241, 0.58);
}

.save-actions .status {
  flex-basis: 100%;
  margin-top: 4px;
}

.guide {
  border-top: 1px solid rgba(22, 59, 89, 0.09);
}

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

.guide-grid {
  margin-bottom: 48px;
}

.guide-grid article,
.promise-grid article {
  min-width: 0;
  padding: 22px;
  border-top: 2px solid var(--gold);
  background: rgba(255, 253, 248, 0.58);
}

.guide-number {
  color: var(--gold);
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
}

.guide-grid h3,
.promise-grid h3 {
  margin: 9px 0 8px;
  font-size: 1.15rem;
}

.guide-grid p,
.promise-grid p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
  line-height: 1.75;
}

.promise-grid article {
  border-top-color: rgba(22, 59, 89, 0.22);
  background: transparent;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 25px;
  padding-top: 25px;
  padding-bottom: 34px;
  border-top: 1px solid rgba(22, 59, 89, 0.12);
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 760px) {
  .shell,
  .site-header {
    width: min(100% - 28px, 620px);
  }

  .site-header {
    min-height: 62px;
  }

  .header-note {
    display: none;
  }

  .hero {
    min-height: 0;
    padding-top: 42px;
    padding-bottom: 50px;
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .hero-art {
    min-height: 190px;
    order: -1;
  }

  h1 {
    font-size: clamp(2.15rem, 11vw, 3.6rem);
  }

  .workspace,
  .results,
  .save-area,
  .guide {
    padding-top: 53px;
    padding-bottom: 53px;
  }

  .choice-row,
  .fields,
  .comparison-cards,
  .save-area,
  .guide-grid,
  .promise-grid {
    grid-template-columns: 1fr;
  }

  .field:first-child {
    grid-column: auto;
  }

  .insert-panel {
    padding: 17px;
  }

  .insert-heading,
  .comparison-heading,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .insert-tip,
  .comparison-heading > p {
    text-align: left;
  }

  .save-area {
    gap: 24px;
  }

  .save-actions {
    min-width: 0;
  }
}

@media (max-width: 360px) {
  .shell,
  .site-header {
    width: calc(100% - 20px);
  }

  .hero {
    padding-top: 31px;
  }

  .hero-art {
    min-height: 155px;
  }

  .letter-form,
  .primary-result {
    padding-right: 15px;
    padding-left: 15px;
  }

  .tone-options {
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }

  .form-actions,
  .result-actions,
  .save-actions {
    align-items: stretch;
  }
}

@media print {
  body {
    background: #fff;
  }

  .site-header,
  .hero,
  .workspace,
  .save-area,
  .guide,
  .site-footer,
  .comparison-heading,
  .comparison-cards,
  .result-actions,
  .result-ribbon,
  .result-intro {
    display: none !important;
  }

  .results,
  .primary-result {
    display: block !important;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .status {
    display: none;
  }
}
