:root {
  --ink: #25231f;
  --muted: #77736d;
  --paper: #f8f5ef;
  --cream: #eee9df;
  --cream-deep: #e5ded2;
  --white: #fffdf9;
  --accent: #ef8b63;
  --accent-dark: #d96e49;
  --line: rgba(37, 35, 31, 0.12);
  --shadow: 0 24px 70px rgba(50, 44, 36, 0.12);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 4%, rgba(255, 255, 255, 0.9), transparent 30%),
    linear-gradient(140deg, #e9e4da 0%, #f8f5ef 44%, #eee7dc 100%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(1180px, calc(100vw - 40px));
  height: min(820px, calc(100vh - 40px));
  min-height: 640px;
  margin: 20px auto;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  overflow: hidden;
  background: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.profile-panel {
  position: relative;
  overflow: hidden;
  padding: 46px 42px 34px;
  background: var(--cream);
  border-right: 1px solid var(--line);
}

.profile-panel::before,
.profile-panel::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.profile-panel::before {
  width: 260px;
  height: 260px;
  top: -120px;
  right: -110px;
  border: 1px solid rgba(37, 35, 31, 0.08);
}

.profile-panel::after {
  width: 180px;
  height: 180px;
  left: -100px;
  bottom: -70px;
  background: rgba(255, 255, 255, 0.3);
}

.brand-mark {
  width: 34px;
  height: 26px;
  position: relative;
  margin-bottom: 38px;
}

.brand-mark span {
  position: absolute;
  top: 7px;
  width: 17px;
  height: 17px;
  background: var(--ink);
  border-radius: 70% 40% 55% 45%;
  transform: rotate(42deg);
}
.brand-mark span:first-child { left: 1px; }
.brand-mark span:last-child { right: 1px; transform: scaleX(-1) rotate(42deg); }

.portrait-wrap {
  position: relative;
  width: 156px;
  height: 156px;
  margin-bottom: 28px;
}

.portrait-wrap::before {
  content: "";
  position: absolute;
  inset: -9px;
  border: 1px solid rgba(37, 35, 31, 0.16);
  border-radius: 50%;
}

.portrait {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 30%;
  filter: saturate(0.75) contrast(1.03);
}

.online-dot {
  position: absolute;
  right: 8px;
  bottom: 12px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #6caa79;
  border: 4px solid var(--cream);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.profile-panel h1 {
  margin: 0;
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: 54px;
  font-weight: 500;
  letter-spacing: -0.05em;
}

.profile-copy {
  max-width: 280px;
  margin: 18px 0 26px;
  color: #625f59;
  font-size: 14px;
  line-height: 1.8;
}

.status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255, 253, 249, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 14px;
}

.status-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--accent-dark);
  background: rgba(239, 139, 99, 0.14);
  border-radius: 50%;
}

.status-card strong,
.status-card span { display: block; }
.status-card strong { font-size: 13px; }
.status-card div > span { margin-top: 3px; color: var(--muted); font-size: 11px; }

.cat-facts {
  margin-top: 25px;
  border-top: 1px solid var(--line);
}

.cat-facts div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.cat-facts span { color: var(--muted); }
.cat-facts strong { font-weight: 650; }

.privacy-note {
  position: absolute;
  left: 42px;
  right: 42px;
  bottom: 24px;
  z-index: 1;
  margin: 0;
  color: #8a857c;
  font-size: 10px;
  line-height: 1.5;
}

.chat-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr) auto;
  background:
    linear-gradient(rgba(255, 253, 249, 0.94), rgba(255, 253, 249, 0.94)),
    radial-gradient(circle at 80% 15%, rgba(239, 139, 99, 0.14), transparent 25%);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 30px;
  border-bottom: 1px solid var(--line);
}
.mobile-identity { display: none; }

.reset-button {
  padding: 9px 14px;
  color: #5c5851;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  transition: 160ms ease;
}
.reset-button:hover { color: var(--accent-dark); border-color: rgba(217, 110, 73, 0.45); }
.reset-button:focus-visible,
.suggestions button:focus-visible,
.action-button:focus-visible,
.attachment-card:focus-visible,
.send-button:focus-visible,
textarea:focus-visible { outline: 3px solid rgba(239, 139, 99, 0.24); outline-offset: 2px; }

.messages {
  overflow-y: auto;
  padding: 42px 56px 26px;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: #dcd5ca; border-radius: 99px; }

.welcome {
  max-width: 560px;
  margin: 10vh auto 0;
  animation: rise 500ms ease both;
}

.paw-badge {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 22px;
  color: var(--accent);
  background: #f6e9e1;
  border-radius: 50% 50% 46% 54%;
  font-size: 12px;
  box-shadow: inset 0 0 0 1px rgba(239, 139, 99, 0.12);
}

.welcome h2 {
  margin: 0 0 13px;
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: clamp(34px, 5vw, 48px);
  font-weight: 500;
  letter-spacing: -0.045em;
}

.welcome > p:not(.eyebrow) {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 28px;
}

.suggestions button {
  padding: 10px 14px;
  color: #5c5851;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  transition: 160ms ease;
}
.suggestions button:hover { color: var(--accent-dark); background: #fff7f1; border-color: rgba(239, 139, 99, 0.4); }

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto 22px;
  animation: rise 250ms ease both;
}
.message-row.user { justify-content: flex-end; }

.message-avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.message-stack { max-width: min(78%, 590px); }
.message-name { margin: 0 0 6px 2px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: 0.09em; }
.bubble {
  padding: 14px 17px;
  border-radius: 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.75;
}
.assistant .bubble { background: var(--cream); border-bottom-left-radius: 5px; }
.user .bubble { color: white; background: var(--ink); border-bottom-right-radius: 5px; }

.typing-dots { display: flex; align-items: center; gap: 5px; min-width: 62px; min-height: 51px; }
.typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: #9f9990; animation: bounce 1.15s infinite ease-in-out; }
.typing-dots span:nth-child(2) { animation-delay: 0.13s; }
.typing-dots span:nth-child(3) { animation-delay: 0.26s; }

.progress-row,
.action-row { align-items: flex-start; }
.progress-row .message-stack,
.action-row .message-stack { width: min(82%, 620px); max-width: min(82%, 620px); }

.progress-card,
.action-card {
  padding: 16px 17px;
  background: #f3eee5;
  border: 1px solid rgba(37, 35, 31, 0.08);
  border-radius: 18px;
  border-bottom-left-radius: 5px;
}

.progress-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 11px;
  font-size: 13px;
}

.progress-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(239, 139, 99, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.progress-list { display: grid; gap: 7px; }
.progress-item {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 7px;
  color: #6e6961;
  font-size: 11px;
  line-height: 1.5;
}
.progress-item.done,
.progress-item.success { color: #537a5b; }
.progress-item.doing,
.progress-item.running { color: var(--accent-dark); }
.progress-item.failed,
.progress-item.error { color: #b4493e; }
.progress-item.info { color: #6c6870; }

.attachment-list { display: grid; gap: 8px; margin-top: 9px; }
.attachment-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  color: var(--ink);
  text-decoration: none;
  background: white;
  border: 1px solid var(--line);
  border-radius: 13px;
  transition: 160ms ease;
}
.attachment-card:hover { border-color: rgba(239, 139, 99, 0.6); transform: translateY(-1px); }
.attachment-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--accent-dark);
  background: #f8ebe4;
  border-radius: 10px;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.08em;
}
.attachment-copy { min-width: 0; }
.attachment-copy strong,
.attachment-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-copy strong { font-size: 12px; }
.attachment-copy small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.attachment-arrow { color: var(--accent-dark); font-size: 16px; }

.action-card { background: #fff8f3; border-color: rgba(239, 139, 99, 0.32); }
.action-eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--accent-dark);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.action-title { display: block; font-family: Georgia, "Noto Serif TC", serif; font-size: 19px; }
.action-card p { margin: 10px 0; color: #5e5951; white-space: pre-wrap; font-size: 12px; line-height: 1.65; }
.action-card small { display: block; color: #8b8379; font-size: 10px; line-height: 1.55; }
.action-unavailable { margin-top: 12px; color: #a44c3e; font-size: 11px; line-height: 1.55; }
.action-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }
.action-button {
  padding: 9px 13px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
}
.action-button.primary { color: white; background: var(--accent); border-color: var(--accent); }
.action-button.secondary { color: #615c55; background: white; }
.action-button:disabled { cursor: not-allowed; opacity: 0.55; }

.composer-wrap {
  padding: 17px 34px 18px;
  background: linear-gradient(to top, var(--white) 78%, rgba(255, 253, 249, 0));
}

.composer {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 9px 9px 9px 19px;
  background: white;
  border: 1px solid rgba(37, 35, 31, 0.14);
  border-radius: 22px;
  box-shadow: 0 12px 32px rgba(50, 44, 36, 0.08);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.composer:focus-within { border-color: rgba(239, 139, 99, 0.65); box-shadow: 0 14px 36px rgba(50, 44, 36, 0.1); }

textarea {
  flex: 1;
  min-width: 0;
  max-height: 150px;
  padding: 10px 0;
  resize: none;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  line-height: 1.5;
}
textarea::placeholder { color: #aaa49b; }

.send-button {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: white;
  background: var(--accent);
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  transition: 160ms ease;
}
.send-button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.send-button:disabled { cursor: not-allowed; opacity: 0.55; transform: none; }
.send-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.composer-note { margin: 8px auto 0; color: #aaa49b; text-align: center; font-size: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  body { background: var(--white); }
  .app-shell { width: 100%; height: 100dvh; min-height: 0; margin: 0; grid-template-columns: 1fr; border: 0; border-radius: 0; }
  .profile-panel { display: none; }
  .chat-panel { grid-template-rows: 68px minmax(0, 1fr) auto; }
  .chat-header { justify-content: space-between; padding: 0 18px; }
  .mobile-identity { display: flex; align-items: center; gap: 10px; }
  .mobile-identity img { width: 39px; height: 39px; border-radius: 50%; object-fit: cover; }
  .mobile-identity strong, .mobile-identity span { display: block; }
  .mobile-identity strong { font-family: Georgia, "Noto Serif TC", serif; font-size: 17px; }
  .mobile-identity span { margin-top: 2px; color: var(--muted); font-size: 9px; }
  .messages { padding: 28px 18px 16px; }
  .welcome { margin-top: 7vh; }
  .welcome h2 { font-size: 38px; }
  .message-stack { max-width: 84%; }
  .progress-row .message-stack,
  .action-row .message-stack { width: 88%; max-width: 88%; }
  .composer-wrap { padding: 12px 12px max(12px, env(safe-area-inset-bottom)); }
  .composer-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
