:root {
  color-scheme: light;
  --paper: #f4faf7;
  --surface: #ffffff;
  --surface-strong: #f9fbfd;
  --ink: #18201e;
  --muted: #65736f;
  --line: #d5e1dc;
  --green: #15705f;
  --green-dark: #0d4f45;
  --red: #cf4e45;
  --yellow: #f2c14e;
  --blue: #385f8d;
  --shadow: 0 22px 60px rgba(24, 32, 30, 0.12);
  --radius: 8px;
  --font-body: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  --font-data: "SFMono-Regular", Consolas, "Roboto Mono", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(21, 112, 95, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(21, 112, 95, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
  color: var(--ink);
  font-family: var(--font-body);
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

[hidden] {
  display: none !important;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(242, 193, 78, 0.95);
  outline-offset: 2px;
}

.app-shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 28px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 360px);
  gap: 24px;
  align-items: end;
  min-height: 220px;
  padding: 28px 0 24px;
}

.kicker {
  margin: 0 0 8px;
  color: var(--green-dark);
  font-family: var(--font-data);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin: 0;
  font-size: clamp(2.7rem, 8vw, 6.8rem);
  line-height: 0.92;
  font-weight: 900;
}

.lead {
  max-width: 620px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.8;
}

.ticker {
  border-left: 8px solid var(--red);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px 18px 18px 20px;
}

.ticker span {
  display: block;
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.82rem;
}

.ticker strong {
  display: block;
  margin-top: 8px;
  font-size: 1.05rem;
  line-height: 1.45;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.shared-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
  padding: 18px 20px;
  border-left: 8px solid var(--blue);
}

.shared-panel h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.shared-panel p:not(.kicker) {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.shared-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.shared-panel-actions button {
  min-height: 42px;
  border-radius: var(--radius);
  padding: 0 14px;
  font-weight: 800;
}

.shared-view .workbench {
  grid-template-columns: minmax(0, 1fr);
}

.shared-view .entry-panel,
.shared-view .library {
  display: none;
}

.shared-panel,
.entry-panel,
.result-panel,
.library,
.affiliate-box {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.entry-panel {
  display: grid;
  gap: 16px;
  padding: 22px;
  position: sticky;
  top: 16px;
}

.panel-heading h2,
.section-heading h2 {
  margin: 0;
  font-size: 1.45rem;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink);
  padding: 12px 13px;
}

textarea {
  resize: vertical;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions,
.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.ghost-button,
.share-actions button,
.item-actions button,
.affiliate-links a {
  min-height: 42px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  background: var(--green);
  color: white;
}

.ghost-button,
.share-actions button,
.item-actions button {
  background: var(--surface-strong);
  border-color: var(--line);
  color: var(--ink);
}

.result-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.card-style-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}

.card-style-picker p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.card-style-switch {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  gap: 4px;
  border: 2px solid var(--ink);
  background: var(--ink);
  padding: 4px;
}

.card-style-switch button {
  min-height: 34px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: white;
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 900;
}

.card-style-switch button[aria-pressed="true"] {
  background: var(--yellow);
  color: var(--ink);
}

.receipt-card {
  position: relative;
  overflow: hidden;
  border: 2px solid var(--ink);
  background:
    repeating-linear-gradient(0deg, rgba(56, 95, 141, 0.08), rgba(56, 95, 141, 0.08) 1px, transparent 1px, transparent 22px),
    #fffefb;
  padding: 24px;
}

.receipt-card::before {
  content: none;
}

.receipt-card::after {
  content: "実質無料";
  position: absolute;
  right: 18px;
  bottom: 18px;
  transform: rotate(-8deg);
  border: 5px solid rgba(207, 78, 69, 0.76);
  color: rgba(207, 78, 69, 0.78);
  border-radius: 50%;
  padding: 28px 18px;
  font-weight: 900;
  font-size: 1.1rem;
  pointer-events: none;
}

.receipt-card[data-style="approval"] {
  border-width: 4px;
  background:
    radial-gradient(circle at 14% 18%, rgba(242, 193, 78, 0.95) 0 56px, transparent 57px),
    repeating-linear-gradient(135deg, rgba(207, 78, 69, 0.16) 0 12px, transparent 12px 24px),
    #fff7d1;
  box-shadow: 10px 10px 0 var(--ink);
}

.receipt-card[data-style="approval"]::before {
  content: "散財承認済";
  position: absolute;
  top: 58px;
  right: -34px;
  z-index: 0;
  transform: rotate(12deg);
  border: 5px solid var(--red);
  background: rgba(255, 255, 255, 0.82);
  color: var(--red);
  padding: 12px 42px;
  font-size: clamp(1.35rem, 4vw, 2.8rem);
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}

.receipt-card[data-style="approval"]::after {
  content: "ヨシ!";
  right: 18px;
  bottom: 16px;
  transform: rotate(-9deg);
  border: 0;
  border-radius: 0;
  background: var(--red);
  color: white;
  padding: 10px 14px;
  font-size: 1.8rem;
  box-shadow: 5px 5px 0 var(--ink);
}

.receipt-card[data-style="approval"] .receipt-top,
.receipt-card[data-style="approval"] h2,
.receipt-card[data-style="approval"] .result-comment,
.receipt-card[data-style="approval"] .metrics,
.receipt-card[data-style="approval"] .free-meter {
  position: relative;
  z-index: 1;
}

.receipt-card[data-style="approval"] .receipt-top {
  border-bottom: 4px solid var(--ink);
  color: var(--ink);
}

.receipt-card[data-style="approval"] h2 {
  max-width: 74%;
  text-transform: uppercase;
}

.receipt-card[data-style="approval"] .result-comment {
  max-width: 68%;
  color: #5f2d28;
  font-weight: 800;
}

.receipt-card[data-style="approval"] .metrics div {
  border: 3px solid var(--ink);
  background: #ffffff;
  box-shadow: 4px 4px 0 rgba(24, 32, 30, 0.96);
}

.receipt-card[data-style="approval"] .meter-track {
  height: 18px;
  border-width: 3px;
  background: #ffffff;
}

.receipt-card[data-style="victory"] {
  border: 0;
  background:
    linear-gradient(110deg, transparent 0 58%, rgba(21, 112, 95, 0.22) 58% 100%),
    radial-gradient(circle at 82% 12%, rgba(242, 193, 78, 0.95) 0 70px, transparent 72px),
    #18201e;
  color: white;
  box-shadow: 0 18px 0 #f2c14e, 0 28px 34px rgba(24, 32, 30, 0.25);
}

.receipt-card[data-style="victory"]::before {
  content: "買った自分、優勝";
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 18px;
  color: rgba(255, 255, 255, 0.1);
  font-size: clamp(2.6rem, 8vw, 6.5rem);
  font-weight: 900;
  line-height: 0.9;
  pointer-events: none;
}

.receipt-card[data-style="victory"]::after {
  content: "優勝";
  top: 22px;
  right: 20px;
  z-index: 2;
  bottom: auto;
  transform: rotate(6deg);
  border: 4px solid #f2c14e;
  border-radius: 4px;
  background: #18201e;
  color: #f2c14e;
  padding: 9px 13px;
  font-size: 1.35rem;
  box-shadow: 0 0 0 4px rgba(24, 32, 30, 0.9);
}

.receipt-card[data-style="victory"] .receipt-top,
.receipt-card[data-style="victory"] h2,
.receipt-card[data-style="victory"] .result-comment,
.receipt-card[data-style="victory"] .metrics,
.receipt-card[data-style="victory"] .free-meter {
  position: relative;
  z-index: 1;
}

.receipt-card[data-style="victory"] .receipt-top {
  border-bottom-color: rgba(255, 255, 255, 0.46);
  color: #f2c14e;
}

.receipt-card[data-style="victory"] h2 {
  max-width: 74%;
  color: white;
}

.receipt-card[data-style="victory"] .result-comment {
  max-width: 68%;
  color: #ffe8a6;
  font-weight: 800;
}

.receipt-card[data-style="victory"] .metrics div {
  border: 2px solid rgba(242, 193, 78, 0.95);
  background: rgba(255, 255, 255, 0.08);
}

.receipt-card[data-style="victory"] .metrics dt,
.receipt-card[data-style="victory"] .free-meter p {
  color: #ffe8a6;
}

.receipt-card[data-style="victory"] .metrics dd {
  color: white;
}

.receipt-card[data-style="victory"] .meter-track {
  border-color: #f2c14e;
  background: rgba(255, 255, 255, 0.16);
}

.receipt-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px dashed var(--ink);
  padding-bottom: 12px;
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.82rem;
}

.receipt-top p {
  margin: 0;
  font-weight: 800;
}

.receipt-card h2 {
  margin: 22px 0 8px;
  max-width: 80%;
  font-size: clamp(1.6rem, 4vw, 3.3rem);
  line-height: 1.08;
}

.result-comment {
  max-width: 72%;
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 24px 0 20px;
}

.metrics div {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  padding: 14px;
  min-width: 0;
}

.metrics dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.metrics dd {
  margin: 6px 0 0;
  font-family: var(--font-data);
  font-size: clamp(1.25rem, 3vw, 2rem);
  font-weight: 900;
  white-space: nowrap;
}

.free-meter {
  max-width: 70%;
}

.meter-track {
  height: 13px;
  border: 1px solid var(--ink);
  background: white;
}

.meter-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--yellow), var(--green));
  transition: width 240ms ease;
}

.free-meter p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.share-actions button {
  flex: 1 1 138px;
}

.share-actions .x-post-button {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
}

.share-note {
  margin: -4px 2px 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.65;
}

.affiliate-box {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(240px, 1.2fr);
  gap: 16px;
  align-items: center;
  padding: 16px;
  box-shadow: none;
}

.ad-label {
  display: inline-block;
  margin: 0 0 8px;
  background: #18201e;
  color: white;
  font-size: 0.72rem;
  font-weight: 900;
  padding: 4px 7px;
}

.affiliate-box h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.affiliate-box p:not(.ad-label) {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.affiliate-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.affiliate-links a {
  display: inline-flex;
  align-items: center;
  border-color: var(--green);
  color: var(--green-dark);
  background: #effaf6;
  text-decoration: none;
}

.library {
  margin-top: 22px;
  padding: 22px;
}

.items-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.item-card {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  padding: 14px;
}

.item-card.is-active {
  border-color: var(--green);
  box-shadow: inset 0 0 0 2px rgba(21, 112, 95, 0.22);
}

.item-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.item-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.86rem;
}

.item-actions {
  display: flex;
  gap: 8px;
}

.item-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.empty-state {
  border: 1px dashed var(--line);
  color: var(--muted);
  padding: 18px;
  line-height: 1.7;
}

.site-footer {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.7;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 36px));
  background: var(--ink);
  color: white;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-weight: 800;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 900px) {
  .hero,
  .workbench,
  .shared-panel,
  .affiliate-box {
    grid-template-columns: 1fr;
  }

  .entry-panel {
    position: static;
  }

  .shared-panel-actions,
  .affiliate-links {
    justify-content: flex-start;
  }

  .items-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .receipt-card h2,
  .result-comment,
  .free-meter {
    max-width: 100%;
  }

  .receipt-card[data-style="approval"] h2,
  .receipt-card[data-style="approval"] .result-comment,
  .receipt-card[data-style="victory"] h2,
  .receipt-card[data-style="victory"] .result-comment {
    max-width: 100%;
  }

  .receipt-card::after {
    opacity: 0.26;
  }

  .receipt-card[data-style="approval"]::before {
    opacity: 0.18;
  }

  .receipt-card[data-style="victory"]::before {
    opacity: 0.7;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 22px, 1160px);
    padding-top: 18px;
  }

  .hero {
    min-height: 0;
    padding-top: 12px;
  }

  .field-grid,
  .metrics,
  .items-list {
    grid-template-columns: 1fr;
  }

  .receipt-card {
    padding: 18px;
  }

  .card-style-picker {
    display: grid;
  }

  .card-style-switch {
    width: 100%;
  }

  .card-style-switch button {
    flex: 1 1 0;
    padding: 0 8px;
  }

  .receipt-top {
    display: grid;
  }

  .metrics dd {
    white-space: normal;
  }
}

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