/* Asagiri's look on a big screen: the phone's Deep Glass style. Frosted panes float over a slow mesh of
   violet and sky blue (docs/branding, VisualStyles.kt). Logical properties throughout, so a right-to-left
   language needs no second stylesheet. */

:root {
  --radius: 18px;
  --radius-sm: 12px;
  color-scheme: dark;

  --base: #080a1c;
  --blob-1: #4038c8;
  --blob-2: #1e6aa8;
  --blob-3: #6a3bc4;
  --blob-4: #1a2e7c;
  --text: #e8e9f6;
  --text-2: #c4c7da;
  --text-3: #8e92a8;
  --primary: #9b8cff;
  --on-primary: #160b3d;
  --sky: #5cc8ff;
  --danger: #ffb4ab;
  --ok: #4ade80;
  --glass: rgb(12 16 32 / 0.42);
  --glass-strong: rgb(18 22 42 / 0.82);
  --glass-border: rgb(255 255 255 / 0.13);
  --hover: rgb(255 255 255 / 0.07);
  --active: rgb(155 140 255 / 0.2);
  --in: rgb(255 255 255 / 0.09);
  --out-a: #5b4bd8;
  --out-b: #2d7fc4;
  --on-out: #ffffff;
  --shadow: 0 18px 50px rgb(0 0 0 / 0.42);
}

:root[data-theme="light"] {
  color-scheme: light;
  --base: #efeeff;
  --blob-1: #c9c2ff;
  --blob-2: #bfe8ff;
  --blob-3: #dccbff;
  --blob-4: #cfe6ff;
  --text: #1a1a2c;
  --text-2: #46465c;
  --text-3: #6d6b88;
  --primary: #5b43e0;
  --on-primary: #ffffff;
  --sky: #0e96d8;
  --danger: #ba1a1a;
  --ok: #15803d;
  --glass: rgb(245 244 255 / 0.5);
  --glass-strong: rgb(250 249 255 / 0.9);
  --glass-border: rgb(255 255 255 / 0.55);
  --hover: rgb(40 30 110 / 0.06);
  --active: rgb(91 67 224 / 0.15);
  --in: rgb(255 255 255 / 0.72);
  --out-a: #5b43e0;
  --out-b: #0e96d8;
  --shadow: 0 18px 50px rgb(40 30 110 / 0.2);
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--base);
  color: var(--text);
  font: 14.5px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Noto Sans", Roboto, sans-serif;
}

h1,
h2,
p {
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

/* The mesh behind everything. */
.mesh {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.mesh i {
  position: absolute;
  width: 58vmax;
  height: 58vmax;
  border-radius: 50%;
  filter: blur(78px);
  opacity: 0.72;
  animation: drift 46s ease-in-out infinite alternate;
}

.mesh i:nth-child(1) {
  inset-block-start: -22vmax;
  inset-inline-start: -14vmax;
  background: var(--blob-1);
}

.mesh i:nth-child(2) {
  inset-block-end: -28vmax;
  inset-inline-end: -12vmax;
  background: var(--blob-2);
  animation-delay: -12s;
}

.mesh i:nth-child(3) {
  inset-block-start: 20vmin;
  inset-inline-end: 8vmax;
  width: 40vmax;
  height: 40vmax;
  background: var(--blob-3);
  animation-delay: -24s;
}

.mesh i:nth-child(4) {
  inset-block-end: -8vmin;
  inset-inline-start: 18vmax;
  width: 44vmax;
  height: 44vmax;
  background: var(--blob-4);
  animation-delay: -36s;
}

@keyframes drift {
  to {
    transform: translate3d(7vmax, 5vmax, 0) scale(1.14);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mesh i {
    animation: none;
  }
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(26px) saturate(1.5);
}

#root {
  position: relative;
}

.icon {
  display: block;
  width: 20px;
  height: 20px;
  fill: currentcolor;
}

.icon-btn {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-2);
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn {
  padding: 8px 16px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--hover);
  font-weight: 600;
}

.btn:hover {
  filter: brightness(1.12);
}

.btn.primary {
  border-color: transparent;
  background: linear-gradient(120deg, var(--primary), var(--sky));
  color: var(--on-primary);
}

.btn.ghost {
  background: none;
}

.btn.danger {
  border-color: var(--danger);
  background: none;
  color: var(--danger);
}

.muted {
  color: var(--text-2);
}

.warn {
  color: var(--danger);
  font-size: 13px;
}

/* Pairing */
.pair-screen {
  display: grid;
  place-items: center;
  height: 100%;
  overflow: auto;
  padding: 20px;
}

.pair-card {
  width: min(430px, 100%);
  padding: 24px 28px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  text-align: center;
}

.pair-logo {
  width: 60px;
  height: 60px;
  border-radius: 16px;
}

.pair-card h1 {
  margin: 8px 0 14px;
  font-size: 21px;
  font-weight: 600;
}

.pair-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.qr {
  padding: 10px;
  border-radius: 16px;
  background: #fff;
}

.qr img {
  display: block;
  width: 232px;
  height: 232px;
  image-rendering: pixelated;
}

.pair-steps {
  margin: 0;
  padding-inline-start: 22px;
  color: var(--text-2);
  text-align: start;
}

.pair-foot {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  color: var(--text-3);
  font-size: 13px;
}

.pair-ask {
  font-size: 17px;
  font-weight: 600;
}

.pair-actions {
  display: flex;
  gap: 10px;
  margin-block-start: 6px;
}

.spinner {
  width: 34px;
  height: 34px;
  margin: 16px;
  border: 3px solid var(--glass-border);
  border-block-start-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(270px, 340px) 1fr;
  gap: 10px;
  height: 100%;
  padding: 10px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: var(--radius);
}

.side-head {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 10px 10px 14px;
}

.logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
}

.brand {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
}

.search {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 12px 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--hover);
  color: var(--text-3);
}

.search .icon {
  width: 18px;
  height: 18px;
}

.search-input {
  width: 100%;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
}

.search:focus-within {
  box-shadow: 0 0 0 2px var(--primary);
}

.chats {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 6px 6px;
}

.chat {
  display: flex;
  gap: 11px;
  align-items: center;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  text-align: start;
}

.chat:hover {
  background: var(--hover);
}

.chat.active {
  background: var(--active);
}

.avatar-wrap {
  position: relative;
  flex: none;
}

.avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--a), var(--b));
  color: #fff;
  font-weight: 600;
}

.dot {
  position: absolute;
  inset-block-end: 1px;
  inset-inline-end: 1px;
  width: 11px;
  height: 11px;
  border: 2px solid var(--base);
  border-radius: 50%;
  background: var(--ok);
}

.chat-main {
  flex: 1;
  min-width: 0;
}

.chat-top,
.chat-bottom {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.chat-name {
  flex: 1;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-time {
  color: var(--text-3);
  font-size: 12px;
}

.chat-preview {
  flex: 1;
  overflow: hidden;
  color: var(--text-2);
  font-size: 13.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: linear-gradient(120deg, var(--primary), var(--sky));
  color: var(--on-primary);
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.empty-list {
  padding: 26px 16px;
  color: var(--text-3);
  text-align: center;
}

.banner {
  margin: 0 8px 8px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--hover);
  color: var(--text-2);
  font-size: 12.5px;
}

.banner[hidden] {
  display: none;
}

/* Conversation */
.conversation {
  min-width: 0;
  min-height: 0;
}

.conv-live {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  min-height: 0;
}

.conv-empty {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
  color: var(--text-2);
  text-align: center;
}

.empty-logo {
  width: 96px;
  height: 96px;
  margin-block-end: 10px;
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.conv-empty h2 {
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
}

.empty-lock {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-block-start: 6px;
  color: var(--text-3);
  font-size: 13px;
}

.empty-lock .icon {
  width: 15px;
  height: 15px;
}

.conv-head {
  display: flex;
  flex: none;
  gap: 11px;
  align-items: center;
  padding: 8px 10px 8px 14px;
  border-radius: var(--radius);
}

.conv-avatar .avatar {
  width: 38px;
  height: 38px;
  font-size: 14px;
}

.conv-title {
  flex: 1;
  min-width: 0;
}

.conv-name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-sub {
  min-height: 17px;
  color: var(--text-3);
  font-size: 12.5px;
}

.conv-sub.online {
  color: var(--ok);
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  outline: 0;
  padding: 8px 10px;
}

.day {
  margin: 10px 0;
  text-align: center;
}

.day span {
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--glass);
  color: var(--text-2);
  font-size: 12px;
  backdrop-filter: blur(12px);
}

.older,
.no-messages {
  padding: 18px;
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
}

.msg {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-block: 3px;
}

.msg.out {
  flex-direction: row-reverse;
}

.bubble {
  position: relative;
  max-width: min(66%, 620px);
  padding: 7px 11px 6px;
  border-radius: 16px;
  background: var(--in);
  overflow-wrap: anywhere;
  backdrop-filter: blur(14px);
}

.msg.in .bubble {
  border-end-start-radius: 5px;
}

.msg.out .bubble {
  border-end-end-radius: 5px;
  background: linear-gradient(135deg, var(--out-a), var(--out-b));
  color: var(--on-out);
}

.msg.bare .bubble {
  padding: 0;
  background: none;
  backdrop-filter: none;
}

.msg.bare .msg-meta {
  color: var(--text-3);
}

.msg-text {
  white-space: pre-wrap;
}

.msg-sender {
  margin-block-end: 2px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

.msg-note {
  color: var(--text-2);
  font-style: italic;
}

.msg.out .msg-note {
  color: rgb(255 255 255 / 0.84);
}

.msg-meta {
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: flex-end;
  margin-block-start: 1px;
  color: var(--text-3);
  font-size: 11px;
}

.msg.out .msg-meta {
  color: rgb(255 255 255 / 0.78);
}

.msg-more {
  width: 28px;
  height: 28px;
  opacity: 0;
}

.msg:hover .msg-more,
.msg-more:focus-visible {
  opacity: 1;
}

.tick {
  display: inline-flex;
}

.tick .icon {
  width: 14px;
  height: 14px;
}

.tick.read {
  color: #a5f3fc;
}

.tick.failed {
  color: var(--danger);
  cursor: pointer;
}

.link {
  color: var(--sky);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.msg.out .link {
  color: #fff;
}

.quote {
  display: flex;
  flex-direction: column;
  max-height: 3.4em;
  margin-block-end: 4px;
  padding: 2px 8px;
  overflow: hidden;
  border-inline-start: 3px solid var(--sky);
  border-radius: 4px;
  background: rgb(0 0 0 / 0.14);
  font-size: 13px;
}

.media {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  cursor: zoom-in;
}

.photo {
  display: block;
  max-width: 100%;
  max-height: 340px;
  min-height: 60px;
  object-fit: contain;
}

.sticker {
  display: block;
  width: 140px;
  height: 140px;
  object-fit: contain;
}

.media.spoiler {
  cursor: pointer;
}

.media.spoiler img {
  filter: blur(26px);
}

.spoiler-tag {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
}

.file-card {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-width: 200px;
  padding: 6px;
  border: 0;
  border-radius: 10px;
  background: rgb(0 0 0 / 0.14);
  color: inherit;
  text-align: start;
}

.file-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.16);
}

.file-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.file-name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  font-size: 12px;
  opacity: 0.8;
}

.reply-bar {
  display: flex;
  flex: none;
  gap: 8px;
  align-items: center;
  padding: 5px 8px 5px 14px;
  border-radius: var(--radius-sm);
  background: var(--glass);
  backdrop-filter: blur(18px);
}

.reply-bar[hidden] {
  display: none;
}

.reply-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  font-size: 13px;
}

.reply-text span {
  overflow: hidden;
  color: var(--text-2);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer {
  display: flex;
  flex: none;
  gap: 4px;
  align-items: flex-end;
  padding: 6px;
  border-radius: var(--radius);
}

.composer-input {
  flex: 1;
  max-height: 160px;
  padding: 7px 6px;
  border: 0;
  outline: 0;
  background: none;
  resize: none;
}

.composer-input::placeholder,
.search-input::placeholder {
  color: var(--text-3);
}

.icon-btn.send {
  background: linear-gradient(120deg, var(--primary), var(--sky));
  color: var(--on-primary);
}

.drop {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  background: var(--glass-strong);
  font-size: 18px;
  font-weight: 600;
}

.drop[hidden] {
  display: none;
}

/* Overlays */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(4 6 16 / 0.5);
}

.dialog {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(440px, 100%);
  max-height: 100%;
  padding: 20px 22px;
  overflow-y: auto;
  border-radius: 20px;
  background: var(--glass-strong);
  box-shadow: var(--shadow);
}

.dialog h2 {
  font-size: 18px;
  font-weight: 600;
}

.dialog.danger h2 {
  color: var(--danger);
}

.dialog-body {
  color: var(--text-2);
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.link-host {
  margin-block-start: 10px;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.link-url {
  max-height: 5.4em;
  overflow-y: auto;
  color: var(--text-3);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.link-risks {
  margin: 10px 0 0;
  padding-inline-start: 20px;
  color: var(--danger);
  font-size: 13.5px;
}

.settings {
  width: min(560px, 100%);
}

.setting {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding-block: 8px;
  border-block-end: 1px solid var(--glass-border);
}

.setting-text {
  flex: 1;
  min-width: 0;
}

.setting-label {
  font-weight: 600;
}

.setting-hint {
  color: var(--text-3);
  font-size: 12.5px;
}

.setting-control {
  flex: none;
  max-width: 56%;
}

.field {
  width: 200px;
  padding: 6px 10px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--hover);
}

.segments {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--hover);
}

.segment {
  padding: 5px 12px;
  border: 0;
  border-radius: 999px;
  background: none;
}

.segment.on {
  background: var(--active);
  font-weight: 600;
}

.switch {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

.folder {
  display: flex;
  gap: 8px;
  align-items: center;
}

.path {
  max-width: 190px;
  overflow: hidden;
  color: var(--text-2);
  direction: ltr;
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-note {
  color: var(--text-2);
  font-size: 13px;
}

.settings-foot {
  display: flex;
  gap: 10px;
  align-items: center;
}

.version {
  flex: 1;
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
}

.menu {
  position: fixed;
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 190px;
  padding: 5px;
  border-radius: 12px;
  background: var(--glass-strong);
  box-shadow: var(--shadow);
}

.menu-item {
  padding: 7px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: start;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--hover);
}

.menu-item.danger {
  color: var(--danger);
}

.toast {
  position: fixed;
  inset-block-end: 22px;
  inset-inline-start: 50%;
  z-index: 40;
  max-width: min(460px, 80vw);
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--glass-strong);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

[dir="rtl"] .toast {
  transform: translateX(50%);
}

.viewer {
  grid-template-rows: 1fr auto;
  gap: 12px;
  background: rgb(4 6 16 / 0.86);
}

.viewer img {
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  object-fit: contain;
  align-self: center;
  justify-self: center;
}

.viewer-bar {
  display: flex;
  gap: 8px;
}

body.offline #root {
  opacity: 0.55;
  pointer-events: none;
}

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 10px;
  background: var(--glass-border);
  background-clip: padding-box;
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: minmax(200px, 40%) 1fr;
    gap: 6px;
    padding: 6px;
  }
}
