:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #102331;
  background: #edf2f5;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: var(--viewport-height, 100dvh);
  overflow: hidden;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
.link-button {
  min-height: 44px;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
}

.app-header {
  flex: 0 0 auto;
  z-index: 10;
  min-height: 70px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  background: #12324a;
}

.test-mode .app-header {
  background: rgb(80, 160, 80);
}

.app-header h1,
.app-header p {
  margin: 0;
}

.app-header h1 {
  font-size: 1.2rem;
}

.app-header p {
  margin-top: 2px;
  color: #d4e3ed;
  font-size: .82rem;
}

.app-header > div {
  min-width: 0;
  flex: 1;
}

main {
  width: min(100%, 720px);
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  margin: 0 auto;
  background: #fff;
}

.hidden {
  display: none !important;
}

.primary,
.secondary,
.refresh,
.tab,
.icon-button {
  padding: 10px 14px;
}

.primary {
  color: #fff;
  background: #1a73e8;
}

.primary:disabled {
  opacity: .55;
}

.secondary:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.secondary,
.icon-button {
  color: #12324a;
  background: #fff;
}

.icon-button {
  min-width: 44px;
  padding: 6px;
  font-size: 1.4rem;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 12px 12px 4px;
}

.tab {
  color: #385466;
  background: #e6edf1;
}

.tab.active {
  color: #fff;
  background: #1a73e8;
}

.inbox-actions {
  display: flex;
  gap: 4px;
  padding: 4px 12px 8px;
}

.refresh {
  color: #1a73e8;
  background: transparent;
}

.search-wrap {
  display: grid;
  gap: 6px;
  padding: 4px 12px 12px;
  color: #6b7280;
  font-size: .82rem;
}

.search-wrap input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  color: #1a1a1a;
  background: #fff;
}

.conversation {
  position: relative;
  width: 100%;
  min-height: 78px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  text-align: left;
  color: inherit;
  background: #fff;
  border: 0;
  border-top: 1px solid #dce5ea;
  border-radius: 0;
}

.conversation.unread::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 0;
  width: 6px;
  border-radius: 0 4px 4px 0;
  background: #1971c2;
}

.conversation.unread strong,
.conversation.unread .preview {
  font-weight: 700;
}

.conversation strong,
.conversation span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation .preview {
  color: #526b79;
  font-size: .9rem;
}

.conversation time {
  color: #6d7d86;
  font-size: .78rem;
}

.empty {
  padding: 40px 24px;
  text-align: center;
  color: #60727d;
}

.thread {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.messages {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 12px;
}

.message {
  width: fit-content;
  max-width: 86%;
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #e8eef2;
}

.message.out {
  margin-left: auto;
  color: #fff;
  background: #1a73e8;
}

.message a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message time,
.message .media-note {
  display: block;
  margin-top: 5px;
  font-size: .72rem;
  opacity: .78;
}

.sent-media-preview {
  width: min(100%, 320px);
  max-height: 280px;
  display: block;
  margin-top: 8px;
  object-fit: contain;
  border-radius: 8px;
  background: #0f1720;
}

.sent-media-preview.expandable {
  cursor: zoom-in;
}

.sent-media-preview.expandable:focus-visible {
  outline: 3px solid #1a73e8;
  outline-offset: 2px;
}

.sent-file-card {
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #e8eef3;
  color: inherit;
  text-decoration: none;
  word-break: break-word;
}

.sent-media-status {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgb(255 255 255 / 18%);
  font-size: .8rem;
}

.sent-media-status.blocked {
  font-weight: 600;
}

.claim-panel {
  padding: 14px;
  border-bottom: 1px solid #dce5ea;
  background: #fff7dd;
}

.claim-panel p {
  margin-top: 0;
}

.claim-panel label,
.task-choice-wrap,
.composer label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  font-weight: 600;
}

.task-choice-wrap {
  padding: 10px 14px;
  margin-bottom: 0;
  border-bottom: 1px solid #dce5ea;
  background: #fff7dd;
}

.task-choice-wrap.hidden {
  display: none;
}

select,
textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #9fb0ba;
  border-radius: 8px;
  color: #102331;
  background: #fff;
}

textarea {
  resize: none;
  overflow: hidden;
}

.composer {
  flex: 0 0 auto;
  min-width: 0;
  overflow: hidden;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid #ccd8df;
  background: #fff;
}

.composer-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.attachment-button {
  position: relative;
  width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #9fb0ba;
  border-radius: 10px;
  font-size: 1.45rem;
  cursor: pointer;
}

.media-file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.composer .attachment-button {
  margin: 0;
  font-weight: 400;
}

.composer textarea {
  min-height: 44px;
  max-height: 96px;
  line-height: 1.35;
  overflow-y: auto;
}

.composer #send {
  width: auto;
  min-width: 64px;
  margin: 0;
}

.compose-body {
  display: grid;
  gap: 12px;
  padding: 16px 14px;
}

.compose-label {
  font-weight: 600;
  color: #102331;
}

#compose-phone,
#compose-body {
  width: 100%;
  padding: 10px;
  border: 1px solid #9fb0ba;
  border-radius: 8px;
  color: #102331;
  background: #fff;
}

#compose-body {
  resize: none;
  min-height: 72px;
  line-height: 1.35;
}

.compose-preview {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #dce5ea;
  border-radius: 8px;
  background: #f4f8fa;
}

.compose-warn {
  padding: 8px;
  border-radius: 6px;
  background: #fff7dd;
  color: #5b4a00;
  font-size: 13px;
}

.compose-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.compose-actions .primary {
  width: auto;
  min-width: 96px;
  margin: 0;
}

.media-list {
  margin-bottom: 8px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x proximity;
}

.media-item {
  width: min(82vw, 300px);
  flex: 0 0 auto;
  padding: 8px;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  border: 1px solid #ccd8df;
  border-radius: 8px;
  background: #f4f7f9;
  scroll-snap-align: start;
}

.media-preview {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  background: #dce5ea;
  object-fit: cover;
}

.media-preview-button {
  width: 64px;
  min-height: 64px;
  padding: 0;
  overflow: hidden;
  border-radius: 6px;
  background: #dce5ea;
}

.media-preview-button:focus-visible {
  outline: 3px solid #1a73e8;
  outline-offset: 2px;
}

.media-viewer {
  position: fixed;
  z-index: 100;
  inset: 0;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: rgb(0 0 0 / 92%);
}

.media-viewer-close {
  z-index: 1;
  justify-self: end;
  width: 44px;
  padding: 0;
  color: #fff;
  background: rgb(255 255 255 / 18%);
  font-size: 1.8rem;
  line-height: 1;
}

.media-viewer-content {
  min-height: 0;
  display: grid;
  place-items: center;
}

.media-viewer-content img,
.media-viewer-content video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.setup-card {
  min-height: 0;
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 20px;
  overflow-y: auto;
  color: #1d2f3a;
  background: #fff;
  border-radius: 12px;
  line-height: 1.45;
}

.setup-card h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.setup-card h3 {
  margin: 16px 0 6px;
  font-size: 1rem;
}

.setup-card ol {
  margin: 0;
  padding-left: 22px;
}

.setup-card li {
  margin: 6px 0;
}

.setup-card p {
  margin: 8px 0;
}

.media-details {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.media-details strong,
.media-details span {
  overflow-wrap: anywhere;
}

.media-details span {
  color: #526b79;
  font-size: .85rem;
}

.media-details progress {
  width: 100%;
}

.media-item .media-remove,
.media-item .media-retry {
  width: auto;
  margin-top: 0;
}

.media-item .media-remove {
  min-width: 36px;
  min-height: 36px;
  padding: 4px 10px;
  font-size: 1.2rem;
  line-height: 1;
}

.media-item .media-retry {
  justify-self: start;
  min-height: 36px;
  padding: 6px 12px;
}

.center-card {
  padding: 64px 24px;
  text-align: center;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  text-decoration: none;
}

.error {
  position: fixed;
  right: 12px;
  bottom: calc(var(--composer-height, 0px) + 12px);
  left: 12px;
  z-index: 20;
  width: min(calc(100% - 24px), 696px);
  margin: 0 auto;
  padding: 12px;
  border-radius: 10px;
  color: #fff;
  background: #9d2626;
}

.notice {
  position: fixed;
  right: 12px;
  bottom: calc(var(--composer-height, 0px) + 12px);
  left: 12px;
  z-index: 20;
  width: min(calc(100% - 24px), 696px);
  margin: 0 auto;
  padding: 12px;
  border-radius: 10px;
  color: #fff;
  background: #12324a;
}

@media (min-width: 721px) {
  main {
    border-right: 1px solid #dce5ea;
    border-left: 1px solid #dce5ea;
  }
}
