@font-face {
  font-family: "Noto Serif SC Masthead";
  src: url("assets/fonts/noto-serif-sc-title.woff2") format("woff2");
  font-style: normal;
  font-weight: 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #191918;
  --muted: #595653;
  --red: #a9222b;
  --rule: #d9d6d0;
  --field-border: #bfbab2;
  --wash: #f5f3ef;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  color: var(--ink);
  background: #eeedeb;
}

*, *::before, *::after { box-sizing: border-box; }
h1, h2, h3, p { margin: 0; }
button, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
::selection { color: var(--ink); background: #f2d9d9; }

body {
  width: min(85rem, calc(100% - 3rem));
  margin: 1.25rem auto 2rem;
  padding-inline: clamp(1.1rem, 3.25vw, 2.85rem);
  border-top: .3rem solid var(--red);
  background: #fff;
  box-shadow: 0 .2rem 1.5rem #1a140a13;
}

.masthead { padding-top: 1.5rem; }

.masthead h1 {
  margin-bottom: 1.25rem;
  color: var(--red);
  font-family: "Noto Serif SC Masthead", "Songti SC", SimSun, serif;
  font-size: clamp(1.58rem, 5.15vw, 3.35rem);
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
}

.edition-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .55rem 1.5rem;
  padding-block: .53rem;
  border-top: 1px solid var(--rule);
  border-bottom: 3px double var(--ink);
}

.edition-nav a, .text-button {
  color: var(--ink);
  font-size: .875rem;
  text-decoration-color: var(--field-border);
  text-underline-offset: .25em;
}

.edition-nav a { padding-block: .12rem; }
.edition-nav .edit-link { color: var(--red); font-weight: 700; }

.edition-nav a:hover, .text-button:hover {
  color: var(--red);
  text-decoration-color: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(17rem, 25vw, 21rem);
  align-items: start;
  gap: clamp(1rem, 2.3vw, 2rem);
  margin-block: 1.5rem 1.7rem;
}

.preview, .editor { min-width: 0; }

.preview-heading, .editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  min-height: 2.1rem;
  padding-bottom: .62rem;
  border-bottom: 1px solid var(--rule);
}

.preview-heading { margin-inline: 3.44% 2.73%; }
.preview-heading h2 { color: var(--red); font-size: .94rem; }

#dimensions {
  color: var(--muted);
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#meme {
  display: block;
  width: 100%;
  height: auto;
  margin-top: .55rem;
  background: #fff;
}

.editor {
  position: sticky;
  top: 1rem;
  scroll-margin-top: 1rem;
  padding-inline-start: 1.25rem;
  border-inline-start: 1px solid var(--rule);
}

.editor-heading h2 { font-size: 1.16rem; line-height: 1.3; }

.text-button {
  padding: .2rem 0 .2rem .35rem;
  border: 0;
  background: none;
  text-decoration-line: underline;
}

.field { margin-top: 1.05rem; }

.field label, .field h3 {
  display: block;
  margin-bottom: .43rem;
  font-size: .94rem;
  font-weight: 700;
}

.headline-control, textarea {
  width: 100%;
  border: 1px solid var(--field-border);
  border-radius: .14rem;
  background: #fff;
}

.headline-control:focus-within {
  border-color: var(--red);
  outline: 1px solid var(--red);
  outline-offset: 1px;
}

.prefix {
  padding: .58rem .72rem .28rem;
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

textarea {
  display: block;
  padding: .57rem .72rem;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.56;
  resize: vertical;
}

textarea::placeholder { color: var(--muted); }

.headline-control textarea {
  padding-top: .25rem;
  border: 0;
  border-radius: 0 0 .12rem .12rem;
  outline: none;
}

.image-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--field-border);
}

.field-status {
  margin-top: .42rem;
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.field-status[data-error="true"] { color: var(--red); }
.field-status:empty { display: none; }

.testimony-field { border-block: 1px solid var(--rule); }

.testimony-field summary {
  display: flex;
  align-items: center;
  gap: .45rem;
  min-height: 2.65rem;
  padding-block: .44rem;
  cursor: pointer;
  font-size: .94rem;
  font-weight: 700;
  line-height: 1.4;
}

.testimony-field summary::-webkit-details-marker { display: none; }

.testimony-field summary::after {
  content: "";
  width: .7rem;
  height: .7rem;
  margin-inline-start: auto;
  background:
    linear-gradient(var(--red), var(--red)) center / 100% 1.5px no-repeat,
    linear-gradient(var(--red), var(--red)) center / 1.5px 100% no-repeat;
}

.testimony-field[open] summary::after { background-size: 100% 1.5px, 0 0; }
.optional { color: var(--muted); font-size: .875rem; font-weight: 400; }
.testimony-field textarea { margin-bottom: .65rem; }
.export-controls { margin-top: 1rem; }

.button {
  min-height: 2.75rem;
  padding: .56rem .48rem;
  border: 0;
  font-size: .94rem;
  font-weight: 700;
}

.secondary { color: var(--ink); background: #fff; }
.secondary + .secondary { border-inline-start: 1px solid var(--field-border); }
.secondary:hover { background: var(--wash); }

.primary {
  width: 100%;
  min-height: 2.95rem;
  border-radius: .12rem;
  color: #fff;
  background: var(--red);
}

.primary:hover:not(:disabled) { background: #831922; }
.primary:disabled { color: #fff; background: #79656a; }

.notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.15rem 2.5rem;
  padding-block: 1rem 1.9rem;
  border-top: 3px double var(--ink);
}

.note { scroll-margin-top: 1rem; }
.note h2 { margin-bottom: .36rem; font-size: 1rem; line-height: 1.4; }
.note p { max-width: 40em; color: var(--muted); line-height: 1.7; }
.shortcut { white-space: nowrap; }
kbd { font-size: .9em; }

@media (max-width: 54rem) {
  body { width: auto; margin: 0; box-shadow: none; }
  .masthead { padding-top: 1.2rem; }
  .masthead h1 { margin-bottom: .9rem; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 1.4rem; margin-top: 1.15rem; }
  .editor { position: static; padding-inline-start: 0; border-inline-start: 0; }
  .editor-heading { padding-top: .7rem; border-top: 1px solid var(--ink); }
}

@media (max-width: 37rem) {
  .notes { grid-template-columns: minmax(0, 1fr); }
}
