:root {
  --ink: #241714;
  --paper: #fff5dd;
  --paper-soft: #ffe8b8;
  --lacquer: #9d1f19;
  --lacquer-dark: #64120f;
  --gold: #d7a84a;
  --ember: #f26b38;
  --smoke: rgba(36, 23, 20, 0.16);
  --white: rgba(255, 255, 255, 0.82);
  --radius-xl: 32px;
  --radius-md: 18px;
  --ease-snap: cubic-bezier(.2, .9, .25, 1.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 12%, rgba(242, 107, 56, .32), transparent 32rem),
    radial-gradient(circle at 88% 8%, rgba(215, 168, 74, .3), transparent 28rem),
    linear-gradient(135deg, #190c0a 0%, #4e110f 42%, #f0b75f 100%);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  font-family: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", serif;
}

body::before,
body::after {
  position: fixed;
  z-index: -1;
  content: "";
  pointer-events: none;
}

body::before {
  inset: 0;
  opacity: .18;
  background-image:
    linear-gradient(30deg, transparent 0 44%, rgba(255, 245, 221, .55) 45% 46%, transparent 47% 100%),
    linear-gradient(150deg, transparent 0 44%, rgba(255, 245, 221, .42) 45% 46%, transparent 47% 100%);
  background-size: 76px 76px;
}

body::after {
  width: 52vw;
  height: 52vw;
  right: -18vw;
  bottom: -24vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 245, 221, .22), transparent 64%);
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 48px 0 34px;
  display: grid;
  grid-template-columns: minmax(260px, 390px) minmax(310px, 520px);
  grid-template-areas:
    "hero stage"
    "editor stage"
    "hint stage";
  gap: 18px 54px;
  align-content: center;
}

.hero {
  grid-area: hero;
  color: var(--paper);
  animation: rise-in .7s var(--ease-snap) both;
}

.eyebrow {
  margin: 0 0 10px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: rgba(255, 245, 221, .72);
  font: 700 12px/1.4 "Copperplate", "Papyrus", fantasy;
}

h1 {
  margin: 0;
  font-family: "Kaiti SC", "STKaiti", "Songti SC", serif;
  font-size: clamp(56px, 10vw, 126px);
  line-height: .86;
  letter-spacing: -.08em;
  text-shadow: 0 16px 34px rgba(0, 0, 0, .28);
}

.intro {
  max-width: 36ch;
  margin: 24px 0 0;
  color: rgba(255, 245, 221, .86);
  font-size: 17px;
  line-height: 1.75;
}

.name-panel {
  grid-area: guide;
  position: relative;
  z-index: 3;
  padding: 22px;
  border: 1px solid rgba(255, 245, 221, .26);
  border-radius: var(--radius-md);
  color: var(--paper);
  background: rgba(36, 23, 20, .22);
  box-shadow: 0 24px 58px rgba(0, 0, 0, .18);
  backdrop-filter: blur(18px);
  animation: rise-in .7s .08s var(--ease-snap) both;
}

.name-panel-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.name-panel-title span {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: var(--lacquer-dark);
  background: var(--gold);
  font: 800 18px/1 "Copperplate", fantasy;
}

.name-panel-title h2 {
  margin: 0;
  color: var(--paper);
  font-family: "Kaiti SC", "STKaiti", "Songti SC", serif;
  font-size: 30px;
  line-height: 1;
  letter-spacing: -.04em;
}

.name-field {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: rgba(255, 245, 221, .82);
  font-size: 15px;
  font-weight: 800;
}

.name-field input {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(255, 245, 221, .3);
  border-radius: 16px;
  color: var(--paper);
  background: rgba(255, 245, 221, .1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
  font: 800 17px/1.2 "Songti SC", "Noto Serif CJK SC", serif;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.name-field input::placeholder {
  color: rgba(255, 245, 221, .45);
}

.name-field input:focus {
  border-color: rgba(215, 168, 74, .9);
  background: rgba(255, 245, 221, .15);
  box-shadow: 0 0 0 4px rgba(215, 168, 74, .16);
}

.name-note {
  margin: 14px 0 0;
  color: rgba(255, 245, 221, .58);
  font-size: 13px;
  line-height: 1.55;
}

.editor-panel,
.sync-panel {
  grid-area: editor;
  position: relative;
  z-index: 3;
  padding: 20px;
  border: 1px solid rgba(255, 245, 221, .26);
  border-radius: var(--radius-md);
  color: var(--paper);
  background: rgba(36, 23, 20, .22);
  box-shadow: 0 24px 58px rgba(0, 0, 0, .16);
  backdrop-filter: blur(18px);
  animation: rise-in .7s .12s var(--ease-snap) both;
}

.sync-panel {
  grid-area: sync;
}

.compact-title {
  margin-bottom: 14px;
}

.compact-title span {
  width: 32px;
  height: 32px;
  font-size: 16px;
}

.compact-title h2 {
  font-size: 26px;
}

.card-editor {
  display: grid;
  gap: 10px;
}

.editor-field {
  display: grid;
  gap: 6px;
  color: rgba(255, 245, 221, .8);
  font-size: 13px;
  font-weight: 800;
}

.editor-field input,
.editor-field textarea,
.editor-field select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid rgba(255, 245, 221, .26);
  border-radius: 14px;
  color: var(--paper);
  background: rgba(255, 245, 221, .1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
  font: 800 15px/1.35 "Songti SC", "Noto Serif CJK SC", serif;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.editor-field textarea {
  min-height: 120px;
  resize: vertical;
  font-weight: 700;
}

.editor-field input::placeholder,
.editor-field textarea::placeholder {
  color: rgba(255, 245, 221, .42);
}

.editor-field input:focus,
.editor-field textarea:focus,
.editor-field select:focus {
  border-color: rgba(215, 168, 74, .9);
  background: rgba(255, 245, 221, .15);
  box-shadow: 0 0 0 4px rgba(215, 168, 74, .14);
}

.creator-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 10px;
}

.creator-fieldset legend,
.card-section-title {
  margin: 0 0 2px;
  color: rgba(255, 245, 221, .92);
  font: 900 14px/1.4 "Songti SC", serif;
  letter-spacing: .08em;
}

.card-section-title {
  margin-top: 4px;
}

.creator-panel {
  position: relative;
  z-index: 1;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(157, 31, 25, .16);
  border-radius: 16px;
  background: rgba(157, 31, 25, .06);
  cursor: auto;
  touch-action: pan-y;
}

.creator-panel-title {
  margin: 0 0 8px;
  color: rgba(36, 23, 20, .62);
  font: 800 11px/1.2 "Copperplate", "Songti SC", serif;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.creator-meta {
  display: grid;
  gap: 6px;
  margin: 0;
}

.creator-meta div {
  display: grid;
  grid-template-columns: 4.8em 1fr;
  gap: 8px;
  align-items: start;
}

.creator-meta dt {
  margin: 0;
  color: rgba(36, 23, 20, .56);
  font: 800 12px/1.45 "Songti SC", serif;
}

.creator-meta dd {
  margin: 0;
  color: rgba(36, 23, 20, .88);
  font: 700 13px/1.45 "Songti SC", serif;
  overflow-wrap: anywhere;
}

.creator-meta a {
  color: var(--lacquer);
  text-decoration: none;
}

.creator-meta a:hover {
  text-decoration: underline;
}

.editor-status {
  min-height: 18px;
  margin: 0;
  color: rgba(255, 245, 221, .62);
  font-size: 12px;
  line-height: 1.5;
}

.editor-actions {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 9px;
}

.editor-actions.single {
  grid-template-columns: 1fr;
}

.sync-note {
  margin: -2px 0 12px;
  color: rgba(255, 245, 221, .66);
  font-size: 13px;
  line-height: 1.55;
}

.sync-actions {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 9px;
  margin-bottom: 10px;
}

.sync-actions.two {
  grid-template-columns: 1fr 1fr;
  margin: 10px 0 0;
}

.sync-actions button,
.file-button {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  text-align: center;
  font-size: 14px;
  font-weight: 900;
}

.file-button {
  color: var(--paper);
  border: 1px solid rgba(255, 245, 221, .34);
  background: rgba(255, 245, 221, .1);
  cursor: pointer;
}

#importFileInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.editor-actions button {
  min-height: 44px;
  padding: 0 12px;
  font-size: 14px;
}

.danger {
  color: #fff5dd;
  border: 1px solid rgba(255, 245, 221, .22);
  background: rgba(157, 31, 25, .82);
}

.stage {
  position: sticky;
  top: 28px;
  z-index: 1;
  grid-area: stage;
  align-self: start;
  width: 100%;
  max-width: 100%;
  height: clamp(650px, calc(100vh - 72px), 760px);
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  perspective: 1400px;
}

.deck-shadow {
  position: absolute;
  width: min(460px, 82vw);
  height: clamp(650px, 84vh, 760px);
  border-radius: var(--radius-xl);
  transform: translate(24px, 24px) rotate(5deg);
  background: rgba(255, 245, 221, .28);
  box-shadow: 0 44px 80px rgba(0, 0, 0, .3);
}

.card {
  position: relative;
  width: min(460px, 100%);
  max-width: 100%;
  height: clamp(650px, 84vh, 760px);
  padding: 28px 32px 30px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(100, 18, 15, .22);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .62), transparent 34%),
    radial-gradient(circle at 18% 13%, rgba(215, 168, 74, .42), transparent 9rem),
    linear-gradient(160deg, var(--paper) 0%, var(--paper-soft) 100%);
  box-shadow: 0 34px 78px rgba(0, 0, 0, .34), inset 0 0 0 10px rgba(157, 31, 25, .05);
  touch-action: pan-y;
  user-select: none;
  cursor: grab;
  animation: card-enter .76s var(--ease-snap) both;
  will-change: transform, opacity;
}

.card::before {
  position: absolute;
  inset: 14px;
  content: "";
  border: 1px solid rgba(157, 31, 25, .28);
  border-radius: 24px;
  pointer-events: none;
}

.card::after {
  position: absolute;
  right: -72px;
  bottom: -72px;
  width: 190px;
  height: 190px;
  content: "";
  border: 22px solid rgba(157, 31, 25, .08);
  border-radius: 50%;
  pointer-events: none;
}

.card:focus-visible {
  outline: 4px solid rgba(215, 168, 74, .84);
  outline-offset: 8px;
}

.card.dragging {
  cursor: grabbing;
  transition: none;
}

.card-topline {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: rgba(36, 23, 20, .68);
  font: 800 12px/1.3 "Copperplate", "Songti SC", serif;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.card-added-by {
  margin-left: auto;
  margin-right: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  color: rgba(36, 23, 20, .72);
  background: rgba(157, 31, 25, .08);
  font: 800 11px/1.2 "Songti SC", serif;
  letter-spacing: .04em;
  white-space: nowrap;
}

.safety-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.safety-dot::before {
  width: 8px;
  height: 8px;
  content: "";
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 0 5px rgba(242, 107, 56, .14);
}

.card h2 {
  position: relative;
  z-index: 1;
  margin: 30px 0 0;
  font-family: "Kaiti SC", "STKaiti", "Songti SC", serif;
  font-size: clamp(38px, 5.6vw, 56px);
  line-height: 1.06;
  letter-spacing: -.06em;
  color: var(--lacquer-dark);
}

.summary {
  position: relative;
  z-index: 1;
  width: 100%;
  margin: 18px 0 18px;
  color: rgba(36, 23, 20, .76);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chips {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0;
}

.tags-board {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: 10px;
  align-items: stretch;
  margin: 0 0 10px;
}

.tags-stack {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.next-card-hit {
  display: grid;
  place-items: center;
  min-height: 88px;
  padding: 10px 8px;
  border: 1px dashed rgba(157, 31, 25, .28);
  border-radius: 18px;
  color: var(--lacquer-dark);
  background: linear-gradient(180deg, rgba(215, 168, 74, .28), rgba(255, 245, 221, .42));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .42);
  font: 900 13px/1.25 "Songti SC", serif;
  letter-spacing: .08em;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.next-card-hit-label {
  writing-mode: vertical-rl;
}

.next-card-hit:hover {
  transform: translateY(-1px);
  border-color: rgba(157, 31, 25, .42);
}

.next-card-hit:active {
  transform: translateY(0);
}

.chips:empty {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 11px;
  border: 1px solid rgba(100, 18, 15, .15);
  border-radius: 999px;
  color: var(--lacquer-dark);
  background: rgba(255, 255, 255, .48);
  box-shadow: 0 8px 18px rgba(36, 23, 20, .07);
  font-size: 13px;
  font-weight: 800;
}

.type-chips .chip {
  color: #fff8ec;
  border-color: transparent;
  background: linear-gradient(135deg, var(--lacquer), var(--ember));
  box-shadow: 0 10px 22px rgba(157, 31, 25, .18);
}

.recipient-chips .chip {
  color: var(--lacquer-dark);
  border-color: rgba(215, 168, 74, .3);
  background: linear-gradient(135deg, rgba(215, 168, 74, .86), rgba(255, 245, 221, .72));
  box-shadow: 0 10px 22px rgba(215, 168, 74, .16);
}

.body-text {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 230px;
  margin: 12px 0 0;
  padding-top: 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: rgba(36, 23, 20, .84);
  border-top: 1px solid rgba(100, 18, 15, .16);
  font-size: 16px;
  line-height: 1.68;
  overflow-wrap: anywhere;
  cursor: auto;
  user-select: text;
  -webkit-user-select: text;
  touch-action: pan-y;
}

button {
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

button:hover {
  transform: translateY(-2px);
}

button:active {
  transform: translateY(0);
}

.primary {
  flex: 1.2;
  color: var(--lacquer-dark);
  background: var(--gold);
  box-shadow: 0 16px 30px rgba(0, 0, 0, .24);
}

.ghost {
  flex: 1;
  color: var(--paper);
  border: 1px solid rgba(255, 245, 221, .34);
  background: rgba(255, 245, 221, .1);
}

.hint {
  grid-area: hint;
  margin: 0;
  color: rgba(255, 245, 221, .68);
  font-size: 14px;
  line-height: 1.6;
  animation: rise-in .7s .22s var(--ease-snap) both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(18px) rotateX(8deg) scale(.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) rotateX(0) scale(1);
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 24px, 520px);
    min-height: auto;
    padding: 28px 0 26px;
    grid-template-columns: 1fr;
    grid-template-areas:
      "hero"
      "stage"
      "editor"
      "hint";
    gap: 18px;
  }

  .intro {
    max-width: none;
    margin-top: 16px;
  }

  .stage {
    position: relative;
    top: auto;
    height: auto;
    min-height: 700px;
  }

  .card {
    width: 100%;
    height: 670px;
    min-height: 0;
    padding: 24px;
  }

  .deck-shadow {
    width: calc(100% - 16px);
    height: 670px;
    min-height: 0;
  }

}

@media (max-width: 480px) {
  .app-shell {
    width: calc(100% - 18px);
  }

  .card h2 {
    margin-top: 30px;
  }

  .body-text {
    min-height: 260px;
    font-size: 15.5px;
  }
}

@media (max-width: 640px) {
  html {
    background:
      radial-gradient(circle at 18% 0%, rgba(242, 107, 56, .34), transparent 18rem),
      radial-gradient(circle at 110% 88%, rgba(215, 168, 74, .34), transparent 22rem),
      linear-gradient(150deg, #210b08 0%, #5c1811 58%, #d49345 100%);
  }

  body {
    min-height: 100svh;
  }

  .app-shell {
    width: 100%;
    min-height: 100svh;
    padding: 12px 12px calc(32px + env(safe-area-inset-bottom));
    grid-template-areas:
      "hero"
      "stage"
      "editor"
      "hint";
    gap: 12px;
  }

  .hero {
    padding: 0 4px;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: 38px;
    line-height: .95;
    letter-spacing: -.06em;
  }

  .intro {
    margin-top: 8px;
    color: rgba(255, 245, 221, .72);
    font-size: 12px;
    line-height: 1.55;
  }

  .stage {
    position: relative;
    top: auto;
    min-height: 0;
    height: auto;
    padding: 0;
    perspective: 1000px;
  }

  .deck-shadow {
    width: calc(100vw - 62px);
    height: clamp(510px, calc(100svh - 148px), 650px);
    transform: translate(6px, 12px) rotate(3deg);
    border-radius: 28px;
  }

  .card {
    width: calc(100vw - 24px);
    height: clamp(510px, calc(100svh - 148px), 650px);
    padding: 20px 20px 22px;
    border-radius: 28px;
    box-shadow: 0 24px 54px rgba(0, 0, 0, .32), inset 0 0 0 8px rgba(157, 31, 25, .05);
  }

  .card::before {
    inset: 10px;
    border-radius: 22px;
  }

  .card-topline {
    gap: 8px;
    font-size: 10px;
    letter-spacing: .1em;
  }

  .safety-dot {
    gap: 6px;
  }

  .safety-dot::before {
    width: 7px;
    height: 7px;
    box-shadow: 0 0 0 4px rgba(242, 107, 56, .14);
  }

  .card h2 {
    margin-top: 22px;
    font-size: clamp(42px, 14vw, 60px);
    line-height: 1.02;
  }

  .summary {
    margin: 14px 0 16px;
    font-size: 15px;
  }

  .chips {
    gap: 6px;
    margin-bottom: 8px;
  }

  .chip {
    min-height: 26px;
    padding: 4px 10px;
    font-size: 12px;
  }

  .body-text {
    min-height: 0;
    margin-top: 16px;
    padding-top: 18px;
    font-size: 15px;
    line-height: 1.62;
  }

  .name-panel,
  .editor-panel,
  .sync-panel {
    position: relative;
    z-index: 3;
    margin: 0 2px;
    padding: 16px;
    border-radius: 20px;
    background: rgba(36, 23, 20, .34);
  }

  .name-panel-title {
    margin-bottom: 14px;
  }

  .name-panel-title span {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }

  .name-panel-title h2,
  .compact-title h2 {
    font-size: 23px;
  }

  .name-field {
    margin-top: 12px;
  }

  .name-field input,
  .editor-field input,
  .editor-field textarea {
    min-height: 46px;
    border-radius: 14px;
    font-size: 16px;
  }

  .editor-field textarea {
    min-height: 132px;
  }

  .editor-actions {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .sync-actions {
    grid-template-columns: 1fr;
  }

  .sync-actions.two {
    grid-template-columns: 1fr 1fr;
  }

  .hint {
    padding: 0 4px;
    font-size: 12px;
    text-align: center;
  }
}

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