:root {
  color-scheme: light;
  --bg: #f7f9f8;
  --panel: #ffffff;
  --ink: #17201d;
  --muted: #5b6964;
  --line: #dbe4df;
  --teal: #127c73;
  --teal-deep: #0b514b;
  --coral: #d85b47;
  --gold: #b6811f;
  --mint: #dff3ed;
  --shadow: 0 18px 45px rgba(18, 42, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Hiragino Sans", "Yu Gothic", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  line-height: 1.6;
}

a {
  color: var(--teal-deep);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

button,
input,
select {
  font: inherit;
}

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

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding: 12px 0 24px;
}

.eyebrow,
.label {
  margin: 0;
  color: var(--teal-deep);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.18;
}

h1 {
  max-width: 760px;
  margin-top: 6px;
  font-size: clamp(2rem, 5vw, 3.7rem);
  word-break: keep-all;
  text-wrap: balance;
}

h2 {
  font-size: 1.12rem;
}

.lead {
  max-width: 680px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.source-badge {
  display: grid;
  gap: 6px;
  justify-items: end;
  min-width: 180px;
  color: var(--muted);
  font-size: 0.9rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.98fr) minmax(320px, 1.02fr);
  gap: 18px;
  align-items: stretch;
}

.control-panel,
.result-panel,
.tabs-section,
.affiliate-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 20px;
}

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

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

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(18, 124, 115, 0.16);
}

.input-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.input-unit input {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.input-unit b {
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
}

.assumption-line {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.result-panel {
  position: relative;
  overflow: hidden;
  display: grid;
  align-content: space-between;
  gap: 18px;
  min-height: 300px;
  padding: 24px;
}

.result-panel::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 9px;
  background: linear-gradient(90deg, var(--teal), var(--coral), var(--gold));
}

.result-visual {
  position: absolute;
  top: 20px;
  right: 22px;
  width: 150px;
  height: 120px;
  opacity: 0.9;
}

.photo-stack {
  position: absolute;
  top: 12px;
  left: 6px;
  width: 86px;
  height: 72px;
}

.photo-stack span {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(11, 81, 75, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(216, 91, 71, 0.18), rgba(18, 124, 115, 0.16)),
    linear-gradient(150deg, transparent 58%, rgba(18, 124, 115, 0.34) 59% 76%, transparent 77%);
}

.photo-stack span:nth-child(1) {
  transform: translate(18px, 18px);
}

.photo-stack span:nth-child(2) {
  transform: translate(9px, 9px);
}

.storage-orbit {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 72px;
  height: 72px;
  border: 1px solid rgba(216, 91, 71, 0.35);
  border-radius: 50%;
}

.storage-orbit div {
  width: 34px;
  height: 34px;
  margin: 18px auto;
  border-radius: 8px;
  background: var(--mint);
  border: 1px solid rgba(11, 81, 75, 0.16);
}

.headline-result {
  position: relative;
  z-index: 1;
  margin: 4px 0 0;
  max-width: 440px;
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 800;
  line-height: 1.12;
}

.sub-result {
  margin: 10px 0 0;
  color: var(--muted);
}

.meter {
  position: relative;
  z-index: 1;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2ef;
}

.meter div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--coral));
  transition: width 180ms ease;
}

.metric-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric-row div {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.metric-row span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.metric-row strong {
  display: block;
  margin-top: 5px;
  font-size: 1.1rem;
  line-height: 1.25;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.tabs-section,
.affiliate-section {
  margin-top: 18px;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 10px;
}

.tab-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

.tab-button.active {
  border-color: rgba(18, 124, 115, 0.22);
  background: var(--mint);
  color: var(--teal-deep);
}

.tab-panel {
  display: none;
  padding: 18px;
}

.tab-panel.active {
  display: block;
}

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

.insight-grid article {
  border-left: 4px solid var(--teal);
  padding: 4px 0 4px 16px;
}

ul {
  margin: 12px 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
}

li + li {
  margin-top: 8px;
}

.cost-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
}

.comparison-table-wrap {
  overflow-x: auto;
}

.comparison-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

.comparison-table th,
.comparison-table td {
  border-bottom: 1px solid var(--line);
  padding: 13px 12px;
  text-align: left;
  vertical-align: top;
}

.comparison-table th {
  color: var(--muted);
  font-size: 0.78rem;
}

.comparison-table strong {
  font-size: 1.05rem;
}

.cost-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 16px;
}

.cost-note p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  padding: 18px 18px 0;
}

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

.affiliate-card {
  display: grid;
  gap: 10px;
  min-height: 172px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 16px;
}

.affiliate-card .slot-art {
  width: 100%;
  height: 38px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(18, 124, 115, 0.2), rgba(216, 91, 71, 0.16)),
    repeating-linear-gradient(90deg, rgba(23, 32, 29, 0.06) 0 1px, transparent 1px 13px);
}

.affiliate-card h3 {
  margin: 0;
  font-size: 1rem;
}

.affiliate-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.affiliate-card a {
  align-self: end;
  font-weight: 700;
}

@media (max-width: 860px) {
  .topbar,
  .workspace,
  .insight-grid,
  .cost-layout,
  .affiliate-grid {
    grid-template-columns: 1fr;
  }

  .source-badge {
    justify-items: start;
  }

  .result-visual {
    opacity: 0.35;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1160px);
    padding-top: 16px;
  }

  .field-grid,
  .metric-row {
    grid-template-columns: 1fr;
  }

  .tabs {
    display: grid;
    grid-template-columns: 1fr;
  }

  .headline-result {
    padding-right: 58px;
  }

  .comparison-table {
    min-width: 0;
  }

  .comparison-table thead {
    display: none;
  }

  .comparison-table,
  .comparison-table tbody,
  .comparison-table tr,
  .comparison-table td {
    display: block;
    width: 100%;
  }

  .comparison-table tr {
    border-bottom: 1px solid var(--line);
    padding: 12px 0;
  }

  .comparison-table td {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 10px;
    border-bottom: 0;
    padding: 6px 0;
  }

  .comparison-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
  }
}
