:root {
  --line-green: #06c755;
  --line-green-hover: #05b34c;
  --line-bubble-mine: #8de055;
  --line-bubble-theirs: #ffffff;
  --line-talk-bg: #7494c0;
  --line-talk-header: #6988b4;
  --line-nav-dark: #20262e;
  --bg-surface: #ffffff;
  --bg-subtle: #f5f6f8;
  --text-main: #111111;
  --text-sub: #6b7280;
  --text-muted: #9ca3af;
  --border-light: #e5e7eb;
  --danger: #ef4444;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  background-color: var(--bg-subtle);
  color: var(--text-main);
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

button,
input,
select,
textarea {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

input,
textarea,
select,
.message-bubble,
code,
pre {
  user-select: text;
  -webkit-user-select: text;
}

/* Common UI SVG Icons */
.ui-icon,
.ui-icon-sm,
.ui-icon-xs,
.nav-svg,
.pin-svg {
  display: inline-block;
  vertical-align: middle;
  pointer-events: none;
  stroke: currentColor;
  fill: none;
  flex-shrink: 0;
}

.ui-icon {
  width: 20px;
  height: 20px;
}

.ui-icon-sm {
  width: 17px;
  height: 17px;
}

.ui-icon-xs {
  width: 14px;
  height: 14px;
}

.nav-svg {
  width: 22px;
  height: 22px;
}

.pin-svg {
  width: 14px;
  height: 14px;
}

.hidden {
  display: none !important;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  top: calc(14px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: min(90vw, 380px);
}

.toast-item {
  background: rgba(17, 24, 39, 0.92);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast-item.error {
  background: rgba(220, 38, 38, 0.95);
}

.toast-item.fade-out {
  opacity: 0;
  transform: translateY(-6px);
}

/* Official LINE Style Login Screen */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  background: #f2f4f7;
  overflow-y: auto;
}

.auth-container {
  width: 100%;
  max-width: 400px;
  margin: auto;
}

.auth-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 32px 28px 24px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  border: 1px solid #eaecf0;
}

.line-logo-header {
  text-align: center;
  margin-bottom: 22px;
}

.line-logo-text {
  font-size: 2.3rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--line-green);
}

.line-logo-sub {
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-top: 6px;
}

.login-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 20px;
}

.login-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-sub);
  padding: 10px 4px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.15s;
}

.login-tab-btn.active {
  color: var(--text-main);
  border-bottom-color: var(--line-green);
}

.login-tab-pane {
  display: none;
}

.login-tab-pane.active {
  display: block;
}

.login-hint {
  font-size: 0.78rem;
  color: var(--text-sub);
  text-align: center;
  margin-top: 12px;
  line-height: 1.4;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 4px;
}

.form-control {
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-control:focus {
  border-color: var(--line-green);
}

.btn-line-primary {
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  border: none;
  background: var(--line-green);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-line-primary:hover {
  background: var(--line-green-hover);
}

.btn-line-sub {
  padding: 7px 12px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #374151;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-line-sub:hover {
  background: #f3f4f6;
}

.btn-line-sub.link-btn {
  text-decoration: none;
  text-align: center;
}

.btn-line-text {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-sub);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}

.btn-row {
  display: flex;
  gap: 8px;
}

.btn-row > * {
  flex: 1;
}

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  margin: 0 auto 14px;
  width: fit-content;
}

.pin-box {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--line-green);
  background: #eefaf2;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.auth-status {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-sub);
  text-align: center;
  min-height: 18px;
  word-break: break-word;
}

.auth-status.error {
  color: var(--danger);
  font-weight: 600;
}

.login-options-box {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #f0f2f5;
}

.auth-card-top-action {
  display: flex;
  justify-content: flex-end;
  margin-bottom: -16px;
}

.btn-open-settings-modal.icon-only {
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.75;
  transition: opacity 0.15s, transform 0.15s, color 0.15s;
}

.btn-open-settings-modal.icon-only:hover {
  opacity: 1;
  color: #111827;
  transform: rotate(25deg);
}

.auth-footer-link {
  margin-top: 14px;
  text-align: center;
}

.btn-open-settings-modal.text-link {
  background: none;
  border: none;
  color: var(--line-green);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-open-settings-modal.text-link:hover {
  color: var(--line-green-hover);
}

/* Modal Backdrop & Card */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
}

.modal-card {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  background: #f9fafb;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-sub);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  background: #f9fafb;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #1f2937;
  padding-bottom: 4px;
  border-bottom: 2px solid #e5e7eb;
}

.settings-desc {
  font-size: 0.78rem;
  color: var(--text-sub);
  line-height: 1.45;
}

.settings-note {
  font-size: 0.74rem;
  color: #6b7280;
  line-height: 1.4;
}

.settings-sub-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  margin-top: 4px;
}

.settings-field-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #374151;
  margin-bottom: 4px;
}

.settings-field-desc {
  font-size: 0.75rem;
  color: #6b7280;
  margin-bottom: 8px;
  line-height: 1.4;
}

.settings-details {
  margin-top: 8px;
  font-size: 0.76rem;
  color: #4b5563;
}

.settings-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--line-green);
}

.settings-ol {
  margin-top: 6px;
  padding-left: 18px;
  line-height: 1.6;
}

.settings-ol a {
  color: var(--line-green);
}

.settings-row {
  display: flex;
  align-items: center;
}

.conn-status-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 6px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  text-align: center;
}

.worker-input-row {
  display: flex;
  gap: 6px;
}

.worker-input-row .form-control {
  padding: 7px 10px;
  font-size: 0.82rem;
}

/* Main App Layout (Official LINE Desktop & Mobile Style) */
.app-layout {
  display: grid;
  grid-template-columns: 310px 1fr 290px;
  grid-template-rows: calc(46px + var(--safe-top)) 1fr;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  background: #ffffff;
}

/* Top Dark Header Bar (LINE Desktop Top Strip) */
.top-bar {
  grid-column: 1 / -1;
  background: var(--line-nav-dark);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--safe-top) 14px 0;
  gap: 8px;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.top-brand {
  font-weight: 900;
  color: var(--line-green);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.top-profile-name {
  font-size: 0.84rem;
  color: #e5e7eb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.top-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #f3f4f6;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.top-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.top-btn.active {
  background: var(--line-green);
  border-color: var(--line-green);
  color: #ffffff;
}

.top-btn.danger {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.35);
}

.chk-inline {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  color: #d1d5db;
  cursor: pointer;
  white-space: nowrap;
}

/* Left Sidebar: White Official LINE Chat List */
.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-controls {
  padding: 10px 12px 8px;
  border-bottom: 1px solid #f0f2f5;
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: #f3f4f6;
  color: var(--text-main);
  font-size: 0.84rem;
  outline: none;
}

.search-input:focus {
  background: #ebedf0;
}

.filter-tabs {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.filter-btn {
  flex: 1;
  padding: 5px 4px;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-sub);
  cursor: pointer;
}

.filter-btn.active {
  background: #111827;
  color: #ffffff;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.chat-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  cursor: pointer;
  transition: background 0.12s;
}

.chat-list-item:hover {
  background: #f8f9fa;
}

.chat-list-item.active {
  background: #edf2f7;
}

.chat-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #cbd5e1;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.chat-avatar.group {
  background: #60a5fa;
}

.chat-avatar.square {
  background: #3b82f6;
  position: relative;
}

.chat-avatar.user {
  background: #34d399;
}

.chat-avatar.keep {
  background: var(--line-green);
}

.oc-badge {
  display: inline-block;
  background: #0284c7;
  color: #ffffff;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 4px;
  margin-right: 4px;
  vertical-align: 1px;
}

.chat-meta {
  flex: 1;
  min-width: 0;
}

.chat-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
  gap: 6px;
}

.chat-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-time-label {
  font-size: 0.7rem;
  color: #9ca3af;
  flex-shrink: 0;
}

.chat-bottom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.chat-preview {
  font-size: 0.78rem;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.unread-badge {
  background: var(--line-green);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}

.pin-btn {
  background: transparent;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 2px 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.pin-btn:hover {
  color: #4b5563;
}

.pin-btn.pinned {
  color: #f59e0b;
}

/* Center Panel: Official LINE Talk Room (#7494C0 Slate-Blue Wallpaper) */
.chat-main {
  display: flex;
  flex-direction: column;
  background: var(--line-talk-bg);
  overflow: hidden;
  min-width: 0;
}

.chat-header {
  height: 54px;
  padding: 0 14px;
  background: rgba(105, 136, 180, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #ffffff;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.mobile-back-btn {
  display: none;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 1.7rem;
  line-height: 1;
  padding: 0 6px 2px 0;
  cursor: pointer;
}

.chat-header-info {
  min-width: 0;
  flex: 1;
}

.chat-header-title {
  font-weight: 700;
  font-size: 0.96rem;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-sub {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.header-action-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(0, 0, 0, 0.14);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.header-action-btn:hover {
  background: rgba(0, 0, 0, 0.24);
}

.header-action-btn.primary {
  background: rgba(255, 255, 255, 0.92);
  color: #1e293b;
  border-color: transparent;
}

/* Message Timeline */
.message-timeline {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.empty-timeline {
  margin: auto;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.88rem;
  background: rgba(0, 0, 0, 0.15);
  padding: 8px 18px;
  border-radius: 999px;
}

/* Official LINE Message Row Layout */
.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  position: relative;
  margin: 1px 0;
}

.msg-row.mine {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-row.theirs {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-theirs-container {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.msg-mini-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #64748b;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
  overflow: hidden;
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.msg-sender {
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: 3px;
  padding-left: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.official-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.62rem;
  font-weight: 700;
  background: #06c755;
  color: #ffffff;
  padding: 1px 5px;
  border-radius: 3px;
}

/* Side-by-side Bubble + Read/Time Metadata (Official LINE layout) */
.msg-line-body {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  position: relative;
}

.msg-row.mine .msg-line-body {
  flex-direction: row-reverse;
}

.msg-bubble {
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
  user-select: text;
  cursor: pointer;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  max-width: 100%;
}

.msg-row.mine .msg-bubble {
  background: var(--line-bubble-mine);
  color: #111111;
  border-top-right-radius: 4px;
}

.msg-row.theirs .msg-bubble {
  background: var(--line-bubble-theirs);
  color: #111111;
  border-top-left-radius: 4px;
}

.msg-bubble.is-sticker {
  background: transparent !important;
  box-shadow: none !important;
  padding: 2px !important;
}

.msg-sticker-img {
  max-width: 130px;
  max-height: 130px;
  display: block;
  object-fit: contain;
  cursor: pointer;
}

.msg-unsent-indicator {
  display: inline-block;
  font-size: 0.7rem;
  color: #dc2626;
  background: rgba(254, 226, 226, 0.9);
  padding: 1px 6px;
  border-radius: 4px;
  margin-bottom: 3px;
  font-weight: 600;
}

.msg-row.inspected .msg-bubble {
  outline: 2px solid #ffffff;
  box-shadow: 0 0 0 3px rgba(6, 199, 85, 0.7);
}

.msg-reply-quote {
  font-size: 0.75rem;
  padding-bottom: 5px;
  margin-bottom: 5px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  color: #374151;
}

/* Official LINE Side Meta (既読 N above 12:34 right beside bubble) */
.msg-side-meta {
  display: flex;
  flex-direction: column;
  font-size: 0.68rem;
  line-height: 1.25;
  color: rgba(255, 255, 255, 0.92);
  flex-shrink: 0;
  white-space: nowrap;
}

.msg-row.mine .msg-side-meta {
  align-items: flex-end;
  text-align: right;
}

.msg-row.theirs .msg-side-meta {
  align-items: flex-start;
  text-align: left;
}

.msg-read-count {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.96);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0;
}

.msg-time {
  color: rgba(255, 255, 255, 0.85);
}

/* Reactions Pill Bubble */
.msg-reactions-bubble {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #ffffff;
  color: #1e293b;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
  margin-top: 2px;
  cursor: pointer;
  user-select: none;
}

/* Subtle Action Bar - Hidden by default to eliminate vertical whitespace */
.msg-actions-row {
  display: none;
  gap: 4px;
  margin-top: 2px;
  z-index: 10;
}

.msg-row:hover .msg-actions-row,
.msg-row.inspected .msg-actions-row {
  display: flex;
}

.msg-action-btn {
  background: rgba(0, 0, 0, 0.32);
  border: none;
  color: #ffffff;
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.msg-action-btn:hover {
  background: rgba(0, 0, 0, 0.55);
}

/* Floating Reaction Picker Popover */
.reaction-picker-menu {
  position: absolute;
  bottom: calc(100% + 4px);
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(8px);
  padding: 3px 6px;
  border-radius: 999px;
  display: flex;
  gap: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  z-index: 100;
}

.reaction-opt-btn {
  background: transparent;
  border: none;
  font-size: 1.18rem;
  line-height: 1;
  padding: 2px 3px;
  cursor: pointer;
  border-radius: 50%;
  transition: transform 0.1s ease;
}

.reaction-opt-btn:hover {
  transform: scale(1.25);
}

/* Sticker Popover in Composer */
.sticker-popover {
  position: absolute;
  bottom: 60px;
  left: 12px;
  width: 280px;
  max-height: 240px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  z-index: 90;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sticker-popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-light);
  font-weight: 700;
  font-size: 0.82rem;
  color: #1e293b;
}

.mini-close-btn {
  background: transparent;
  border: none;
  font-size: 1rem;
  color: #64748b;
  cursor: pointer;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px;
  overflow-y: auto;
  max-height: 190px;
}

.sticker-grid-item {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.1s;
}

.sticker-grid-item:hover {
  background: #f1f5f9;
}

.sticker-grid-item img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.composer-icon-btn {
  background: transparent;
  border: none;
  color: #64748b;
  padding: 4px 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.composer-icon-btn:hover {
  color: var(--line-green);
}

.inspector-chat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: #f8fafc;
  border-radius: 10px;
}

.inspector-large-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #64748b;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.inspector-chat-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #1e293b;
}

/* Reply Banner & White Composer Bar */
.reply-banner {
  background: #f8fafc;
  border-top: 1px solid var(--border-light);
  padding: 7px 14px;
  font-size: 0.78rem;
  color: #374151;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.reply-cancel-btn {
  background: transparent;
  border: none;
  color: var(--text-sub);
  font-size: 0.76rem;
  cursor: pointer;
}

.composer {
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: #ffffff;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.composer textarea {
  flex: 1;
  resize: none;
  height: 40px;
  max-height: 120px;
  padding: 9px 14px;
  border-radius: 20px;
  border: 1px solid #e5e7eb;
  background: #f3f4f6;
  color: var(--text-main);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}

.composer textarea:focus {
  background: #ffffff;
  border-color: var(--line-green);
}

.send-btn {
  height: 40px;
  padding: 0 18px;
  border-radius: 20px;
  border: none;
  background: var(--line-green);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  flex-shrink: 0;
}

.send-btn:hover {
  background: var(--line-green-hover);
}

/* Right Panel: Clean White Read Members & Group Settings */
.inspector {
  background: #ffffff;
  border-left: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.inspector-mobile-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.inspector-section {
  padding: 14px;
  border-bottom: 1px solid #f0f2f5;
}

.inspector-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.inspector-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: #111827;
}

.inspector-sub {
  font-size: 0.74rem;
  color: var(--text-sub);
  margin-bottom: 10px;
}

.member-section-label {
  font-size: 0.76rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.member-section-label.read {
  color: var(--line-green);
}

.member-section-label.unread {
  color: #6b7280;
}

.mini-reset-btn {
  background: #eefaf2;
  border: 1px solid var(--line-green);
  color: var(--line-green);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
}

.reader-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 220px;
  overflow-y: auto;
}

.reader-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-radius: 8px;
  background: #f9fafb;
  font-size: 0.82rem;
}

.reader-name {
  font-weight: 600;
  color: #1f2937;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-time {
  font-size: 0.72rem;
  color: #6b7280;
}

.mini-mention-btn {
  background: #ffffff;
  border: 1px solid #d1d5db;
  color: #374151;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.mini-mention-btn:hover {
  border-color: var(--line-green);
  color: var(--line-green);
}

.inspector-empty {
  font-size: 0.78rem;
  color: #9ca3af;
  padding: 8px 0;
}

.chk-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: #374151;
  cursor: pointer;
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
  display: none;
  background: #ffffff;
  border-top: 1px solid var(--border-light);
  padding-bottom: var(--safe-bottom);
}

.mobile-nav-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: #9ca3af;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}

.mobile-nav-btn .nav-svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
}

.mobile-nav-btn.active {
  color: var(--line-green);
}

/* Tablet / iPad Responsive (769px to 1024px) */
@media (max-width: 1024px) {
  .app-layout {
    grid-template-columns: 320px 1fr;
    position: relative;
  }

  .inspector {
    position: fixed;
    top: calc(46px + var(--safe-top));
    right: 0;
    bottom: 0;
    width: min(340px, 88vw);
    z-index: 200;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.22s ease;
  }

  .inspector.drawer-open {
    transform: translateX(0);
  }

  .inspector-mobile-bar {
    display: flex;
  }
}

/* Smartphone Responsive (<= 768px) */
@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }

  .form-control,
  .search-input,
  .composer textarea {
    font-size: 16px !important;
  }

  .auth-card {
    padding: 24px 18px 20px;
  }

  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: calc(44px + var(--safe-top)) 1fr calc(54px + var(--safe-bottom));
  }

  .sidebar,
  .chat-main,
  .inspector {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    height: 100%;
    position: static;
    transform: none !important;
    box-shadow: none;
  }

  .app-layout[data-mobile-pane="list"] .chat-main,
  .app-layout[data-mobile-pane="list"] .inspector {
    display: none !important;
  }

  .app-layout[data-mobile-pane="chat"] .sidebar,
  .app-layout[data-mobile-pane="chat"] .inspector {
    display: none !important;
  }

  .app-layout[data-mobile-pane="inspector"] .sidebar,
  .app-layout[data-mobile-pane="inspector"] .chat-main {
    display: none !important;
  }

  .mobile-back-btn {
    display: inline-flex;
    align-items: center;
  }

  .mobile-bottom-nav {
    display: flex;
    grid-column: 1;
    grid-row: 3;
  }

  .composer {
    padding-bottom: 10px;
  }

  .msg-row {
    max-width: 90%;
  }

  .msg-actions-row {
    display: none;
  }

  .msg-row.inspected .msg-actions-row {
    display: flex;
  }
}

/* ============================================================
   Disclaimer Box on Login Screen
   ============================================================ */
.auth-disclaimer-box {
  margin-top: 18px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  text-align: left;
}

.auth-disclaimer-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 4px;
}

.auth-disclaimer-text {
  font-size: 0.72rem;
  line-height: 1.45;
  color: #64748b;
  margin: 0;
}

/* ============================================================
   Composer Additions: More Actions Popover & Recording
   ============================================================ */
.more-actions-popover {
  position: absolute;
  bottom: 60px;
  left: 12px;
  width: 240px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 6px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.more-action-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #1f2937;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.more-action-item:hover {
  background: #f3f4f6;
  color: var(--line-green);
}

.composer-icon-btn.recording {
  color: #ef4444 !important;
  animation: pulse-mic 1.2s infinite;
}

@keyframes pulse-mic {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(239, 68, 68, 0.4)); }
  50% { transform: scale(1.15); filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.8)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(239, 68, 68, 0.4)); }
}

/* ============================================================
   Rich Message Types: Images, Audio, Video, Files, Polls, Flex
   ============================================================ */

/* Images */
.msg-bubble.is-image {
  padding: 3px;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.msg-image-preview {
  max-width: 280px;
  max-height: 320px;
  border-radius: 12px;
  object-fit: cover;
  cursor: pointer;
  display: block;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease;
}

.msg-image-preview:hover {
  transform: scale(1.02);
}

/* Audio Player */
.msg-bubble.is-audio {
  padding: 8px 12px;
  min-width: 220px;
}

.msg-audio-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msg-audio-box audio {
  width: 100%;
  max-width: 240px;
  height: 34px;
}

.msg-audio-duration {
  font-size: 0.72rem;
  color: #6b7280;
}

/* Video */
.msg-bubble.is-video {
  padding: 4px;
  background: #000000;
  border-radius: 12px;
  overflow: hidden;
}

.msg-video-player {
  max-width: 280px;
  max-height: 280px;
  display: block;
  border-radius: 8px;
}

/* Files */
.msg-bubble.is-file {
  padding: 10px 14px;
  min-width: 220px;
}

.msg-file-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.msg-file-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.msg-file-details {
  flex: 1;
  min-width: 0;
}

.msg-file-name {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #111827;
}

.msg-file-size {
  font-size: 0.72rem;
  color: #6b7280;
}

.btn-download-file {
  padding: 4px 10px;
  background: var(--line-green);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  margin-top: 4px;
}

/* Location Card */
.msg-bubble.is-location {
  padding: 12px;
  min-width: 230px;
}

.msg-location-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-location-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.88rem;
  color: #dc2626;
}

.msg-location-address {
  font-size: 0.78rem;
  color: #4b5563;
  margin-bottom: 6px;
}

.btn-open-map {
  padding: 5px 12px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #2563eb;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}

/* Poll / Survey */
.msg-bubble.is-poll {
  padding: 14px;
  min-width: 240px;
  background: #ffffff !important;
  color: #111827 !important;
  border: 1px solid #e5e7eb;
}

.msg-poll-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-poll-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #eef2ff;
  color: #4f46e5;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  width: fit-content;
}

.msg-poll-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #111827;
}

.msg-poll-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.poll-option-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.82rem;
}

/* Flex Message */
.msg-bubble.is-flex {
  padding: 0;
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.1);
  overflow: hidden;
  max-width: 320px;
  color: #111827 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.flex-hero-box {
  width: 100%;
  max-height: 180px;
  overflow: hidden;
  background: #f1f5f9;
}

.flex-hero-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.flex-body-box {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.flex-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #111827;
}

.flex-subtitle {
  font-size: 0.8rem;
  color: #6b7280;
  line-height: 1.4;
}

.flex-footer-box {
  padding: 10px 14px;
  border-top: 1px solid #f3f4f6;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.flex-action-btn {
  display: block;
  width: 100%;
  padding: 8px;
  background: var(--line-green);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.flex-action-btn.secondary {
  background: #f3f4f6;
  color: #374151;
}

/* Lightbox */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lightbox-close-btn {
  position: absolute;
  top: 16px;
  right: 20px;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 32px;
  cursor: pointer;
  z-index: 100000;
}

.lightbox-content {
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-media {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.lightbox-toolbar {
  margin-top: 16px;
}
