:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  background: #efeae2;
  color: #17212b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; line-height: 1.5; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
}

.card {
  width: min(100%, 430px);
  padding: 30px 26px;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 18px 50px rgb(17 27 33 / 12%);
}

.auth-card { text-align: center; }
.mark, .member-badge {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 22px;
  background: #075e54;
  color: #fff;
  font-size: 34px;
  font-weight: 700;
}
.member-badge { background: #128c7e; }
.member-badge.small { width: 48px; height: 48px; margin: 0; border-radius: 16px; font-size: 21px; }

.eyebrow { margin: 0; color: #667781; font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
h1 { margin: 7px 0 10px; font-size: clamp(29px, 8vw, 34px); line-height: 1.2; }
h2 { margin: 0; font-size: 22px; }
.muted { margin: 0 0 18px; color: #667781; font-size: 17px; line-height: 1.5; }

.form-stack { display: grid; gap: 9px; margin-top: 18px; text-align: left; }
.form-stack label { margin-top: 3px; color: #40515b; font-size: 16px; font-weight: 700; }
.form-stack input, .form-stack select {
  width: 100%;
  min-height: 58px;
  padding: 0 16px;
  border: 1px solid #d4dadd;
  border-radius: 14px;
  background: #fff;
  color: #17212b;
  font-size: 18px;
  outline: none;
}
.form-stack input:focus, .form-stack select:focus { border-color: #128c7e; box-shadow: 0 0 0 3px rgb(18 140 126 / 12%); }

.primary-button, .secondary-button, .small-button {
  border: 0;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 700;
}
.primary-button { min-height: 58px; margin-top: 10px; background: #075e54; color: #fff; font-size: 18px; }
.secondary-button { width: 100%; min-height: 54px; margin-top: 16px; background: #eef2f2; color: #40515b; font-size: 17px; }
.small-button { min-height: 48px; padding: 10px 14px; background: #eef2f2; color: #075e54; font-size: 16px; white-space: nowrap; }

.alert { margin: 18px 0 0; padding: 12px 14px; border-radius: 12px; background: #fff1f0; color: #a32820; font-size: 14px; line-height: 1.45; text-align: left; }
.status { display: inline-block; margin-top: 14px; padding: 6px 12px; border-radius: 999px; background: #d9fdd3; color: #075e54; font-size: 12px; font-weight: 700; }

.dashboard-card { text-align: left; }
.top-row, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.top-row h1 { margin-bottom: 0; }
.welcome-panel { margin: 20px 0 14px; padding: 18px; border-radius: 18px; background: linear-gradient(135deg, #075e54, #128c7e); color: #fff; }
.welcome-panel p { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
.welcome-panel span { font-size: 15px; opacity: .9; }
.action-list { overflow: hidden; border: 1px solid #e5e9eb; border-radius: 16px; }
.action-list a { display: flex; align-items: center; justify-content: space-between; min-height: 62px; padding: 0 17px; color: #17212b; font-size: 17px; font-weight: 600; text-decoration: none; }
.action-list a + a { border-top: 1px solid #e5e9eb; }
.action-list span { color: #667781; font-size: 26px; }

.admin-shell { width: min(100% - 28px, 900px); margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 0 max(28px, env(safe-area-inset-bottom)); }
.page-header { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; }
.page-header h1 { margin-bottom: 0; }
.back-link { min-height: 48px; display: inline-flex; align-items: center; padding: 10px 14px; border-radius: 12px; background: #fff; color: #075e54; font-size: 17px; font-weight: 700; text-decoration: none; }
.panel { margin-bottom: 18px; padding: 22px; border-radius: 20px; background: #fff; box-shadow: 0 10px 30px rgb(17 27 33 / 7%); }
.member-list { margin-top: 14px; }
.member-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; }
.member-row + .member-row { border-top: 1px solid #e8ecee; }
.member-row strong, .member-row span { display: block; }
.member-row span { margin-top: 3px; color: #667781; font-size: 15px; }
.section-heading span { color: #667781; font-size: 14px; }
.table-wrap { margin-top: 14px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 12px 10px; border-bottom: 1px solid #e8ecee; text-align: left; white-space: nowrap; }
th { color: #667781; font-size: 12px; }
.result { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.result.success { background: #d9fdd3; color: #075e54; }
.result.failed { background: #fff1f0; color: #a32820; }
.empty { padding: 28px; color: #667781; text-align: center; }
.link-button { display: inline-flex; align-items: center; text-decoration: none; }
.request-actions { display: flex; align-items: center; gap: 7px; }
.small-button.approve { background: #d9fdd3; }
.small-button.reject { background: #fff1f0; color: #a32820; }

.chat-shell { height: 100dvh; display: grid; grid-template-rows: auto auto 1fr auto; overflow: hidden; background: #efeae2; }
.chat-header { z-index: 3; display: flex; align-items: center; gap: 12px; min-height: 70px; padding: max(9px, env(safe-area-inset-top)) 14px 9px; background: #075e54; color: #fff; box-shadow: 0 2px 10px rgb(0 0 0 / 15%); }
.chat-back { display: grid; place-items: center; width: 46px; height: 46px; color: #fff; font-size: 38px; line-height: 1; text-decoration: none; }
.chat-title { display: grid; min-width: 0; }
.chat-title strong { font-size: 19px; }
.chat-title span { overflow: hidden; font-size: 13px; opacity: .82; text-overflow: ellipsis; white-space: nowrap; }
.chat-alert { margin: 8px auto 0; padding: 10px 14px; border-radius: 10px; background: #fff1f0; color: #a32820; font-size: 14px; }
.messages { overflow-y: auto; padding: 18px max(12px, calc((100% - 900px) / 2)) 22px; scroll-behavior: smooth; }
.message-row { display: flex; margin: 8px 0; }
.message-row.mine { justify-content: flex-end; }
.message-bubble { width: fit-content; max-width: min(82%, 620px); padding: 9px 11px 7px; border-radius: 8px 14px 14px; background: #fff; box-shadow: 0 1px 2px rgb(17 27 33 / 12%); }
.mine .message-bubble { border-radius: 14px 8px 14px 14px; background: #d9fdd3; }
.message-bubble.deleted { color: #667781; font-style: italic; }
.deleted-copy { margin: 0; }
.message-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin-bottom: 5px; color: #075e54; font-size: 13px; }
.message-meta time { color: #667781; font-size: 11px; font-weight: 400; }
.reply-preview { display: grid; grid-template-columns: auto 1fr; margin: 0 0 7px; padding: 7px 9px; border-left: 4px solid #128c7e; border-radius: 5px; background: rgb(0 0 0 / 5%); color: inherit; font-size: 13px; text-decoration: none; }
.reply-preview img { grid-row: 1 / 3; width: 42px; height: 42px; margin-right: 8px; border-radius: 5px; object-fit: cover; }
.reply-preview span { overflow: hidden; color: #667781; text-overflow: ellipsis; white-space: nowrap; }
.image-open { display: block; max-width: 100%; padding: 0; border: 0; border-radius: 9px; background: transparent; cursor: zoom-in; }
.chat-image { display: block; width: min(100%, 420px); max-height: 480px; margin: 2px 0 8px; border-radius: 9px; object-fit: contain; background: #e8ecee; }
.chat-audio { width: min(100%, 340px); min-width: 260px; margin: 3px 0 7px; }
.file-card { display: flex; align-items: center; gap: 11px; min-width: min(68vw, 300px); margin: 2px 0 8px; padding: 12px; border-radius: 10px; background: rgb(255 255 255 / 68%); color: #17212b; text-decoration: none; }
.file-card .file-icon { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 9px; background: #075e54; color: #fff; font-size: 24px; }
.file-card > span:last-child { display: grid; min-width: 0; }
.file-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card small { color: #667781; }
.original-text, .translated-text, .image-explanation { white-space: pre-wrap; overflow-wrap: anywhere; }
.original-text { font-size: 16px; }
.translated-text { margin-top: 7px; padding-top: 7px; border-top: 1px solid rgb(17 27 33 / 12%); color: #34434c; }
.translated-text > span { display: block; margin-bottom: 2px; color: #128c7e; font-size: 11px; font-weight: 800; }
.translation-error { color: #a32820; font-size: 14px; }
.translation-pending { color: #667781; font-size: 14px; }
.mention-list { margin-top: 5px; color: #075e54; font-size: 12px; font-weight: 700; }
.no-image-text, .edited-label, .read-status { color: #667781; font-size: 11px; }
.image-explanation { margin-top: 9px; padding: 10px; border-radius: 9px; background: #fff7da; font-size: 14px; }
.image-explanation strong { display: block; margin-bottom: 3px; color: #7a5900; }
.request-status { display: inline-block; margin-top: 8px; padding: 5px 8px; border-radius: 999px; background: #eef2f2; color: #667781; font-size: 12px; }
.request-status.approved { background: #d9fdd3; color: #075e54; }
.request-status.rejected, .request-status.failed { background: #fff1f0; color: #a32820; }
.inline-action, .text-action { padding: 5px 0; border: 0; background: transparent; color: #075e54; font-size: 13px; font-weight: 700; cursor: pointer; }
.reaction-summary { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.reaction-summary-button { padding: 2px 7px; border: 1px solid #d4dadd; border-radius: 999px; background: #fff; font-size: 13px; cursor: pointer; }
.reaction-summary-button.mine { border-color: #128c7e; background: #e4f7f2; }
.message-actions { display: flex; align-items: center; gap: 12px; min-height: 29px; margin-top: 3px; }
.message-actions details { position: relative; }
.message-actions summary { color: #075e54; font-size: 13px; font-weight: 700; cursor: pointer; list-style: none; }
.reaction-picker, .message-menu { position: absolute; z-index: 4; bottom: 30px; right: 0; display: flex; gap: 3px; padding: 8px; border-radius: 12px; background: #fff; box-shadow: 0 5px 24px rgb(17 27 33 / 22%); }
.theirs .reaction-picker, .theirs .message-menu { right: auto; left: 0; }
.reaction-picker button { width: 40px; height: 40px; border: 0; border-radius: 8px; background: #f4f6f6; font-size: 21px; }
.message-menu { width: min(300px, 78vw); display: grid; gap: 7px; }
.message-menu button { width: 100%; min-height: 40px; border: 0; border-radius: 8px; background: #eef2f2; color: #075e54; font-weight: 700; }
.message-menu textarea { width: 100%; min-height: 70px; padding: 8px; border: 1px solid #d4dadd; border-radius: 8px; font: inherit; }
.message-menu .danger-text { background: #fff1f0; color: #a32820; }
.read-status { text-align: right; }
.empty-chat { display: grid; place-items: center; min-height: 50vh; color: #667781; text-align: center; }
.empty-chat strong { font-size: 20px; color: #40515b; }
.message-row.optimistic { opacity: .72; }
.new-message-button { position: fixed; z-index: 5; right: 18px; bottom: calc(82px + env(safe-area-inset-bottom)); min-height: 40px; padding: 8px 14px; border: 0; border-radius: 999px; background: #075e54; color: #fff; box-shadow: 0 4px 16px rgb(17 27 33 / 24%); font-weight: 800; }
.new-message-button[hidden] { display: none; }
.composer { z-index: 3; padding: 8px max(10px, calc((100% - 900px) / 2)) max(8px, env(safe-area-inset-bottom)); border-top: 1px solid #d4dadd; background: #f6f7f7; }
.reply-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; padding: 7px 10px; border-left: 4px solid #128c7e; border-radius: 7px; background: #fff; }
.reply-banner[hidden] { display: none; }
.reply-banner > div { display: grid; min-width: 0; font-size: 13px; }
.reply-banner span { overflow: hidden; color: #667781; text-overflow: ellipsis; white-space: nowrap; }
.reply-banner button { width: 38px; height: 38px; border: 0; background: transparent; font-size: 23px; }
.composer-row { display: grid; grid-template-columns: 46px 1fr 52px; gap: 8px; }
.composer-row textarea { min-height: 52px; max-height: 120px; padding: 13px 15px; resize: none; border: 1px solid #d4dadd; border-radius: 18px; background: #fff; font: inherit; font-size: 17px; outline: none; }
.send-button { width: 52px; height: 52px; border: 0; border-radius: 50%; background: #075e54; color: #fff; font-size: 22px; }
.send-button:disabled { opacity: .55; }
.attach-button { width: 46px; height: 52px; padding: 0; border: 0; background: transparent; color: #075e54; font-size: 34px; font-weight: 300; }
.mention-menu { position: absolute; z-index: 7; right: max(70px, calc((100% - 760px) / 2)); bottom: calc(72px + env(safe-area-inset-bottom)); display: grid; width: min(270px, calc(100% - 92px)); max-height: 220px; padding: 7px; overflow-y: auto; border: 1px solid #d4dadd; border-radius: 12px; background: #fff; box-shadow: 0 8px 30px rgb(17 27 33 / 20%); }
.mention-menu[hidden], .mention-menu button[hidden] { display: none; }
.mention-menu button { min-height: 44px; padding: 8px 12px; border: 0; border-radius: 8px; background: #fff; color: #17212b; text-align: left; font: inherit; font-weight: 700; }
.mention-menu button:active { background: #e5eded; }
.visually-hidden { position: fixed; left: -10000px; width: 1px; height: 1px; opacity: 0; }
.modal-backdrop { position: fixed; z-index: 20; inset: 0; background: rgb(0 0 0 / 48%); }
.attachment-sheet { position: fixed; z-index: 21; bottom: max(12px, env(safe-area-inset-bottom)); left: 50%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; width: min(calc(100% - 24px), 430px); padding: 18px 14px 12px; border-radius: 22px; background: #fff; box-shadow: 0 16px 50px rgb(0 0 0 / 28%); transform: translateX(-50%); }
.attachment-sheet button { min-height: 82px; padding: 8px; border: 0; border-radius: 14px; background: #f0f5f4; color: #075e54; font-weight: 700; }
.attachment-sheet button span { display: block; margin-bottom: 5px; font-size: 27px; }
.attachment-sheet .sheet-cancel { grid-column: 1 / -1; min-height: 48px; background: #eef0f1; color: #40515b; }
.upload-dialog { position: fixed; z-index: 22; inset: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto auto; gap: 12px; max-width: 720px; margin: auto; padding: 14px; border-radius: 20px; background: #17212b; color: #fff; }
.upload-dialog.compact { inset: auto 12px max(18px, env(safe-area-inset-bottom)); grid-template-rows: auto auto auto; width: min(calc(100% - 24px), 470px); }
.upload-dialog header { display: flex; align-items: center; justify-content: space-between; font-size: 19px; }
.upload-dialog header button { width: 42px; height: 42px; border: 0; background: transparent; color: #fff; font-size: 30px; }
.image-preview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; min-height: 0; overflow-y: auto; }
.image-preview-item { position: relative; min-height: 130px; border-radius: 10px; overflow: hidden; background: #0c1217; }
.image-preview-item img { width: 100%; height: 100%; min-height: 130px; object-fit: contain; }
.image-preview-item button { position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgb(0 0 0 / 70%); color: #fff; font-size: 24px; }
.upload-add-row { display: flex; align-items: center; gap: 8px; }
.upload-add-row button { min-height: 42px; padding: 7px 11px; border: 1px solid #60717c; border-radius: 10px; background: transparent; color: #fff; }
.upload-add-row span { margin-left: auto; color: #cbd3d7; }
.upload-dialog textarea { width: 100%; min-height: 54px; padding: 12px; border: 1px solid #60717c; border-radius: 12px; background: #26343d; color: #fff; font: inherit; resize: none; }
.upload-send { min-height: 52px; border: 0; border-radius: 13px; background: #128c7e; color: #fff; font-weight: 800; }
.upload-send:disabled { opacity: .65; }
.selected-file { overflow-wrap: anywhere; padding: 18px; border-radius: 12px; background: #26343d; }
.image-viewer { position: fixed; z-index: 30; inset: 0; display: grid; grid-template-rows: auto 1fr; background: #080b0d; }
.image-viewer header { z-index: 1; display: flex; justify-content: space-between; padding: max(8px, env(safe-area-inset-top)) 12px 8px; background: rgb(0 0 0 / 55%); }
.image-viewer button, .image-viewer a { min-width: 48px; min-height: 44px; display: grid; place-items: center; border: 0; background: transparent; color: #fff; font-size: 18px; text-decoration: none; }
.image-viewer button { font-size: 32px; }
.image-viewer img { width: 100%; height: 100%; min-height: 0; object-fit: contain; touch-action: pinch-zoom; }
.reaction-viewer { position: fixed; z-index: 31; inset: auto 12px max(18px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr auto; gap: 8px; width: min(calc(100% - 24px), 430px); margin: auto; padding: 18px; border-radius: 18px; background: #fff; box-shadow: 0 10px 40px rgb(17 27 33 / 30%); }
.reaction-viewer[hidden] { display: none; }
.reaction-viewer button { grid-column: 2; grid-row: 1; width: 40px; height: 40px; border: 0; background: transparent; font-size: 28px; }
.reaction-viewer strong { grid-column: 1; grid-row: 1; font-size: 28px; }
.reaction-viewer p { grid-column: 1 / -1; margin: 0; color: #40515b; font-size: 16px; }
.media-actions { display: flex; align-items: center; gap: 7px; margin-top: 6px; overflow-x: auto; }
.media-actions form { display: contents; }
.media-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 7px 11px; border: 0; border-radius: 10px; background: #e5eded; color: #075e54; font: inherit; font-size: 14px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.media-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.record-button.recording { background: #fff1f0; color: #a32820; }

.settings-shell { width: min(100% - 28px, 680px); }
.settings-panel .section-heading p { margin: 4px 0 0; color: #667781; font-size: 15px; }
.setting-status { padding: 5px 9px; border-radius: 999px; background: #eef2f2; color: #667781; font-size: 12px; font-weight: 800; white-space: nowrap; }
.setting-status.enabled { background: #d9fdd3; color: #075e54; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 0; }
.setting-row + .setting-row { border-top: 1px solid #e8ecee; }
.setting-row > div { min-width: 0; }
.setting-row strong, .setting-row span { display: block; }
.setting-row span { margin-top: 3px; color: #667781; font-size: 14px; }
.setting-row form { flex: none; }
.setting-choice-form { display: flex; align-items: center; gap: 8px; }
.setting-choice-form select { min-height: 42px; padding: 8px 10px; border: 1px solid #ccd3d6; border-radius: 9px; background: #fff; }
.setting-message { min-height: 24px; margin: 4px 0 0; color: #40515b; font-size: 14px; }

@media (max-width: 520px) {
  .shell {
    display: block;
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  }
  .card { min-height: calc(100dvh - 20px); padding: 22px 18px; border-radius: 18px; }
  .auth-card { padding-top: 26px; }
  .mark, .member-badge { margin-bottom: 14px; }
  .dashboard-card { min-height: auto; }
  .admin-shell { width: min(100% - 16px, 900px); padding-top: max(12px, env(safe-area-inset-top)); }
  .page-header { align-items: flex-start; gap: 10px; margin-bottom: 14px; }
  .page-header h1 { font-size: 27px; }
  .panel { margin-bottom: 12px; padding: 17px 14px; border-radius: 16px; }
  .member-row { align-items: center; padding: 12px 0; }
  .member-row > div { min-width: 0; }
  .setting-row { align-items: flex-start; flex-direction: column; gap: 10px; }
  .setting-row .small-button, .setting-row form { width: 100%; }
  .setting-choice-form select { flex: 1; min-width: 0; }
  .setting-choice-form .small-button { width: auto; }
  .request-row { align-items: flex-start; flex-direction: column; }
  .request-actions { width: 100%; flex-wrap: wrap; }
  .table-wrap { overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { padding: 12px 0; border-bottom: 1px solid #e8ecee; }
  tr:last-child { border-bottom: 0; }
  td { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 4px 0; border: 0; white-space: normal; }
  td::before { content: attr(data-label); color: #667781; font-size: 14px; font-weight: 700; }
  td.empty { display: block; padding: 24px 0; }
  td.empty::before { content: none; }
  .message-menu {
    position: fixed;
    inset: 50% 12px auto;
    width: auto;
    max-height: min(72dvh, 560px);
    overflow-y: auto;
    transform: translateY(-50%);
  }
  .theirs .message-menu { right: 12px; left: 12px; }
}
