:root {
  color-scheme: light;
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --surface-strong: #dff2f6;
  --text: #13202b;
  --muted: #677688;
  --line: #d6dde7;
  --line-strong: #c6d0dc;
  --accent: #11708a;
  --accent-soft: #dcf2f7;
  --accent-2: #8c5d28;
  --ok: #1f7a4d;
  --shadow: 0 18px 40px rgba(19, 32, 43, 0.08);
  --shadow-soft: 0 8px 24px rgba(19, 32, 43, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(17, 112, 138, 0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(140, 93, 40, 0.06), transparent 24%),
    var(--bg);
  color: var(--text);
  font-family: "SF Pro Display", "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.shell,
.login-shell {
  width: min(1380px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  padding: 20px;
  width: min(420px, 100%);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-badge {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(180deg, #1b90ae 0%, #0d6b84 100%);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.muted,
.empty {
  color: var(--muted);
  margin-top: 6px;
}

.counters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.counters span,
.meta span {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 13px;
}

.counters span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.counters strong,
.counters small {
  line-height: 1;
}

.counters strong {
  color: var(--text);
  font-size: 14px;
}

.counters small {
  color: var(--muted);
  font-size: 12px;
}

form {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  font: inherit;
  background: #fff;
}

input:focus-visible,
textarea:focus-visible,
button:focus-visible,
.account-trigger:focus-visible,
.bubble-link:focus-visible,
.back:focus-visible {
  outline: 2px solid rgba(17, 112, 138, 0.28);
  outline-offset: 2px;
}

textarea {
  resize: vertical;
  min-height: 108px;
}

button,
.back {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 0 14px;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

button:hover,
.back:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(17, 112, 138, 0.16);
}

.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: none;
}

.ghost:hover {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 18px rgba(19, 32, 43, 0.08);
}

.wide {
  width: 100%;
}

.logout-form {
  display: block;
}

.warning,
.alert,
.success {
  border-radius: 12px;
  padding: 10px 12px;
}

.warning {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #7c2d12;
}

.alert {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.success {
  background: #ecfdf3;
  border: 1px solid #86efac;
  color: #166534;
}

.compact {
  margin: 0;
}

.page-banner {
  margin-bottom: 14px;
}

.back {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  text-decoration: none;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 136px);
}

.sidebar,
.workspace-main,
.chat-panel {
  min-width: 0;
}

.sidebar-card,
.panel-card,
.chat-panel {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(214, 221, 231, 0.95);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.sidebar,
.workspace-main {
  display: grid;
  gap: 14px;
}

.sidebar-card,
.panel-card {
  padding: 16px;
}

.sidebar-title,
.lane-head,
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.sidebar-title span,
.lane-head span {
  color: var(--accent-2);
  font-weight: 700;
  font-size: 13px;
}

.nav-stack,
.signal-list,
.panel-list {
  display: grid;
  gap: 10px;
}

.nav-item,
.signal,
.panel-item {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.nav-item.active {
  background: var(--accent-soft);
  border-color: #b7dfea;
}

.thread-list {
  display: grid;
  gap: 10px;
}

.thread-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.thread-item.active {
  background: linear-gradient(180deg, #e2f4f8 0%, #d4edf3 100%);
  border-color: #b7dfea;
}

.thread-item:hover {
  transform: translateY(-1px);
  border-color: #b7dfea;
  box-shadow: 0 10px 22px rgba(19, 32, 43, 0.08);
}

.thread-item p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.thread-top,
.thread-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.thread-top span,
.thread-meta span {
  color: var(--muted);
  font-size: 12px;
}

.nav-item strong,
.signal strong {
  display: block;
}

.nav-item small,
.signal-label {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.signal {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.workspace-main {
  align-content: start;
}

.tabbar {
  display: flex;
  gap: 10px;
  padding: 6px;
  border: 1px solid rgba(214, 221, 231, 0.95);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.tablink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 700;
}

.tablink:hover {
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

.tablink.active {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px #b7dfea;
}

.tab-panel {
  display: grid;
}

.panel-fill {
  min-height: calc(100vh - 206px);
}

.chat-header {
  padding: 18px 20px 12px;
  border-bottom: 1px solid rgba(214, 221, 231, 0.9);
}

.chat-presence {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.chat-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ok);
  font-size: 13px;
  font-weight: 700;
}

.chat-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(31, 122, 77, 0.12);
}

.chat-presence small {
  color: var(--muted);
  font-size: 12px;
}

.chat-feed {
  display: grid;
  gap: 14px;
  padding: 18px 20px;
  overflow: auto;
  align-content: start;
  background:
    linear-gradient(180deg, rgba(247, 249, 252, 0.8), rgba(247, 249, 252, 0.35)),
    repeating-linear-gradient(
      135deg,
      rgba(17, 112, 138, 0.03) 0,
      rgba(17, 112, 138, 0.03) 18px,
      transparent 18px,
      transparent 36px
    );
}

.chat-feed::-webkit-scrollbar {
  width: 10px;
}

.chat-feed::-webkit-scrollbar-thumb {
  background: rgba(103, 118, 136, 0.25);
  border-radius: 999px;
}

.bubble {
  max-width: min(78%, 760px);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 10px;
}

.bubble p {
  line-height: 1.45;
}

.bubble-user {
  justify-self: end;
  background: linear-gradient(180deg, #dff2f6 0%, #cbeaf1 100%);
  border: 1px solid #b7dfea;
  border-bottom-right-radius: 6px;
}

.bubble-system {
  justify-self: start;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-bottom-left-radius: 6px;
}

.bubble-empty {
  justify-self: center;
  background: rgba(255, 255, 255, 0.88);
  border: 1px dashed var(--line-strong);
}

.bubble-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.bubble-route {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bubble-route span,
.bubble-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(17, 112, 138, 0.16);
  color: var(--text);
  font-size: 13px;
}

.bubble-link:hover {
  background: #ffffff;
  border-color: rgba(17, 112, 138, 0.28);
}

.attachment-list {
  display: grid;
  gap: 8px;
}

.attachment-card {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(17, 112, 138, 0.16);
  background: rgba(255, 255, 255, 0.72);
}

.attachment-card strong {
  color: var(--text);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.attachment-card span {
  color: var(--muted);
  font-size: 12px;
}

.attachment-card:hover {
  background: #ffffff;
  border-color: rgba(17, 112, 138, 0.28);
}

.state-ok {
  color: var(--ok);
}

.state-warn {
  color: var(--accent-2);
}

.bubble-action {
  justify-items: start;
}

.composer-dock {
  border-top: 1px solid rgba(214, 221, 231, 0.9);
  padding: 16px 18px 18px;
  background: rgba(255, 255, 255, 0.92);
}

.composer-dock textarea {
  min-height: 84px;
  border-radius: 16px;
}

.attachment-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.attachment-picker small {
  color: var(--muted);
  font-size: 12px;
}

.file-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  cursor: pointer;
}

.file-trigger:hover {
  border-color: #b7dfea;
  background: #ffffff;
}

.file-trigger span {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.file-trigger input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.composer-hint {
  color: var(--muted);
  font-size: 13px;
}

.composer-buttons,
.prepare-draft-form {
  display: flex;
  justify-content: flex-end;
}

.prepare-draft-form {
  margin-top: 10px;
}

.panel-item {
  display: grid;
  gap: 12px;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.panel-item:hover {
  transform: translateY(-1px);
  border-color: #b7dfea;
  box-shadow: 0 10px 22px rgba(19, 32, 43, 0.08);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.account-menu {
  position: relative;
}

.account-menu[open] .account-trigger {
  background: var(--surface);
  border-color: var(--line-strong);
}

.account-trigger {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  cursor: pointer;
}

.account-trigger:hover {
  background: rgba(255, 255, 255, 0.98);
}

.account-trigger::-webkit-details-marker {
  display: none;
}

.account-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(180deg, #1b90ae 0%, #0d6b84 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.account-name {
  font-weight: 700;
}

.menu-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: min(360px, calc(100vw - 40px));
  padding: 14px;
  display: grid;
  gap: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
  z-index: 10;
}

.menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

dt {
  color: var(--muted);
  font-size: 13px;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .bubble {
    max-width: 100%;
  }

  .composer-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .composer-buttons,
  .prepare-draft-form {
    width: 100%;
  }

  .attachment-picker {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-presence {
    justify-items: start;
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  h1 {
    font-size: 28px;
  }

  .counters {
    justify-content: flex-start;
  }

  .top-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .tabbar {
    overflow: auto;
  }

  .tablink {
    flex: 1 0 auto;
    min-width: 100px;
  }

  .counters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .counters span {
    justify-content: center;
  }

  .sidebar-card,
  .panel-card,
  .tabbar,
  .chat-header,
  .chat-feed,
  .composer-dock {
    padding-left: 14px;
    padding-right: 14px;
  }

  .chat-feed {
    gap: 10px;
  }

  .panel-fill {
    min-height: auto;
  }

  .bubble {
    padding: 12px 13px;
  }

  .composer-dock textarea {
    min-height: 72px;
  }

  .composer-actions button,
  .prepare-draft-form button,
  .bubble-action button,
  .panel-item button {
    width: 100%;
  }
}
