@font-face {
  font-family: "Golos";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/golos-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153;
}

@font-face {
  font-family: "Golos";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/golos-400.woff2") format("woff2");
  unicode-range: U+0400-04FF, U+0500-052F;
}

@font-face {
  font-family: "Golos";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/golos-500.woff2") format("woff2");
  unicode-range: U+0400-04FF, U+0500-052F;
}

@font-face {
  font-family: "Unbounded";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/unbounded-latin-600.woff2") format("woff2");
  unicode-range: U+0000-00FF;
}

@font-face {
  font-family: "Unbounded";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/unbounded-600.woff2") format("woff2");
  unicode-range: U+0400-04FF;
}

:root {
  --desk: #6f86a0;
  --desk-deep: #4d647a;
  --sheet: #e7f0f6;
  --ink: #142433;
  --mute: #5b7388;
  --rule: #b9c9d6;
  --lamp: #e6b422;
  --stamp: #c42b22;
  --mine: #1c3b56;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 17px/1.45 Golos, "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, #88a0b6, transparent),
    linear-gradient(180deg, var(--desk) 0%, var(--desk-deep) 100%);
}

.desk {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px 20px;
}

.sheet {
  width: min(520px, 100%);
  background:
    linear-gradient(90deg, transparent 47px, #d7e4ee 47px, #d7e4ee 48px, transparent 48px),
    var(--sheet);
  box-shadow: 0 18px 50px rgba(20, 36, 51, .28), 0 0 0 1px rgba(20, 36, 51, .08);
  position: relative;
  display: flex;
  flex-direction: column;
}

.lamp {
  height: 7px;
  background: linear-gradient(90deg, #c49212, var(--lamp), #fff1b0 46%, var(--lamp));
}

.docno {
  margin: 0;
  padding: 14px 28px 0;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--mute);
}

h1 {
  font-family: Unbounded, Golos, sans-serif;
  font-size: clamp(42px, 7vw, 64px);
  font-weight: 600;
  letter-spacing: -.04em;
  margin: 8px 28px 0;
}

.lead, .hint, p { color: var(--mute); }
.lead { margin: 10px 28px 28px; max-width: 22em; }

label {
  display: block;
  margin: 0 28px 8px;
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--mute);
}

input[type="password"], textarea, select {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  padding: 8px 0;
}

input[type="password"] {
  width: calc(100% - 56px);
  margin: 0 28px;
  font-size: 20px;
}

textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
}

button {
  font: 500 16px/1 Golos, sans-serif;
  border: 0;
  background: var(--ink);
  color: var(--sheet);
  padding: 12px 18px;
  cursor: pointer;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
  padding: 8px 12px;
}

button:disabled { opacity: .4; cursor: default; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--lamp);
  outline-offset: 3px;
}

.login-actions { margin: 28px 28px 0; }
.err {
  color: var(--stamp);
  min-height: 1.3em;
  margin: 14px 28px 24px;
}

#gate, #app { width: 100%; display: flex; justify-content: center; }
#app { display: none; height: calc(100vh - 48px); }
body.ready #gate { display: none; }
body.ready #app { display: flex; }
body.ready .desk { align-items: stretch; }
body.ready .sheet { width: min(820px, 100%); }

.journal { height: 100%; }

header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 28px 12px;
  border-bottom: 1px solid var(--rule);
}

header strong {
  display: block;
  font-family: Unbounded, Golos, sans-serif;
  font-size: 28px;
  letter-spacing: -.03em;
}

header .docno { padding: 0; }
.tools { display: flex; gap: 8px; align-items: center; }
select { width: auto; padding: 7px 4px; }

#log {
  flex: 1;
  overflow: auto;
  padding: 8px 0 12px;
}

.msg {
  display: grid;
  grid-template-columns: 72px minmax(42px, 78px) 1fr;
  gap: 10px;
  padding: 10px 28px;
  border-bottom: 1px solid #d5e2ec;
}

.msg .when, .msg .who {
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--mute);
  padding-top: 3px;
}

.msg.user .who { color: var(--mine); }
.msg .body { min-width: 0; }
.msg .bubble { white-space: pre-wrap; }

.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.msg .thumbs { margin-top: 8px; }

.thumb {
  position: relative;
  width: 112px;
  background: #f4f8fb;
  border: 1px solid var(--rule);
}

.thumb button.look {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.thumb img {
  display: block;
  width: 100%;
  height: 86px;
  object-fit: cover;
}

.thumb .filechip {
  display: block;
  padding: 18px 8px;
  font-size: 13px;
  text-align: left;
}

.thumb .drop {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: var(--ink);
  color: var(--sheet);
  font-size: 14px;
  line-height: 22px;
}

.attach-bar { margin-bottom: 12px; }
.attach-count {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--mute);
}

#lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: rgba(20, 36, 51, .82);
  cursor: zoom-out;
}

#lightbox[hidden] { display: none; }

#lightbox img {
  max-width: min(1100px, 100%);
  max-height: calc(100vh - 80px);
  object-fit: contain;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

#lightbox-caption {
  margin: 0;
  color: #e7f0f6;
  font-size: 14px;
}

#composer {
  border-top: 1px solid var(--rule);
  padding: 14px 28px 18px;
}

.row { display: flex; gap: 10px; align-items: flex-end; }
.row textarea { flex: 1; }
.hint { font-size: 13px; margin: 10px 0 0; }

@media (max-width: 720px) {
  .desk { padding: 0; }
  .sheet { min-height: 100vh; box-shadow: none; }
  .msg { grid-template-columns: 56px 52px 1fr; padding: 10px 18px; }
  header, .docno, h1, .lead, label, .login-actions, .err, #composer { padding-left: 18px; padding-right: 18px; }
  input[type="password"] { width: calc(100% - 36px); margin: 0 18px; }
  #app { height: 100vh; }
  header { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
