:root {
  --accent: #2f6f4f;
  --bg: #f5f3ee;
  --bubble-bot: #ffffff;
  --bubble-user: #2f6f4f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: #222;
  height: 100vh;
  height: 100dvh; /* 모바일 브라우저 주소창 때문에 100vh가 실제 화면보다 커지는 문제 보정 */
  overflow: hidden;
}

.screen {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
}

.hidden { display: none !important; }

h1 { font-size: 1.4rem; margin: 8px 0 4px; }
.hint { color: #777; margin-bottom: 20px; font-size: 0.95rem; }

input[type="password"], input[type="text"], textarea {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid #ddd;
  border-radius: 12px;
  margin-bottom: 12px;
}

textarea {
  resize: none;
  line-height: 1.4;
  max-height: 120px;
  overflow-y: auto;
}

input[type="file"] { margin-bottom: 16px; }

button {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  margin-bottom: 10px;
}

button.secondary {
  background: #e8e6df;
  color: #333;
}

.error { color: #c0392b; font-size: 0.9rem; }

#account-section { margin-bottom: 22px; }

.account-row-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.help-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e8e6df;
  color: #555;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#account-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 2px solid #e5e3dc;
  border-radius: 12px;
  background: white;
  cursor: pointer;
}

.account-card.selected { border-color: var(--accent); background: #f0f7f3; }
.account-card.disabled { opacity: 0.5; cursor: default; }

.account-card .name { font-weight: 600; }
.account-card .status { font-size: 0.8rem; color: #888; margin-top: 2px; }
.account-card .status.ok { color: var(--accent); }
.account-card .status.warn { color: #c0392b; }

.account-card .connect-link {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-end;
  z-index: 50;
}

.modal-box {
  background: white;
  width: 100%;
  max-height: 80vh;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  font-weight: 700;
  border-bottom: 1px solid #eee;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
}

.modal-body h3 { margin: 14px 0 6px; font-size: 1rem; }
.modal-body h3:first-child { margin-top: 0; }
.modal-body p { margin: 0 0 8px; font-size: 0.92rem; line-height: 1.55; color: #333; }

#photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
#photo-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
}

#chat-screen { padding: 0; }

#chat-header {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  background: white;
  flex-shrink: 0;
}
#chat-header button {
  width: auto;
  background: none;
  color: #777;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 4px;
  margin-bottom: 0;
}

#chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble {
  max-width: 82%;
  padding: 12px 14px;
  border-radius: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  font-size: 0.97rem;
}

.bubble.bot {
  background: var(--bubble-bot);
  border: 1px solid #eee;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.bubble.user {
  background: var(--bubble-user);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.bubble img {
  max-width: 160px;
  border-radius: 10px;
  display: block;
}

.bubble.draft {
  background: #fff;
  border: 1px solid #ddd;
  align-self: stretch;
  max-width: 100%;
  font-size: 0.9rem;
}

.input-area {
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: white;
  border-top: 1px solid #eee;
}

.input-area input, .input-area textarea { margin-bottom: 0; flex: 1; max-height: 100px; }
.input-area button { padding: 10px 12px; font-size: 0.9rem; }
.input-area .icon-btn { width: 44px; padding: 10px 0; font-size: 1.1rem; flex-shrink: 0; }
.input-area button { width: auto; padding: 12px 16px; margin-bottom: 0; white-space: nowrap; }

.spinner {
  align-self: flex-start;
  color: #999;
  font-size: 0.9rem;
}
