:root {
  color-scheme: light;
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-soft: #f7f9fb;
  --line: #dfe5ec;
  --text: #17202a;
  --muted: #6b7788;
  --accent: #1677ff;
  --accent-dark: #0f5fc9;
  --bubble: #ffffff;
  --mine: #dff3ff;
  --system: #edf4ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.app-shell.is-guest {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 24px;
}

.app-shell.is-guest .workspace-panel,
.app-shell.is-guest .chat-panel {
  display: none;
}

.login-view {
  width: min(420px, 100%);
}

.login-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 28px;
  box-shadow: 0 20px 48px rgb(23 32 42 / 10%);
}

.login-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  margin-bottom: 18px;
}

.login-card h1 {
  margin: 0;
  font-size: 24px;
}

.login-card p {
  margin: 8px 0 22px;
  color: var(--muted);
}

.login-form,
.group-box,
.people-box,
.admin-box {
  display: grid;
  gap: 10px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.login-form input,
.group-box input,
.people-box select,
.admin-box input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  padding: 10px 12px;
}

.login-form button,
.group-box button,
.people-box button,
.admin-box button,
.composer button[type="submit"] {
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  min-height: 40px;
  cursor: pointer;
}

.workspace-panel {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.workspace-header strong {
  display: block;
  font-size: 17px;
}

.workspace-header span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.workspace-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.workspace-header button,
.mobile-menu-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-height: 36px;
  padding: 0 10px;
  cursor: pointer;
}

.workspace-close-button {
  display: none;
}

.conversation-section {
  min-height: 0;
  overflow: auto;
  padding: 14px 10px;
}

.section-label {
  padding: 0 8px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 10px 8px;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: #edf4ff;
}

.conversation-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 10px;
  background: #dcecff;
  color: var(--accent-dark);
  font-weight: 700;
}

.conversation-copy {
  min-width: 0;
}

.conversation-copy strong,
.conversation-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-copy small {
  color: var(--muted);
  margin-top: 3px;
}

.workspace-actions,
.tools-panel,
.settings-panel {
  border-top: 1px solid var(--line);
  padding: 12px 18px;
}

.workspace-actions button,
.settings-panel header button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-height: 40px;
  cursor: pointer;
}

.settings-panel {
  display: grid;
  gap: 14px;
  max-height: 48vh;
  overflow: auto;
  background: var(--panel);
}

.settings-panel[hidden],
.workspace-actions[hidden] {
  display: none;
}

.settings-panel header {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 8px;
  align-items: center;
}

.settings-panel h2 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.tools-panel summary {
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 12px;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100vh;
  background: var(--panel-soft);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 14px 20px;
}

.mobile-menu-button {
  display: none;
}

.chat-title-block {
  min-width: 0;
  flex: 1;
}

.chat-title-block h1 {
  margin: 0;
  font-size: 19px;
}

.chat-title-block p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  border-radius: 999px;
  background: #edf4ff;
  color: var(--accent-dark);
  padding: 7px 11px;
  font-size: 12px;
  white-space: nowrap;
}

.workspace-scrim {
  display: none;
}

.message-list {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 22px;
  overflow: auto;
}

.message {
  width: fit-content;
  max-width: min(680px, 82%);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bubble);
  padding: 10px 12px;
  box-shadow: 0 2px 8px rgb(23 32 42 / 4%);
}

.message.mine {
  justify-self: end;
  background: var(--mine);
}

.message.system {
  justify-self: center;
  max-width: min(520px, 92%);
  background: var(--system);
  text-align: center;
}

.message strong {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.message p {
  margin: 0 0 6px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.translation {
  border-left: 3px solid var(--accent);
  color: var(--muted);
  padding-left: 8px;
}

.attachment {
  margin-top: 10px;
}

.attachment img,
.attachment video {
  max-width: min(420px, 100%);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.attachment audio {
  width: min(420px, 100%);
}

.composer {
  display: grid;
  grid-template-columns: 42px 1fr 42px 42px 72px;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 12px 16px;
}

.composer input,
.composer textarea {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px 12px;
}

.composer textarea {
  width: 100%;
  height: 42px;
  max-height: 150px;
  resize: none;
  line-height: 1.4;
  overflow-y: hidden;
}

.composer button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: 42px;
  padding: 0 10px;
  cursor: pointer;
}

.recording {
  border-color: #b42318 !important;
  color: #b42318;
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
    height: 100dvh;
    overflow: hidden;
  }

  .app-shell.is-guest {
    display: grid;
    height: 100dvh;
    padding: 18px;
  }

  .workspace-panel {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    width: min(86vw, 340px);
    transform: translateX(-102%);
    transition: transform 160ms ease;
    box-shadow: 12px 0 32px rgb(23 32 42 / 18%);
  }

  .app-shell.show-workspace .workspace-panel {
    transform: translateX(0);
  }

  .workspace-close-button {
    display: inline-block;
  }

  .workspace-scrim {
    position: fixed;
    inset: 0;
    z-index: 9;
    display: none;
    border: 0;
    background: rgb(23 32 42 / 18%);
  }

  .app-shell.show-workspace .workspace-scrim {
    display: block;
  }

  .chat-panel {
    height: 100dvh;
  }

  .chat-header {
    min-height: 64px;
    padding: 10px 12px;
  }

  .mobile-menu-button {
    display: inline-block;
  }

  .chat-title-block h1 {
    font-size: 18px;
  }

  .status-pill {
    display: none;
  }

  .message-list {
    padding: 14px 12px;
  }

  .message {
    max-width: 88%;
  }

  .composer {
    grid-template-columns: 40px minmax(0, 1fr) 40px 40px 58px;
    gap: 6px;
    padding: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .composer input,
  .composer textarea {
    height: 42px;
    padding: 9px 10px;
    font-size: 16px;
  }

  .composer button {
    min-height: 42px;
    padding: 0;
    font-size: 18px;
  }

  .composer button[type="submit"] {
    display: inline-block;
    min-width: 0;
    font-size: 14px;
  }
}
