:root {
  color-scheme: light;
  --portal-ink: #211d20;
  --portal-muted: #6f686d;
  --portal-line: #dedadd;
  --portal-surface: #ffffff;
  --portal-canvas: #f2f3f4;
  --portal-accent: #9b3d57;
  --portal-accent-dark: #742c40;
  --portal-vk: #2979ff;
  --portal-success: #287a5a;
  --portal-danger: #b33d4b;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html,
body { min-height: 100%; }

body {
  margin: 0;
  background: var(--portal-canvas);
  color: var(--portal-ink);
  font-size: 16px;
  letter-spacing: 0;
}

a { color: inherit; }
button, textarea, input { font: inherit; letter-spacing: 0; }
button, a, label { -webkit-tap-highlight-color: transparent; }

.portal-access {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(460px, 1.1fr);
  background: var(--portal-surface);
}

.portal-access-panel {
  width: min(100%, 620px);
  min-height: 100vh;
  padding: clamp(28px, 5vw, 72px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.portal-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--portal-ink);
  text-decoration: none;
}

.portal-brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.portal-brand span,
.portal-profile > span,
.portal-identity span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.portal-brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 19px; }
.portal-brand small,
.portal-profile small,
.portal-identity small { color: var(--portal-muted); font-size: 12px; }

.portal-access-copy {
  width: 100%;
  margin: auto 0 28px;
}

.portal-eyebrow {
  margin: 0 0 14px;
  color: var(--portal-accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.portal-access-copy h1 {
  max-width: 560px;
  margin: 0 0 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 56px;
  line-height: 1.02;
  font-weight: 500;
}

.portal-access-copy p:last-child {
  max-width: 520px;
  margin: 0;
  color: var(--portal-muted);
  font-size: 18px;
  line-height: 1.6;
}

.portal-access-photo {
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  background: #d9dddc;
}

.portal-access-photo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

.portal-button {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 6px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  color: #fff;
  text-decoration: none;
  font-weight: 750;
}

.portal-button--vk { background: var(--portal-vk); }
.portal-button--ok { background: #ee8208; }
.portal-button--primary { background: var(--portal-accent); }
.portal-button:hover { filter: brightness(0.96); }

.portal-vk-mark,
.portal-ok-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: #fff;
  font-size: 11px;
  font-weight: 900;
}

.portal-vk-mark { color: var(--portal-vk); }
.portal-ok-mark { color: #c86400; }

.portal-back-link {
  align-self: center;
  margin-top: 18px;
  color: var(--portal-muted);
  text-decoration: none;
  font-size: 14px;
}

.portal-link-button {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
}

.portal-logout-form { width: 100%; text-align: center; }

.portal-notice {
  width: 100%;
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--portal-line);
  border-radius: 6px;
  font-size: 14px;
}

.portal-notice--success { border-color: #badbcc; color: var(--portal-success); background: #eff8f4; }
.portal-notice--error { border-color: #ebc2c8; color: var(--portal-danger); background: #fff3f4; }

.portal-identity {
  width: 100%;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--portal-line);
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.portal-identity img {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
}

.portal-app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 68px minmax(0, 1fr);
}

.portal-topbar {
  padding: 0 28px;
  border-bottom: 1px solid var(--portal-line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--portal-surface);
}

.portal-topbar .portal-brand img { width: 38px; height: 38px; }
.portal-profile { display: flex; align-items: center; gap: 14px; text-align: right; }

.portal-icon-button,
.portal-send-button {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 1px solid var(--portal-line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--portal-surface);
  color: var(--portal-ink);
  cursor: pointer;
  text-decoration: none;
}

.portal-icon-button:hover { border-color: #aaa4a8; }

.portal-chat {
  width: min(100%, 980px);
  height: calc(100vh - 68px);
  min-height: 0;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--portal-surface);
  border-inline: 1px solid var(--portal-line);
}

.portal-chat-header {
  min-height: 74px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--portal-line);
  display: flex;
  align-items: center;
  gap: 12px;
}

.portal-photographer-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background: #d5d8d7;
}

.portal-photographer-avatar img { width: 100%; height: 100%; object-fit: cover; }
.portal-chat-header h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 20px; }
.portal-chat-header p { margin: 3px 0 0; color: var(--portal-muted); font-size: 13px; }
.portal-online-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--portal-success); }

.portal-message-list {
  min-height: 0;
  overflow-y: auto;
  padding: 24px max(18px, 5vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f6f7f7;
  scrollbar-gutter: stable;
}

.portal-empty-chat {
  margin: auto;
  display: grid;
  gap: 6px;
  color: var(--portal-muted);
  text-align: center;
}

.portal-empty-chat strong { color: var(--portal-ink); font-family: Georgia, "Times New Roman", serif; font-size: 22px; }

.portal-message {
  width: fit-content;
  max-width: min(76%, 620px);
  padding: 10px 13px;
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  background: var(--portal-surface);
}

.portal-message--own {
  align-self: flex-end;
  border-color: #e4c5ce;
  background: #faedf1;
}

.portal-message-meta { margin-bottom: 5px; display: flex; justify-content: space-between; gap: 18px; font-size: 11px; }
.portal-message-meta strong { color: var(--portal-accent-dark); }
.portal-message-meta time { color: var(--portal-muted); white-space: nowrap; }
.portal-message p { margin: 0; overflow-wrap: anywhere; line-height: 1.45; }

.portal-attachments { margin-top: 9px; display: grid; gap: 8px; }
.portal-media-preview { display: block; color: inherit; }
.portal-media-preview img,
.portal-video-preview {
  width: min(100%, 520px);
  max-height: 420px;
  border-radius: 5px;
  display: block;
  object-fit: contain;
  background: #181719;
}

.portal-file {
  min-height: 46px;
  padding: 6px 8px;
  border: 1px solid rgba(33, 29, 32, 0.12);
  border-radius: 5px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.7);
}

.portal-file > span:first-child { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #eef0f1; }
.portal-file > span:last-child { min-width: 0; display: grid; gap: 2px; }
.portal-file strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-file small { color: var(--portal-muted); }

.portal-compose {
  padding: 12px 16px;
  border-top: 1px solid var(--portal-line);
  background: var(--portal-surface);
}

.portal-compose-row { display: flex; align-items: flex-end; gap: 10px; }
.portal-compose textarea {
  width: 100%;
  min-height: 44px;
  max-height: 132px;
  resize: none;
  padding: 11px 14px;
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  color: var(--portal-ink);
  background: #f8f9f9;
  outline: none;
}

.portal-compose textarea:focus { border-color: var(--portal-accent); background: #fff; }
.portal-attach-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.portal-attach-button span { font-size: 25px; line-height: 1; }
.portal-send-button { border-color: var(--portal-accent); background: var(--portal-accent); color: #fff; font-size: 21px; }
.portal-send-button:disabled { opacity: 0.45; cursor: wait; }

.portal-upload-queue { margin: 0 54px 10px; display: grid; gap: 7px; }
.portal-upload-item { display: grid; grid-template-columns: minmax(0, 1fr) 140px; align-items: center; gap: 12px; font-size: 12px; }
.portal-upload-item span { min-width: 0; display: grid; gap: 2px; }
.portal-upload-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-upload-item small { color: var(--portal-muted); }
.portal-upload-item progress { width: 100%; accent-color: var(--portal-accent); }
.portal-upload-item--ready progress { accent-color: var(--portal-success); }
.portal-compose-error { margin: 8px 54px 0; color: var(--portal-danger); font-size: 13px; }

@media (max-width: 760px) {
  .portal-access { grid-template-columns: 1fr; min-height: 100dvh; }
  .portal-access-panel { min-height: 100dvh; padding: 24px 20px 32px; }
  .portal-access-copy { margin: auto 0 24px; }
  .portal-access-copy h1 { font-size: 38px; }
  .portal-access-copy p:last-child { font-size: 16px; }
  .portal-access-photo { display: none; }

  .portal-app { min-height: 100dvh; grid-template-rows: 60px minmax(0, 1fr); }
  .portal-topbar { padding: 0 12px; }
  .portal-topbar .portal-brand img { width: 34px; height: 34px; }
  .portal-topbar .portal-brand small,
  .portal-profile > span { display: none; }
  .portal-chat { height: calc(100dvh - 60px); border-inline: 0; }
  .portal-chat-header { min-height: 64px; padding: 8px 14px; }
  .portal-photographer-avatar { width: 44px; height: 44px; }
  .portal-message-list { padding: 16px 12px; }
  .portal-message { max-width: 88%; }
  .portal-compose { padding: 9px 8px max(9px, env(safe-area-inset-bottom)); }
  .portal-compose-row { gap: 7px; }
  .portal-icon-button,
  .portal-send-button { width: 42px; height: 42px; flex-basis: 42px; }
  .portal-upload-queue { margin: 0 0 9px; }
  .portal-upload-item { grid-template-columns: minmax(0, 1fr) 92px; }
  .portal-compose-error { margin-inline: 49px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

.portal-loading {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--portal-muted);
}
.portal-loading img { width: 64px; height: 64px; object-fit: contain; }
.portal-loading strong { color: var(--portal-ink); font-family: Georgia, "Times New Roman", serif; font-size: 22px; }
.portal-loading .portal-button { width: min(320px, 90vw); margin-top: 12px; }
noscript { display: block; padding: 24px; text-align: center; }
