:root {
  color-scheme: light;
  --bg: #eef5f8;
  --ink: #273043;
  --muted: #697386;
  --line: #d8e1ea;
  --panel: #ffffff;
  --accent: #6d5df6;
  --bar: #747887;
  --shadow: 0 16px 40px rgba(53, 63, 86, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0)), #000000;
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.page-shell {
  width: min(980px, calc(100% - 48px));
  min-height: 100vh;
  padding: 40px 0 72px;
  margin: 0 auto;
}

.content-panel {
  width: min(620px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 20px 46px rgba(64, 78, 105, 0.08);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.25;
}

.editor-header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.editor-header button,
.editor-actions button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  font-weight: 800;
}

.field-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

textarea {
  width: 100%;
  min-height: 48vh;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  color: #1d2433;
  background: #f8fafc;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(109, 93, 246, 0.16);
}

.editor-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.editor-actions button:first-child {
  background: var(--accent);
}

.editor-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.editor-note.is-error {
  color: #bc2f4a;
}

.avatar-widget {
  position: fixed;
  right: 28px;
  bottom: 18px;
  z-index: 20;
  width: min(360px, calc(100vw - 24px));
  height: min(540px, calc(100vh - 28px));
  overflow: visible;
  pointer-events: none;
}

.avatar-widget.is-minimized {
  display: none;
}

.avatar-canvas {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  width: 100%;
  height: calc(100% - 128px);
  pointer-events: auto;
}

.stage-status {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 2;
  transform: translateX(-50%);
  padding: 8px 14px;
  border: 1px solid rgba(109, 93, 246, 0.16);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 20px rgba(72, 84, 110, 0.08);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: auto;
}

.stage-status.is-hidden {
  display: none;
}

.assistant-panel {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 3;
  width: min(340px, calc(100% - 20px));
  transform: translateX(-50%);
  text-align: center;
  pointer-events: auto;
}

.assistant-prompt {
  margin-bottom: 9px;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  -webkit-text-stroke: 3px rgba(47, 50, 65, 0.72);
  paint-order: stroke fill;
  text-shadow:
    0 1px 2px rgba(47, 50, 65, 0.9),
    0 3px 8px rgba(47, 50, 65, 0.46);
}

.faq-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 12px;
  margin: 0 auto 12px;
}

.faq-chip {
  min-height: 34px;
  padding: 8px 16px;
  border-radius: 999px;
  color: #6552f1;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 18px rgba(89, 96, 180, 0.18);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.faq-chip:hover,
.faq-chip:focus-visible {
  color: #fff;
  background: var(--accent);
}

.reply-bubble {
  max-width: 330px;
  margin: 0 auto 12px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: rgba(47, 53, 70, 0.84);
  box-shadow: var(--shadow);
  line-height: 1.65;
  text-align: left;
}

.text-input-row {
  display: flex;
  gap: 6px;
  width: min(330px, 100%);
  margin: 0 auto 10px;
}

.text-input-row input {
  min-width: 0;
  flex: 1;
  height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(109, 93, 246, 0.18);
  border-radius: 999px;
  outline: 0;
  color: #273043;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 18px rgba(89, 96, 180, 0.14);
  font-size: 14px;
}

.text-input-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(109, 93, 246, 0.18);
}

.send-control {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(89, 96, 180, 0.18);
  font-size: 16px;
  font-weight: 900;
}

.control-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px;
  border-radius: 18px;
  background: var(--bar);
  box-shadow: 0 10px 20px rgba(68, 74, 92, 0.25);
}

.assistant-panel.is-compact .assistant-prompt,
.assistant-panel.is-compact .faq-chips,
.assistant-panel.is-compact .reply-bubble,
.assistant-panel.is-compact .text-input-row {
  display: none;
}

.primary-control,
.icon-control {
  height: 40px;
  border-radius: 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  font-weight: 900;
}

.primary-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  background: var(--accent);
}

.primary-control.is-listening {
  background: #e34c85;
}

.icon-control.is-active {
  background: rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.24);
}

.icon-control {
  width: 40px;
  font-size: 18px;
}

.avatar-restore-button {
  position: fixed;
  right: 28px;
  bottom: 24px;
  z-index: 21;
  display: none;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 12px 28px rgba(70, 78, 110, 0.28);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.person-icon {
  position: relative;
  display: block;
  width: 28px;
  height: 30px;
}

.person-icon::before,
.person-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: currentColor;
}

.person-icon::before {
  top: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.person-icon::after {
  bottom: 2px;
  width: 24px;
  height: 15px;
  border-radius: 14px 14px 8px 8px;
}

.avatar-restore-button.is-visible {
  display: grid;
  place-items: center;
}

@media (max-width: 760px) {
  .page-shell {
    width: calc(100% - 28px);
    padding-top: 24px;
    padding-bottom: 150px;
  }

  .content-panel {
    padding: 22px 16px;
  }

  .editor-header {
    display: block;
  }

  .editor-header button {
    margin-top: 14px;
  }

  .avatar-widget {
    right: 10px;
    bottom: 12px;
    width: calc(100vw - 20px);
    height: min(640px, calc(100vh - 24px));
    transform: none;
  }

  .avatar-canvas {
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(100% - 118px);
    pointer-events: none;
  }

  .assistant-panel {
    right: 0;
    left: auto;
    width: 100%;
    transform: none;
  }

  .avatar-restore-button {
    right: 18px;
    bottom: 18px;
  }
}

@media (max-width: 430px) {
  .avatar-widget {
    right: 6px;
    width: calc(100vw - 12px);
    height: min(620px, calc(100vh - 18px));
  }

  .avatar-canvas {
    width: 100%;
    height: calc(100% - 112px);
  }

  .faq-chip {
    max-width: 44vw;
    padding-inline: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .control-bar {
    gap: 4px;
  }

  .primary-control {
    padding-inline: 12px;
  }

  .icon-control {
    width: 38px;
  }

}
