@font-face {
  font-family: "Iansui";
  src: url("fonts/Iansui-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --fridge: #b7c9d1;
  --paper: #e7f2f4;
  --slip: #ffffff;
  --ink: #142830;
  --sticker: #f0c400;
  --bag: #184e86;
  --chili: #9d241c;
  --hint: #3e555f;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Iansui", "PingFang HK", "PingFang TC", "Noto Sans HK", "Microsoft JhengHei", "WenQuanYi Micro Hei", sans-serif;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.7;
}

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

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin: 0;
  font-weight: 400;
}

h1 {
  font-size: 2.4rem;
  line-height: 1.15;
}

h2 {
  font-size: 1.25rem;
  line-height: 1.35;
}

a {
  color: var(--bag);
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

::placeholder {
  color: var(--hint);
  opacity: 1;
}

.sheet {
  width: min(390px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--paper);
}

.view {
  padding: 18px 16px 32px;
}

.mast,
.intro,
.form,
.slip-text,
.confirm,
.title-row {
  display: flex;
  flex-direction: column;
}

.mast {
  gap: 12px;
  margin-bottom: 16px;
}

.intro {
  gap: 6px;
  margin: 8px 0 4px;
}

.lede,
.byline,
.count,
.hint {
  font-size: 1.02rem;
  line-height: 1.6;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label,
legend {
  padding: 0;
  font-size: 1.02rem;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice {
  position: relative;
  display: inline-block;
}

.choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.choice span,
.cats button,
.mark {
  border: 2px solid var(--ink);
  background: var(--slip);
}

.choice span {
  display: grid;
  place-items: center;
  min-width: 52px;
  min-height: 44px;
  padding: 6px 12px;
}

.choice input:checked + span,
.cats button[aria-pressed="true"],
.mark,
.flash {
  background: var(--sticker);
}

.choice input:focus-visible + span {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.choice.person input:checked + span {
  background: var(--ink);
  color: var(--slip);
}

input[type="text"],
input[type="search"],
input[type="url"],
textarea,
select {
  width: 100%;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--slip);
  padding: 10px 12px;
  line-height: 1.5;
}

select,
input[type="text"],
input[type="search"],
input[type="url"] {
  min-height: 48px;
}

textarea {
  resize: vertical;
  min-height: 8rem;
}

textarea[name="note"] {
  min-height: 5rem;
}

input.invalid,
textarea.invalid {
  border-color: var(--chili);
}

fieldset.invalid legend {
  color: var(--chili);
}

.cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cats button {
  min-height: 44px;
  padding: 6px 12px;
  font-size: 1rem;
}

#results {
  margin-top: 4px;
}

.slips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slip {
  width: 100%;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  text-align: left;
  background: var(--slip);
  border: 2px solid var(--ink);
  padding: 12px;
}

.slip-text {
  gap: 2px;
  min-width: 0;
}

.slip-title {
  font-size: 1.28rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.slip-meta,
.slip-who {
  font-size: 0.98rem;
  line-height: 1.45;
}

.mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 4px;
  font-size: 0.95rem;
  line-height: 1.15;
  text-align: center;
}

.cover {
  display: block;
  width: 100%;
  height: 210px;
  object-fit: cover;
  border: 2px solid var(--ink);
  background: var(--slip);
}

.title-row {
  gap: 6px;
  margin-top: 4px;
}

.title-row.with-mark {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.title-row h1 {
  font-size: 1.9rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.ingredients,
.steps {
  margin: 8px 0 0;
}

.ingredients {
  list-style: none;
  padding: 0;
}

.ingredients li {
  padding: 8px 0;
  border-bottom: 2px solid var(--ink);
}

.steps {
  padding-left: 1.45rem;
}

.steps li {
  margin: 8px 0;
  padding-left: 0.25rem;
}

.steps li::marker {
  color: var(--bag);
}

.block {
  margin-top: 18px;
}

.source-link {
  overflow-wrap: anywhere;
}

.empty,
.alert,
.slot,
.confirm {
  border: 2px solid var(--ink);
  background: var(--slip);
  padding: 12px;
}

.alert,
.confirm,
.delete {
  border-color: var(--chili);
}

.alert ul {
  margin: 0;
  padding-left: 1.2rem;
}

.slot {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin-top: 16px;
  border-style: dashed;
  border-color: var(--bag);
  background: transparent;
}

.slot[hidden] {
  display: none !important;
}

.slot h2 {
  margin-bottom: 6px;
}

.flash {
  margin-bottom: 12px;
  border: 2px solid var(--ink);
  background: var(--sticker);
  padding: 12px;
}

.back {
  display: inline-block;
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--bag);
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

.go,
.secondary,
.delete,
.danger {
  min-height: 52px;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  background: var(--slip);
  font-size: 1.12rem;
}

.go {
  width: 100%;
}

.delete {
  color: var(--chili);
}

.danger {
  width: 100%;
  border-color: var(--chili);
  background: var(--chili);
  color: var(--slip);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 20px;
}

.confirm {
  gap: 8px;
  margin-top: 12px;
}

.form {
  gap: 14px;
}

#cover-preview .cover {
  margin-top: 8px;
}

@media (hover: hover) {
  .slip:hover {
    background: #fff4c2;
  }
}

.slip:active,
.go:active,
.secondary:active {
  background: var(--sticker);
}

@media (max-width: 340px) {
  h1,
  .title-row h1 {
    font-size: 1.7rem;
  }

  .view {
    padding-left: 12px;
    padding-right: 12px;
  }
}

@media (min-width: 520px) {
  html,
  body {
    background: var(--fridge);
  }

  body {
    padding: 28px 16px;
  }

  .sheet {
    min-height: calc(100vh - 56px);
    border: 2px solid var(--ink);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
