:root {
  --ink: #101b2b;
  --ink-soft: #263651;
  --paper: #f3f6f7;
  --white: #ffffff;
  --line: #d7e0e3;
  --muted: #7a8894;
  --cyan: #62e4da;
  --cyan-deep: #1db6ae;
  --orange: #ff9e63;
  --danger: #ff6d71;
  --shadow: 0 24px 70px rgba(11, 26, 45, .16);
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background: #dfe8e9;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { min-height: 100vh; overflow-x: hidden; background: radial-gradient(circle at 80% 0%, #fbffff 0, #dfe8e9 48%, #cbd9dc 100%); }
button, input, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(29, 182, 174, .42); outline-offset: 2px; }

.grain { position: fixed; inset: 0; pointer-events: none; opacity: .18; mix-blend-mode: multiply; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E"); }
.app-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; position: relative; z-index: 1; }

.landing { width: min(1020px, 100%); display: grid; grid-template-columns: 1.05fr .95fr; background: var(--paper); box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,.65); min-height: 650px; }
.landing-copy { padding: clamp(34px, 7vw, 92px); display: flex; flex-direction: column; justify-content: space-between; background: var(--ink); color: var(--white); position: relative; overflow: hidden; }
.landing-copy::after { content: ''; position: absolute; width: 320px; height: 320px; border: 1px solid rgba(98,228,218,.34); border-radius: 50%; right: -120px; bottom: -80px; box-shadow: 0 0 0 34px rgba(98,228,218,.06), 0 0 0 68px rgba(98,228,218,.035); }
.brand { display: flex; gap: 12px; align-items: center; letter-spacing: .1em; font-family: Consolas, 'SFMono-Regular', monospace; font-size: 13px; color: var(--cyan); }
.brand-mark { width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid var(--cyan); border-radius: 50%; font-size: 14px; }
.landing h1 { max-width: 480px; margin: 80px 0 18px; font-size: clamp(42px, 6vw, 75px); line-height: .98; letter-spacing: -.07em; font-weight: 800; }
.landing h1 span { color: var(--cyan); }
.landing-intro { max-width: 390px; color: #b7c5ce; line-height: 1.7; font-size: 15px; }
.landing-foot { color: #8295a3; font-family: Consolas, 'SFMono-Regular', monospace; font-size: 11px; letter-spacing: .06em; }
.landing-actions { padding: clamp(28px, 5vw, 68px); display: flex; flex-direction: column; justify-content: center; background: var(--paper); }
.eyebrow { color: var(--muted); font: 500 11px Consolas, 'SFMono-Regular', monospace; letter-spacing: .08em; text-transform: uppercase; }
.landing-actions h2 { margin: 12px 0 30px; font-size: 29px; letter-spacing: -.04em; }
.action-block { padding: 22px 0 28px; border-top: 1px solid var(--line); }
.action-block:last-child { border-bottom: 1px solid var(--line); }
.action-title { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.action-title strong { font-size: 17px; }
.action-title span { font: 12px Consolas, 'SFMono-Regular', monospace; color: var(--muted); }
.helper { margin: 0 0 17px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.button { min-height: 48px; display: inline-flex; justify-content: center; align-items: center; gap: 9px; padding: 0 18px; border-radius: 2px; font-weight: 700; transition: transform .18s ease, background .18s ease, color .18s ease; }
.button svg { width: 18px; height: 18px; flex: 0 0 auto; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--cyan); color: var(--ink); }
.button-primary:hover { background: #8ff5ec; }
.button-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.button-ghost:hover { background: var(--white); }
.button-danger { background: rgba(255,109,113,.13); color: #c44b54; }
.button-danger:hover { background: rgba(255,109,113,.22); }
.button-wide { width: 100%; }
.join-form { display: grid; gap: 10px; }
.join-form[hidden] { display: none; }
.pinned-actions { display: grid; gap: 10px; }
.remember-row { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.remember-row input { accent-color: var(--cyan); }
.text-button { border: 0; padding: 0; color: var(--muted); background: transparent; cursor: pointer; font: inherit; font-size: 12px; text-align: left; }
.text-button:hover { color: var(--ink); }
.field { width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 2px; color: var(--ink); background: var(--white); letter-spacing: .03em; }
.field::placeholder { color: #a7b2b8; }
.field-mono { font-family: Consolas, 'SFMono-Regular', monospace; text-transform: uppercase; letter-spacing: .13em; }
.error-text { min-height: 18px; margin: 10px 0 0; color: #bd4a54; font-size: 12px; }

.room-shell { width: min(1180px, 100%); min-height: min(760px, calc(100vh - 56px)); display: grid; grid-template-columns: 278px minmax(0, 1fr); background: var(--paper); box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,.65); overflow: hidden; }
.room-aside { background: var(--ink); color: var(--white); padding: 26px 20px 20px; display: flex; flex-direction: column; gap: 28px; }
.room-aside .brand { margin-bottom: 10px; }
.room-label { color: #90a2af; font: 11px Consolas, 'SFMono-Regular', monospace; letter-spacing: .08em; text-transform: uppercase; }
.room-code { margin: 8px 0 0; font: 500 25px Consolas, 'SFMono-Regular', monospace; letter-spacing: .12em; color: var(--cyan); }
.room-note { color: #a5b3bd; font-size: 12px; line-height: 1.55; margin: 9px 0 0; }
.side-card { border-top: 1px solid rgba(255,255,255,.13); padding-top: 16px; }
.side-stat { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 12px 0; font-size: 12px; color: #b7c3ca; }
.side-stat strong { color: var(--white); font: 500 12px Consolas, 'SFMono-Regular', monospace; }
.status-dot { display: inline-flex; align-items: center; gap: 7px; }
.status-dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 4px rgba(98,228,218,.12); }
.side-spacer { flex: 1; }
.privacy-note { color: #7e929f; font-size: 11px; line-height: 1.6; }
.privacy-note b { color: #afc3cb; font-weight: 600; }

.chat-panel { min-width: 0; display: flex; flex-direction: column; background: var(--white); }
.chat-header { min-height: 76px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); gap: 16px; }
.chat-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chat-heading h2 { margin: 0; font-size: 17px; letter-spacing: -.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.security-pill { display: inline-flex; align-items: center; gap: 6px; color: #328e89; background: #e5f8f5; padding: 6px 9px; font-size: 11px; white-space: nowrap; }
.security-pill svg { width: 13px; height: 13px; }
.chat-actions { display: flex; align-items: center; gap: 8px; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; background: transparent; color: var(--muted); border: 1px solid transparent; }
.icon-button:hover { border-color: var(--line); color: var(--ink); }
.icon-button svg { width: 17px; height: 17px; }
.message-list { flex: 1; min-height: 340px; overflow: auto; padding: 30px 28px; background: #fbfcfc; }
.empty-state { height: 100%; min-height: 340px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty-inner { max-width: 310px; }
.empty-symbol { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 18px; color: var(--cyan-deep); border: 1px solid #b6e8e2; border-radius: 50%; background: #effcfb; }
.empty-symbol svg { width: 24px; height: 24px; }
.empty-state h3 { margin: 0 0 8px; color: var(--ink); font-size: 18px; letter-spacing: -.03em; }
.empty-state p { margin: 0; font-size: 13px; line-height: 1.6; }
.message-row { display: flex; margin: 0 0 18px; }
.message-row.mine { justify-content: flex-end; }
.message-meta { margin: 0 0 6px; color: var(--muted); font: 10px Consolas, 'SFMono-Regular', monospace; }
.message-row.mine .message-meta { text-align: right; }
.message-bubble { max-width: min(560px, 86%); padding: 13px 15px; border: 1px solid var(--line); background: var(--white); color: var(--ink); line-height: 1.6; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-row.mine .message-bubble { background: var(--ink); border-color: var(--ink); color: #f4ffff; }
.file-card { min-width: min(300px, 75vw); display: flex; align-items: center; gap: 12px; }
.file-icon { width: 36px; height: 36px; display: grid; place-items: center; background: #e7f8f5; color: var(--cyan-deep); flex: 0 0 auto; }
.file-icon svg { width: 18px; }
.file-info { min-width: 0; flex: 1; }
.file-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 13px; }
.file-size { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.message-row.mine .file-size { color: #a7c2c5; }
.download-button { color: var(--cyan-deep); background: transparent; padding: 5px; font-size: 12px; font-weight: 700; }
.message-row.mine .download-button { color: var(--cyan); }
.composer { border-top: 1px solid var(--line); padding: 16px 20px 18px; background: var(--white); }
.composer-row { display: flex; align-items: flex-end; gap: 10px; }
.composer textarea { min-height: 48px; max-height: 130px; flex: 1; resize: none; border: 1px solid var(--line); padding: 13px 14px; color: var(--ink); background: #fbfcfc; line-height: 1.45; }
.composer textarea::placeholder { color: #a8b4ba; }
.attach-button { flex: 0 0 auto; }
.send-button { flex: 0 0 auto; min-width: 84px; }
.composer-hint { margin: 9px 0 0 46px; color: var(--muted); font-size: 11px; }
.upload-input { display: none; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(360px, calc(100vw - 48px)); z-index: 4; padding: 12px 16px; color: var(--white); background: var(--ink); box-shadow: 0 12px 28px rgba(10, 20, 32, .2); font-size: 13px; }
.toast.error { background: #8e3540; }
.modal-backdrop { position: fixed; inset: 0; z-index: 3; display: grid; place-items: center; padding: 22px; background: rgba(16,27,43,.48); }
.modal { width: min(440px, 100%); padding: 28px; background: var(--paper); box-shadow: var(--shadow); }
.modal h2 { margin: 0 0 10px; font-size: 22px; letter-spacing: -.04em; }
.modal p { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.destroyed { width: min(560px, 100%); padding: 42px; text-align: center; background: var(--paper); box-shadow: var(--shadow); }
.destroyed h1 { margin: 20px 0 10px; font-size: 32px; letter-spacing: -.05em; }
.destroyed p { color: var(--muted); line-height: 1.65; font-size: 14px; }

@media (max-width: 760px) {
  .app-shell { padding: 0; align-items: stretch; }
  .landing { min-height: 100vh; grid-template-columns: 1fr; box-shadow: none; border: 0; }
  .landing-copy { min-height: 46vh; padding: 28px 24px 32px; }
  .landing h1 { margin: 48px 0 14px; font-size: clamp(46px, 16vw, 74px); }
  .landing-actions { padding: 30px 24px 38px; }
  .room-shell { min-height: 100vh; grid-template-columns: 1fr; box-shadow: none; border: 0; }
  .room-aside { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 16px 12px; }
  .room-aside .brand { grid-column: 1 / -1; margin-bottom: 0; }
  .room-summary { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .room-summary .room-note { display: none; }
  .room-summary .room-code { margin: 0; font-size: 20px; }
  .status-card, .side-spacer, .privacy-note { display: none; }
  .invite-card { grid-column: 1; border-top: 0; padding-top: 0; }
  .invite-card .room-label { display: none; }
  .invite-card .button, .room-aside > .button-danger { min-height: 40px; }
  .room-aside > .button-danger { grid-column: 2; }
  .chat-header { min-height: 66px; padding: 0 16px; }
  .security-pill { display: none; }
  .message-list { padding: 22px 16px; }
  .composer { padding: 12px 12px 14px; }
  .composer-hint { margin-left: 4px; }
  .send-button { min-width: 68px; padding: 0 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
