:root {
  --bg: #f6f8fd;
  --panel: #fefefe;
  --line: #dde3ef;
  --ink: #111827;
  --muted: #556174;
  --primary: #0f5c5d;
  --user: #d9f4ff;
  --assistant: #f3f5ff;
  --shadow: 0 12px 30px rgba(8, 24, 43, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: radial-gradient(circle at top left, #e6ecff, var(--bg));
  color: var(--ink);
}

.app-shell {
  width: min(860px, 96vw);
  height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 0.9rem;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}

.top-bar h1 {
  font-size: 1.1rem;
  margin: 0;
}

.top-bar button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
}

.chat-area {
  flex: 1;
  overflow: auto;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), #fff);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.message {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: var(--user);
  max-width: 78%;
}

.message.assistant {
  align-self: flex-start;
  background: var(--assistant);
  max-width: 78%;
}

.message img {
  width: 180px;
  max-width: 100%;
  border-radius: 10px;
  margin-top: 0.4rem;
  display: block;
}

.chat-form {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 14px;
  padding: 0.65rem;
}

.chat-form textarea {
  width: 100%;
  border: 1px solid #d5dceb;
  border-radius: 10px;
  padding: 0.8rem;
  min-height: 74px;
  resize: none;
  font: inherit;
}

.form-actions {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

.form-actions button,
.attach-button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}

.attach-button {
  position: relative;
}

.attach-button input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.fast-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-right: auto;
  color: var(--muted);
  font-size: 0.9rem;
}

.fast-toggle input {
  margin: 0;
}

#sendBtn {
  background: var(--primary);
  color: white;
  font-weight: 700;
  border-color: var(--primary);
}

#sendBtn:disabled,
input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.preview-wrap {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 0.55rem;
  margin-bottom: 0.55rem;
  width: 100%;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.preview-meta {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.preview-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-size {
  color: var(--muted);
  font-size: 0.82rem;
}

.preview-wrap img {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 8px;
  flex: 0 0 auto;
}

.preview-wrap button {
  margin-left: 0.35rem;
  cursor: pointer;
}

.status {
  margin: 0.2rem 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

@media (max-width: 600px) {
  .app-shell {
    height: 100dvh;
    width: 100vw;
    padding: 0.7rem;
  }

  .message.user,
  .message.assistant {
    max-width: 100%;
  }
}
