:root {
  --font-scale: 1;
  --font-sans: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* Dark Theme (Default) */
html[data-theme="dark"] {
  --bg-body: #0b1120;
  --bg-card: #131c31;
  --bg-card-elevated: #1c2842;
  --bg-input: #0f172a;
  --border-subtle: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(148, 163, 184, 0.34);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --brand-primary: #3b82f6;
  --brand-accent: #f97316;
  --cf-orange: #f6821f;

  /* Green = 一定可以 */
  --green-bg: rgba(16, 185, 129, 0.22);
  --green-bg-hover: rgba(16, 185, 129, 0.34);
  --green-border: #10b981;
  --green-text: #6ee7b7;
  --green-solid: #10b981;

  /* Yellow = 可調整 */
  --yellow-bg: rgba(245, 158, 11, 0.22);
  --yellow-bg-hover: rgba(245, 158, 11, 0.34);
  --yellow-border: #f59e0b;
  --yellow-text: #fcd34d;
  --yellow-solid: #f59e0b;

  /* Empty / None */
  --none-bg: rgba(15, 23, 42, 0.55);
  --none-border: rgba(148, 163, 184, 0.18);
  --none-text: #94a3b8;

  --weekend-tint: rgba(249, 115, 22, 0.075);
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.55);
}

/* Light Theme */
html[data-theme="light"] {
  --bg-body: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-elevated: #f8fafc;
  --bg-input: #ffffff;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --brand-primary: #2563eb;
  --brand-accent: #ea580c;
  --cf-orange: #ea580c;

  /* Green = 一定可以 */
  --green-bg: #d1fae5;
  --green-bg-hover: #a7f3d0;
  --green-border: #059669;
  --green-text: #065f46;
  --green-solid: #10b981;

  /* Yellow = 可調整 */
  --yellow-bg: #fef3c7;
  --yellow-bg-hover: #fde68a;
  --yellow-border: #d97706;
  --yellow-text: #92400e;
  --yellow-solid: #f59e0b;

  /* Empty / None */
  --none-bg: #f8fafc;
  --none-border: #cbd5e1;
  --none-text: #64748b;

  --weekend-tint: rgba(251, 146, 60, 0.085);
  --shadow-card: 0 4px 20px -4px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: calc(15.5px * var(--font-scale, 1));
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* Top Navbar */
.top-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  padding: 0.75rem 1.5rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  font-size: 1.75rem;
  line-height: 1;
}

.brand-name-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.brand-name {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.cf-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  background: rgba(246, 130, 31, 0.16);
  color: var(--cf-orange);
  border: 1px solid rgba(246, 130, 31, 0.38);
}

.brand-domain {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.nav-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.font-scale-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-card-elevated);
  padding: 0.25rem 0.45rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border-subtle);
}

.control-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0 0.25rem;
  font-weight: 600;
}

.scale-btn {
  padding: 0.2rem 0.45rem;
  border-radius: 0.4rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.scale-btn:hover {
  background: var(--border-subtle);
  color: var(--text-primary);
}

.scale-btn.active {
  background: var(--brand-primary);
  color: #ffffff;
}

.theme-toggle-btn,
.action-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.75rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card-elevated);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-toggle-btn:hover,
.action-pill-btn:hover {
  border-color: var(--brand-primary);
  transform: translateY(-1px);
}

/* Auth Overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(11, 17, 32, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.auth-overlay[hidden] {
  display: none !important;
}

.auth-card {
  width: 100%;
  max-width: 28rem;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 1.2rem;
  padding: 2rem 1.75rem;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.65);
}

.auth-icon {
  font-size: 2.8rem;
  margin-bottom: 0.5rem;
}

.auth-card h1 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.auth-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 0.7rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  font-size: 1.05rem;
  text-align: center;
  letter-spacing: 0.1em;
}

.auth-submit {
  width: 100%;
  padding: 0.8rem 1rem;
  font-size: 1rem;
}

.auth-error {
  margin-top: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid #ef4444;
  color: #fca5a5;
  font-size: 0.88rem;
}

.auth-footer-hint {
  margin-top: 1.2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Main Container */
.app-container {
  max-width: 1680px;
  margin: 0 auto;
  padding: 1.15rem 1.35rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

/* Event Header & Range Config */
.event-header-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  padding: 1.1rem 1.35rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow-card);
}

.event-title-area {
  flex: 1 1 20rem;
}

.title-edit-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.event-title {
  font-size: 1.38rem;
  font-weight: 800;
  cursor: pointer;
}

.icon-btn {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

.event-subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

.range-config-box {
  flex: 1 1 34rem;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 0.85rem;
  padding: 0.85rem 1.05rem;
}

.range-box-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.range-box-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--brand-primary);
}

.range-quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.mini-chip {
  padding: 0.2rem 0.58rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.mini-chip:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.file-upload-chip {
  display: inline-flex;
  align-items: center;
}

.range-inputs-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.date-input-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.date-input-field label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.date-picker-input {
  padding: 0.35rem 0.55rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  font-family: var(--font-mono);
  font-size: 0.86rem;
}

.range-arrow {
  color: var(--text-muted);
  font-weight: 700;
}

.slot-toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.slot-check-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.58rem;
  border-radius: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.range-meta-info {
  margin-top: 0.45rem;
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  border: none;
  border-radius: 0.6rem;
  padding: 0.45rem 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 0.6rem;
  padding: 0.42rem 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
  border: 1px solid #ef4444;
  border-radius: 0.6rem;
  padding: 0.42rem 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

/* Cloudflare AI Studio & Windows PC LINE Parser */
.ai-studio-card {
  background: linear-gradient(145deg, var(--bg-card), var(--bg-card-elevated));
  border: 1.5px solid rgba(246, 130, 31, 0.45);
  border-radius: 1rem;
  padding: 1.15rem 1.35rem;
  box-shadow: var(--shadow-card);
}

.ai-studio-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.ai-title-group {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
}

.ai-sparkle-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.ai-title-group h2 {
  font-size: 1.12rem;
  font-weight: 800;
}

.ai-subtitle {
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.ai-header-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.btn-pc-line-toggle {
  padding: 0.38rem 0.78rem;
  border-radius: 0.55rem;
  border: 1px solid #06c755;
  background: rgba(6, 199, 85, 0.15);
  color: #34d399;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

html[data-theme="light"] .btn-pc-line-toggle {
  color: #047857;
}

.ai-model-selector-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
}

.ai-model-select {
  padding: 0.36rem 0.68rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  font-weight: 600;
}

/* Windows PC LINE Log Parser Panel */
.pc-line-panel {
  background: var(--bg-card);
  border: 1px solid rgba(6, 199, 85, 0.4);
  border-radius: 0.85rem;
  padding: 0.9rem 1rem;
  margin-bottom: 0.9rem;
}

.pc-line-panel[hidden] {
  display: none !important;
}

.pc-line-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.75rem;
}

.pc-line-toolbar-left,
.pc-line-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.pc-line-badge {
  font-weight: 800;
  font-size: 0.85rem;
  color: #10b981;
}

.pc-line-rule-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.22rem 0.6rem;
  border-radius: 0.45rem;
  background: rgba(16, 185, 129, 0.12);
  border: 1px dashed rgba(16, 185, 129, 0.45);
  color: var(--text-primary);
  font-size: 0.76rem;
}

.pc-line-rule-tag strong {
  color: #10b981;
}

.pc-filter-check {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.pc-line-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
  gap: 0.9rem;
}

.pc-raw-col,
.pc-parsed-col {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.pc-col-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.pc-parsed-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

.btn-send-selection {
  padding: 0.25rem 0.65rem;
  border-radius: 0.45rem;
  border: none;
  background: #06c755;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-send-selection:hover {
  filter: brightness(1.08);
}

.pc-raw-textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  resize: vertical;
  min-height: 9.5rem;
}

.pc-raw-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pc-parsed-list {
  height: 10.5rem;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 0.6rem;
  background: var(--bg-input);
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.pc-msg-item {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  padding: 0.38rem 0.55rem;
  border-radius: 0.45rem;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  cursor: pointer;
}

.pc-msg-item.is-meetup-relevant {
  border-color: rgba(16, 185, 129, 0.45);
}

.pc-msg-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.pc-msg-sender {
  font-weight: 800;
  color: var(--cf-orange);
  margin-right: 0.3rem;
}

.pc-msg-body {
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* AI Prompt Chips & Input */
.ai-prompt-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}

.chip-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.prompt-chip {
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(246, 130, 31, 0.35);
  background: rgba(246, 130, 31, 0.09);
  color: var(--text-primary);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.prompt-chip:hover {
  background: rgba(246, 130, 31, 0.22);
  border-color: var(--cf-orange);
}

.ai-input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: stretch;
}

.ai-textarea-wrap {
  flex: 1 1 32rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.ai-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 0.65rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  resize: vertical;
  min-height: 4.5rem;
}

.ai-textarea:focus {
  outline: 2px solid var(--cf-orange);
  border-color: transparent;
}

.ai-target-indicator {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.ai-target-indicator strong {
  color: var(--cf-orange);
}

.ai-action-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.45rem;
  min-width: 12.5rem;
}

.btn-ai-run {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1rem;
  border-radius: 0.65rem;
  border: none;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: 0 6px 20px -4px rgba(249, 115, 22, 0.5);
  transition: all 0.15s;
}

.btn-ai-run:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-ai-run:disabled {
  opacity: 0.6;
  cursor: wait;
}

.ai-feedback-banner {
  margin-top: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: 0.65rem;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.38);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.ai-feedback-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.ai-bot-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 0.35rem;
  background: var(--green-solid);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 700;
}

.ai-feedback-text {
  font-weight: 600;
  font-size: 0.88rem;
}

.ai-telemetry-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.telemetry-pill {
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: var(--text-secondary);
}

/* Cards Common */
.roster-card,
.calendar-card,
.leaderboard-card,
.line-report-card,
.ai-history-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  padding: 1.15rem 1.35rem;
  box-shadow: var(--shadow-card);
}

.section-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}

.section-header-row h2 {
  font-size: 1.08rem;
  font-weight: 800;
}

.section-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.roster-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.filter-tab {
  padding: 0.28rem 0.65rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card-elevated);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.filter-tab.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.95rem;
}

.member-pill {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0.42rem;
  padding: 0.58rem 0.7rem;
  border-radius: 0.75rem;
  border: 1.5px solid var(--border-subtle);
  background: var(--bg-card-elevated);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.member-pill:hover {
  border-color: var(--brand-primary);
  transform: translateY(-1px);
}

.member-pill.active {
  border-color: var(--cf-orange);
  background: rgba(246, 130, 31, 0.14);
  box-shadow: 0 0 0 2px rgba(246, 130, 31, 0.28);
}

.member-pill.just-updated {
  animation: aiPulseHighlight 1.6s ease-out;
}

.member-pill-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  width: 100%;
}

.member-pill-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.member-avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 800;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.member-name-wrap {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.member-name-text {
  font-weight: 800;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-stat-mini {
  font-size: 0.71rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-dots {
  display: flex;
  align-items: center;
  gap: 0.22rem;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.stat-badge-g {
  color: var(--green-text);
  font-weight: 700;
}

.stat-badge-y {
  color: var(--yellow-text);
  font-weight: 700;
}

.member-messages-box {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  padding-top: 0.35rem;
  border-top: 1px dashed var(--border-subtle);
  max-height: 7.5rem;
  overflow-y: auto;
}

.member-messages-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.member-msg-item {
  font-size: 0.73rem;
  line-height: 1.38;
  color: var(--text-primary);
  background: var(--bg-card);
  border-left: 2.5px solid var(--cf-orange);
  padding: 0.24rem 0.42rem;
  border-radius: 0.3rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.member-msg-empty {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
}

.active-messages-summary {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.2rem;
  font-size: 0.76rem;
}

.active-msg-chip {
  background: var(--bg-card);
  border-left: 3px solid #10b981;
  padding: 0.25rem 0.5rem;
  border-radius: 0.35rem;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Active Member Editor Bar */
.active-member-bar {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 0.75rem;
  padding: 0.75rem 0.95rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.active-member-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  flex: 1 1 24rem;
}

.active-avatar {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  background: var(--brand-primary);
  font-size: 0.92rem;
}

.active-member-text {
  flex: 1 1 18rem;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.active-name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.editing-tag {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.active-member-name {
  font-size: 1rem;
  color: var(--cf-orange);
}

.mini-edit-btn,
.mini-save-btn {
  padding: 0.18rem 0.5rem;
  border-radius: 0.4rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.active-note-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.note-inline-input {
  flex: 1 1 13rem;
  padding: 0.26rem 0.55rem;
  border-radius: 0.4rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
}

.magic-wand-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.wand-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.wand-btn {
  padding: 0.26rem 0.6rem;
  border-radius: 0.48rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.wand-green {
  background: var(--green-bg);
  border-color: var(--green-border);
  color: var(--green-text);
}

.wand-yellow {
  background: var(--yellow-bg);
  border-color: var(--yellow-border);
  color: var(--yellow-text);
}

.wand-clear {
  background: var(--none-bg);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

/* =====================================================
   7-Column (Mon-Sun) Weekly Calendar with Users Inside
   ===================================================== */
.calendar-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.7rem;
}

.view-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.view-tab {
  padding: 0.4rem 0.85rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-card-elevated);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.view-tab.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

.brush-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.brush-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.brush-btn {
  padding: 0.3rem 0.6rem;
  border-radius: 0.5rem;
  border: 1.5px solid var(--border-subtle);
  background: var(--bg-card-elevated);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.brush-btn.active {
  box-shadow: 0 0 0 2px var(--brand-primary);
  border-color: var(--brand-primary);
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
  padding: 0.5rem 0.8rem;
  border-radius: 0.6rem;
  background: var(--bg-card-elevated);
  font-size: 0.78rem;
  margin-bottom: 0.9rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.dot {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 999px;
  display: inline-block;
}

.dot-green {
  background: var(--green-solid);
}

.dot-yellow {
  background: var(--yellow-solid);
}

.weekly-calendar-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-strong);
  border-radius: 0.85rem;
  background: var(--bg-card-elevated);
}

.weekly-calendar-scroll {
  min-width: 76rem;
}

.week-header-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(10.8rem, 1fr));
  background: var(--bg-card);
  border-bottom: 2px solid var(--border-strong);
  position: sticky;
  top: 0;
  z-index: 10;
}

.week-head-cell {
  padding: 0.6rem 0.5rem;
  text-align: center;
  font-weight: 800;
  font-size: 0.88rem;
  border-right: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.week-head-cell:last-child {
  border-right: none;
}

.week-head-cell.is-weekend {
  color: var(--cf-orange);
  background: var(--weekend-tint);
}

.weekly-rows-container {
  display: flex;
  flex-direction: column;
}

.week-row-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(10.8rem, 1fr));
  border-bottom: 1px solid var(--border-strong);
}

.week-row-grid:last-child {
  border-bottom: none;
}

.week-day-cell {
  border-right: 1px solid var(--border-subtle);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  min-height: 11.5rem;
  background: var(--bg-card-elevated);
  transition: background-color 0.15s;
}

.week-day-cell:last-child {
  border-right: none;
}

.week-day-cell.is-weekend {
  background: linear-gradient(180deg, var(--weekend-tint), var(--bg-card-elevated));
}

.week-day-cell.out-of-range {
  opacity: 0.35;
  background: var(--bg-body);
  pointer-events: none;
}

.day-cell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem;
  padding: 0.25rem 0.4rem;
  border-radius: 0.45rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  user-select: none;
}

.day-cell-head:hover {
  border-color: var(--brand-primary);
}

.day-num-label {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.86rem;
}

.day-head-action {
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 0.06rem 0.35rem;
  border-radius: 0.3rem;
  background: var(--bg-card-elevated);
}

.day-slots-stack {
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
  flex: 1;
}

.day-slot-box {
  border-radius: 0.55rem;
  border: 1.5px solid var(--none-border);
  background: var(--none-bg);
  padding: 0.35rem 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  cursor: pointer;
  transition: all 0.12s ease;
  flex: 1;
}

.day-slot-box:hover {
  border-color: var(--brand-primary);
}

/* Highlight slot box border when active selected member is inside */
.day-slot-box.my-slot-green {
  border-color: var(--green-border);
  background: rgba(16, 185, 129, 0.09);
}

.day-slot-box.my-slot-yellow {
  border-color: var(--yellow-border);
  background: rgba(245, 158, 11, 0.09);
}

.slot-box-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  font-size: 0.74rem;
}

.slot-box-title {
  font-weight: 800;
  color: var(--text-secondary);
}

.slot-box-count {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
}

.slot-users-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.22rem;
  align-items: center;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  padding: 0.1rem 0.38rem;
  border-radius: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
  transition: transform 0.1s;
}

.user-chip:hover {
  transform: scale(1.06);
}

.user-chip-green {
  background: var(--green-bg);
  color: var(--green-text);
  border: 1px solid var(--green-border);
}

.user-chip-yellow {
  background: var(--yellow-bg);
  color: var(--yellow-text);
  border: 1px solid var(--yellow-border);
}

.user-chip.is-active-member {
  box-shadow: 0 0 0 1.5px var(--cf-orange);
}

.slot-empty-placeholder {
  font-size: 0.68rem;
  color: var(--text-muted);
  opacity: 0.6;
}

/* Matrix Table View */
.calendar-matrix-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.matrix-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.84rem;
}

.matrix-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-weight: 600;
}

.matrix-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.matrix-scroll-box {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 0.75rem;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.matrix-table th,
.matrix-table td {
  padding: 0.42rem 0.5rem;
  border: 1px solid var(--border-subtle);
  text-align: center;
  white-space: nowrap;
}

.matrix-table thead th {
  background: var(--bg-card-elevated);
  position: sticky;
  top: 0;
  font-weight: 700;
}

.matrix-cell-btn {
  width: 100%;
  min-width: 2.3rem;
  padding: 0.22rem;
  border-radius: 0.4rem;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
}

.matrix-cell-btn.cell-green {
  background: var(--green-bg);
  border-color: var(--green-border);
}

.matrix-cell-btn.cell-yellow {
  background: var(--yellow-bg);
  border-color: var(--yellow-border);
}

/* Bottom Analytics Row */
.bottom-analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
  gap: 1.15rem;
  align-items: start;
}

.leaderboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.responded-pill {
  padding: 0.2rem 0.58rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.18);
  color: var(--brand-primary);
  border: 1px solid rgba(59, 130, 246, 0.35);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.leader-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.leader-filter-btn {
  flex: 1;
  padding: 0.3rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card-elevated);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.leader-filter-btn.active {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 26rem;
  overflow-y: auto;
}

.rank-item {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 0.7rem;
  padding: 0.65rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rank-item.rank-top {
  border-color: var(--green-border);
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.25);
}

.rank-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.rank-title {
  font-weight: 800;
  font-size: 0.88rem;
}

.rank-score-badge {
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  background: var(--green-bg);
  color: var(--green-text);
  border: 1px solid var(--green-border);
}

.rank-names-row {
  font-size: 0.76rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

/* LINE Report & Badges */
.line-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.line-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
}

.btn-ai-mini {
  padding: 0.3rem 0.6rem;
  border-radius: 0.48rem;
  border: 1px solid var(--cf-orange);
  background: rgba(246, 130, 31, 0.15);
  color: var(--cf-orange);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-line-copy {
  padding: 0.3rem 0.65rem;
  border-radius: 0.48rem;
  border: none;
  background: #06c755;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.line-report-textarea {
  width: 100%;
  padding: 0.65rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  font-size: 0.8rem;
  line-height: 1.48;
  resize: vertical;
  margin-bottom: 0.8rem;
}

.badges-sub-box h4 {
  font-size: 0.88rem;
  font-weight: 800;
  margin-bottom: 0.45rem;
}

.fun-badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.fun-badge-box {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 0.6rem;
  padding: 0.45rem 0.65rem;
}

.fun-badge-title {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
}

.fun-badge-winner {
  font-size: 0.84rem;
  font-weight: 800;
  margin-top: 0.1rem;
}

.pending-members-box {
  padding: 0.55rem 0.75rem;
  border-radius: 0.6rem;
  background: var(--bg-card-elevated);
  border: 1px dashed var(--border-strong);
  font-size: 0.76rem;
  color: var(--text-secondary);
}

/* AI History Card */
.ai-history-card h3 {
  font-size: 0.98rem;
  font-weight: 800;
  margin-bottom: 0.6rem;
}

.ai-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 24rem;
  overflow-y: auto;
}

.history-item {
  padding: 0.5rem 0.65rem;
  border-radius: 0.55rem;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.76rem;
}

.history-meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-bottom: 0.18rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 180;
  background: rgba(11, 17, 32, 0.8);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-content {
  width: 100%;
  max-width: 54rem;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 1rem;
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow-card);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1rem;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
}

.settings-sec-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.batch-names-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.5rem;
}

.batch-name-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-card-elevated);
  padding: 0.35rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-subtle);
}

.batch-slot-num {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  width: 1.7rem;
}

.batch-name-input {
  flex: 1.3;
  min-width: 0;
  padding: 0.25rem 0.4rem;
  border-radius: 0.35rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  font-size: 0.8rem;
}

.batch-short-input {
  flex: 0.8;
  min-width: 0;
  padding: 0.25rem 0.4rem;
  border-radius: 0.35rem;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  font-size: 0.78rem;
}

.modal-divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 1.25rem 0;
}

.settings-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 1rem;
}

.settings-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0.65rem;
}

.inline-form-row {
  display: flex;
  gap: 0.5rem;
}

.settings-input {
  flex: 1;
  padding: 0.42rem 0.65rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast-msg {
  padding: 0.65rem 1rem;
  border-radius: 0.65rem;
  background: var(--bg-card-elevated);
  border: 1.5px solid var(--brand-primary);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.88rem;
  box-shadow: var(--shadow-card);
}

@keyframes aiPulseHighlight {
  0% {
    box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.85);
    transform: scale(1.02);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(249, 115, 22, 0);
    transform: scale(1);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(249, 115, 22, 0);
  }
}
