:root {
  color-scheme: light;
  --line: #06c755;
  --line-dark: #078a3f;
  --chat-bg: #dfeaf4;
  --chat-bg-deep: #cdddea;
  --panel: #ffffff;
  --panel-soft: #f7faf8;
  --text: #17211d;
  --muted: #66746e;
  --border: #dce5df;
  --blue: #2563eb;
  --amber: #b45309;
  --red: #b42318;
  --shadow: 0 20px 60px rgba(23, 33, 29, 0.14);
  --focus: 0 0 0 3px rgba(6, 199, 85, 0.28);
  font-family:
    "Yu Gothic UI", "Meiryo", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--chat-bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

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

.case-sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fbfbfb;
  border-right: 1px solid var(--border);
}

.client-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

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

.client-header h1,
.case-header h2,
.thread-toolbar h3,
.rail-heading h3,
.notes-header h3 {
  margin: 0;
  line-height: 1.25;
  letter-spacing: 0;
}

.client-header h1 {
  font-size: 24px;
}

.round-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid #a8dfbc;
  border-radius: 50%;
  background: #e9faef;
  color: #086a34;
  font-size: 24px;
  line-height: 1;
  font-weight: 600;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.count-pill,
.mobile-status,
.status-badge,
.case-chip,
.mini-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 4px 10px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.client-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}

.client-summary > div {
  min-width: 0;
  padding: 10px;
  background: #fbfdfb;
}

.summary-number,
.summary-label {
  display: block;
  overflow-wrap: anywhere;
}

.summary-number {
  font-size: 17px;
  font-weight: 800;
}

.summary-label {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.account-panel {
  display: grid;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px 12px;
  background: #fff;
}

.account-current {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.account-current strong,
.account-current span {
  display: block;
  overflow-wrap: anywhere;
}

.account-current strong {
  font-size: 14px;
}

.account-current span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.account-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.account-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 8px;
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  background: #fbfdfb;
  color: var(--text);
  text-align: left;
}

.account-row[aria-current="true"] {
  border-color: #73d896;
  background: #eaf8ef;
}

.account-avatar,
.participant-chip span:first-child {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 900;
}

.account-avatar {
  width: 30px;
  height: 30px;
  background: #e7f8ed;
  color: #086a34;
  font-size: 12px;
}

.account-avatar[data-org="client"] {
  background: #eef4ff;
  color: #1d4ed8;
}

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

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

.account-copy strong {
  font-size: 12px;
  line-height: 1.2;
}

.account-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b8c8bf;
}

.presence-dot[data-state="online"] {
  background: var(--line);
}

.presence-dot[data-state="away"] {
  background: #f1b84b;
}

.case-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow-y: auto;
}

.case-empty {
  padding: 18px 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
}

.case-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-height: 78px;
  border: 0;
  border-bottom: 1px solid #ebefec;
  border-radius: 0;
  padding: 12px 14px;
  background: #fbfbfb;
  color: inherit;
  text-align: left;
  transition: background 120ms ease;
}

.case-row:hover {
  background: #f1f6f3;
}

.case-row[aria-current="true"] {
  background: #eaf8ef;
}

.talk-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #06c755, #38df7e);
  color: #063f20;
  font-weight: 900;
  grid-row: span 3;
}

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

.case-row-top,
.case-row-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.case-row-meta {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
}

.unread-badge {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  padding: 0 5px;
  color: #fff;
  background: #06c755;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.case-row-title {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.case-row-summary {
  display: block;
  margin: 3px 0 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.case-workspace {
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.mobile-topbar {
  display: none;
}

.case-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--chat-bg);
}

.case-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.98);
}

.case-title-block {
  min-width: 0;
}

.case-number {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.case-header h2 {
  font-size: 19px;
  overflow-wrap: anywhere;
}

.case-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.participant-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.participant-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px 3px 4px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.participant-chip span:first-child {
  width: 20px;
  height: 20px;
  background: #e7f8ed;
  color: #086a34;
  font-size: 10px;
}

.participant-chip[data-org="client"] span:first-child {
  background: #eef4ff;
  color: #1d4ed8;
}

.case-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-badge[data-tone="green"],
.mini-badge[data-tone="green"] {
  border-color: #9dddb7;
  color: #086a34;
  background: #e7f8ed;
}

.status-badge[data-tone="amber"],
.mini-badge[data-tone="amber"] {
  border-color: #f1c27d;
  color: #8a4b0b;
  background: #fff4df;
}

.status-badge[data-tone="blue"],
.mini-badge[data-tone="blue"] {
  border-color: #aac4ff;
  color: #1d4ed8;
  background: #eef4ff;
}

.ghost-button,
.small-button,
.chip-button,
.note-button,
.tiny-button,
.send-button,
.icon-button {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-weight: 800;
}

.ghost-button,
.small-button,
.chip-button,
.note-button,
.tiny-button {
  padding: 8px 12px;
}

.tiny-button {
  min-height: 32px;
  padding: 5px 9px;
  border-color: #d7e1da;
  color: var(--muted);
  background: #fbfdfb;
  font-size: 12px;
}

.ghost-button:hover,
.small-button:hover,
.chip-button:hover,
.note-button:hover,
.icon-button:hover {
  border-color: #b8c8bf;
  background: #f7faf8;
}

.note-button {
  min-height: 36px;
  border-color: #bfe8cf;
  color: #086a34;
  background: #effbf3;
}

.announce-bar {
  min-height: 38px;
  border-bottom: 1px solid rgba(6, 199, 85, 0.22);
  padding: 8px 18px;
  background: #f2fff6;
  color: #086a34;
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.thread-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--chat-bg);
}

.thread-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(138, 158, 174, 0.35);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
}

.thread-toolbar h3,
.rail-heading h3 {
  font-size: 15px;
}

.thread-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.message-log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 18px 18px 20px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 18px 18px, rgba(255, 255, 255, 0.24) 0 2px, transparent 3px),
    var(--chat-bg);
  background-size: 28px 28px, auto;
}

.date-separator {
  align-self: center;
  border-radius: 999px;
  padding: 5px 12px;
  background: rgba(78, 102, 119, 0.28);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.message {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: end;
  max-width: min(620px, 84%);
}

.message.is-own {
  grid-template-columns: minmax(0, 1fr) 32px;
  align-self: flex-end;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2f80ed;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.is-own .avatar {
  background: var(--line);
  color: #063f20;
  grid-column: 2;
}

.avatar[data-org="client"] {
  background: #2f80ed;
}

.avatar[data-org="self"] {
  background: var(--line);
  color: #063f20;
}

.bubble-wrap {
  min-width: 0;
}

.is-own .bubble-wrap {
  grid-column: 1;
  grid-row: 1;
  text-align: right;
}

.message-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  color: #526575;
  font-size: 11px;
}

.is-own .message-meta {
  justify-content: flex-end;
}

.bubble {
  position: relative;
  display: inline-block;
  max-width: 100%;
  border: 0;
  border-radius: 18px;
  padding: 10px 13px;
  background: var(--panel);
  text-align: left;
  line-height: 1.55;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(31, 49, 61, 0.08);
}

.is-own .bubble {
  background: #8de055;
}

.bubble::before {
  position: absolute;
  bottom: 2px;
  left: -5px;
  width: 12px;
  height: 12px;
  background: inherit;
  clip-path: polygon(0 100%, 100% 0, 100% 100%);
  content: "";
}

.is-own .bubble::before {
  right: -5px;
  left: auto;
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.bubble[data-kind="file"] {
  background: #fff;
}

.file-message {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.file-message-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.file-message-action {
  flex: 0 0 auto;
  color: #08783d;
  font-size: 11px;
  font-weight: 800;
}

.bubble.image-message {
  width: min(360px, 100%);
  max-width: 360px;
  overflow: hidden;
  border-radius: 8px;
  padding: 0;
  background: #fff;
  vertical-align: bottom;
}

.is-own .bubble.image-message {
  background: #8de055;
}

.bubble.image-message::before {
  display: none;
}

.image-message-preview {
  display: block;
  width: 100%;
  max-height: 280px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 0;
  padding: 0;
  background: #e6ebee;
  cursor: zoom-in;
}

.image-message-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-message-preview:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid #1479e8;
  outline-offset: -3px;
}

.image-message-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  padding: 6px 9px 7px;
  text-align: left;
}

.image-message-meta span {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-message-meta small {
  flex: 0 0 auto;
  color: #526575;
  font-size: 10px;
}

.image-preview-dialog {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  border: 0;
  padding: 0;
  background: #090b0d;
  color: #fff;
}

.image-preview-dialog:not([open]) {
  display: none;
}

.image-preview-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.image-preview-dialog::backdrop {
  background: rgba(0, 0, 0, 0.9);
}

.image-preview-header {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 58px;
  padding: 8px 12px 8px 16px;
  background: #15191d;
}

.image-preview-copy {
  display: flex;
  flex: 1;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.image-preview-copy strong {
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-preview-copy span {
  flex: 0 0 auto;
  color: #aeb8c0;
  font-size: 11px;
}

.image-preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.image-preview-original {
  min-height: 36px;
  border-radius: 6px;
  padding: 8px 10px;
  background: #2a3036;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.image-preview-close {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #2a3036;
  color: #fff;
  font-size: 24px;
  line-height: 1;
}

.image-preview-original:hover,
.image-preview-close:hover {
  background: #3a4249;
}

.image-preview-original:focus-visible,
.image-preview-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.image-preview-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  cursor: zoom-out;
}

.image-preview-stage img {
  display: block;
  width: auto;
  max-width: min(1200px, calc(100vw - 32px));
  height: auto;
  max-height: calc(100dvh - 90px);
  border-radius: 4px;
  object-fit: contain;
  cursor: default;
}

.message-check {
  margin-top: 6px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
}

.composer {
  border-top: 1px solid rgba(138, 158, 174, 0.35);
  padding: 9px 12px 11px;
  background: rgba(255, 255, 255, 0.96);
}

.composer-options,
.composer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-options {
  justify-content: flex-start;
  margin-bottom: 7px;
}

.plus-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid #cdd7d1;
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 22px;
  font-weight: 500;
}

.check-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  background: #f9fbfa;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.check-option input {
  width: 18px;
  height: 18px;
}

.composer-row textarea {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  max-height: 130px;
  resize: vertical;
  border: 1px solid #d7e1da;
  border-radius: 20px;
  padding: 10px 14px;
  color: var(--text);
  background: #fbfdfb;
  line-height: 1.5;
}

.send-button {
  min-width: 60px;
  min-height: 42px;
  padding: 0 14px;
  border-color: var(--line);
  border-radius: 999px;
  background: var(--line);
  color: #063f20;
}

.send-button:hover {
  background: #0cba52;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

.form-error {
  min-height: 18px;
  margin: 6px 0 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
}

.status-rail {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: #f6f8f7;
}

.notes-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.notes-header h3 {
  font-size: 16px;
}

.notes-close {
  width: 40px;
  height: 40px;
}

.status-section {
  padding: 14px;
  background: var(--panel);
}

.rail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.rail-heading span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.pending-list,
.decision-list,
.file-list {
  display: grid;
  gap: 8px;
}

.rail-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: var(--panel-soft);
}

.rail-item[data-priority="high"] {
  border-color: #f1c27d;
  background: #fff7e8;
}

.rail-item strong {
  display: block;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.rail-item p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.file-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
  background: var(--panel-soft);
  color: var(--text);
  text-decoration: none;
  text-align: left;
  overflow-wrap: anywhere;
}

.file-link:hover {
  border-color: #b8c8bf;
  background: #eef8f2;
}

.file-link span:last-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.file-link small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.file-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: #e8f2ec;
  color: var(--line-dark);
  font-size: 11px;
  font-weight: 900;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid #9dddb7;
  border-radius: 8px;
  padding: 12px 14px;
  background: #f1fff6;
  color: #064a25;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(23, 33, 29, 0.45);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mobile-account {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(23, 33, 29, 0.42);
}

.case-modal-backdrop[hidden] {
  display: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: var(--chat-bg);
}

.login-screen[hidden] {
  display: none;
}

.invite-screen {
  z-index: 95;
}

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

.login-card h2 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: 0;
}

.login-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.login-card input,
.login-card select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #d7e1da;
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--text);
  background: #fbfdfb;
}

.invite-account-summary {
  display: grid;
  gap: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel-soft);
}

.invite-account-summary strong {
  font-size: 15px;
}

.invite-account-summary span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.invite-registration-fields {
  display: grid;
  gap: 12px;
}

.invite-registration-fields[hidden] {
  display: none;
}

.login-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.case-modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 1;
}

.new-case-form {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.invite-create-fields,
.invite-result {
  display: grid;
  gap: 12px;
}

.invite-create-fields[hidden],
.invite-result[hidden] {
  display: none;
}

.new-case-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.new-case-form input,
.new-case-form textarea,
.new-case-form select {
  width: 100%;
  min-width: 0;
  border: 1px solid #d7e1da;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  background: #fbfdfb;
  font: inherit;
}

.new-case-form textarea {
  resize: vertical;
}

.label-optional {
  color: var(--muted);
  font-weight: 500;
}

.invite-copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.invite-copy-row .ghost-button {
  min-width: 72px;
}

.invite-result input[readonly] {
  background: #f1f5f2;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .status-rail {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: 220px;
    border-top: 1px solid var(--border);
    border-left: 0;
  }
}

@media (max-width: 760px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    display: block;
  }

  .case-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(86vw, 340px);
    transform: translateX(-102%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  .case-sidebar.is-open {
    transform: translateX(0);
  }

  .case-workspace,
  .case-main {
    width: 100%;
    height: 100vh;
  }

  .case-workspace {
    flex-direction: column;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 62px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
  }

  .mobile-topbar > div {
    min-width: 0;
    flex: 1;
  }

  .mobile-topbar strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
  }

  .menu-lines,
  .menu-lines::before,
  .menu-lines::after {
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: var(--text);
    content: "";
  }

  .menu-lines::before {
    transform: translateY(-7px);
  }

  .menu-lines::after {
    transform: translateY(5px);
  }

  .case-header {
    padding: 12px 14px 10px;
  }

  .case-header h2 {
    font-size: 18px;
  }

  .case-header p,
  .case-number {
    font-size: 12px;
  }

  .case-actions {
    align-items: flex-end;
    flex-direction: column;
    gap: 6px;
  }

  .participant-strip {
    gap: 5px;
  }

  .ghost-button {
    min-height: 36px;
    padding: 6px 9px;
    font-size: 12px;
  }

  .workspace-grid {
    display: flex;
    flex-direction: column;
  }

  .thread-toolbar {
    min-height: 52px;
    padding: 10px 12px;
  }

  .small-button {
    min-height: 36px;
    padding: 6px 9px;
    font-size: 12px;
  }

  .message-log {
    gap: 10px;
    padding: 12px 12px 14px;
  }

  .message {
    max-width: 96%;
  }

  .status-rail {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    display: block;
    max-height: min(76vh, 640px);
    overflow-y: auto;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    box-shadow: var(--shadow);
    transform: translateY(102%);
    transition: transform 180ms ease;
  }

  .status-rail.is-open {
    transform: translateY(0);
  }

  .notes-header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
  }

  .status-section + .status-section {
    border-top: 1px solid var(--border);
  }

  .composer {
    padding: 9px 10px;
  }

  .composer-row {
    align-items: flex-end;
  }

  .composer-row textarea {
    min-height: 42px;
  }

  .send-button {
    min-width: 58px;
  }
}

@media (max-width: 440px) {
  .case-header {
    flex-direction: column;
    gap: 10px;
  }

  .case-actions {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
  }

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

  .composer-options {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .chip-button {
    padding: 6px 10px;
  }

  .desktop-note-button {
    display: none;
  }

  .account-list {
    grid-template-columns: 1fr;
  }

  .case-modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .case-modal {
    width: 100%;
    max-height: 86vh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
  }
}

body.simple-mode .count-pill,
body.simple-mode .client-summary,
body.simple-mode .account-list,
body.simple-mode .case-row-bottom,
body.simple-mode .case-number,
body.simple-mode #caseLead,
body.simple-mode .participant-strip,
body.simple-mode .case-actions,
body.simple-mode .announce-bar,
body.simple-mode .thread-toolbar,
body.simple-mode .status-rail,
body.simple-mode #mobileNoteButton,
body.simple-mode .check-option,
body.simple-mode #decisionButton,
body.simple-mode #attachButton,
body.simple-mode .message-check,
body.simple-mode .optional-case-field {
  display: none !important;
}

body.simple-mode .app-shell {
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
}

body.simple-mode .client-header {
  align-items: center;
  padding: 18px 16px;
}

body.simple-mode .account-panel {
  padding: 10px 14px;
}

body.simple-mode .account-current .eyebrow,
body.simple-mode .account-current span {
  display: none;
}

body.simple-mode .case-row {
  grid-template-columns: minmax(0, 1fr);
  min-height: 62px;
  padding: 12px 16px;
}

body.simple-mode .talk-avatar {
  display: none;
}

body.simple-mode .case-row-title {
  min-width: 0;
  font-size: 15px;
}

body.simple-mode .case-row-summary {
  display: block;
  max-width: 100%;
  margin: 4px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.simple-mode .case-header {
  min-height: 68px;
  padding: 18px 22px;
}

body.simple-mode .case-header h2 {
  font-size: 22px;
}

body.simple-mode .workspace-grid {
  grid-template-columns: minmax(0, 1fr);
}

body.simple-mode .thread-panel {
  flex: 1 1 auto !important;
}

body.simple-mode .message-log {
  padding: 22px 24px;
}

body.simple-mode .composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: end;
  padding: 10px 12px 12px;
}

body.simple-mode .composer-options {
  margin: 0;
}

body.simple-mode .plus-button {
  width: 42px;
  height: 42px;
}

body.simple-mode .composer-row {
  min-width: 0;
}

body.simple-mode .composer .form-error {
  grid-column: 1 / -1;
  margin: 0;
}

@media (max-width: 760px) {
  body.simple-mode .app-shell {
    display: block;
  }

  body.simple-mode .mobile-topbar {
    min-height: 60px;
  }

  body.simple-mode .case-header {
    display: none;
  }

  body.simple-mode .workspace-grid,
  body.simple-mode .thread-panel {
    flex: 1;
    min-height: 0;
  }

  body.simple-mode .message-log {
    padding: 14px 12px 16px;
  }
}

@media (max-width: 440px) {
  body.simple-mode .thread-toolbar {
    display: none !important;
  }

  body.simple-mode .composer {
    grid-template-columns: auto minmax(0, 1fr);
  }

  body.simple-mode .composer-options {
    flex-wrap: nowrap;
  }

  .image-preview-header {
    gap: 8px;
    min-height: 54px;
    padding: 7px 8px 7px 12px;
  }

  .image-preview-copy span {
    display: none;
  }

  .image-preview-original {
    padding-inline: 8px;
  }
}
