:root {
      color-scheme: light;
      --bg: #f6f7f9;
      --panel: #ffffff;
      --line: #d9dee7;
      --text: #18212f;
      --muted: #667085;
      --brand: #1769e0;
      --agent: #ffffff;
      --user: #dbeafe;
      --system: #eef2f7;
    }

    * {
      box-sizing: border-box;
    }

    html, body {
      margin: 0;
      padding: 0;
      height: 100%;
      font-family: Arial, "Microsoft YaHei", sans-serif;
      color: var(--text);
      background: var(--bg);
    }

    .app {
      /* 移动端 100vh 在 iOS Safari 上不会随地址栏收缩，
         用 100dvh / 100svh 取动态视口，回退到 100vh。 */
      height: 100vh;
      height: 100svh;
      height: 100dvh;
      display: grid;
      grid-template-rows: auto 1fr auto auto;
      max-width: 760px;
      margin: 0 auto;
      background: var(--panel);
      border-left: 1px solid var(--line);
      border-right: 1px solid var(--line);
    }

    header {
      padding: 10px 16px;
      border-bottom: 1px solid var(--line);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .name {
      font-size: 16px;
      font-weight: 700;
      min-width: 0;
      overflow-wrap: anywhere;
    }

    .status {
      flex: 0 0 auto;
      color: var(--muted);
      font-size: 13px;
    }

    .notice {
      display: none;
      font-size: 12px;
      padding: 6px 12px;
      background: #fff7e6;
      color: #92400e;
      border-bottom: 1px solid #facc15;
      cursor: pointer;
    }

    .notice[data-show="1"] {
      display: block;
    }

    main {
      overflow: auto;
      min-height: 0;
      padding: 12px;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    .msg {
      width: fit-content;
      max-width: min(82%, 560px);
      padding: 10px 12px;
      border: 1px solid var(--line);
      border-radius: 8px;
      white-space: pre-wrap;
      overflow-wrap: anywhere;
      line-height: 1.55;
      font-size: 14px;
    }

    .msg.agent {
      background: var(--agent);
      align-self: flex-start;
    }

    .msg.user {
      background: var(--user);
      border-color: #bfdbfe;
      align-self: flex-end;
    }

    .msg.system {
      max-width: 100%;
      background: var(--system);
      color: var(--muted);
      align-self: center;
      text-align: center;
      font-size: 13px;
    }

    .from {
      color: var(--muted);
      font-size: 12px;
      margin-bottom: 4px;
    }

    .media {
      display: block;
      max-width: 100%;
      width: min(360px, 100%);
      max-height: 360px;
      object-fit: contain;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #f3f4f6;
    }

    .file-card,
    .expired {
      width: min(360px, 100%);
      min-height: 86px;
      border: 1px solid var(--line);
      border-radius: 6px;
      display: grid;
      align-items: center;
      padding: 12px;
      background: #f8fafc;
      color: var(--muted);
      overflow-wrap: anywhere;
    }

    .note-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
      gap: 8px;
      margin-top: 8px;
      width: min(420px, 100%);
    }

    .quick {
      display: flex;
      gap: 8px;
      overflow-x: auto;
      padding: 8px 12px 0;
      border-top: 1px solid var(--line);
    }

    .quick button {
      flex: 0 0 auto;
      border: 1px solid #1457c8;
      background: #e8f1ff;
      color: #0f3f95;
      height: 36px;
      border-radius: 6px;
      padding: 0 12px;
      cursor: pointer;
      font-weight: 700;
      max-width: 220px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 13px;
      box-shadow: 0 1px 2px rgba(15, 63, 149, .14);
    }

    .quick button:hover,
    .quick button:focus-visible {
      background: #1769e0;
      border-color: #1769e0;
      color: #fff;
      outline: none;
    }

    .quick button:active {
      background: #0f55bd;
      border-color: #0f55bd;
    }

    footer {
      padding: 8px 12px;
      padding-bottom: max(8px, env(safe-area-inset-bottom));
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 8px;
      border-top: 0;
    }

    textarea {
      width: 100%;
      min-height: 40px;
      max-height: 120px;
      resize: vertical;
      border: 1px solid var(--line);
      border-radius: 6px;
      padding: 8px 10px;
      font: inherit;
      line-height: 1.4;
    }

    .send {
      width: 64px;
      border: 0;
      border-radius: 6px;
      background: var(--brand);
      color: #fff;
      font-weight: 700;
      cursor: pointer;
    }

    @media (max-width: 640px) {
      .app {
        border: 0;
      }

      header {
        padding: 8px 12px;
      }

      .msg {
        max-width: 90%;
      }
    }
