:root {
  --navy-950: #06284b;
  --navy-900: #082f57;
  --blue-700: #0969da;
  --blue-600: #0b76e0;
  --blue-100: #e8f2ff;
  --green-700: #167543;
  --green-100: #e8f6ee;
  --red-700: #b42318;
  --red-100: #fff0ee;
  --amber-700: #9a5b00;
  --amber-100: #fff6df;
  --gray-950: #17202a;
  --gray-700: #4e5967;
  --gray-500: #7d8794;
  --gray-300: #cfd5dc;
  --gray-200: #e3e7eb;
  --gray-100: #f5f7f9;
  --white: #fff;
  --header-height: 66px;
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: var(--gray-950);
  background: var(--white);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-size: 16px; line-height: 1.5; }
button, input, textarea { font: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.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; }

.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: 9px 17px; border: 1px solid #aeb7c2; border-radius: 5px; background: var(--white);
  color: var(--gray-950); text-decoration: none; cursor: pointer; font-weight: 600;
}
.button:hover { background: var(--gray-100); border-color: #8995a3; }
.button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(11,118,224,.25); outline-offset: 1px; }
.button:disabled, [aria-disabled="true"] .button { cursor: not-allowed; opacity: .55; }
.button.primary { border-color: var(--blue-700); background: var(--blue-700); color: var(--white); }
.button.primary:hover { background: #075ebd; }
.button.warning { color: var(--amber-700); border-color: #d8a449; }
.button.danger { color: var(--red-700); border-color: #d5aaa6; }
.button.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.button.full { width: 100%; }

.app-header {
  min-height: var(--header-height); display: flex; align-items: center; gap: 24px; padding: 0 24px;
  color: var(--white); background: var(--navy-950); border-bottom: 1px solid #001c35;
}
.app-brand { color: var(--white); text-decoration: none; font-size: 24px; font-weight: 700; letter-spacing: -.3px; white-space: nowrap; }
.header-spacer { flex: 1; }
.header-label, .header-room { white-space: nowrap; }
.header-room { padding-left: 22px; border-left: 1px solid rgba(255,255,255,.28); font-size: 16px; }
.header-room strong { font-size: 21px; letter-spacing: 1px; }
.header-status, .header-presence, .connection-status { white-space: nowrap; font-size: 14px; }
.header-status, .header-presence { font-weight: 600; }
.header-status.active, .header-presence.online { color: #70e69f; }
.header-status.closed { color: #ffaaa4; }
.connection-status { color: #b8c9db; }
.header-button { color: var(--white); background: transparent; border: 1px solid rgba(255,255,255,.4); border-radius: 5px; padding: 7px 12px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.header-button:hover { background: rgba(255,255,255,.1); }
.header-button.danger { border-color: #ff9189; color: #ffd6d2; }
.app-header form { margin: 0; }

.entry-page { background: var(--gray-100); }
.entry-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.entry-panel { width: min(410px, 100%); background: var(--white); border: 1px solid var(--gray-300); border-radius: 8px; padding: 38px; }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 20px; border-radius: 7px; background: var(--navy-950); color: var(--white); font-weight: 800; }
.entry-panel h1 { margin: 0; font-size: 28px; }
.entry-panel > p { margin: 8px 0 26px; color: var(--gray-700); }
.entry-form, .stack-form { display: grid; gap: 12px; }
.entry-form input, .stack-form input, .create-room-form input {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid #aeb7c2; border-radius: 5px; background: var(--white);
}
.entry-form input { text-align: center; font-size: 27px; letter-spacing: 8px; font-weight: 700; }
.stack-form label, .create-room-form label { font-weight: 600; font-size: 13px; }
.form-message { min-height: 22px; color: var(--gray-700); }
.form-message.error { color: var(--red-700); }
.entry-panel .form-message { margin-top: 10px; text-align: center; }
.subtle-link { display: block; margin-top: 14px; color: var(--gray-700); text-align: center; font-size: 13px; }

.dashboard-page { max-width: 1440px; margin: 0 auto; padding: 34px 28px 60px; }
.dashboard-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.dashboard-heading h1 { margin: 0; font-size: 28px; }
.dashboard-heading p { margin: 7px 0 0; color: var(--gray-700); }
.create-room-panel { margin-bottom: 28px; padding: 20px; background: var(--gray-100); border: 1px solid var(--gray-300); }
.create-room-form { display: grid; grid-template-columns: 1fr 1.5fr auto; align-items: end; gap: 16px; }
.table-section h2 { font-size: 20px; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th { padding: 12px 14px; color: var(--gray-700); background: #fafbfc; border-top: 1px solid var(--gray-300); border-bottom: 1px solid var(--gray-300); font-size: 13px; font-weight: 700; white-space: nowrap; }
.data-table td { padding: 17px 14px; border-bottom: 1px solid var(--gray-200); vertical-align: middle; }
.data-table tbody tr:hover { background: #fbfcfd; }
.data-table td:first-child { max-width: 420px; overflow-wrap: anywhere; }
.empty-cell, .empty-row td { color: var(--gray-500); text-align: center; padding: 26px !important; }
.room-code { color: var(--navy-900); letter-spacing: 1.2px; }
.status, .presence { display: inline-block; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 700; }
.status.active, .presence.online { color: var(--green-700); background: var(--green-100); }
.status.closed, .presence { color: var(--gray-700); background: var(--gray-100); }
.actions { display: flex; gap: 7px; align-items: center; white-space: nowrap; }
.actions form { margin: 0; }

.room-page { overflow: hidden; }
.closed-banner { padding: 9px 24px; color: #7a271a; background: var(--red-100); border-bottom: 1px solid #efb7b0; text-align: center; font-weight: 700; }
.room-layout { display: grid; grid-template-columns: minmax(0, 2.15fr) minmax(330px, .95fr); height: calc(100vh - var(--header-height)); }
.closed-banner:not([hidden]) + .room-layout { height: calc(100vh - var(--header-height) - 43px); }
.file-workspace { min-width: 0; overflow-y: auto; border-right: 1px solid var(--gray-300); }
.file-section { padding: 24px; }
.file-section + .file-section { border-top: 1px dashed #aeb7c2; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-heading h1, .section-heading h2 { margin: 0; font-size: 24px; }
.section-note { color: var(--gray-700); font-size: 12px; text-align: right; }
.upload-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.file-button input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.selected-summary { min-width: 0; overflow: hidden; color: var(--gray-700); text-overflow: ellipsis; white-space: nowrap; }
.progress-line { display: grid; grid-template-columns: minmax(100px, 1fr) 48px; align-items: center; gap: 12px; min-height: 25px; }
.progress-line progress { width: 100%; height: 8px; accent-color: var(--blue-700); }
.progress-line span { color: var(--gray-700); font-size: 12px; text-align: right; }
.download-link { color: var(--blue-700); font-weight: 700; text-decoration: none; }
.download-link:hover { text-decoration: underline; }
.file-actions { display: inline-flex; align-items: center; gap: 12px; white-space: nowrap; }
.file-delete-button { padding: 0; border: 0; background: transparent; color: var(--red-700); cursor: pointer; font: inherit; font-weight: 700; }
.file-delete-button:hover { text-decoration: underline; }
.file-delete-button:focus-visible { outline: 3px solid rgba(180,35,24,.2); outline-offset: 2px; }
.file-delete-button:disabled { color: var(--gray-500); cursor: not-allowed; text-decoration: none; }
.disabled-link { color: var(--gray-500); }

.chat-panel { display: grid; grid-template-rows: auto 1fr auto; min-width: 0; height: 100%; background: var(--white); }
.chat-heading { display: flex; align-items: baseline; justify-content: space-between; padding: 20px; border-bottom: 1px solid var(--gray-300); }
.chat-heading h2 { margin: 0; font-size: 24px; }
.chat-heading span { color: var(--gray-500); font-size: 12px; }
.message-list { overflow-y: auto; padding: 18px 18px 10px; }
.message { max-width: 86%; margin-bottom: 16px; }
.message.admin { margin-left: auto; }
.message-meta { margin: 0 7px 4px; color: var(--gray-500); font-size: 12px; }
.message.admin .message-meta { text-align: right; color: var(--blue-700); }
.message-content { display: inline-block; padding: 11px 14px; border-radius: 6px; background: #f0f2f4; overflow-wrap: anywhere; }
.message.admin .message-content { display: block; margin-left: auto; width: fit-content; background: var(--blue-100); }
.message.system { max-width: 100%; color: var(--gray-500); text-align: center; font-size: 12px; }
.message.system .message-content { padding: 4px 8px; background: transparent; }
.chat-form { padding: 14px 18px 18px; border-top: 1px solid var(--gray-300); }
.chat-form textarea { display: block; width: 100%; resize: vertical; min-height: 78px; max-height: 150px; padding: 10px; border: 1px solid #aeb7c2; border-radius: 5px; }
.chat-form .button { float: right; margin-top: 10px; min-width: 90px; }

@media (max-width: 980px) {
  .room-page { overflow: auto; }
  .room-header { flex-wrap: wrap; gap: 10px 16px; padding-top: 10px; padding-bottom: 10px; }
  .room-header .header-spacer { display: none; }
  .room-layout, .closed-banner:not([hidden]) + .room-layout { grid-template-columns: 1fr; height: auto; }
  .file-workspace { overflow: visible; border-right: 0; }
  .chat-panel { min-height: 620px; border-top: 2px solid var(--navy-950); }
  .create-room-form { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .app-header { padding-left: 14px; padding-right: 14px; }
  .app-brand { font-size: 18px; }
  .header-room { padding-left: 0; border-left: 0; }
  .dashboard-page, .file-section { padding-left: 14px; padding-right: 14px; }
  .dashboard-heading { align-items: stretch; flex-direction: column; }
  .upload-controls, .section-heading { align-items: stretch; flex-direction: column; }
  .section-note { text-align: left; }
  .selected-summary { white-space: normal; }
  .data-table th, .data-table td { padding: 10px; }
  .entry-panel { padding: 26px 22px; }
}
