:root {
  --ink: #17211c;
  --forest: #163f30;
  --forest-deep: #0d2d22;
  --mint: #c8f36a;
  --paper: #f3f1ea;
  --white: #fffef9;
  --line: #dcded6;
  --muted: #6e7872;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.05fr) minmax(420px, .95fr); }
.brand-panel { background: var(--forest); color: white; padding: 64px clamp(48px, 7vw, 112px); display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.brand-panel::after { content: ""; position: absolute; width: 520px; height: 520px; border: 1px solid rgba(200,243,106,.18); border-radius: 50%; right: -230px; bottom: -180px; box-shadow: 0 0 0 72px rgba(200,243,106,.035), 0 0 0 144px rgba(200,243,106,.025); }
.brand-mark, .wordmark span { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 13px; background: var(--mint); color: var(--forest-deep); font-weight: 900; font-size: 24px; }
.brand-panel h1 { font-family: Georgia, serif; font-size: clamp(52px, 6vw, 82px); line-height: .98; letter-spacing: -.045em; margin: 24px 0; font-weight: 500; max-width: 720px; }
.brand-copy { max-width: 480px; font-size: 18px; color: #c8d6cf; line-height: 1.7; }
.eyebrow { font-size: 11px; letter-spacing: .18em; font-weight: 800; color: var(--mint); margin: 24px 0 8px; }
.eyebrow.dark { color: #3e6b58; margin-top: 0; }
.signal-row { display: flex; gap: 7px; align-items: center; margin-top: 80px; color: #b9c8c1; }
.signal-row span { width: 7px; height: 7px; background: var(--mint); border-radius: 50%; }
.signal-row small { margin-left: 8px; }
.login-panel { display: grid; place-items: center; padding: 48px; background: var(--white); }
.login-card { width: min(430px, 100%); }
.login-card h2 { font-family: Georgia, serif; font-size: 44px; font-weight: 500; letter-spacing: -.035em; margin: 8px 0; }
.muted, .login-card > p { color: var(--muted); }
label { display: grid; gap: 8px; font-size: 13px; font-weight: 700; margin: 22px 0; }
input, select { width: 100%; border: 1px solid var(--line); background: #fafaf6; border-radius: 10px; padding: 14px 15px; outline: none; color: var(--ink); }
input:focus, select:focus { border-color: #4d7967; box-shadow: 0 0 0 3px rgba(77,121,103,.12); }
.primary { width: 100%; border: 0; border-radius: 10px; padding: 15px 18px; background: var(--forest); color: white; font-weight: 800; display: flex; align-items: center; justify-content: space-between; }
.primary:hover { background: var(--forest-deep); }
.primary:disabled { opacity: .6; cursor: wait; }
.primary.compact { width: auto; padding: 11px 16px; }
.demo-hint { text-align: center; font-size: 12px; margin-top: 20px; }
code { background: #eceee8; color: var(--forest); padding: 3px 6px; border-radius: 5px; }
.notice { border-radius: 9px; padding: 11px 13px; margin: 16px 0; font-size: 13px; }
.notice.error { background: #fbe8e5; color: #8c3026; border: 1px solid #f1c8c1; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 255px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--forest-deep); color: white; display: flex; flex-direction: column; padding: 28px 20px; }
.wordmark { display: flex; align-items: center; gap: 12px; letter-spacing: .08em; font-size: 13px; }
.wordmark span { width: 36px; height: 36px; border-radius: 10px; font-size: 18px; }
nav { margin-top: 54px; display: grid; gap: 7px; }
.nav-item { border: 0; background: transparent; color: #aabcb4; border-radius: 9px; padding: 12px 14px; text-align: left; display: flex; gap: 12px; }
.nav-item:hover, .nav-item.active { background: #204b3b; color: white; }
.nav-item.active { box-shadow: inset 3px 0 var(--mint); }
.nav-badge, .unread { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; display: grid; place-items: center; border-radius: 99px; background: var(--mint); color: var(--forest-deep); font-size: 10px; }
.sidebar-foot { margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.1); display: grid; grid-template-columns: 38px 1fr 30px; align-items: center; gap: 10px; }
.avatar, .mini-avatar { display: grid; place-items: center; border-radius: 50%; background: var(--mint); color: var(--forest-deep); font-weight: 900; }
.avatar { width: 38px; height: 38px; font-size: 12px; }
.sidebar-foot strong, .sidebar-foot small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot strong { font-size: 12px; }
.sidebar-foot small { font-size: 10px; text-transform: uppercase; color: #94a89e; margin-top: 3px; }
.icon-button { border: 0; background: transparent; color: inherit; font-size: 20px; }
.workspace { padding: 30px clamp(24px, 5vw, 70px) 70px; overflow: hidden; }
.workspace header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 25px; border-bottom: 1px solid var(--line); }
.workspace header h1 { margin: 0; font-family: Georgia, serif; font-size: 34px; font-weight: 500; }
.status-pill { background: var(--white); border: 1px solid var(--line); padding: 8px 12px; border-radius: 99px; font-size: 11px; color: var(--muted); }
.status-pill i { display: inline-block; width: 7px; height: 7px; background: #45a66a; border-radius: 50%; margin-right: 6px; }
.welcome { padding: 46px 0 30px; display: flex; align-items: end; justify-content: space-between; }
.welcome h2 { font-family: Georgia, serif; font-size: clamp(38px, 5vw, 62px); font-weight: 500; letter-spacing: -.04em; margin: 7px 0; }
.welcome p, .welcome time { color: var(--muted); }
.welcome time { font-size: 12px; text-transform: capitalize; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.metric-grid article, .panel { background: var(--white); border: 1px solid var(--line); border-radius: 14px; }
.metric-grid article { padding: 24px; }
.metric-grid span { font-size: 10px; letter-spacing: .13em; color: var(--muted); font-weight: 800; }
.metric-grid strong { display: block; font-family: Georgia, serif; font-size: 48px; font-weight: 500; margin: 12px 0 4px; }
.metric-grid small { color: var(--muted); }
.panel { margin-top: 18px; padding: 26px; }
.panel-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.panel-title h3, dialog h3 { font-family: Georgia, serif; font-size: 28px; font-weight: 500; margin: 4px 0; }
.user-list { border-top: 1px solid var(--line); }
.user-row { display: grid; grid-template-columns: 38px minmax(150px, 1fr) 100px 90px auto; gap: 14px; align-items: center; padding: 14px 2px; border-bottom: 1px solid var(--line); font-size: 12px; }
.mini-avatar { width: 36px; height: 36px; background: #e4eadf; }
.user-main strong, .user-main small { display: block; }
.user-main small { color: var(--muted); margin-top: 3px; }
.role { text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-size: 9px; font-weight: 800; }
.state { color: #a86a5e; }
.state::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; }
.state.online { color: #38835a; }
.text-button { border: 0; background: transparent; color: #3f6c59; font-weight: 700; font-size: 11px; }
.empty { color: var(--muted); padding: 20px 0; }
dialog { width: min(480px, calc(100% - 32px)); border: 0; border-radius: 16px; padding: 0; box-shadow: 0 24px 80px rgba(13,45,34,.24); }
dialog::backdrop { background: rgba(13,35,27,.55); backdrop-filter: blur(3px); }
dialog form { padding: 28px; }
.dialog-head { display: flex; justify-content: space-between; }
.dialog-head .icon-button { color: var(--ink); }

.app-shell:has(.chat-shell) { height: 100vh; height: 100dvh; overflow: hidden; }
.workspace:has(.chat-shell) { min-width: 0; min-height: 0; height: 100vh; height: 100dvh; padding: 0; }
.workspace:has(.chat-shell) > header { display: none; }
.workspace:has(.chat-shell) > #content { height: 100%; min-height: 0; }
.chat-shell { width: 100%; height: 100%; min-height: 0; margin: 0; display: grid; grid-template-columns: minmax(280px, 34%) 1fr; overflow: hidden; background: var(--white); border: 0; border-radius: 0; box-shadow: none; }
.contacts-pane { min-width: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: #fbfbf7; }
.contacts-head { padding: 24px 22px 14px; display: flex; align-items: center; justify-content: space-between; }
.contacts-head h2 { margin: 2px 0; font: 500 30px Georgia, serif; }
.add-contact-button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--forest); color: white; font-size: 22px; line-height: 1; }
.add-contact-button:hover { background: var(--forest-deep); }
.contact-search { margin: 0 16px 14px; position: relative; display: block; }
.contact-search span { position: absolute; left: 13px; top: 10px; color: var(--muted); font-size: 20px; }
.contact-search input { padding: 11px 12px 11px 39px; border-radius: 99px; background: #f1f2ed; }
.contact-list { overflow-y: auto; padding: 0 8px 12px; }
.contact-item { width: 100%; border: 0; background: transparent; padding: 11px 10px; border-radius: 12px; display: flex; align-items: center; gap: 11px; text-align: left; color: var(--ink); }
.contact-item:hover, .contact-item.active { background: #e9eee7; }
.contact-item.active { box-shadow: inset 3px 0 var(--forest); }
.contact-avatar { width: 43px; height: 43px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: #dce9d2; color: var(--forest); font-weight: 900; font-size: 12px; }
.contact-copy { min-width: 0; flex: 1; }
.contact-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.contact-line strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-line small { display: block; min-width: 0; margin-top: 5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-line time { flex: none; font-size: 9px; color: var(--muted); }
.unread { flex: none; margin-top: 4px; }
.chat-empty-list { padding: 24px 14px; color: var(--muted); text-align: center; font-size: 13px; }
.conversation-pane { min-width: 0; display: flex; flex-direction: column; background-color: #f3f1ea; background-image: radial-gradient(rgba(22,63,48,.055) .7px, transparent .7px); background-size: 13px 13px; }
.conversation-head { flex: none; height: 70px; padding: 12px 20px; display: flex; align-items: center; gap: 12px; background: rgba(255,254,249,.96); border-bottom: 1px solid var(--line); }
.conversation-head strong, .conversation-head small { display: block; }
.conversation-head small { color: var(--muted); margin-top: 4px; font-size: 11px; }
.chat-back { display: none; border: 0; background: transparent; font-size: 30px; color: var(--forest); }
.message-list { flex: 1; min-height: 0; overflow-y: auto; padding: 24px clamp(18px, 4vw, 55px); scroll-behavior: smooth; }
.message-row { display: flex; margin: 5px 0; }
.message-row.mine { justify-content: flex-end; }
.message-bubble { max-width: min(72%, 560px); padding: 9px 12px 6px; background: var(--white); border-radius: 5px 15px 15px 15px; box-shadow: 0 1px 2px rgba(23,33,28,.1); }
.message-row.mine .message-bubble { background: #dff2bf; border-radius: 15px 5px 15px 15px; }
.message-bubble p { margin: 0; line-height: 1.45; font-size: 14px; overflow-wrap: anywhere; }
.message-bubble span { display: block; margin-top: 3px; text-align: right; color: #718075; font-size: 9px; }
.day-divider { display: flex; justify-content: center; margin: 18px 0; }
.day-divider span { padding: 5px 10px; border-radius: 99px; background: rgba(255,254,249,.92); color: var(--muted); font-size: 10px; box-shadow: 0 1px 2px rgba(23,33,28,.08); }
.message-composer { flex: none; padding: 12px 16px max(12px, env(safe-area-inset-bottom)); display: flex; align-items: end; gap: 10px; background: rgba(255,254,249,.96); border-top: 1px solid var(--line); }
.message-composer textarea { flex: 1; min-height: 44px; max-height: 120px; resize: vertical; border: 1px solid var(--line); border-radius: 22px; background: #f7f7f2; padding: 12px 16px; color: var(--ink); outline: none; }
.message-composer textarea:focus { border-color: #4d7967; }
.message-composer button { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: var(--forest); color: white; }
.conversation-empty, .new-chat { margin: auto; text-align: center; color: var(--muted); padding: 30px; }
.conversation-empty h2 { margin: 14px 0 8px; font: 500 30px Georgia, serif; color: var(--ink); }
.conversation-empty p { max-width: 330px; line-height: 1.6; }
.empty-chat-icon { width: 70px; height: 70px; margin: auto; display: grid; place-items: center; border-radius: 50%; background: var(--forest); color: var(--mint); font-size: 36px; }
.new-chat { padding-top: 25%; }
.new-chat span, .new-chat strong { display: block; }
.new-chat span { font-size: 30px; }
.new-chat strong { margin-top: 10px; color: var(--ink); }
.contact-dialog-body { padding: 28px; }
.contact-dialog-copy { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.contact-dialog .add-search { margin: 0 0 12px; }
.available-contact-list { max-height: 360px; overflow-y: auto; }
.available-contact { display: grid; grid-template-columns: 43px 1fr auto; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.available-contact strong, .available-contact small { display: block; }
.available-contact strong { font-size: 13px; }
.available-contact small { margin-top: 4px; color: var(--muted); }
.available-contact > button { border: 0; border-radius: 8px; padding: 8px 11px; background: #e5eddf; color: var(--forest); font-size: 11px; font-weight: 800; }
.available-contact > button:hover { background: var(--mint); }
.available-contact > button:disabled { opacity: .5; cursor: wait; }

@media (max-width: 850px) {
  .login-shell { grid-template-columns: 1fr; }
  .brand-panel { min-height: 44vh; padding: 38px 28px; }
  .brand-panel h1 { font-size: 48px; }
  .brand-copy, .signal-row { display: none; }
  .login-panel { padding: 38px 24px; }
  .app-shell { grid-template-columns: 1fr; }
  .app-shell:has(.chat-shell) { grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { position: static; height: auto; padding: 16px 18px; display: grid; grid-template-columns: auto 1fr auto; }
  .sidebar nav { margin: 0; display: flex; justify-content: center; }
  .sidebar-foot { margin: 0; border: 0; padding: 0; }
  .sidebar-foot > div:not(.avatar), .sidebar-foot .avatar { display: none; }
  .workspace { padding: 24px 18px 50px; }
  .workspace:has(.chat-shell) { height: auto; padding: 0; overflow: hidden; }
}

@media (max-width: 620px) {
  .wordmark strong, .status-pill, .welcome time { display: none; }
  .welcome { padding-top: 30px; }
  .welcome h2 { font-size: 38px; }
  .metric-grid { grid-template-columns: 1fr; }
  .user-row { grid-template-columns: 36px 1fr auto; }
  .user-row .role, .user-row .state { display: none; }
  .panel { padding: 18px; }
  .panel-title { align-items: flex-start; gap: 16px; }
  .workspace:has(.chat-shell) { padding: 0; }
  .workspace:has(.chat-shell) > header { display: none; }
  .chat-shell { height: 100%; min-height: 0; margin: 0; grid-template-columns: 1fr; }
  .contacts-pane { border-right: 0; }
  .conversation-pane { display: none; }
  .chat-shell:has(.conversation-head) .contacts-pane { display: none; }
  .chat-shell:has(.conversation-head) .conversation-pane { display: flex; }
  .chat-back { display: block; }
  .message-bubble { max-width: 86%; }
}
