/* ============================================
   主样式
   ============================================ */

.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  max-width: 540px;
  margin: 0 auto;
  background: var(--bg-canvas);
  overflow: hidden;
}

/* ============== 状态栏 ============== */
.status-bar {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) var(--space-6) 0;
  height: calc(36px + var(--safe-top));
  padding-top: calc(var(--space-2) + var(--safe-top));
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-primary);
}
.status-bar__icons {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-primary);
}
.status-bar__battery {
  font-size: var(--fs-sm);
  font-weight: 600;
}

/* ============== 顶部栏 ============== */
.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 var(--space-4);
  background: var(--bg-canvas);
  position: relative;
  z-index: 10;
}
.topbar__back {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  border-radius: var(--radius-pill);
  transition: background var(--duration-fast) var(--ease-out);
}
.topbar__back:hover {
  background: var(--border-soft);
}
.topbar__back svg {
  width: 22px;
  height: 22px;
}
.topbar__back[hidden] {
  visibility: hidden;
}
.topbar__title {
  flex: 1;
  text-align: center;
  font-size: var(--fs-md);
  font-weight: 600;
  margin: 0 var(--space-2);
}
.topbar__actions {
  display: flex;
  gap: var(--space-1);
}
.topbar__icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  border-radius: var(--radius-pill);
  transition: background var(--duration-fast) var(--ease-out);
}
.topbar__icon-btn:hover {
  background: var(--border-soft);
}
.topbar__icon-btn svg {
  width: 22px;
  height: 22px;
}

/* ============== 主体 ============== */
.main {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 0 var(--space-5) var(--space-5);
  animation: pageFadeIn var(--duration-base) var(--ease-out);
}

/* ============== 欢迎页 ============== */
.welcome__hero {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding: var(--space-4) 0 var(--space-7);
  min-height: 280px;
}
.welcome__copy {
  flex: 1;
  z-index: 2;
  padding-top: var(--space-3);
}
.welcome__hello {
  font-size: var(--fs-4xl);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: var(--space-2);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.welcome__sub {
  font-size: var(--fs-xl);
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: var(--text-primary);
}
.welcome__desc {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 260px;
}
.welcome__orb {
  position: absolute;
  top: -20px;
  right: -30px;
  width: 220px;
  height: 220px;
  z-index: 1;
  pointer-events: none;
  animation: orbFloat 6s ease-in-out infinite;
}
.orb-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(var(--shadow-orb));
}

/* ============== 快捷入口 ============== */
.quick-entries {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  padding: var(--space-4) 0;
}
.quick-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
  box-shadow: var(--shadow-xs);
  transition: all var(--duration-fast) var(--ease-out);
  cursor: pointer;
  gap: var(--space-2);
}
.quick-entry:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: var(--border-medium);
}
.quick-entry:active {
  transform: translateY(0);
}
.quick-entry__label {
  flex: 1;
  line-height: 1.4;
  font-size: var(--fs-sm);
}
.quick-entry__arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}
.quick-entry__arrow svg {
  width: 14px;
  height: 14px;
  transform: rotate(-45deg);
}

/* ============== 对话页 ============== */
.chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.chat__message {
  display: flex;
  gap: var(--space-2);
  animation: messageSlideIn var(--duration-base) var(--ease-out);
}
.chat__message--user {
  flex-direction: row-reverse;
}
.chat__avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--accent-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse);
  font-size: var(--fs-sm);
  font-weight: 600;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}
.chat__message--user .chat__avatar {
  background: var(--accent-warm);
}
.chat__bubble {
  max-width: 76%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border-soft);
}
.chat__message--user .chat__bubble {
  background: var(--accent-warm);
  color: var(--text-inverse);
  border-color: var(--accent-warm-deep);
}
.chat__bubble h1, .chat__bubble h2, .chat__bubble h3 {
  margin: var(--space-3) 0 var(--space-2);
  font-weight: 600;
  line-height: 1.3;
}
.chat__bubble h1 { font-size: var(--fs-lg); }
.chat__bubble h2 { font-size: var(--fs-md); }
.chat__bubble h3 { font-size: var(--fs-base); }
.chat__bubble p {
  margin: var(--space-2) 0;
}
.chat__bubble ul, .chat__bubble ol {
  margin: var(--space-2) 0;
  padding-left: var(--space-5);
}
.chat__bubble ul { list-style: disc; }
.chat__bubble ol { list-style: decimal; }
.chat__bubble li { margin: var(--space-1) 0; }
.chat__bubble strong { font-weight: 600; color: var(--text-primary); }
.chat__bubble code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 1px 5px;
  background: var(--border-soft);
  border-radius: 3px;
}

/* 思考中消息气泡 */
.chat__bubble--thinking {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-card);
  color: var(--accent-secondary-deep);
}
.thinking-dots {
  display: inline-flex;
  gap: 3px;
}
.thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-secondary);
  animation: dotBounce 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.30s; }

/* 底部状态条（仿 GenFlow） */
.chat__status {
  position: sticky;
  bottom: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--border-soft);
  z-index: 5;
}
.chat__status-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.chat__status-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--accent-secondary);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.chat__status-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--bg-card), var(--accent-primary));
  opacity: 0.4;
  animation: iconPulse 1.5s ease-in-out infinite;
}
.chat__status-text {
  flex: 1;
  min-width: 0;
}
.chat__status-title {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text-primary);
}
.chat__status-sub {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.chat__status-stop {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--text-primary);
  border-radius: 50%;
  color: var(--text-primary);
  flex-shrink: 0;
}
.chat__status-stop svg {
  width: 20px;
  height: 20px;
}

/* ============== Skill 详情页 ============== */
.skill-detail {
  padding: var(--space-4) 0;
}
.skill-detail__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-xs);
}
.skill-detail__icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: var(--text-inverse);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.skill-detail__icon svg {
  width: 24px;
  height: 24px;
}
.skill-detail__title {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}
.skill-detail__desc {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}
.skill-detail__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.form-field__label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
}
.form-field__input,
.form-field__textarea,
.form-field__select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  font-size: var(--fs-base);
  color: var(--text-primary);
  transition: border-color var(--duration-fast) var(--ease-out);
}
.form-field__input:focus,
.form-field__textarea:focus,
.form-field__select:focus {
  border-color: var(--accent-primary);
}
.form-field__textarea {
  min-height: 96px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.6;
}
.form-field__select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%236B655D' stroke-width='2'><polyline points='1,1 6,6 11,1'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: var(--space-7);
}
.form-field__hint {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.skill-detail__submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-deep));
  color: var(--text-inverse);
  border-radius: var(--radius-pill);
  font-size: var(--fs-md);
  font-weight: 600;
  margin-top: var(--space-2);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-fast) var(--ease-out);
}
.skill-detail__submit:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.skill-detail__submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ============== 底部输入栏 ============== */
.composer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  padding-bottom: calc(var(--space-3) + var(--safe-bottom));
  background: var(--bg-canvas);
  border-top: 1px solid var(--border-soft);
}
.composer__icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  border-radius: var(--radius-pill);
  flex-shrink: 0;
  transition: background var(--duration-fast) var(--ease-out);
  position: relative;
}
.composer__icon-btn:hover {
  background: var(--border-soft);
}
.composer__icon-btn svg {
  width: 22px;
  height: 22px;
}
.composer__icon-btn--accent {
  color: var(--accent-warm-deep);
}
.composer__icon-btn--accent:hover {
  background: rgba(201, 183, 156, 0.15);
}
.dot-indicator {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-blush);
  box-shadow: 0 0 0 1.5px var(--bg-canvas);
}
.composer__input-wrap {
  flex: 1;
  min-width: 0;
}
.composer__input {
  width: 100%;
  height: 38px;
  padding: 0 var(--space-3);
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-pill);
  font-size: var(--fs-base);
  color: var(--text-primary);
  transition: border-color var(--duration-fast) var(--ease-out);
}
.composer__input:focus {
  border-color: var(--accent-primary);
}
.composer__send {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-primary);
  color: var(--text-inverse);
  border-radius: var(--radius-pill);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.composer__send svg {
  width: 20px;
  height: 20px;
}

/* ============== 思考中光球（覆盖层） ============== */
.thinking-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  pointer-events: none;
  background: rgba(245, 241, 235, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeIn var(--duration-base) var(--ease-out);
}
.thinking-orb {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}
.thinking-orb__bubble {
  background: var(--accent-secondary);
  color: var(--text-inverse);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 500;
  box-shadow: var(--shadow-md);
  position: relative;
  animation: bubbleFloat 2s ease-in-out infinite;
}
.thinking-orb__bubble::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  background: var(--accent-secondary);
  transform: translateX(-50%) rotate(45deg);
}
.thinking-orb__shape {
  width: 200px;
  height: 200px;
  background: var(--orb-gradient);
  border-radius: 50%;
  box-shadow: var(--shadow-orb);
  animation: orbMorph 4s ease-in-out infinite;
  position: relative;
}
.thinking-orb__shape::before {
  content: '';
  position: absolute;
  top: 20%;
  left: 25%;
  width: 30%;
  height: 20%;
  background: rgba(251, 248, 242, 0.5);
  border-radius: 50%;
  filter: blur(8px);
}
