:root {
  --navy-950: #000033;
  --navy-900: #00004f;
  --navy-800: #00136d;
  --navy-700: #00278f;
  --navy-500: #174ea6;
  --gray-100: #eeeeee;
  --gray-200: #d4d0c8;
  --gray-300: #c0c0c0;
  --gray-500: #808080;
  --gray-700: #404040;
  --white: #ffffff;
  --black: #101010;
  --green: #00a000;
  --red: #b00000;
  --z-app: 10;
  --z-login: 30;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #1b2a55;
}

body {
  min-height: 100dvh;
  margin: 0;
  padding: 18px;
  color: var(--black);
  background-color: #1b2a55;
  font-family: "MS Sans Serif", Tahoma, "SimSun", "宋体", sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: none;
  text-rendering: optimizeSpeed;
}

button,
input,
textarea {
  font: inherit;
}

button,
a,
label[for] {
  cursor: pointer;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.chat-window {
  position: relative;
  z-index: var(--z-app);
  width: min(1380px, 100%);
  min-height: calc(100dvh - 36px);
  margin: 0 auto;
  border: 3px solid;
  border-color: var(--white) var(--gray-700) var(--gray-700) var(--white);
  background: var(--gray-200);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.35);
}

.title-bar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 10px;
  color: var(--white);
  background: var(--navy-900);
}

.title-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.title-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 2px solid;
  border-color: #8da9ff #00102f #00102f #8da9ff;
  background: var(--navy-700);
  color: #ffff66;
  font-family: "Courier New", monospace;
  font-size: 24px;
  font-weight: 900;
}

.title-brand h1,
.title-brand p,
.panel-heading h2,
.panel-heading p {
  margin: 0;
}

.title-brand h1 {
  font-family: "Courier New", monospace;
  font-size: 30px;
  line-height: 1;
}

.title-brand p {
  margin-top: 5px;
  font-size: 15px;
  font-weight: 700;
}

.window-buttons {
  display: flex;
  align-items: center;
  gap: 5px;
}

.window-buttons span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 2px solid;
  border-color: var(--white) var(--gray-700) var(--gray-700) var(--white);
  background: var(--gray-200);
  color: var(--black);
  font-family: Arial, sans-serif;
  font-weight: 900;
}

.menu-bar {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border-bottom: 2px solid var(--gray-500);
  background: var(--gray-200);
}

.menu-bar a,
.menu-bar button {
  min-height: 32px;
  padding: 5px 12px;
  border: 1px solid transparent;
  background: transparent;
  color: #00005f;
  font-weight: 700;
  text-decoration: none;
}

.menu-bar a:hover,
.menu-bar button:hover,
.menu-bar a:focus-visible,
.menu-bar button:focus-visible {
  border: 1px solid;
  border-color: var(--white) var(--gray-700) var(--gray-700) var(--white);
  outline: 0;
}

.connection-state {
  margin-left: auto;
  padding: 4px 8px;
  color: #303030;
  white-space: nowrap;
}

.connection-state b {
  color: #b48b00;
}

.connection-state.is-online b {
  color: var(--green);
}

.connection-state.is-offline b {
  color: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  min-height: calc(100dvh - 190px);
  gap: 10px;
  padding: 10px;
}

.history-panel,
.compose-panel {
  min-width: 0;
  border: 2px solid;
  border-color: var(--gray-700) var(--white) var(--white) var(--gray-700);
  background: var(--gray-300);
}

.history-panel {
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr);
}

.panel-heading {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 2px solid var(--gray-500);
  background: var(--gray-200);
}

.panel-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 2px solid;
  border-color: var(--white) var(--gray-700) var(--gray-700) var(--white);
  background: var(--navy-800);
  color: var(--white);
  font-family: "Courier New", monospace;
  font-size: 28px;
  font-weight: 900;
}

.panel-heading h2 {
  color: var(--navy-900);
  font-family: "SimHei", "黑体", sans-serif;
  font-size: 22px;
  line-height: 1.2;
}

.panel-heading p {
  margin-top: 4px;
  color: var(--gray-700);
  font-size: 13px;
}

.message-list {
  min-height: 0;
  max-height: calc(100dvh - 276px);
  overflow: auto;
  padding: 10px;
  border: 3px solid;
  border-color: var(--gray-700) var(--white) var(--white) var(--gray-700);
  background: var(--white);
  scrollbar-color: var(--gray-500) var(--gray-200);
}

.loading-box,
.empty-box {
  padding: 30px 18px;
  border: 1px dashed var(--gray-500);
  color: var(--navy-800);
  font-weight: 700;
  text-align: center;
}

.message-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 8px;
  border-bottom: 1px dotted #747474;
}

.message-row:last-child {
  border-bottom: 0;
}

.message-avatar {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 2px solid;
  border-color: #7797ff #00002d #00002d #7797ff;
  background: var(--navy-900);
  color: #ffff77;
  font-family: "SimHei", "黑体", sans-serif;
  font-size: 21px;
  font-weight: 900;
}

.message-main {
  min-width: 0;
}

.message-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 7px;
  background: #e8e8ef;
  color: var(--navy-900);
}

.message-meta strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 16px;
}

.message-meta time {
  flex: 0 0 auto;
  color: #555555;
  font-family: "Courier New", monospace;
  font-size: 12px;
}

.message-text {
  margin: 10px 6px 7px;
  color: #171717;
  font-family: "SimSun", "宋体", serif;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.75;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-media {
  margin: 10px 6px 3px;
  padding: 6px;
  border: 2px solid;
  border-color: var(--gray-500) var(--gray-100) var(--gray-100) var(--gray-500);
  background: var(--gray-200);
}

.message-media img,
.message-media video {
  display: block;
  max-width: 100%;
  max-height: 560px;
  margin: 0 auto;
  background: #000000;
}

.message-media a {
  display: block;
  color: var(--navy-700);
  text-decoration: none;
}

.message-media a:hover {
  text-decoration: underline;
}

.media-caption {
  display: block;
  padding: 6px 3px 1px;
  color: #404040;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.compose-panel {
  align-self: start;
  padding-bottom: 10px;
}

.compose-heading {
  border-color: var(--gray-500);
}

#messageForm {
  padding: 13px;
}

.field-label {
  display: block;
  margin: 0 0 5px;
  color: var(--navy-900);
  font-family: "SimHei", "黑体", sans-serif;
  font-weight: 700;
}

.field-label:not(:first-child) {
  margin-top: 13px;
}

.retro-input {
  width: 100%;
  min-height: 42px;
  padding: 7px 9px;
  border: 3px solid;
  border-color: var(--gray-700) var(--white) var(--white) var(--gray-700);
  border-radius: 0;
  background: var(--white);
  color: var(--black);
  outline: 0;
}

.retro-input:focus {
  outline: 2px dotted var(--navy-700);
  outline-offset: -6px;
}

.retro-textarea {
  min-height: 158px;
  resize: vertical;
  font-family: "SimSun", "宋体", serif;
  line-height: 1.6;
}

.media-picker {
  display: flex;
  align-items: stretch;
  gap: 7px;
  margin-top: 13px;
}

#mediaInput {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.retro-button,
.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 3px solid;
  border-color: var(--white) var(--gray-700) var(--gray-700) var(--white);
  border-radius: 0;
  background: var(--gray-200);
  color: var(--black);
  font-weight: 700;
  text-decoration: none;
}

.retro-button:active,
.small-button:active {
  border-color: var(--gray-700) var(--white) var(--white) var(--gray-700);
  padding-top: 2px;
}

.retro-button:focus-visible,
.small-button:focus-visible {
  outline: 2px dotted var(--navy-900);
  outline-offset: -6px;
}

.file-button {
  min-height: 54px;
  flex: 1 1 auto;
  padding: 7px 10px;
}

.small-button {
  padding: 5px 8px;
  font-size: 12px;
}

.button-icon {
  color: var(--navy-700);
  font-family: "Courier New", monospace;
  font-size: 28px;
  line-height: 1;
}

.file-status {
  min-height: 32px;
  margin-top: 7px;
  padding: 6px 8px;
  border: 1px solid var(--gray-500);
  background: #ececec;
  color: #464646;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.upload-track {
  height: 18px;
  margin-top: 7px;
  padding: 3px;
  border: 2px solid;
  border-color: var(--gray-700) var(--white) var(--white) var(--gray-700);
  background: var(--white);
}

.upload-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--navy-700);
}

.send-button {
  width: 100%;
  min-height: 62px;
  margin-top: 13px;
  padding: 8px 14px;
  color: var(--white);
  border-color: #6685db #00002d #00002d #6685db;
  background: var(--navy-900);
  font-family: "SimHei", "黑体", sans-serif;
  font-size: 18px;
}

.send-button .button-icon {
  color: #ffff66;
}

.send-button:disabled {
  color: #9c9c9c;
  background: #555555;
  cursor: wait;
}

.system-box {
  margin: 0 13px;
  padding: 10px;
  border: 2px solid;
  border-color: var(--gray-700) var(--white) var(--white) var(--gray-700);
  background: #eeeeee;
  color: #333333;
  font-family: "Courier New", monospace;
  font-size: 12px;
}

.system-box strong {
  display: block;
  margin-bottom: 7px;
  color: var(--navy-800);
}

.system-box p {
  margin: 3px 0;
}

.status-bar {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 7px 7px;
  padding: 5px 8px;
  border: 2px solid;
  border-color: var(--gray-500) var(--white) var(--white) var(--gray-500);
  color: #303030;
  font-size: 12px;
}

.password-screen {
  position: fixed;
  inset: 0;
  z-index: var(--z-login);
  display: grid;
  place-items: center;
  padding: 18px;
  background: #1b2a55;
}

.password-dialog {
  width: min(520px, 100%);
  border: 3px solid;
  border-color: var(--white) var(--gray-700) var(--gray-700) var(--white);
  background: var(--gray-200);
  box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.4);
}

.dialog-title {
  padding: 8px 10px;
  background: var(--navy-900);
  color: var(--white);
  font-family: "Courier New", monospace;
  font-weight: 900;
}

.dialog-body {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 28px 24px 20px;
}

.lock-icon {
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  border: 3px solid;
  border-color: #7998ff #00002b #00002b #7998ff;
  background: var(--navy-800);
  color: #ffff66;
  font-size: 48px;
}

.password-copy h1 {
  margin: 0 0 16px;
  color: var(--navy-900);
  font-family: "SimHei", "黑体", sans-serif;
  font-size: 24px;
}

.password-copy label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

.login-error {
  min-height: 22px;
  margin: 7px 0 0;
  color: var(--red);
  font-weight: 700;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px 18px;
}

.dialog-actions .retro-button {
  min-width: 94px;
  min-height: 42px;
  padding: 7px 15px;
}

.login-button {
  color: var(--white);
  border-color: #6685db #00002d #00002d #6685db;
  background: var(--navy-900);
}

@media (max-width: 900px) {
  body {
    padding: 0;
  }

  .chat-window {
    min-height: 100dvh;
    border-width: 0;
    box-shadow: none;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .history-panel {
    grid-template-rows: auto minmax(58dvh, 1fr);
  }

  .message-list {
    max-height: 64dvh;
  }

  .compose-panel {
    order: 2;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 15px;
  }

  .title-bar {
    min-height: 64px;
    padding: 7px;
  }

  .title-icon {
    width: 46px;
    height: 46px;
    font-size: 20px;
  }

  .title-brand h1 {
    font-size: 24px;
  }

  .title-brand p {
    font-size: 12px;
  }

  .window-buttons span {
    width: 25px;
    height: 25px;
  }

  .window-buttons span:first-child {
    display: none;
  }

  .menu-bar {
    flex-wrap: wrap;
  }

  .menu-bar a,
  .menu-bar button {
    padding-inline: 8px;
    font-size: 13px;
  }

  .connection-state {
    width: 100%;
    margin-left: 0;
    padding-left: 8px;
  }

  .workspace {
    padding: 7px;
    gap: 7px;
  }

  .panel-heading {
    min-height: 62px;
    padding: 7px 9px;
  }

  .panel-icon {
    width: 42px;
    height: 42px;
    font-size: 24px;
  }

  .panel-heading h2 {
    font-size: 19px;
  }

  .message-list {
    padding: 6px;
  }

  .message-row {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 7px;
    padding: 9px 3px;
  }

  .message-avatar {
    width: 38px;
    height: 38px;
    font-size: 17px;
  }

  .message-meta {
    display: block;
  }

  .message-meta time {
    display: block;
    margin-top: 3px;
  }

  .message-text {
    margin-inline: 3px;
    font-size: 16px;
  }

  #messageForm {
    padding: 10px;
  }

  .media-picker {
    flex-wrap: wrap;
  }

  .small-button {
    min-height: 42px;
  }

  .status-bar {
    display: block;
  }

  .status-bar span {
    display: block;
  }

  .status-bar span + span {
    margin-top: 3px;
  }

  .password-screen {
    padding: 10px;
  }

  .dialog-body {
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 12px;
    padding: 20px 15px 14px;
  }

  .lock-icon {
    width: 58px;
    height: 58px;
    font-size: 32px;
  }

  .password-copy h1 {
    font-size: 20px;
  }
}

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