:root {
  color-scheme: dark;
  --bg: #101827;
  --panel: #1b2538;
  --text: #e7edf6;
  --muted: #aab7ca;
  --line: #2c3950;
  --accent: #4f8cff;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #0d1422, #131d2d);
  color: var(--text);
  font-family: "Segoe UI", Roboto, sans-serif;
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  width: min(520px, 95vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.chat-card {
  width: min(900px, 95vw);
}

.title {
  margin: 0;
  font-size: 1.5rem;
}

.subtitle {
  margin: 8px 0 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

.calc-display {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0c1523;
  color: var(--text);
  font-size: 2rem;
  text-align: right;
  padding: 14px;
}

.calc-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.btn {
  border: 1px solid var(--line);
  background: #182334;
  color: var(--text);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
}

.btn:hover {
  filter: brightness(1.1);
}

.btn-op {
  background: #294d92;
}

.btn-muted {
  background: #263247;
}

.btn-wide {
  grid-column: span 2;
}

.actions {
  margin-top: 14px;
}

.link-button,
.secondary-link {
  color: #b7d0ff;
  text-decoration: none;
}

.secondary-link {
  margin-right: 10px;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel {
  background: #121d2c;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-top: 12px;
}

.hidden {
  display: none !important;
}

.form-grid {
  display: grid;
  gap: 10px;
}

label {
  font-size: 0.9rem;
  color: var(--muted);
  display: grid;
  gap: 6px;
}

input {
  border: 1px solid var(--line);
  background: #0e1726;
  color: var(--text);
  border-radius: 8px;
  padding: 10px;
}

.actions-inline {
  display: flex;
  gap: 8px;
}

.messages {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-height: 260px;
  max-height: 400px;
  overflow: auto;
  background: #0d1624;
}

.message {
  border-bottom: 1px solid #263247;
  padding: 10px 0;
}

.message:last-child {
  border-bottom: none;
}

.meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin-top: 12px;
}

.message img {
  width: 160px;
  margin-top: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.message-row {
  display: flex;
  margin: 8px 0;
}

.message-row.mine {
  justify-content: flex-end;
}

.message-row.theirs {
  justify-content: flex-start;
}

.bubble {
  max-width: min(74%, 520px);
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.bubble.mine {
  background: #123d7a;
  border-color: #2b64bb;
}

.bubble.theirs {
  background: #1d2738;
  border-color: #32415d;
}

.bubble-photo {
  width: min(260px, 100%);
  border-radius: 10px;
  margin-top: 8px;
  border: 1px solid #3a4c6a;
}

.bubble-meta {
  margin-top: 8px;
  font-size: 0.75rem;
  color: #b8c7de;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.tick {
  font-weight: 700;
  letter-spacing: -0.04em;
}

.tick.sent {
  color: #d2deef;
}

.tick.delivered {
  color: #d2deef;
}

.tick.read {
  color: #55b6ff;
}

.date-separator {
  width: fit-content;
  margin: 10px auto;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  color: #d8e6fb;
  background: rgba(43, 66, 104, 0.65);
  border: 1px solid #3b5783;
  position: sticky;
  top: 8px;
  z-index: 2;
  backdrop-filter: blur(2px);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  margin: 0 8px;
  align-self: flex-end;
}

.avatar.mine {
  background: #2b64bb;
  color: #e7f0ff;
}

.avatar.theirs {
  background: #3a4b67;
  color: #d9e3f3;
}

.bubble {
  position: relative;
}

.bubble.mine::after,
.bubble.theirs::after {
  content: "";
  position: absolute;
  bottom: 10px;
  width: 0;
  height: 0;
  border: 7px solid transparent;
}

.bubble.mine::after {
  right: -13px;
  border-left-color: #123d7a;
}

.bubble.theirs::after {
  left: -13px;
  border-right-color: #1d2738;
}

.error {
  border: 1px solid #7c2c2c;
  color: #ffcaca;
  background: #3a1e1e;
  border-radius: 10px;
  padding: 10px;
}

.lock-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 16, 0.92);
  display: grid;
  place-items: center;
  z-index: 1000;
}

.lock-card {
  width: min(420px, 90vw);
  background: #131d2d;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.small-note {
  font-size: 0.82rem;
  color: var(--muted);
}

@media (max-width: 680px) {
  .composer {
    grid-template-columns: 1fr;
  }
}

.chat-app {
  min-height: 100vh;
  padding: 16px;
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 12px;
}

.chat-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

.topbar-left h1 {
  margin: 0;
  font-size: 1.2rem;
}

.topbar-left p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-settings {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: end;
}

.chat-main {
  min-height: 60vh;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 10px;
}

.modern-messages {
  min-height: 45vh;
  max-height: none;
  padding: 8px 10px 16px;
}

.modern-composer {
  grid-template-columns: 1fr auto auto;
}

.file-chip {
  border: 1px solid var(--line);
  background: #1a273a;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
}

.file-chip input {
  display: none;
}

@media (max-width: 760px) {
  .chat-settings {
    grid-template-columns: 1fr;
  }
  .modern-composer {
    grid-template-columns: 1fr;
  }
}
