:root {
  --sea: #e0f7fa;
  --sand: #fff8e1;
  --sunset: #ffcc80;
  --ocean: #28aee4;
  --ocean-deep: #1a365d;
  --coral: #ff9f7a;
  --mint: #8edfc7;
  --paper: #fffaf0;
  --ink: #1a365d;
  --muted: #4a5568;
  --line: rgba(26, 54, 93, 0.2);
  --glass: rgba(255, 255, 255, 0.44);
  --glass-strong: rgba(255, 255, 255, 0.64);
  --shadow: 0 30px 90px rgba(26, 54, 93, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--sea);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(160deg, rgba(224, 247, 250, 0.58) 0%, rgba(255, 248, 225, 0.42) 56%, rgba(255, 204, 128, 0.28) 100%),
    url("./assets/beach-tavern-bg.png"),
    linear-gradient(160deg, var(--sea) 0%, var(--sand) 72%, var(--sunset) 100%);
  background-position: center;
  background-size: cover;
  background-attachment: fixed;
}

body::before,
body::after {
  position: fixed;
  inset: auto -12% -18% -12%;
  height: 42vh;
  pointer-events: none;
  content: "";
  z-index: 0;
}

body::before {
  background:
    radial-gradient(ellipse at 22% 0%, rgba(255, 255, 255, 0.72), transparent 45%),
    radial-gradient(ellipse at 66% 20%, rgba(40, 174, 228, 0.22), transparent 48%);
  filter: blur(18px);
  animation: shoreBreath 12s ease-in-out infinite alternate;
}

body::after {
  inset: 0;
  height: auto;
  background:
    radial-gradient(circle at 10% 12%, rgba(255, 255, 255, 0.48), transparent 18%),
    radial-gradient(circle at 88% 18%, rgba(255, 204, 128, 0.32), transparent 20%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 34%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.screen-shell {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 34px;
}

.terminal-panel,
.loading-panel,
.poster-panel {
  width: min(940px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 32px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.56), rgba(255, 255, 255, 0.32)),
    var(--glass);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.84),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    var(--shadow);
  backdrop-filter: blur(30px) saturate(1.24);
  -webkit-backdrop-filter: blur(30px) saturate(1.24);
}

.terminal-panel {
  padding: 34px 40px 32px;
}

.terminal-topbar,
.poster-terminal-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: fit-content;
  min-height: 42px;
  margin: 0 auto 32px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 999px;
  padding: 4px 8px 4px 16px;
  color: var(--ocean-deep);
  font-size: 14px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.32);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.topbar-badge,
.poster-terminal-head span:last-child,
.status-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid rgba(40, 174, 228, 0.18);
  border-radius: 999px;
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.58);
}

.brand-lockup {
  margin: 6px auto 38px;
  text-align: center;
}

.kicker,
.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
  font-weight: 600;
}

.glitch-title {
  margin: 10px 0 12px;
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: clamp(40px, 8vw, 76px);
  font-weight: 800;
  line-height: 1.05;
}

.glitch-title::before,
.glitch-title::after,
.terminal-cursor,
.poster-barcode {
  display: none;
}

.terminal-form {
  display: grid;
  gap: 28px;
}

.field-line,
.mbti-field,
.module-line {
  display: grid;
  gap: 12px;
  min-width: 0;
  border: 0;
  margin: 0;
  padding: 0;
}

.prompt {
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
}

.input-frame,
.textarea-frame,
.select-frame {
  display: block;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(26, 54, 93, 0.18);
  border-radius: 20px;
  outline: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input,
select {
  height: 54px;
  padding: 0 18px;
}

select {
  appearance: none;
  padding-right: 52px;
}

.select-frame {
  position: relative;
}

.select-frame::after {
  position: absolute;
  top: 50%;
  right: 20px;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  content: "";
  pointer-events: none;
  transform: translateY(-68%) rotate(45deg);
}

textarea {
  min-height: 112px;
  resize: vertical;
  padding: 16px 18px;
  line-height: 1.7;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(40, 174, 228, 0.48);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 0 0 5px rgba(40, 174, 228, 0.14);
}

::placeholder {
  color: rgba(74, 85, 104, 0.82);
}

.module-line {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.toggle-switch {
  justify-self: start;
}

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

.toggle-track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 220px;
  min-height: 50px;
  align-items: center;
  border: 1px solid rgba(40, 174, 228, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  overflow: hidden;
}

.toggle-option {
  position: relative;
  z-index: 1;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.toggle-thumb {
  position: absolute;
  inset: 5px auto 5px 5px;
  width: 104px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--ocean), #75d7ea);
  box-shadow: 0 8px 18px rgba(40, 174, 228, 0.28);
  transition: transform 0.22s ease;
}

.toggle-switch input:not(:checked) + .toggle-track .toggle-thumb {
  transform: translateX(106px);
  background: linear-gradient(135deg, var(--sunset), #ffe0a8);
}

.toggle-switch input:checked + .toggle-track .toggle-option--on,
.toggle-switch input:not(:checked) + .toggle-track .toggle-option--off {
  color: #ffffff;
}

.terminal-error {
  margin: 0;
  border-radius: 18px;
  padding: 14px 16px;
  color: #9b2626;
  background: rgba(255, 235, 235, 0.9);
}

.execute-button,
.ghost-button {
  min-height: 54px;
  border: 0;
  border-radius: 999px;
  padding: 0 28px;
  font-weight: 800;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.execute-button {
  justify-self: center;
  min-width: 240px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--ocean), #5dcbe4);
  box-shadow: 0 16px 34px rgba(40, 174, 228, 0.32);
}

.execute-button:hover,
.ghost-button:hover {
  transform: translateY(-2px);
}

.execute-button:disabled {
  opacity: 0.72;
  cursor: wait;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
  font-size: 13px;
}

.loading-panel {
  display: grid;
  justify-items: center;
  gap: 18px;
  width: min(620px, 100%);
  padding: 54px 34px;
  text-align: center;
}

.loading-panel[hidden],
.poster-panel[hidden] {
  display: none;
}

.terminal-panel.is-hidden {
  display: none;
}

.wave-loader {
  position: relative;
  width: 86px;
  height: 116px;
  border: 4px solid rgba(20, 121, 154, 0.42);
  border-top: 0;
  border-radius: 0 0 30px 30px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.5);
}

.wave-loader::before {
  position: absolute;
  inset: 14px 12px auto;
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  content: "";
  z-index: 2;
}

.shaker-cap {
  position: absolute;
  inset: 0;
  display: none;
}

.shaker-body {
  position: absolute;
  left: -18%;
  right: -18%;
  bottom: -10%;
  height: 76%;
  border-radius: 44% 44% 0 0;
  background: linear-gradient(180deg, rgba(117, 215, 234, 0.82), rgba(40, 174, 228, 0.94));
  animation: pourWave 2.2s ease-in-out infinite;
}

.shaker-body::before {
  position: absolute;
  inset: -16px 0 auto;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
  content: "";
  animation: waveSway 2.2s ease-in-out infinite;
}

.loading-title {
  margin: 0;
  color: var(--ink);
  font-size: clamp(24px, 5vw, 34px);
}

.loading-status {
  margin: 0;
  color: var(--ocean-deep);
  font-size: 15px;
  font-weight: 700;
}

.loading-status::after {
  display: block;
  width: min(320px, 72vw);
  height: 8px;
  margin: 18px auto 0;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(40, 174, 228, 0.18), rgba(255, 204, 128, 0.32)),
    linear-gradient(90deg, var(--ocean), #8ee5f3, var(--sunset));
  background-size: 100% 100%, 42% 100%;
  background-position: center, 0 0;
  background-repeat: no-repeat;
  content: "";
  animation: tideProgress 1.9s ease-in-out infinite alternate;
}

.personality-hint {
  margin: 8px 0 0;
  min-height: 22px;
  color: var(--ocean-deep);
  font-size: 14px;
  font-weight: 600;
  font-style: italic;
  text-align: center;
  opacity: 0;
  animation: fadeStep 0.35s ease both;
}

.personality-hint.is-active {
  opacity: 1;
}

.poster-panel {
  padding: 26px;
}

/* ===== 全景通栏商业海报 ===== */
.poster-container {
  --drink-color: #f06a3a;
  --poster-text-primary: #1c2d37;
  --poster-text-secondary: #4a5568;
  --poster-card-bg: rgba(255, 255, 255, 0.65);
  position: relative;
  width: min(760px, 100%);
  min-height: 960px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 30px;
  color: var(--poster-text-primary);
  background: #0b2a3a;
  box-shadow: 0 24px 70px rgba(62, 129, 153, 0.26);
}

/* 暗色场景（深海/夜幕/阴天）：文字翻白，卡片更透 */
.poster-container.poster--dark {
  --poster-text-primary: #f5f7fa;
  --poster-text-secondary: #c8d0d8;
  --poster-card-bg: rgba(255, 255, 255, 0.2);
}

/* 暗色场景：遮罩层改用深蓝冷调，衬托白色文字 */
.poster-container.poster--dark .poster-overlay {
  background:
    linear-gradient(to right,
      rgba(11, 42, 58, 0.92) 0%,
      rgba(11, 42, 58, 0.78) 26%,
      rgba(11, 42, 58, 0.42) 46%,
      rgba(11, 42, 58, 0.12) 60%,
      transparent 76%
    ),
    linear-gradient(to bottom,
      rgba(11, 42, 58, 0.24) 0%,
      transparent 12%,
      transparent 88%,
      rgba(15, 45, 61, 0.28) 100%
    );
}

/* 暗色场景：底部寄语条背景也跟随变暗 */
.poster-container.poster--dark .poster-footer {
  background: linear-gradient(to right,
    rgba(11, 42, 58, 0.80) 0%,
    rgba(11, 42, 58, 0.38) 55%,
    transparent 80%
  );
  border-top-color: rgba(255, 255, 255, 0.18);
}

/* 全幅背景图：AI 生成的酒杯大图铺满整个海报 */
.poster-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: right center;
  z-index: 0;
}

/* 左→右渐变遮罩：左侧白雾衬托文字，右侧完整透出海景与酒杯 */
.poster-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(to right,
      rgba(255, 253, 247, 0.93) 0%,
      rgba(255, 253, 247, 0.84) 26%,
      rgba(255, 253, 247, 0.48) 46%,
      rgba(255, 253, 247, 0.14) 60%,
      transparent 76%
    ),
    linear-gradient(to bottom,
      rgba(255, 253, 247, 0.3) 0%,
      transparent 12%,
      transparent 88%,
      rgba(15, 45, 61, 0.18) 100%
    );
  pointer-events: none;
}

/* 内容悬浮层 */
.poster-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-height: 960px;
  padding: 32px 38px 0;
}

/* 顶部品牌条 */
.poster-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
  position: relative;
}

.poster-brand-mark {
  color: var(--poster-text-secondary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.7;
}

.poster-brand-title {
  color: var(--poster-text-primary);
  font-size: 14px;
  font-weight: 700;
  opacity: 0.8;
}

/* 文字区域：只占左侧约 46%，右侧留给大海与酒杯 */
.poster-text-zone {
  max-width: 46%;
  display: flex;
  flex-direction: column;
}

.poster-kicker {
  margin: 0;
  color: var(--poster-text-secondary);
  font-size: 13px;
  line-height: 1.72;
}

.poster-drink-name {
  display: inline-block;
  width: fit-content;
  margin: 14px 0 14px;
  border: 1px solid rgba(154, 123, 69, 0.28);
  border-radius: 999px;
  padding: 8px 16px;
  color: var(--poster-text-primary);
  background: var(--poster-card-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}

.poster-copyline {
  margin: 0 0 18px;
  color: var(--poster-text-primary);
  font-size: 15px;
  line-height: 1.75;
  font-weight: 700;
}

.poster-mood,
.poster-color-note {
  margin: 0;
  color: var(--poster-text-secondary);
  font-size: 13px;
  line-height: 1.72;
}

/* 配方卡片：半透明毛玻璃 */
.poster-recipe {
  display: grid;
  gap: 8px;
  margin: 22px 0 0;
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--poster-card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.65);
}

.poster-recipe div {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: baseline;
  gap: 10px;
}

.poster-recipe dt {
  color: #9a7b45;
  font-size: 13px;
  font-weight: 800;
}

.poster-recipe dd {
  min-width: 0;
  margin: 0;
  color: var(--poster-text-primary);
  font-size: 14px;
  line-height: 1.5;
}

/* 巨型酒名：海报最大视觉锚点 */
.poster-hero-name {
  max-width: 52%;
  margin-top: auto;
  padding: 32px 0 8px;
  color: var(--poster-text-primary);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: clamp(46px, 9vw, 80px);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.01em;
  word-break: keep-all;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 20px rgba(255, 255, 255, 0.55);
}

/* 底部寄语条 */
.poster-footer {
  position: relative;
  margin: 16px -38px 0;
  padding: 18px 38px 28px;
  color: var(--poster-text-primary);
  font-family: "STSong", "SimSun", "Songti SC", "Georgia", serif;
  font-size: 13px;
  line-height: 1.8;
  font-weight: 600;
  background: linear-gradient(to right,
    rgba(255, 253, 247, 0.75) 0%,
    rgba(255, 253, 247, 0.35) 55%,
    transparent 80%
  );
  border-top: 1px solid rgba(255, 255, 255, 0.45);
  letter-spacing: 0.02em;
}

/* 隐藏兼容字段 */
.poster-price,
.poster-stamps {
  display: none;
}

.poster-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
}

.poster-button {
  margin: 0;
}

.ghost-button {
  color: var(--ocean-deep);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 12px 26px rgba(62, 129, 153, 0.12);
}

.result-cache {
  display: none;
}

@keyframes shoreBreath {
  from {
    transform: translate3d(-1.5%, 0, 0) scale(1);
  }

  to {
    transform: translate3d(1.5%, -2%, 0) scale(1.04);
  }
}

@keyframes pourWave {
  0%,
  100% {
    height: 62%;
  }

  50% {
    height: 78%;
  }
}

@keyframes waveSway {
  0%,
  100% {
    transform: translateX(-8px);
  }

  50% {
    transform: translateX(8px);
  }
}

@keyframes fadeStep {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

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

@keyframes tideProgress {
  from {
    background-position: center, 0 0;
  }

  to {
    background-position: center, 100% 0;
  }
}

@media (max-width: 760px) {
  .screen-shell {
    padding: 18px;
  }

  .terminal-panel,
  .poster-panel {
    border-radius: 24px;
    padding: 20px;
  }

  .terminal-topbar,
  .poster-terminal-head {
    flex-direction: column;
    margin-bottom: 20px;
  }

  .terminal-topbar {
    width: 100%;
    align-items: center;
    padding: 10px 12px;
    text-align: center;
  }

  .poster-terminal-head {
    align-items: flex-start;
  }

  .module-line {
    grid-template-columns: 1fr;
  }

  .toggle-track {
    width: 204px;
  }

  .toggle-thumb {
    width: 96px;
  }

  .toggle-switch input:not(:checked) + .toggle-track .toggle-thumb {
    transform: translateX(98px);
  }

  .poster-container {
    min-height: 720px;
  }

  .poster-content {
    min-height: 720px;
    padding: 24px 22px 0;
  }

  .poster-text-zone {
    max-width: 58%;
  }

  .poster-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 20px;
  }

  .poster-drink-name {
    max-width: 100%;
  }

  .poster-hero-name {
    max-width: 62%;
    padding-top: 22px;
    font-size: clamp(36px, 12vw, 56px);
  }

  .poster-recipe {
    padding: 12px 14px;
  }

  .poster-recipe div {
    grid-template-columns: 44px 1fr;
  }

  .poster-footer {
    margin: 16px -22px 0;
    padding: 14px 22px 22px;
  }
}
