:root {
  --bg: #0f141a;
  --panel: #18222d;
  --incoming: #202d3a;
  --text: #ecf1f7;
  --muted: #94a2b3;
  --accent: #3390ec;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  justify-content: center;
  position: relative;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 14, 18, 0.92);
  backdrop-filter: blur(6px);
}

.auth-overlay[hidden],
.app[hidden],
.progress[hidden],
.result[hidden],
.photo-preview[hidden] {
  display: none !important;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 22px 20px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid #314154;
}

.login-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.login-hint {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}

.login-field input,
.field input,
.field textarea {
  border: 1px solid #314154;
  border-radius: 10px;
  background: #111923;
  color: var(--text);
  font-size: 16px;
  padding: 12px;
  outline: none;
  font-family: inherit;
}

.login-field input:focus,
.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
}

.login-error {
  margin: 0 0 12px;
  font-size: 13px;
  color: #f07178;
}

.login-submit {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--accent);
}

.login-submit:active {
  opacity: 0.9;
}

.login-submit:disabled {
  opacity: 0.7;
  cursor: default;
}

.login-field[hidden],
.login-submit[hidden] {
  display: none !important;
}

.app {
  width: 100%;
  max-width: 760px;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #121922;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #273445;
  background: rgba(16, 23, 32, 0.92);
}

.header-text {
  flex: 1;
  min-width: 0;
}

.header-text h1 {
  margin: 0;
  font-size: 16px;
}

.header-text p {
  margin: 2px 0 0;
  font-size: 12px;
}

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

.header-btn {
  border: 1px solid #314154;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 10px;
  cursor: pointer;
}

.header-btn-logout {
  color: #d7dee8;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.online-dot {
  color: #7ad17a;
}

.status-warn {
  color: #e0b15a;
}

.header-user-sep {
  color: var(--muted);
}

.header-user {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 42vw;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.workspace {
  min-height: 0;
  overflow-y: auto;
  padding: 16px 16px 28px;
}

.intro-card {
  margin: 0 0 16px;
  padding: 14px 14px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid #314154;
}

.intro-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

.report-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}

.field textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.4;
}

.dropzone {
  display: block;
  border: 1px dashed #3d5166;
  border-radius: 12px;
  padding: 18px 12px;
  text-align: center;
  background: #111923;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.dropzone input {
  display: none;
}

.dropzone.dragover {
  border-color: var(--accent);
  color: var(--text);
}

.photo-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.photo-preview figure {
  margin: 0;
  position: relative;
}

.photo-preview img {
  width: 100%;
  height: 88px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #314154;
  display: block;
}

.photo-preview button {
  position: absolute;
  top: 4px;
  right: 4px;
  border: none;
  border-radius: 8px;
  width: 22px;
  height: 22px;
  background: rgba(12, 16, 22, 0.8);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.progress {
  margin-top: 18px;
  padding: 16px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid #314154;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.progress p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.4;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid #314154;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.result {
  margin-top: 18px;
  padding: 16px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid #314154;
}

.result-ok {
  color: #7ad17a;
  margin: 0 0 10px;
  font-size: 14px;
}

.result-err {
  color: #f07178;
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}

.result a {
  color: #7ec8ff;
  word-break: break-all;
}

.download-btn {
  display: inline-block;
  margin-top: 8px;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

@media (max-width: 480px) {
  .workspace {
    padding: 12px 12px 24px;
  }
}
