:root {
  --page-bg: #f4f3fb;
  --panel: #ffffff;
  --ink: #26242d;
  --muted: #706d7a;
  --line: #dedbed;
  --pink: #dd2f92;
  --blue: #6069e6;
  --left-bubble: #d7ef64;
  --right-bubble: #b8adf8;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background:
    radial-gradient(circle at 12% 18%, rgba(221, 47, 146, 0.15), transparent 28rem),
    radial-gradient(circle at 86% 72%, rgba(96, 105, 230, 0.16), transparent 32rem),
    var(--page-bg);
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(574px, 1fr);
  gap: 28px;
  align-items: start;
  width: min(1240px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 32px 0;
}

.editor-panel {
  position: sticky;
  top: 24px;
  min-width: 0;
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid rgba(93, 89, 123, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 48px rgba(45, 39, 78, 0.12);
}

.panel-heading h1 {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.2;
}

.panel-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.message-tools h2,
.sticker-heading h2 {
  color: #403c4b;
  font-size: 14px;
  font-weight: 700;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.field input {
  height: 42px;
  padding: 0 12px;
}

.field textarea {
  min-height: 108px;
  padding: 12px;
  resize: vertical;
  line-height: 1.5;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(96, 105, 230, 0.14);
}

.composer {
  display: grid;
  gap: 12px;
}

.sticker-picker {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaff;
}

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

.sticker-heading h2 {
  margin: 0;
}

.sticker-heading span {
  color: var(--muted);
  font-size: 12px;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.sticker-option {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 8px 6px;
  border: 1px solid #e1deef;
  border-radius: 8px;
  color: #4d485b;
  background: #fff;
}

.sticker-option:hover,
.sticker-option:focus-visible {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(96, 105, 230, 0.12);
}

.sticker-option img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  object-fit: contain;
  background: #f4f2fb;
}

.sticker-option span {
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sender-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border-radius: 8px;
  background: #efedf8;
}

.sender-switch label {
  min-width: 0;
}

.sender-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sender-switch span {
  display: grid;
  height: 38px;
  place-items: center;
  border-radius: 6px;
  color: #686174;
  font-weight: 700;
}

.sender-switch input:checked + span {
  color: #fff;
  background: var(--blue);
}

.primary-button,
.download-button,
.ghost-button,
.row-button {
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

.primary-button,
.download-button {
  height: 46px;
  color: #fff;
  background: var(--pink);
}

.download-button {
  width: 100%;
  background: linear-gradient(135deg, var(--pink), var(--blue));
}

.export-bar {
  display: grid;
  gap: 10px;
}

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

.ghost-button,
.row-button {
  height: 34px;
  padding: 0 12px;
  color: #5b5770;
  background: #f1eff8;
}

.message-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.message-tools h2 {
  margin: 0;
}

.message-list {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.message-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaff;
}

.message-item textarea {
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.5;
  resize: vertical;
}

.message-sticker-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.message-sticker-preview img {
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}

.message-sticker-preview span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.empty-state {
  padding: 20px;
  border: 1px dashed #c9c5dc;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.preview-panel {
  display: flex;
  min-width: 0;
  justify-content: center;
}

.chat-frame {
  width: 574px;
  min-height: 789px;
  padding: 8px 8px 14px;
  border-radius: 32px 32px 24px 24px;
  background: linear-gradient(180deg, #dd2f92 0%, #dd2f92 45%, #6069e6 72%, #6069e6 100%);
  box-shadow: 0 24px 70px rgba(30, 28, 64, 0.22);
}

.game-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 84px;
  padding: 14px 24px 12px;
}

.fast-forward {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 55px;
  height: 48px;
  border: 6px solid #fff;
}

.fast-forward span {
  width: 0;
  height: 0;
  margin-left: -2px;
  border-top: 15px solid transparent;
  border-bottom: 15px solid transparent;
  border-left: 17px solid #fff;
}

.close-button {
  position: relative;
  width: 61px;
  height: 61px;
  border-radius: 50%;
  background: #f6bf68;
}

.close-button::before,
.close-button::after {
  content: "";
  position: absolute;
  left: 27px;
  top: 11px;
  width: 10px;
  height: 40px;
  border-radius: 8px;
  background: #fff;
}

.close-button::before {
  transform: rotate(45deg);
}

.close-button::after {
  transform: rotate(-45deg);
}

.chat-window {
  overflow: hidden;
  min-height: 574px;
  margin: 0 6px;
  border: 6px solid #6268e5;
  border-radius: 30px;
  background: #fff;
}

.chat-title {
  height: 56px;
  padding: 6px 20px 0;
  color: #34313b;
  background: #e7e7fb;
  font-size: 34px;
  line-height: 50px;
}

.chat-messages {
  display: grid;
  gap: 34px;
  min-height: 512px;
  padding: 92px 28px 36px;
}

.chat-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.chat-row.right {
  justify-content: flex-end;
}

.avatar {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-row.right .avatar {
  filter: drop-shadow(0 2px 0 rgba(255, 255, 255, 0.5));
}

.bubble {
  max-width: min(306px, calc(100% - 70px));
  min-height: 52px;
  padding: 13px 17px;
  border-radius: 12px;
  color: #3d3743;
  font-size: 18px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

.left .bubble {
  background: var(--left-bubble);
}

.right .bubble {
  background: var(--right-bubble);
}

.sticker-message {
  display: block;
  max-width: min(140px, calc(100% - 70px));
  max-height: 118px;
  object-fit: contain;
}

.chat-input-bar {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 8px;
  align-items: center;
  padding: 18px 38px 0;
}

.preview-input {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 60px;
  padding: 0 15px;
  border-radius: 13px;
  color: #44404d;
  background: #fff;
  font-size: 20px;
  line-height: 1.2;
  word-break: break-word;
}

.send-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 92px;
  height: 60px;
  border: 0;
  border-radius: 15px;
  background: #f6bf68;
}

.send-button img {
  display: block;
  width: 72px;
  height: auto;
}

@media (max-width: 1060px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(720px, calc(100vw - 24px));
    padding: 20px 0;
  }

  .editor-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  body {
    background:
      radial-gradient(circle at 10% 10%, rgba(221, 47, 146, 0.12), transparent 18rem),
      radial-gradient(circle at 90% 82%, rgba(96, 105, 230, 0.14), transparent 20rem),
      var(--page-bg);
  }

  .app-shell {
    width: 100%;
    gap: 16px;
    padding: 12px;
  }

  .editor-panel {
    gap: 16px;
    padding: 16px;
    box-shadow: 0 12px 32px rgba(45, 39, 78, 0.1);
  }

  .panel-heading h1 {
    font-size: 22px;
  }

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

  .message-list {
    max-height: 46vh;
  }

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

  .message-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .row-button {
    flex: 1 1 calc(50% - 6px);
  }

  .preview-panel {
    justify-content: center;
    width: 100%;
  }

  .chat-frame {
    width: min(574px, 100%);
    min-height: auto;
    padding: clamp(5px, 1.4vw, 8px) clamp(5px, 1.4vw, 8px) clamp(10px, 2.8vw, 14px);
    border-radius: clamp(20px, 7vw, 32px) clamp(20px, 7vw, 32px) clamp(16px, 5vw, 24px) clamp(16px, 5vw, 24px);
    box-shadow: 0 16px 42px rgba(30, 28, 64, 0.18);
  }

  .game-topbar {
    height: clamp(56px, 15vw, 84px);
    padding: clamp(10px, 2.8vw, 14px) clamp(14px, 5vw, 24px) clamp(8px, 2.4vw, 12px);
  }

  .fast-forward {
    width: clamp(36px, 10vw, 55px);
    height: clamp(32px, 9vw, 48px);
    border-width: clamp(4px, 1.2vw, 6px);
  }

  .fast-forward span {
    border-top-width: clamp(10px, 2.8vw, 15px);
    border-bottom-width: clamp(10px, 2.8vw, 15px);
    border-left-width: clamp(11px, 3.2vw, 17px);
  }

  .close-button {
    width: clamp(42px, 12vw, 61px);
    height: clamp(42px, 12vw, 61px);
  }

  .close-button::before,
  .close-button::after {
    left: calc(50% - clamp(3px, 1vw, 5px));
    top: 18%;
    width: clamp(6px, 2vw, 10px);
    height: 64%;
  }

  .chat-window {
    min-height: clamp(430px, 118vw, 574px);
    margin: 0 clamp(3px, 1vw, 6px);
    border-width: clamp(4px, 1.2vw, 6px);
    border-radius: clamp(18px, 5.6vw, 30px);
  }

  .chat-title {
    height: clamp(42px, 11vw, 56px);
    padding: clamp(4px, 1.2vw, 6px) clamp(12px, 4vw, 20px) 0;
    font-size: clamp(23px, 7vw, 34px);
    line-height: clamp(38px, 9.8vw, 50px);
  }

  .chat-messages {
    gap: clamp(20px, 6vw, 34px);
    min-height: clamp(388px, 107vw, 512px);
    padding: clamp(50px, 16vw, 92px) clamp(14px, 4.5vw, 28px) clamp(24px, 6vw, 36px);
  }

  .chat-row {
    gap: clamp(9px, 3vw, 16px);
  }

  .avatar {
    width: clamp(40px, 12vw, 54px);
    height: clamp(40px, 12vw, 54px);
  }

  .bubble {
    max-width: calc(100% - clamp(49px, 15vw, 70px));
    min-height: clamp(42px, 12vw, 52px);
    padding: clamp(10px, 3vw, 13px) clamp(12px, 4vw, 17px);
    border-radius: clamp(9px, 3vw, 12px);
    font-size: clamp(15px, 4.5vw, 18px);
  }

  .sticker-message {
    max-width: calc(100% - clamp(49px, 15vw, 70px));
    max-height: clamp(96px, 32vw, 118px);
  }

  .chat-input-bar {
    grid-template-columns: minmax(0, 1fr) clamp(64px, 22vw, 92px);
    gap: clamp(6px, 2vw, 8px);
    padding: clamp(12px, 4vw, 18px) clamp(16px, 8vw, 38px) 0;
  }

  .preview-input {
    height: clamp(46px, 14vw, 60px);
    padding: 0 clamp(10px, 3vw, 15px);
    border-radius: clamp(10px, 3vw, 13px);
    font-size: clamp(16px, 4.8vw, 20px);
  }

  .send-button {
    width: clamp(64px, 22vw, 92px);
    height: clamp(46px, 14vw, 60px);
    border-radius: clamp(11px, 3.6vw, 15px);
  }

  .send-button img {
    width: clamp(50px, 17vw, 72px);
  }
}
