:root {
  --primary: #15797d;
  --primary-hover: #116265;
  --primary-light: #e6f4f2;
  --bg: #f4f8f7;
  --surface: #ffffff;
  --text: #1b3838;
  --text-muted: #668280;
  --border: #d4e5e2;
  --border-light: #e5f0ee;
  --danger: #c23934;
  --danger-bg: #fdf2f2;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --success: #059669;
  --success-bg: #ecfdf5;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Thai", Helvetica, Arial, sans-serif;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 20px rgba(18, 59, 56, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font-family);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.page {
  max-width: 1200px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
}

/* Header */
.topbar {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
}

.brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.brand strong {
  color: var(--primary);
}

.brand small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.user-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  font-size: 13px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 99px;
}

.tier-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  border-radius: 6px;
  background: #fef08a;
  color: #854d0e;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
}

.btn-text:hover {
  color: var(--danger);
}

/* Main Navigation */
.main-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}

.nav-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 99px;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.nav-tab:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-tab.active {
  background: var(--primary);
  color: #ffffff;
}

.nav-tab .badge {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.3);
  padding: 2px 6px;
  border-radius: 99px;
}

.nav-tab:not(.active) .badge {
  background: var(--border);
  color: var(--text);
}

/* Main Views */
main {
  flex: 1;
  padding: 24px 0 40px;
}

.view-header {
  margin-bottom: 24px;
}

.view-header h2 {
  font-size: 26px;
  margin: 0 0 6px;
  color: var(--text);
}

.view-header p {
  color: var(--text-muted);
  margin: 0;
  font-size: 15px;
}

/* Buttons */
.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn-secondary:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* View: Auth */
.intro {
  max-width: 720px;
  margin: 30px 0;
}

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--primary);
}

.intro h1 {
  font-size: clamp(30px, 4.5vw, 48px);
  line-height: 1.18;
  margin: 12px 0;
  color: var(--text);
}

.intro h1 span {
  color: var(--primary);
}

.intro p {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-muted);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 540px;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.auth-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 24px;
}

.btn-google {
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
}

.pilot-box {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.pilot-box h3 {
  font-size: 15px;
  margin: 0 0 6px;
}

.pilot-box p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 14px;
}

.pilot-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* View: Discover */
.candidates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
}

.candidate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.candidate-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 20px;
  flex: none;
}

.candidate-meta h3 {
  margin: 0;
  font-size: 18px;
}

.candidate-meta span {
  font-size: 13px;
  color: var(--text-muted);
}

.candidate-body {
  flex: 1;
}

.intent-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  margin-bottom: 12px;
}

.candidate-bio {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 16px;
}

/* Explainable Compatibility Badges */
.compat-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 16px;
}

.compat-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.compat-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.badge-aligned {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #a7f3d0;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}

.badge-discuss {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid #fde68a;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}

.badge-dealbreaker {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}

.compat-disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.compat-toggle {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-top: 6px;
  text-decoration: underline;
}

.compat-details {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #cbd5e1;
  font-size: 12px;
}

.compat-item {
  margin-bottom: 6px;
}

.compat-item strong {
  display: block;
}

.compat-item span {
  color: var(--text-muted);
}

.candidate-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.btn-like {
  flex: 2;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}

.btn-skip {
  flex: 1;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

/* View: Chat */
.chat-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 540px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: #fbfdfc;
}

.side-head {
  height: 60px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}

.rooms {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
}

.room {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  border: none;
  background: transparent;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.room:hover, .room.active {
  background: var(--primary-light);
}

.room strong {
  display: block;
  font-size: 14px;
  color: var(--text);
}

.room small {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.privacy-note {
  border-top: 1px solid var(--border);
  padding: 14px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
  background: #fdfefe;
}

.conversation {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.conversation-head {
  height: 60px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.peer-heading {
  flex: 1;
  min-width: 0;
}

.peer-heading strong {
  display: block;
  font-size: 15px;
}

.peer-heading small {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.safety-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.safety-actions select, .safety-actions button {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface);
}

.safety-actions .danger {
  border-color: #fca5a5;
  color: var(--danger);
}

.messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fdfdfd;
  max-height: 480px;
}

.bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: #edf3f2;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble.mine {
  align-self: flex-end;
  background: var(--primary);
  color: #ffffff;
}

.bubble small {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.75;
  text-align: right;
}

.composer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

.composer input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
}

.composer button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0 20px;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
}

/* Forms */
.profile-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.form-group input, .form-group select, .form-group textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
}

.hint {
  font-size: 11px;
  color: var(--text-muted);
}

.topics-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.topic-box {
  background: #f8fbfa;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px;
}

.topic-box h4 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--primary);
}

.topic-box input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 8px;
}

.topic-box select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.consent-box {
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
}

.consent-box h3 {
  margin: 0 0 12px;
  font-size: 14px;
  color: #0f766e;
}

.checkbox-label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.5;
  cursor: pointer;
}

.checkbox-label input {
  margin-top: 3px;
}

/* Membership */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  max-width: 800px;
}

.price-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

#premium-sandbox-card[hidden],
#pilot-box[hidden] {
  display: none;
}

.price-card.featured {
  border-color: var(--primary);
  position: relative;
}

.badge-featured {
  position: absolute;
  top: -12px;
  right: 20px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  letter-spacing: 0.05em;
}

.price-card h3 {
  margin: 0 0 8px;
}

.price {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 8px;
}

.price span {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.price-card ul {
  padding-left: 0;
  list-style: none;
  margin: 20px 0;
  flex: 1;
}

.price-card li {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
}

.sandbox-notice {
  font-size: 12px;
  background: var(--warn-bg);
  color: #92400e;
  padding: 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  line-height: 1.4;
}

/* Privacy */
.privacy-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.danger-card {
  border-color: #fecaca;
}

.danger-card h3 {
  color: var(--danger);
}

/* Support */
.support-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}

.faq-item h4 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--primary);
}

.faq-item p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
}

.ticket-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.my-tickets {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.ticket-item {
  background: #f8fbfa;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 8px;
  font-size: 13px;
}

.ticket-status {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #e2e8f0;
}

/* Admin Table */
.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th, .admin-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  background: #f8fafc;
  font-weight: 700;
  color: var(--text-muted);
}

/* Footer */
footer {
  min-height: 70px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 12px;
  padding: 16px 0;
}

.signature {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.signature img {
  width: 36px;
  height: auto;
  object-fit: contain;
  vertical-align: middle;
}

.empty, .muted {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

/* Mobile Responsiveness (390px iPhone 13) */
@media (max-width: 768px) {
  .page {
    padding: 0 14px;
  }

  .topbar {
    height: 64px;
  }

  .brand {
    font-size: 16px;
  }

  .brand img {
    width: 34px;
    height: 34px;
  }

  .chat-shell {
    grid-template-columns: 1fr;
    min-height: 600px;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 180px;
  }

  .form-grid, .topics-form, .support-layout {
    grid-template-columns: 1fr;
  }

  .conversation-head {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 14px;
  }

  .safety-actions {
    width: 100%;
    justify-content: flex-end;
  }

  footer {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 0 24px;
  }
}
