:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --line: #d1d5db;
  --text: #111827;
  --accent: #0f766e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(160deg, #ecfeff, #f9fafb 45%, #f0fdf4);
  color: var(--text);
  font-family: 'Segoe UI', 'Noto Sans KR', sans-serif;
}

.chat-shell {
  width: min(760px, 92vw);
  margin: 40px auto;
  display: grid;
  gap: 16px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.back-btn {
  width: auto;
  border-radius: 999px;
  padding: 8px 14px;
  background: #334155;
  font-size: 13px;
}

.back-btn:hover {
  background: #1f2937;
}

.secondary-btn {
  width: auto;
  background: #e2e8f0;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  padding: 8px 12px;
}

.secondary-btn:hover {
  background: #cbd5e1;
}

.typing-indicator {
  margin-top: 4px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  color: #075985;
  font-size: 13px;
  font-weight: 600;
}

.pinned-message {
  margin-top: 8px;
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fef9c3;
  border: 1px solid #fde68a;
  font-size: 13px;
  color: #92400e;
}

.chat-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 8px 0;
}

.status-badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
}

.status-pending {
  background: #fef3c7;
  color: #92400e;
}

.status-approved {
  background: #dcfce7;
  color: #166534;
}

.status-rejected {
  background: #fee2e2;
  color: #991b1b;
}

.message-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.message-text {
  flex: 1;
}

.pin-btn {
  width: auto;
  padding: 2px 8px;
  font-size: 11px;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.attachment {
  margin-top: 6px;
}

.attachment img {
  max-width: 240px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

label {
  display: block;
  margin-bottom: 10px;
  font-size: 14px;
}

input,
button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
}

input.is-readonly {
  background: #f3f4f6;
  color: #4b5563;
}

.linked-account {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  border-radius: 12px;
}

.linked-account img {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid #cbd5e1;
}

.linked-account strong {
  display: block;
  font-size: 15px;
  margin-bottom: 2px;
}

.linked-account p {
  margin: 0;
  font-size: 13px;
  color: #475569;
}

#messages {
  height: 360px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin: 10px 0;
  background: #fafafa;
}

.message {
  margin-bottom: 8px;
  font-size: 14px;
  word-break: break-word;
}

.message.system {
  color: #6b7280;
}

.hidden {
  display: none;
}

#message-form {
  display: grid;
  grid-template-columns: 1fr 100px;
  gap: 8px;
}

@media (max-width: 640px) {
  .chat-shell {
    margin: 20px auto;
  }

  .header-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .back-btn {
    width: 100%;
  }

  #messages {
    height: 300px;
  }

  #message-form {
    grid-template-columns: 1fr;
  }

  .chat-tools {
    grid-template-columns: 1fr;
  }
}
