:root {
  --bg: #ffffff;
  --chat-bg: #f7f7f8;
  --user-bubble: #2563eb;
  --user-bubble-text: #ffffff;
  --assistant-bubble: #ffffff;
  --assistant-bubble-text: #111827;
  --border: #e5e7eb;
  --muted: #6b7280;
  --error: #b91c1c;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--assistant-bubble-text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logout-btn {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}

.login-body {
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 280px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.login-card h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 8px;
  text-align: center;
}

.login-card input[type="password"] {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 15px;
  outline: none;
}

.login-card input[type="password"]:focus {
  border-color: var(--user-bubble);
}

.login-card button {
  border: none;
  border-radius: 10px;
  padding: 10px;
  background: var(--user-bubble);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

.login-error {
  color: var(--error);
  font-size: 13px;
  text-align: center;
}

.new-item-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
  color: var(--assistant-bubble-text);
}

.new-item-btn:hover {
  background: var(--chat-bg);
}

.chat {
  flex: 1;
  overflow-y: auto;
  background: var(--chat-bg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.row {
  display: flex;
  width: 100%;
}

.row.user {
  justify-content: flex-end;
}

.row.assistant {
  justify-content: flex-start;
}

.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.45;
  font-size: 15px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.row.user .bubble {
  background: var(--user-bubble);
  color: var(--user-bubble-text);
  border-bottom-right-radius: 4px;
}

.row.assistant .bubble {
  background: var(--assistant-bubble);
  color: var(--assistant-bubble-text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.bubble img.attached-photo,
.bubble img.generated-photo {
  display: block;
  max-width: min(60%, 320px);
  width: 100%;
  height: auto;
  border-radius: 10px;
  margin-top: 8px;
  cursor: zoom-in;
}

.description-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.copy-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--assistant-bubble-text);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
}

.copy-btn:hover {
  background: var(--chat-bg);
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 8px;
}

.lightbox button {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.lightbox button:hover {
  background: rgba(255, 255, 255, 0.3);
}

.bubble .warning {
  margin-top: 8px;
  font-size: 13px;
  color: #92400e;
}

.bubble .error {
  color: var(--error);
}

.typing {
  color: var(--muted);
  font-style: italic;
}

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}

.attach-btn:hover {
  background: var(--chat-bg);
}

#message-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 15px;
  outline: none;
}

#message-input:focus {
  border-color: var(--user-bubble);
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--user-bubble);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.send-btn:disabled {
  background: var(--muted);
  cursor: not-allowed;
}

.image-preview {
  position: relative;
  flex-shrink: 0;
}

.image-preview img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.image-preview button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--error);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
