:root {
  --ink: #142621;
  --muted: #687a74;
  --line: #dfe8e4;
  --paper: #ffffff;
  --wash: #f3f8f6;
  --green: #0b6b5f;
  --green-dark: #07483f;
  --mint: #dff4ed;
  --coral: #d45b4d;
  --navy: #0d2020;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--wash);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 16% 0%, #e3f5ef 0, transparent 28rem), var(--wash); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(440px, 100%); padding: 42px; background: rgba(255,255,255,.94); border: 1px solid rgba(11,107,95,.13); border-radius: 28px; box-shadow: 0 28px 80px rgba(10,58,51,.14); }
.brand-lockup { display: flex; align-items: center; gap: 11px; font-weight: 760; letter-spacing: -.02em; color: var(--green-dark); }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: #fff; background: linear-gradient(145deg,var(--green),#159c87); font-family: Georgia,serif; font-size: 23px; box-shadow: 0 6px 18px rgba(11,107,95,.2); }
.brand-lockup.compact .brand-mark { width: 32px; height: 32px; border-radius: 9px; font-size: 19px; }
.eyebrow,.kicker { display: block; color: var(--green); letter-spacing: .14em; font-size: 11px; font-weight: 800; }
.login-card .eyebrow { margin: 38px 0 8px; }
h1 { margin: 0; font-family: Georgia,"Times New Roman",serif; font-size: 36px; line-height: 1.08; font-weight: 500; letter-spacing: -.03em; }
.muted { color: var(--muted); line-height: 1.6; }
label { display: block; margin: 28px 0 8px; font-size: 13px; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); outline: none; }
input:focus,textarea:focus,select:focus { border-color: #6fb8aa; box-shadow: 0 0 0 3px rgba(11,107,95,.11); }
input { height: 48px; padding: 0 14px; }
.button { min-height: 44px; padding: 0 18px; border: 0; border-radius: 12px; font-weight: 760; }
.button.primary { background: var(--green); color: #fff; box-shadow: 0 8px 24px rgba(11,107,95,.2); }
.button.danger { background: #fff0ee; color: #a8382c; border: 1px solid #f2cbc6; }
.button.ghost { background: #fff; color: var(--muted); border: 1px solid var(--line); }
.wide { width: 100%; margin-top: 16px; }
.privacy-note { margin-top: 26px; padding: 13px 15px; border-radius: 12px; background: var(--wash); color: var(--muted); font-size: 12px; line-height: 1.5; }
.error { min-height: 20px; color: #af352b; font-size: 13px; }

.app { min-height: 100vh; }
.topbar { height: 64px; padding: 0 22px; display: grid; grid-template-columns: 220px 1fr auto; align-items: center; gap: 18px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(18px); }
.consult-title { display: flex; align-items: center; justify-content: center; gap: 11px; min-width: 0; }
.consult-title strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.status-pill { padding: 4px 9px; border-radius: 999px; background: #eef2f1; color: var(--muted); font-size: 11px; font-weight: 800; }
.status-pill.live { background: #e2f6ee; color: var(--green); }
.status-pill.ended { background: #f1f1f1; color: #888; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.identity { font-size: 12px; font-weight: 750; }
.connection { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.connection i,.presence-dot { width: 7px; height: 7px; border-radius: 50%; background: #acb9b5; }
.connection.online i,.video-card.online .presence-dot { background: #1cb785; box-shadow: 0 0 0 4px rgba(28,183,133,.12); }
.icon-button,.text-button { border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
.workspace { min-height: calc(100vh - 64px); display: grid; grid-template-columns: minmax(0,1.8fr) minmax(330px,.75fr); transition: grid-template-columns .22s ease; }
.workspace.record-open { grid-template-columns: minmax(0,1.18fr) minmax(520px,.92fr); }
.call-area { padding: 18px; display: flex; flex-direction: column; min-width: 0; background: #071a19; }
.notice { min-height: 38px; display: grid; place-items: center; padding: 8px 14px; margin-bottom: 12px; border-radius: 10px; background: rgba(255,255,255,.08); color: #d9e9e4; font-size: 12px; }
.video-grid { flex: 1; min-height: 480px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.video-card { position: relative; overflow: hidden; min-height: 220px; border-radius: 18px; background: linear-gradient(145deg,#102d2a,#081614); border: 1px solid rgba(255,255,255,.1); }
.video-grid.media-layout-active { grid-template-columns: minmax(0,2.15fr) minmax(210px,.85fr); grid-template-rows: repeat(2,minmax(0,1fr)); }
.video-grid.media-layout-active .video-card.is-main { grid-column: 1; grid-row: 1 / 3; }
.video-grid.media-layout-active .video-card.is-side[data-side-position="1"] { grid-column: 2; grid-row: 1; }
.video-grid.media-layout-active .video-card.is-side[data-side-position="2"] { grid-column: 2; grid-row: 2; }
.video-card:first-child:last-child { grid-column: 1/-1; }
.video-card video { width: 100%; height: 100%; object-fit: cover; display: block; position: relative; z-index: 2; background: transparent; }
.video-card:not(.has-video) video { opacity: 0; }
.avatar-fallback { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; color: #d7e7e2; }
.avatar-fallback span { width: 72px; height: 72px; border-radius: 24px; display: grid; place-items: center; background: rgba(109,200,179,.13); border: 1px solid rgba(151,227,209,.2); font-family: Georgia,serif; font-size: 30px; color: #94d8c9; }
.avatar-fallback small { color: #7fa099; }
.video-label { position: absolute; z-index: 4; left: 13px; bottom: 13px; display: flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 999px; color: #fff; background: rgba(4,18,16,.72); backdrop-filter: blur(10px); font-size: 11px; }
.video-label em { font-style: normal; color: #a9c0b9; }
.focus-switch { position: absolute; z-index: 6; top: 12px; left: 12px; width: 38px; height: 38px; display: none; place-items: center; padding: 0; border: 1px solid rgba(255,255,255,.18); border-radius: 11px; color: #eef8f5; background: rgba(5,29,26,.7); backdrop-filter: blur(10px); box-shadow: 0 8px 22px rgba(0,0,0,.18); transition: background .16s ease, transform .16s ease; }
.focus-switch:hover { background: rgba(17,100,88,.9); transform: translateY(-1px); }
.focus-switch:focus-visible { outline: 3px solid rgba(148,216,201,.55); outline-offset: 2px; }
.focus-switch svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.video-grid.media-layout-active .video-card.is-side .focus-switch { display: grid; }
.video-grid.media-layout-active .video-card.is-side .avatar-fallback span { width: 58px; height: 58px; border-radius: 19px; font-size: 25px; }
.video-grid.media-layout-active .video-card.is-side .video-label { max-width: calc(100% - 26px); }
.video-grid.media-layout-active .video-card.is-side .video-label em { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.controls { min-height: 78px; display: flex; align-items: center; justify-content: center; gap: 10px; padding-top: 14px; }
.control { min-height: 46px; display: inline-flex; align-items: center; gap: 8px; padding: 0 15px; border: 1px solid rgba(255,255,255,.14); border-radius: 13px; background: rgba(255,255,255,.08); color: #e7f2ef; }
.control b { font-size: 12px; }
.control:disabled { opacity: .42; cursor: not-allowed; }
.primary-control { background: var(--green); border-color: var(--green); }
.danger-control { color: #ffb7ae; }

.side-panel { position: relative; overflow: hidden; background: var(--paper); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.summary-card { padding: 22px; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 12px; }
h2 { margin: 3px 0 0; font-family: Georgia,"Times New Roman",serif; font-size: 21px; font-weight: 500; }
.summary-preview { min-height: 121px; max-height: 121px; overflow: hidden; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--wash); white-space: pre-line; font-size: 13px; line-height: 1.55; }
.summary-header-button { min-height: 32px; display: inline-flex; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid #cfe2dc; border-radius: 10px; background: #f7fbfa; color: var(--green); font-size: 10px; font-weight: 800; white-space: nowrap; }
.summary-header-button:hover { background: var(--mint); }
.summary-header-button b { font-size: 12px; }
.tabs { min-height: 54px; display: flex; align-items: center; gap: 2px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.tab { height: 47px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 12px; font-weight: 760; }
.tab.active { color: var(--green); border-bottom-color: var(--green); }
.conversation-select { width: min(270px,48%); height: 36px; margin-left: auto; padding: 0 9px; flex: 0 1 270px; font-size: 11px; }
.badge { min-width: 17px; height: 17px; padding: 0 5px; display: inline-grid; place-items: center; border-radius: 999px; background: var(--coral); color: #fff; font-size: 9px; }
.tab-panel { display: none; min-height: 0; flex: 1; padding: 16px 18px; }
.tab-panel.active { display: flex; flex-direction: column; }
.select { height: 38px; padding: 0 10px; font-size: 12px; }
.messages { flex: 1; min-height: 200px; overflow-y: auto; padding: 10px 2px 8px; display: flex; flex-direction: column; gap: 6px; }
.message { width: fit-content; min-width: 96px; max-width: 86%; align-self: flex-start; padding: 6px 9px 7px; border-radius: 12px 12px 12px 4px; background: var(--wash); font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.message.mine { align-self: flex-end; border-radius: 12px 12px 4px 12px; background: var(--mint); }
.message-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 2px; color: var(--muted); font-size: 9px; line-height: 1.2; }
.chat-compose { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.chat-compose textarea { min-height: 40px; max-height: 96px; resize: none; padding: 8px 10px; line-height: 1.35; }
.send-button { height: 40px; padding: 0 15px; border: 0; border-radius: 11px; background: var(--green); color: #fff; font-weight: 760; }
.upload-box { margin: 0; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 14px; border: 1px dashed #a8c7bf; border-radius: 11px; background: var(--wash); color: var(--green); transition: background .16s ease,border-color .16s ease; }
.upload-box:hover { background: var(--mint); border-color: #72ad9f; }
.upload-box input { display: none; }
.upload-box span { font-size: 12px; font-weight: 800; }
.upload-box small { color: var(--muted); font-size: 10px; font-weight: 600; white-space: nowrap; }
.files-list { overflow-y: auto; padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.file-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.file-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--mint); color: var(--green); font-size: 11px; font-weight: 900; }
.file-row b,.file-row small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.file-row b { font-size: 12px; }
.file-row small { color: var(--muted); font-size: 9px; }
.file-preview-button { min-height: 36px; padding: 0 13px; border: 1px solid #cfe2dc; border-radius: 10px; background: #fff; color: var(--green); font-size: 11px; font-weight: 800; }
.file-preview-button:hover { background: var(--mint); }
.manage-head { margin-bottom: 12px; }
.participant-controls { display: flex; flex-direction: column; gap: 9px; }
.participant-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.participant-row small { display: block; color: var(--muted); margin-top: 3px; }
.participant-row button { border: 0; border-radius: 9px; padding: 8px 10px; background: var(--mint); color: var(--green); font-size: 11px; font-weight: 800; }
.direct-access { border-radius: 999px; padding: 6px 9px; background: var(--mint); color: var(--green); font-size: 10px; font-weight: 800; }
.manage-actions { margin-top: 10px; }
.record-drawer { position: absolute; inset: 0; z-index: 15; min-height: calc(100vh - 64px); display: flex; flex-direction: column; background: #fff; }
.record-header { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 17px 22px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.97); }
.record-header h2 { margin-top: 2px; }
.record-header small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.record-header-actions { display: flex; align-items: center; gap: 7px; }
.compact-button { min-height: 36px; padding: 0 13px; font-size: 11px; }
.record-close { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--muted); font-size: 22px; line-height: 1; }
.record-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 22px; background: #f8fbfa; }
.record-content { display: flex; flex-direction: column; gap: 14px; }
.record-section { padding: 17px 18px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: 0 5px 18px rgba(18,71,62,.04); }
.record-section h3 { margin: 0 0 11px; color: var(--green-dark); font-family: Georgia,"Times New Roman",serif; font-size: 17px; font-weight: 600; }
.record-field { display: grid; grid-template-columns: minmax(100px,132px) 1fr; gap: 12px; padding: 7px 0; border-top: 1px solid #edf2f0; font-size: 12px; line-height: 1.65; }
.record-field:first-of-type { border-top: 0; padding-top: 0; }
.record-field:last-child { padding-bottom: 0; }
.record-field strong { color: #526a63; }
.record-field span { color: var(--ink); }
.record-paragraph { margin: 0; color: var(--ink); font-size: 12px; line-height: 1.8; }
.record-editor { width: 100%; min-height: calc(100vh - 230px); padding: 18px; resize: vertical; border-radius: 15px; background: #fff; font-size: 13px; line-height: 1.75; }
.record-footer { min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; background: #fff; }
.file-preview { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 22px; background: rgba(2,15,14,.78); backdrop-filter: blur(12px); }
.preview-shell { width: min(1120px,100%); height: min(88vh,860px); display: flex; flex-direction: column; overflow: hidden; border: 1px solid rgba(255,255,255,.18); border-radius: 20px; background: #f8fbfa; box-shadow: 0 30px 90px rgba(0,0,0,.38); }
.preview-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: #fff; }
.preview-header h2 { max-width: 66vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.preview-header small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.preview-actions { display: flex; align-items: center; gap: 8px; }
.preview-actions a { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.preview-body { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; overflow: auto; background: #eaf0ee; }
.preview-image { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; cursor: zoom-in; transition: max-width .18s ease,max-height .18s ease; }
.preview-image.zoomed { max-width: none; max-height: none; cursor: zoom-out; }
.preview-pdf { width: 100%; height: 100%; border: 0; background: #fff; }
.preview-document { align-self: start; width: min(820px,calc(100% - 32px)); min-height: calc(100% - 32px); margin: 16px; padding: 34px 42px; overflow: visible; white-space: pre-wrap; word-break: break-word; border-radius: 5px; background: #fff; color: #24312e; box-shadow: 0 8px 34px rgba(0,0,0,.12); font-family: Georgia,"Times New Roman","Songti SC",serif; font-size: 14px; line-height: 1.85; }
.preview-message { max-width: 520px; padding: 24px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.7; }
body.preview-open { overflow: hidden; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%,20px); padding: 11px 16px; border-radius: 12px; background: #132a27; color: #fff; box-shadow: 0 10px 32px rgba(0,0,0,.2); opacity: 0; pointer-events: none; transition: .2s; z-index: 50; font-size: 12px; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 900px) {
  .topbar { grid-template-columns: auto 1fr; height: auto; min-height: 64px; padding: 10px 14px; }
  .topbar .brand-lockup { display: none; }
  .consult-title { justify-content: flex-start; }
  .identity { display: none; }
  .workspace { display: block; }
  .workspace.record-open { display: block; }
  .call-area { min-height: 58vh; padding: 10px; }
  .video-grid { min-height: 340px; }
  .video-grid.media-layout-active { min-height: 520px; grid-template-columns: repeat(2,minmax(0,1fr)); grid-template-rows: minmax(300px,1fr) minmax(150px,.5fr); }
  .video-grid.media-layout-active .video-card.is-main { grid-column: 1 / 3; grid-row: 1; }
  .video-grid.media-layout-active .video-card.is-side[data-side-position="1"] { grid-column: 1; grid-row: 2; }
  .video-grid.media-layout-active .video-card.is-side[data-side-position="2"] { grid-column: 2; grid-row: 2; }
  .side-panel { min-height: 52vh; border-left: 0; }
  .record-drawer { position: fixed; top: 64px; right: 0; bottom: 0; left: 0; min-height: 0; z-index: 30; }
}

@media (max-width: 560px) {
  .topbar { gap: 8px; }
  .top-actions { gap: 6px; }
  .connection { display: none; }
  .consult-title strong { max-width: 53vw; font-size: 13px; }
  .call-area { min-height: 50vh; }
  .video-grid { grid-template-columns: 1fr; min-height: 360px; }
  .video-card { min-height: 210px; }
  .video-grid.media-layout-active { min-height: 440px; grid-template-columns: repeat(2,minmax(0,1fr)); grid-template-rows: minmax(260px,1fr) minmax(130px,.5fr); }
  .video-grid.media-layout-active .video-card.is-main { min-height: 260px; }
  .video-grid.media-layout-active .video-card.is-side { min-height: 130px; border-radius: 14px; }
  .video-grid.media-layout-active .video-card.is-side .video-label { left: 8px; bottom: 8px; padding: 5px 7px; }
  .video-grid.media-layout-active .video-card.is-side .video-label em { display: none; }
  .focus-switch { top: 8px; left: 8px; width: 34px; height: 34px; }
  .controls { position: sticky; bottom: 0; z-index: 8; gap: 6px; overflow-x: auto; justify-content: flex-start; }
  .control { flex: 0 0 auto; min-height: 43px; padding: 0 11px; }
  .control b { display: none; }
  .side-panel { min-height: 58vh; }
  .summary-card { padding: 17px; }
  .summary-preview { min-height: 112px; max-height: 112px; }
  .record-header { min-height: 78px; padding: 13px 14px; }
  .record-header .kicker,.record-header small { display: none; }
  .record-header h2 { font-size: 18px; }
  .record-scroll { padding: 13px; }
  .record-section { padding: 14px; }
  .record-field { grid-template-columns: 1fr; gap: 3px; }
  .record-editor { min-height: calc(100vh - 205px); }
  .record-footer { padding: 8px 14px; }
  .record-footer span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .file-preview { padding: 0; }
  .preview-shell { width: 100%; height: 100%; border: 0; border-radius: 0; }
  .preview-header { min-height: 66px; padding: 10px 12px; }
  .preview-header .kicker,.preview-header small { display: none; }
  .preview-header h2 { max-width: 44vw; font-size: 16px; }
  .preview-actions .button { padding: 0 9px; }
  .preview-document { width: calc(100% - 20px); min-height: calc(100% - 20px); margin: 10px; padding: 22px 18px; }
  .tab-panel { min-height: 360px; padding: 13px; }
  .tabs { padding: 0 10px; }
  .tab { padding: 0 9px; }
  .conversation-select { width: 42%; flex-basis: 42%; }
  .login-card { padding: 30px 24px; }
  h1 { font-size: 31px; }
}
