/* ============================================================
   EchoChat Rebuild · Responsive Styles
   断点：<768px 移动端 / 768-1024px 平板 / >1024px 桌面
   ============================================================ */

/* ---- 桌面端（默认）---- */
@media (min-width: 1024px) {
  .nav-rail {
    display: flex;
  }
  .bottom-nav {
    display: none;
  }
  .list-pane {
    display: flex;
  }
  .app-shell {
    width: 100%;
    max-width: none;
    margin: 0;
  }
  .chat-pane {
    min-width: 360px;
    flex: 1;
  }
  .chat-messages {
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
    padding-left: var(--space-5);
    padding-right: var(--space-5);
  }
  .chat-input-area {
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
    padding-left: var(--space-5);
    padding-right: var(--space-5);
  }
  .chat-empty {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

@media (min-width: 1024px) and (max-width: 1279px) {
  :root {
    --list-width: 260px;
  }
  .profile-pane {
    display: none;
  }
  .profile-pane.open {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-drawer);
    background: var(--color-surface-elevated, var(--color-surface));
    border-left: 1px solid color-mix(in srgb, var(--color-mint) 28%, var(--color-border));
    box-shadow: var(--shadow-xl);
  }
}

@media (min-width: 1280px) {
  .profile-pane {
    display: flex;
    width: var(--profile-width);
  }
  .profile-close {
    display: none;
  }
}

/* ---- 平板端（768-1024px）---- */
@media (min-width: 768px) and (max-width: 1023px) {
  :root {
    --list-width: 260px;
    --profile-width: 280px;
  }
  .nav-rail {
    display: flex;
  }
  .bottom-nav {
    display: none;
  }
  .profile-pane {
    display: none; /* 平板默认隐藏资料面板，通过按钮打开抽屉 */
  }
  .profile-pane.open {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-drawer);
    background: var(--color-surface-elevated, var(--color-surface));
    border-left: 1px solid color-mix(in srgb, var(--color-mint) 28%, var(--color-border));
    box-shadow: var(--shadow-xl);
  }
}

/* ---- 移动端（<768px）---- */
@media (max-width: 767px) {
  :root {
    --sidebar-width: 0px;
    --topbar-height: 52px;
    --input-height: 48px;
  }

  .nav-rail {
    display: none;
  }
  .app-shell {
    flex-direction: column;
  }
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    width: 100%;
  }
  .moments-pane,
  .me-pane {
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
  }
  .chat-back-btn {
    display: flex;
  }
  .continuity-legend {
    display: none;
  }

  /* 会话列表：全屏覆盖 */
  .list-pane {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: var(--bottom-nav-height);
    width: 100%;
    z-index: var(--z-base);
    border-right: none;
  }
  .list-pane.hidden-mobile {
    display: none;
  }

  /* 聊天区：默认隐藏，选中会话后显示 */
  .chat-pane {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: var(--bottom-nav-height);
    z-index: var(--z-sticky);
    background: var(--color-bg);
  }
  .app-shell-chat .chat-pane {
    top: var(--vv-top, 0px);
    height: var(--app-height, 100dvh);
    bottom: auto;
  }
  .chat-pane.hidden-mobile {
    display: none;
  }

  /* 资料面板：抽屉 */
  .profile-pane {
    display: none;
  }
  .profile-pane.open {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 85vw;
    max-width: 320px;
    z-index: var(--z-drawer);
    background: var(--color-surface-elevated, var(--color-surface));
    border-left: 1px solid color-mix(in srgb, var(--color-mint) 28%, var(--color-border));
    box-shadow: var(--shadow-xl);
    animation: drawer-in var(--dur-normal) var(--ease-out);
  }

  /* Landing */
  .welcome-screen {
    padding: 40px 20px 48px;
    justify-content: center;
  }
  .welcome-screen h1 {
    font-size: 24px;
  }
  .welcome-lead {
    font-size: 14px;
    max-width: none;
  }
  .welcome-beats {
    grid-template-columns: minmax(0, 1fr);
    max-width: 22em;
  }
  .onboard-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Onboarding */
  .onboarding-body {
    padding: var(--space-4);
  }
  .onboarding-footer {
    padding: var(--space-3) var(--space-4);
    padding-bottom: calc(var(--space-3) + var(--safe-bottom));
  }

  /* 弹窗：底部 Sheet */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: min(92dvh, calc(100dvh - var(--safe-bottom)));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: motion-sheet var(--dur-normal) var(--ease-drawer, var(--ease-out));
  }
  .modal-handle {
    display: block;
  }
  .modal-header,
  .modal-body {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
  .modal-footer {
    padding: var(--space-3) var(--space-4);
    padding-bottom: calc(var(--space-3) + var(--safe-bottom));
  }
  .modal-footer .btn {
    flex: 1 1 calc(50% - 8px);
  }

  .api-block,
  .api-block-head,
  .key-steps,
  .preset-card,
  .theme-swatch {
    min-width: 0;
  }
  .api-block-head {
    flex-wrap: wrap;
  }
  .api-more-toggle {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .api-more-toggle .sub {
    white-space: normal;
  }
  .key-steps,
  .key-steps li,
  .preset-card .pnote {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .chip-btn span {
    display: none;
  }

  /* 气泡列宽：相对整行约束，避免嵌套百分比把短消息挤瘦、长消息撑出 */
  .msg {
    padding: 8px 12px;
  }
  .msg-col {
    max-width: calc(100% - 48px);
  }

  /* 动态页 */
  .moments-feed {
    padding: var(--space-3);
  }

  /* 我的页 */
  .me-content {
    padding: var(--space-4);
  }

  /* Toast：默认贴底避开底栏；打开弹层或聊天时改到顶部，避免挡住操作 */
  .toast-container {
    top: auto;
    bottom: calc(var(--bottom-nav-height) + var(--space-4) + var(--safe-bottom));
  }
  body:has(.modal-overlay) .toast-container,
  body:has(.app-shell-chat) .toast-container {
    top: calc(var(--space-3) + var(--safe-top));
    bottom: auto;
  }
}

/* ---- 超小屏（<380px）---- */
@media (max-width: 379px) {
  :root {
    --font-body: 14px;
    --font-section: 16px;
    --font-title: 18px;
  }
  .welcome-screen h1 {
    font-size: 22px;
  }
  .onboard-grid {
    grid-template-columns: 1fr;
  }
  .msg-bubble {
    max-width: 90%;
  }
}

/* ---- 横屏移动端 ---- */
@media (max-height: 500px) and (orientation: landscape) {
  .bottom-nav {
    display: none;
  }
  .nav-rail {
    display: flex;
    width: 56px;
  }
  .list-pane {
    position: static;
    width: 240px;
    bottom: 0;
  }
  .chat-pane {
    position: static;
    bottom: 0;
  }
}

/* ---- 大屏优化（>1440px）---- */
@media (min-width: 1440px) {
  :root {
    --list-width: 340px;
    --profile-width: 360px;
  }
}

/* ---- 打印样式 ---- */
@media print {
  .nav-rail,
  .bottom-nav,
  .chat-input-area,
  .list-pane,
  .profile-pane {
    display: none !important;
  }
  .chat-pane {
    position: static;
  }
}
