* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, sans-serif;
  background: #f2f2f5;
  color: #222;
}

body.dragging {
  outline: 3px dashed #4a7dff;
  outline-offset: -8px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid #ddd;
}

header h1 {
  margin: 0;
  font-size: 1.1rem;
}

#list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  max-width: min(80%, 600px);
  align-self: flex-start;
  background: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.1);
}

.msg.mine {
  align-self: flex-end;
  background: #dbe6ff;
}

.msg .meta {
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 4px;
}

.msg .body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg img {
  display: block;
  max-width: 100%;
  max-height: 300px;
  border-radius: 6px;
  cursor: zoom-in;
}

.msg .actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.8rem;
}

.msg .actions button,
.msg .actions a {
  background: none;
  border: none;
  padding: 0;
  color: #4a7dff;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

#error {
  padding: 6px 12px;
  background: #fde8e8;
  color: #b3261e;
  font-size: 0.85rem;
}

#upload {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 12px;
  background: #fff;
  border-top: 1px solid #ddd;
  font-size: 0.85rem;
}

#upload[hidden] {
  display: none;
}

#idle {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(0 0 0 / 0.5);
  color: #fff;
  cursor: pointer;
}

#idle[hidden] {
  display: none;
}

#upload-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#composer[inert] {
  opacity: 0.6;
}

#composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 8px;
  background: #fff;
  border-top: 1px solid #ddd;
}

#composer textarea {
  flex: 1;
  resize: none;
  max-height: 40vh;
  padding: 8px;
  font: inherit;
}

#viewer {
  max-width: 100vw;
  max-height: 100dvh;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-out;
}

#viewer::backdrop {
  background: rgb(0 0 0 / 0.85);
}

#viewer img {
  display: block;
  max-width: 100vw;
  max-height: 100dvh;
  object-fit: contain;
}

#login form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#login-error {
  margin: 0;
  color: crimson;
}

.file-btn {
  cursor: pointer;
  font-size: 1.4rem;
  padding: 4px;
}
