:root {
  color-scheme: light;
  --bg: #f6f3ee;
  --paper: #fffdf8;
  --ink: #1f2a2c;
  --muted: #667275;
  --line: #ddd7cc;
  --green: #14795a;
  --green-soft: #dff0e7;
  --coral: #cf5d3f;
  --coral-soft: #f8dfd5;
  --amber: #ad7418;
  --amber-soft: #f4e7c8;
  --plum: #6f5aa6;
  --plum-soft: #e8e0f2;
  --blue: #2d6f9f;
  --blue-soft: #dcecf6;
  --shadow: 0 20px 60px rgba(47, 42, 35, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(45, 111, 159, 0.12), transparent 34rem),
    linear-gradient(135deg, #f8f5ef 0%, #eef4f0 100%);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  white-space: nowrap;
  border: 0;
  clip: rect(0 0 0 0);
}

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

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

.kicker {
  margin: 0 0 2px;
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 2.4rem, 2.4rem);
  line-height: 1.05;
}

.brand-logo {
  display: inline-flex;
  align-items: baseline;
  gap: 0.02em;
  color: var(--ink);
  font-weight: 950;
  letter-spacing: 0;
}

.logo-kana {
  display: inline-flex;
  align-items: baseline;
  font-weight: 1000;
}

.logo-kana span {
  display: inline-block;
  transform-origin: 50% 80%;
}

.logo-kana span:nth-child(1) {
  transform: rotate(-5deg) translateY(0.02em);
}

.logo-kana span:nth-child(2) {
  transform: rotate(3deg) translateY(-0.03em);
}

.logo-kana span:nth-child(3) {
  transform: rotate(-2deg);
}

.logo-tag {
  position: relative;
  display: inline-block;
  margin-left: 0.02em;
  padding: 0.02em 0.12em 0.04em 0.16em;
  color: #fffdf8;
  background: linear-gradient(135deg, var(--green), #0d6f56);
  border-radius: 7px 7px 7px 2px;
  font-weight: 1000;
  box-shadow:
    0 0.09em 0 rgba(31, 42, 44, 0.18),
    inset 0 -0.08em 0 rgba(0, 0, 0, 0.16);
  transform: rotate(-2deg) translateY(-0.02em);
}

.logo-question {
  position: relative;
  display: inline-block;
  color: var(--coral);
  font-weight: 1000;
  text-shadow: 0.06em 0.06em 0 var(--amber-soft);
  transform: rotate(9deg) translateY(-0.05em);
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.ghost-button {
  border: 0;
  min-height: 42px;
  border-radius: 8px;
  font-weight: 800;
}

.ghost-button {
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.78);
  border: 1px solid rgba(31, 42, 44, 0.12);
}

.ghost-button:hover {
  background: #fff;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

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

.product-card,
.result-panel {
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid rgba(31, 42, 44, 0.1);
  box-shadow: var(--shadow);
}

.product-card {
  position: relative;
  display: grid;
  gap: 16px;
  min-height: 342px;
  padding: 20px;
  border-radius: 8px;
  overflow: hidden;
}

.product-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: var(--blue);
}

.product-b::before {
  background: var(--coral);
}

.product-c::before {
  background: var(--amber);
}

.product-d::before {
  background: var(--plum);
}

.product-card.is-winner {
  outline: 3px solid rgba(20, 121, 90, 0.28);
  outline-offset: -3px;
}

.card-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.badge {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #fff;
  background: var(--blue);
  border-radius: 50%;
  font-weight: 900;
}

.product-b .badge {
  background: var(--coral);
}

.product-c .badge {
  background: var(--amber);
}

.product-d .badge {
  background: var(--plum);
}

.name-input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-bottom: 2px solid var(--line);
  padding: 8px 0 12px;
  color: var(--ink);
  background: transparent;
  font-size: 1.45rem;
  font-weight: 850;
}

.name-input:focus,
.field input:focus,
.field select:focus {
  outline: 3px solid rgba(45, 111, 159, 0.18);
  outline-offset: 3px;
}

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

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  font-weight: 850;
}

.field input::placeholder {
  color: #b8b0a6;
  opacity: 1;
}

.input-shell {
  position: relative;
  display: block;
}

.input-shell input {
  padding-right: 12px;
}

.field:first-child .input-shell input {
  padding-right: 48px;
}

.input-suffix {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 900;
  pointer-events: none;
  transform: translateY(-50%);
}

.input-shell:has(input:placeholder-shown) .input-suffix {
  color: #c3bbb0;
}

.field select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 21px,
    calc(100% - 12px) 21px;
  background-size:
    6px 6px,
    6px 6px;
  background-repeat: no-repeat;
}

.unit-readout {
  align-self: end;
  display: grid;
  gap: 6px;
  padding: 16px;
  background: var(--blue-soft);
  border-radius: 8px;
}

.product-b .unit-readout {
  background: var(--coral-soft);
}

.product-c .unit-readout {
  background: var(--amber-soft);
}

.product-d .unit-readout {
  background: var(--plum-soft);
}

.unit-readout span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.unit-readout strong {
  min-height: 34px;
  font-size: 1.55rem;
  line-height: 1.1;
}

.result-panel {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 20px;
  min-height: 342px;
  padding: 20px;
  border-radius: 8px;
}

.section-heading h2 {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
}

.winner-block {
  display: grid;
  align-content: center;
  gap: 10px;
  min-height: 140px;
}

.basis-label {
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 900;
}

.winner-block h2 {
  font-size: 2rem;
  line-height: 1.05;
}

.winner-block p:last-child {
  color: var(--muted);
  line-height: 1.5;
}

.bars {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-row.is-empty {
  display: none;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.bar-label span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-label strong {
  color: var(--ink);
  white-space: nowrap;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  background: #ebe5dc;
  border-radius: 999px;
}

.bar-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition:
    width 180ms ease,
    opacity 180ms ease;
}

.fill-a {
  background: var(--blue);
}

.fill-b {
  background: var(--coral);
}

.fill-c {
  background: var(--amber);
}

.fill-d {
  background: var(--plum);
}

.primary-button {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: #fff;
  background: var(--green);
  font-weight: 800;
}

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

.share-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.share-button {
  min-width: 0;
  min-height: 40px;
  border: 1px solid rgba(31, 42, 44, 0.12);
  border-radius: 8px;
  padding: 0 8px;
  color: var(--ink);
  background: #fff;
  font-size: 0.82rem;
  font-weight: 850;
}

.share-button:hover {
  background: var(--green-soft);
}

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

.share-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.memo-panel {
  margin-top: 16px;
  padding: 18px;
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid rgba(31, 42, 44, 0.1);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.text-button {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  color: var(--green);
  background: transparent;
  font-weight: 800;
}

.text-button:hover {
  background: #fff;
}

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

.memo-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.memo-item {
  position: relative;
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 164px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.memo-item::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--green);
}

.memo-a::before {
  background: var(--blue);
}

.memo-b::before {
  background: var(--coral);
}

.memo-c::before {
  background: var(--amber);
}

.memo-d::before {
  background: var(--plum);
}

.memo-a {
  background: linear-gradient(180deg, rgba(220, 236, 246, 0.45), #fff 42%);
}

.memo-b {
  background: linear-gradient(180deg, rgba(248, 223, 213, 0.5), #fff 42%);
}

.memo-c {
  background: linear-gradient(180deg, rgba(244, 231, 200, 0.55), #fff 42%);
}

.memo-d {
  background: linear-gradient(180deg, rgba(232, 224, 242, 0.55), #fff 42%);
}

.memo-item strong {
  line-height: 1.25;
}

.memo-a strong {
  color: var(--blue);
}

.memo-b strong {
  color: var(--coral);
}

.memo-c strong {
  color: var(--amber);
}

.memo-d strong {
  color: var(--plum);
}

.memo-item span {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.memo-item .share-actions {
  margin-top: 4px;
}

.empty-memo {
  grid-column: 1 / -1;
  color: var(--muted);
  padding: 10px 0;
  font-weight: 700;
}

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

  .result-panel {
    grid-template-rows: auto;
  }

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

@media (max-width: 760px) {
  body {
    background: #f8f5ef;
  }

  .app-shell {
    width: 100%;
    padding: 12px 10px 28px;
  }

  .topbar {
    align-items: stretch;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-bottom: 10px;
  }

  .kicker {
    font-size: 0.72rem;
  }

  h1 {
    font-size: 1.65rem;
  }

  .quick-actions {
    display: grid;
    grid-template-columns: 56px;
    align-self: center;
    gap: 6px;
  }

  .ghost-button,
  .primary-button,
  .share-button {
    min-height: 48px;
  }

  .ghost-button {
    padding: 0 6px;
    font-size: 0.8rem;
  }

  .workspace,
  .compare-grid,
  .memo-list {
    grid-template-columns: 1fr;
  }

  .workspace {
    gap: 10px;
  }

  .result-panel {
    position: sticky;
    top: 0;
    z-index: 2;
    order: -1;
    grid-template-columns: minmax(0, 1fr) minmax(112px, 34%);
    align-items: center;
    gap: 6px 8px;
    min-height: 0;
    padding: 8px 10px;
    border-radius: 0 0 8px 8px;
  }

  .winner-block {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: baseline;
    column-gap: 6px;
    min-height: 0;
    row-gap: 1px;
  }

  .basis-label {
    font-size: 0.68rem;
    white-space: nowrap;
  }

  .winner-block h2 {
    min-width: 0;
    overflow: hidden;
    font-size: 1.08rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .winner-block p:last-child {
    grid-column: 1 / -1;
    min-width: 0;
    overflow: hidden;
    font-size: 0.8rem;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bars {
    display: none;
  }

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

  .result-panel .primary-button {
    grid-column: 2;
    grid-row: 1;
    min-height: 40px;
    padding: 0 8px;
    font-size: 0.92rem;
  }

  .result-panel .share-button {
    min-height: 36px;
  }

  .share-button {
    padding: 0 4px;
    font-size: 0.72rem;
  }

  .product-card,
  .result-panel,
  .memo-panel {
    box-shadow: 0 14px 34px rgba(47, 42, 35, 0.1);
  }

  .product-card {
    gap: 12px;
    min-height: 0;
    padding: 14px;
  }

  .card-heading {
    font-size: 0.82rem;
  }

  .badge {
    width: 30px;
    height: 30px;
  }

  .name-input {
    padding: 2px 0 8px;
    font-size: 1.12rem;
  }

  .field-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 104px;
    gap: 8px;
  }

  .field {
    gap: 6px;
    font-size: 0.8rem;
  }

  .field input,
  .field select {
    height: 58px;
    padding: 0 12px;
    font-size: 1.18rem;
  }

  .field select {
    background-position:
      calc(100% - 17px) 25px,
      calc(100% - 11px) 25px;
  }

  .input-shell input {
    padding-right: 12px;
  }

  .field:first-child .input-shell input {
    padding-right: 50px;
  }

  .input-suffix {
    right: 13px;
    font-size: 1rem;
  }

  .unit-readout {
    padding: 12px;
  }

  .unit-readout strong {
    min-height: 26px;
    font-size: 1.28rem;
  }

}
