:root {
  color-scheme: light;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: #172a27;
  background: #e7efeb;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --green: #147461;
  --green-dark: #0e5c4d;
  --green-light: #e3f3ec;
  --ink: #172a27;
  --muted: #788681;
  --line: #e8eeeb;
  --surface: #fff;
  --shadow: 0 30px 100px rgb(26 56 45 / 12%);
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 9% 0%, rgb(200 228 215 / 78%), transparent 34rem),
    radial-gradient(ellipse at 100% 100%, rgb(207 227 218 / 62%), transparent 38rem),
    #edf3f0;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
::selection { color: #123d33; background: #bce3d3; }

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgb(20 116 97 / 28%);
  outline-offset: 2px;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.auth-card {
  position: relative;
  width: min(100%, 430px);
  overflow: hidden;
  padding: 42px;
  border: 1px solid rgb(220 232 225 / 90%);
  border-radius: 26px;
  background: rgb(255 255 255 / 94%);
  box-shadow: var(--shadow);
  animation: card-enter 420ms ease both;
}

.auth-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, #147461, #8cc9ad);
  content: "";
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 24%);
  border-radius: 19px;
  color: #fff;
  background: linear-gradient(145deg, #1d8a71, #0d584b);
  box-shadow: 0 10px 24px rgb(20 116 97 / 24%);
  font: 800 29px "Segoe UI", Arial, sans-serif;
}

.brand-mark.small {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 15px;
  font-size: 22px;
}

.eyebrow {
  margin: 25px 0 8px;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .17em;
}

h1, h2, p { margin-top: 0; }
h1, h2 { font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif; }
.auth-card h1 { margin-bottom: 8px; font-size: 32px; letter-spacing: -.045em; }
.muted { color: var(--muted); }
.auth-card > .muted { margin-bottom: 26px; font-size: 14px; line-height: 1.6; }

label {
  display: block;
  margin: 16px 0 7px;
  color: #40514b;
  font-size: 12px;
  font-weight: 700;
}

input, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #dfe8e3;
  border-radius: 12px;
  outline: none;
  background: #fbfdfc;
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:hover, textarea:hover { border-color: #cbd9d2; }
input:focus, textarea:focus {
  border-color: #72ac9b;
  background: #fff;
  box-shadow: 0 0 0 4px rgb(20 116 97 / 9%);
}

.primary-button, .secondary-button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, #19816a, #116653);
  box-shadow: 0 5px 13px rgb(17 102 83 / 17%);
}

.primary-button:hover, .send-button:hover {
  background: linear-gradient(135deg, #126f5c, #0d5849);
  box-shadow: 0 7px 18px rgb(17 102 83 / 23%);
  transform: translateY(-1px);
}

.primary-button:active, .secondary-button:active, .send-button:active { transform: translateY(0); }
#auth-submit { width: 100%; margin-top: 18px; }

.text-button {
  display: block;
  margin: 18px auto 0;
  padding: 5px;
  border: 0;
  color: var(--green);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.text-button:hover { color: var(--green-dark); text-decoration: underline; }
.error { min-height: 18px; margin: 8px 0 0; color: #b52e3b; font-size: 12px; line-height: 1.5; }

.chat-view {
  width: min(1440px, calc(100vw - 64px));
  height: min(920px, calc(100vh - 64px));
  min-height: 540px;
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  overflow: hidden;
  margin: 32px auto;
  border: 1px solid rgb(219 230 224 / 95%);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: card-enter 420ms ease both;
}

.sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #fff;
}

.sidebar-header {
  min-height: 84px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #fcfdfc);
}

.account { min-width: 0; display: grid; gap: 3px; flex: 1; }
.account strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.account .muted { font-size: 12px; }

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #53645e;
  background: transparent;
  font-size: 20px;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.icon-button:hover { border-color: #e8efeb; color: var(--green-dark); background: #f1f7f4; }
.sidebar-content { min-height: 0; overflow-y: auto; flex: 1; padding: 23px 16px 12px; }
.sidebar-content h2 { margin: 0 0 18px; font-size: 19px; letter-spacing: -.025em; }
.compact-form label { margin: 11px 0 7px; font-size: 11px; }
.compact-form input { min-width: 0; padding: 11px 12px; font-size: 13px; }
.form-row { display: flex; gap: 8px; }
.form-row input { min-width: 0; }
.compact-button { width: 44px; min-height: 42px; padding: 0; font-size: 23px; }

.group-details {
  margin-top: 12px;
  padding: 12px 0 15px;
  border-bottom: 1px solid var(--line);
}

.group-details summary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--green);
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 700;
}

.group-details summary::-webkit-details-marker { display: none; }
.group-details summary::before { content: "+"; font-size: 17px; line-height: 1; }
.group-details[open] summary::before { content: "−"; }
.secondary-button { min-height: 40px; margin-top: 10px; color: var(--green-dark); background: var(--green-light); font-size: 12px; }
.secondary-button:hover { background: #d3ecdf; }

.conversation-list { display: grid; gap: 4px; margin-top: 12px; }
.conversation-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  text-align: left;
  background: transparent;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.conversation-item:hover { border-color: #edf2ef; background: #f7faf8; transform: translateX(2px); }
.conversation-item.active { border-color: #e0eee7; background: #eff7f3; }

.avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgb(20 116 97 / 8%);
  border-radius: 16px;
  color: #176650;
  background: linear-gradient(145deg, #eaf6ef, #dcefe5);
  font-size: 15px;
  font-weight: 800;
}

.conversation-copy { min-width: 0; flex: 1; }
.conversation-copy strong, .conversation-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-copy strong { margin-bottom: 5px; color: #20332e; font-size: 13px; }
.conversation-copy span { color: var(--muted); font-size: 11px; }
.sidebar-note { margin: 0; padding: 14px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }

.chat-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 82% 18%, rgb(237 246 241 / 80%), transparent 25rem),
    #f6f9f7;
}

.empty-state { max-width: 440px; margin: auto; padding: 32px; text-align: center; }
.empty-illustration {
  width: 90px;
  height: 90px;
  display: grid;
  place-items: center;
  margin: 0 auto 22px;
  border: 1px solid #d9eae1;
  border-radius: 29px;
  color: var(--green);
  background: linear-gradient(145deg, #f1f8f4, #deefe6);
  box-shadow: 0 12px 30px rgb(37 93 71 / 9%);
  font-size: 42px;
}

.empty-state h2 { margin-bottom: 9px; font-size: 23px; letter-spacing: -.035em; }
.empty-state p { color: var(--muted); font-size: 14px; line-height: 1.6; }

.conversation-view { min-height: 0; display: flex; flex-direction: column; flex: 1; }
.conversation-header {
  min-height: 78px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 27px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 2px 8px rgb(26 56 45 / 2%);
  backdrop-filter: blur(12px);
}

.conversation-header h2 { margin: 0 0 4px; color: #20332e; font-size: 15px; letter-spacing: -.01em; }
.conversation-header p { margin: 0; font-size: 11px; }
.back-button { display: none; }

.messages {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
  overflow-y: auto;
  flex: 1;
  padding: 25px clamp(18px, 5vw, 76px);
  scroll-behavior: smooth;
  scrollbar-color: #cbdad2 transparent;
  scrollbar-width: thin;
}

.message {
  width: fit-content;
  max-width: min(76%, 560px);
  padding: 11px 14px 8px;
  border: 1px solid #e6ece8;
  border-radius: 16px 16px 16px 5px;
  background: #fff;
  box-shadow: 0 3px 10px rgb(28 55 44 / 4%);
  animation: message-enter 180ms ease both;
}

.message.own {
  align-self: flex-end;
  border-color: #d8ece1;
  border-radius: 16px 16px 5px 16px;
  background: linear-gradient(145deg, #e8f6ee, #e0f2e8);
}

.message-author { display: block; margin-bottom: 5px; color: var(--green); font-size: 10px; font-weight: 800; }
.message-body { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; font-size: 13px; line-height: 1.55; }
.message-time { display: block; margin-top: 6px; color: #87938d; text-align: right; font-size: 9px; }
.message-media { display: block; max-width: min(100%, 380px); max-height: 340px; margin: 5px 0; border-radius: 11px; }
.message-video { width: min(100%, 380px); margin: 5px 0; border-radius: 11px; }
.file-link { display: inline-block; margin: 5px 0; color: var(--green-dark); font-size: 12px; font-weight: 600; }

.message-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 0 22px 8px;
  padding: 9px 10px;
  border: 1px solid #e1eae5;
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 8px 24px rgb(28 55 44 / 6%);
}

.attach-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  margin: 0;
  border-radius: 12px;
  color: var(--green);
  cursor: pointer;
  font-size: 25px;
  transition: background 150ms ease, transform 150ms ease;
}

.attach-button:hover { background: var(--green-light); transform: rotate(12deg); }
.composer-fields { min-width: 0; flex: 1; }
.composer-fields textarea { display: block; min-height: 40px; resize: none; padding: 10px 5px; border: 0; background: transparent; box-shadow: none; font-size: 13px; }
.composer-fields textarea:focus-visible { outline: none; }
.attachment-name { display: block; overflow: hidden; padding: 2px 5px; color: var(--green); text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }

.send-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, #19816a, #116653);
  box-shadow: 0 5px 13px rgb(17 102 83 / 17%);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.send-button:disabled { cursor: wait; opacity: .6; }
.composer-error { margin: 0 26px 8px; }

@keyframes card-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes message-enter {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 760px) {
  .chat-view {
    width: calc(100vw - 28px);
    height: calc(100dvh - 28px);
    min-height: 480px;
    grid-template-columns: 310px minmax(0, 1fr);
    margin: 14px;
    border-radius: 20px;
  }
}

@media (max-width: 640px) {
  body { background: #f6f9f7; }
  .chat-view {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    grid-template-columns: minmax(0, 1fr);
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .sidebar { border-right: 0; }
  .chat-panel { display: none; }
  .chat-view.show-conversation .sidebar { display: none; }
  .chat-view.show-conversation .chat-panel { display: flex; }
  .back-button { display: grid; }
  .messages { gap: 9px; padding: 18px 14px; }
  .message { max-width: 88%; }
  .message-composer { gap: 6px; margin: 0 10px 5px; padding: 8px; border-radius: 15px; }
  .attach-button { width: 36px; height: 38px; }
  .send-button { width: 38px; height: 38px; }
  .auth-view { padding: 18px; }
  .auth-card { padding: 34px 26px; border-radius: 23px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

:root {
  color-scheme: dark;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: #dce8e4;
  background: #080d0c;
  --green: #67f5b2;
  --green-dark: #20c783;
  --green-light: #122a21;
  --ink: #e4efeb;
  --muted: #82948c;
  --line: #1c3028;
  --surface: #0e1714;
  --shadow: 0 28px 90px rgb(0 0 0 / 55%), 0 0 70px rgb(38 225 145 / 5%);
}

body {
  color: var(--ink);
  background:
    radial-gradient(ellipse at 18% 0%, rgb(16 91 61 / 20%), transparent 34rem),
    radial-gradient(ellipse at 100% 100%, rgb(16 83 92 / 13%), transparent 38rem),
    repeating-linear-gradient(0deg, transparent 0 39px, rgb(99 245 178 / 2%) 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgb(99 245 178 / 2%) 40px),
    #080d0c;
}

::selection { color: #07110c; background: #67f5b2; }

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline-color: rgb(103 245 178 / 55%);
}

.auth-card {
  border-color: #20372d;
  border-radius: 18px;
  background: linear-gradient(145deg, rgb(17 29 24 / 98%), rgb(10 17 15 / 98%));
  box-shadow: var(--shadow), inset 0 1px rgb(255 255 255 / 3%);
}

.auth-card::before {
  height: 2px;
  background: linear-gradient(90deg, transparent, #67f5b2 35%, #57c9ee 70%, transparent);
  box-shadow: 0 0 18px rgb(103 245 178 / 50%);
}

.brand-mark {
  border-color: rgb(103 245 178 / 30%);
  border-radius: 15px;
  color: #83ffbf;
  background: linear-gradient(145deg, #163d2b, #0d2119);
  box-shadow: 0 0 28px rgb(45 230 142 / 16%), inset 0 0 16px rgb(45 230 142 / 8%);
  font-family: Consolas, "Courier New", monospace;
}

.eyebrow {
  color: var(--green);
  font-family: Consolas, "Courier New", monospace;
  letter-spacing: .2em;
}

h1, h2 { font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif; }
.auth-card h1 { color: #f0faf5; }
.muted { color: var(--muted); }

label { color: #a7b9b0; }

input, textarea {
  border-color: #263b32;
  border-radius: 9px;
  background: #0a110e;
  color: var(--ink);
}

input:hover, textarea:hover { border-color: #3a6952; }
input:focus, textarea:focus {
  border-color: #4bcf91;
  background: #0b1510;
  box-shadow: 0 0 0 3px rgb(66 221 144 / 11%), 0 0 18px rgb(66 221 144 / 7%);
}

.primary-button,
.send-button {
  color: #06120b;
  background: linear-gradient(135deg, #79ffc0, #39d991);
  box-shadow: 0 0 18px rgb(57 217 145 / 16%);
}

.primary-button:hover,
.send-button:hover {
  color: #041009;
  background: linear-gradient(135deg, #a0ffd1, #52e5a0);
  box-shadow: 0 0 24px rgb(57 217 145 / 28%);
}

.secondary-button { color: #8cf7bb; background: #14271e; }
.secondary-button:hover { background: #1a3829; }
.text-button { color: #67f5b2; }
.text-button:hover { color: #a3ffd1; }
.error { color: #ff8290; }

.chat-view {
  height: min(920px, calc(100vh - 64px));
  grid-template-columns: 350px minmax(0, 1fr);
  grid-template-rows: 44px minmax(0, 1fr);
  border-color: #263c31;
  border-radius: 15px;
  background: #0b1210;
  box-shadow: var(--shadow), 0 0 0 1px rgb(103 245 178 / 3%);
}

.window-titlebar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  grid-column: 1 / -1;
  padding: 0 14px;
  border-bottom: 1px solid #20352b;
  background: #101916;
  color: #9fb3a8;
  font: 10px Consolas, "Courier New", monospace;
  letter-spacing: .08em;
}

.window-title,
.window-meta,
.connection-indicator,
.window-controls {
  display: flex;
  align-items: center;
}

.window-title { min-width: 0; gap: 9px; }
.window-title > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.window-app-icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 1px solid #376b50;
  border-radius: 5px;
  color: #81ffbe;
  background: #14261c;
  font-weight: 800;
}

.title-divider { color: #4c775e; }
.window-meta { gap: 20px; }
.connection-indicator { gap: 7px; color: #99a89f; }
.connection-indicator[data-state="online"] { color: #81ffb8; }
.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #66746d;
}

.connection-indicator[data-state="online"] .connection-dot {
  background: #67f5a6;
  box-shadow: 0 0 9px #67f5a6;
}

.window-controls { gap: 5px; }
.window-controls i {
  width: 7px;
  height: 7px;
  border: 1px solid #567064;
  border-radius: 50%;
}

.sidebar {
  grid-row: 2;
  border-right-color: var(--line);
  background: linear-gradient(180deg, #0e1713, #0b1210);
}

.sidebar-header {
  min-height: 76px;
  border-bottom-color: var(--line);
  background: #101916;
}

.account strong { color: #e4f0e9; }
.account .muted { color: #84988d; }
.brand-mark.small { box-shadow: 0 0 20px rgb(45 230 142 / 12%); }
.icon-button { color: #92a69a; }
.icon-button:hover { border-color: #294536; color: #83ffbf; background: #14241b; }
.sidebar-content h2 { color: #e4f0e9; }
.compact-form label { color: #9fb3a8; }
.group-details { border-bottom-color: var(--line); }
.group-details summary { color: #72e8a9; }

.conversation-item:hover { border-color: #1c3628; background: #101d16; }
.conversation-item.active {
  border-color: #28523a;
  background: linear-gradient(90deg, #14291d, #101c16);
  box-shadow: inset 2px 0 #67f5a6;
}

.avatar {
  border-color: #28513a;
  border-radius: 13px;
  color: #8affbf;
  background: linear-gradient(145deg, #193725, #102319);
  font-family: Consolas, "Courier New", monospace;
}

.conversation-copy strong { color: #dbe8e0; }
.conversation-copy span,
.sidebar-note { color: #82948c; }
.sidebar-note { border-top-color: var(--line); }

.chat-panel {
  grid-row: 2;
  background:
    radial-gradient(ellipse at 82% 18%, rgb(22 83 54 / 10%), transparent 25rem),
    #0b1210;
}

.empty-illustration {
  border-color: #294a37;
  border-radius: 22px;
  color: #79ffb8;
  background: linear-gradient(145deg, #14271c, #0d1912);
  box-shadow: 0 0 32px rgb(37 210 125 / 10%);
}

.empty-state h2 { color: #e6f3eb; }
.empty-state p { color: var(--muted); }

.conversation-header {
  border-bottom-color: var(--line);
  background: rgb(14 23 19 / 95%);
  box-shadow: 0 2px 12px rgb(0 0 0 / 12%);
}

.conversation-header h2 { color: #e4f0e9; }
.messages { scrollbar-color: #31503e transparent; }

.message {
  border-color: #25372e;
  border-radius: 13px 13px 13px 4px;
  background: #121c17;
  box-shadow: 0 4px 16px rgb(0 0 0 / 14%);
}

.message.own {
  border-color: #28543a;
  border-radius: 13px 13px 4px 13px;
  background: linear-gradient(145deg, #173322, #12271b);
}

.message-author { color: #7bf0ac; }
.message-body { color: #dce9e1; }
.message-time { color: #84968b; }
.file-link { color: #77f0ae; }

.message-composer {
  border-color: #263c30;
  border-radius: 12px;
  background: #101916;
  box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
}

.attach-button { color: #7cecb0; }
.attach-button:hover { background: #173323; }
.composer-fields textarea { color: #e4f0e9; }
.attachment-name { color: #78efa9; }
.send-button { border-radius: 10px; }

@media (max-width: 760px) {
  .chat-view { grid-template-columns: 310px minmax(0, 1fr); }
}

@media (max-width: 640px) {
  body { background: #080d0c; }
  .chat-view {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 44px minmax(0, 1fr);
    border-color: #263c31;
  }

  .window-titlebar { padding: 0 10px; }
  .window-meta { gap: 10px; }
  .window-controls { display: none; }
  .sidebar { grid-row: 2; border-right: 0; }
  .chat-panel { grid-row: 2; }
  .chat-view.show-conversation .sidebar { display: none; }
  .chat-view.show-conversation .chat-panel { display: flex; }
  .auth-view { padding: 18px; }
  .auth-card { padding: 34px 26px; border-radius: 16px; }
}
