/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #1a56db;
  --primary-light: #e8effc;
  --primary-dark: #1041a8;
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --success: #10b981;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
}

html {
  font-size: 16px;
}

body {
  font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(26, 86, 219, 0.3);
}

.header-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px 0;
}

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.logo span {
  font-weight: 400;
  opacity: 0.85;
  margin-left: 4px;
}

.tabs {
  display: flex;
  gap: 0;
}

.tab {
  flex: 1;
  padding: 10px 8px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  font-family: inherit;
}

.tab.active {
  color: #fff;
  border-bottom-color: var(--accent);
}

.tab:hover {
  color: #fff;
}

/* ===== Container ===== */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label:not(.radio-label) {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

label.required::after {
  content: ' *';
  color: var(--danger);
}

select,
input[type="text"],
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea {
  resize: vertical;
}

.radio-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  transition: all 0.2s;
}

.radio-label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}

.radio-label input[type="radio"] {
  width: auto;
  accent-color: var(--primary);
}

/* ===== Optional Section ===== */
.optional-section {
  margin-bottom: 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0;
}

.optional-section summary {
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
}

.optional-section summary::before {
  content: '+ ';
  font-weight: 700;
  color: var(--primary);
}

.optional-section[open] summary::before {
  content: '- ';
}

.optional-section[open] {
  border-color: var(--primary);
}

.optional-section>.form-group {
  padding: 0 16px;
}

.optional-section>.form-group:last-child {
  padding-bottom: 16px;
}

/* ===== Buttons ===== */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(26, 86, 219, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26, 86, 219, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  padding: 8px 16px;
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* ===== Spinner ===== */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== Result ===== */
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.result-header .card-title {
  margin-bottom: 0;
}

.result-actions {
  display: flex;
  gap: 8px;
}

.result-content {
  background: var(--bg);
  border-radius: 8px;
  padding: 16px;
  font-size: 0.9rem;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60vh;
  overflow-y: auto;
}

.result-footer {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* ===== Vote Buttons ===== */
.btn-vote {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
}

.btn-vote:hover {
  border-color: var(--text-secondary);
}

.btn-like.voted {
  color: var(--success);
  border-color: var(--success);
  background: #ecfdf5;
}

.btn-dislike.voted {
  color: var(--danger);
  border-color: var(--danger);
  background: #fef2f2;
}

/* ===== Leaderboard ===== */
.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.leaderboard-header .card-title {
  margin-bottom: 0;
}

.sort-select {
  width: auto;
  padding: 6px 32px 6px 10px;
  font-size: 0.85rem;
  border-radius: 6px;
}

/* ===== Leaderboard Filters ===== */
.leaderboard-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}
.leaderboard-filters::-webkit-scrollbar {
  height: 4px;
}
.leaderboard-filters::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.filter-select {
  width: auto;
  min-width: 100px;
  padding: 6px 28px 6px 10px;
  font-size: 0.8rem;
  border-radius: 6px;
  white-space: nowrap;
}
.btn-clear {
  padding: 6px 12px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}
.btn-clear:hover {
  background: var(--border);
  color: var(--text);
}

/* ===== Pitch List ===== */
.pitch-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pitch-item {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  transition: all 0.2s;
}

.pitch-item:hover {
  box-shadow: var(--shadow);
}

.pitch-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.tag-industry {
  background: #dbeafe;
  color: #1e40af;
}

.tag-channel {
  background: #fef3c7;
  color: #92400e;
}

.tag-role {
  background: #ede9fe;
  color: #5b21b6;
}

.pitch-preview {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}

.pitch-preview.expanded {
  -webkit-line-clamp: unset;
  white-space: pre-wrap;
}

.pitch-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.pitch-stats {
  display: flex;
  gap: 12px;
  align-items: center;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 3px;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  margin-right: 6px;
  flex-shrink: 0;
}

.rank-1 {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.rank-2 {
  background: linear-gradient(135deg, #9ca3af, #6b7280);
}

.rank-3 {
  background: linear-gradient(135deg, #b45309, #92400e);
}

.rank-other {
  background: var(--border);
  color: var(--text-secondary);
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 32px 16px;
  font-size: 0.9rem;
}

.loading-placeholder {
  text-align: center;
  color: var(--text-secondary);
  padding: 24px;
}

.btn-loadmore {
  width: 100%;
  margin-top: 12px;
}

/* ===== FAB ===== */
.fab-container {
  position: fixed;
  bottom: 24px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 50;
}

.fab-label {
  background: var(--card);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  border: 1px solid var(--primary-light);
  white-space: nowrap;
  animation: bounceX 2s infinite;
}

.fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(26, 86, 219, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fab:hover {
  transform: scale(1.1) rotate(5deg);
}

.fab svg {
  stroke-width: 2.5;
}

@keyframes bounceX {

  0%,
  100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(-5px);
  }
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s;
}

.modal {
  background: var(--card);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 640px;
  max-height: 80dvh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
}

.modal-header h2 {
  font-size: 1rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.modal-body {
  padding: 16px 20px 24px;
}

.event-theme {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.event-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.info-section {
  margin-bottom: 16px;
}

.info-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.info-row {
  font-size: 0.875rem;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.info-section ul {
  list-style: none;
  padding: 0;
}

.info-section li {
  font-size: 0.85rem;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}

/* ===== Tab Content ===== */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.2s;
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.875rem;
  z-index: 300;
  animation: fadeIn 0.2s;
  box-shadow: var(--shadow-lg);
}

/* ===== Edit Textarea ===== */
.edit-textarea {
  width: 100%;
  min-height: 200px;
  padding: 16px;
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.8;
  color: var(--text);
  background: #fff;
  resize: vertical;
}

.edit-textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== Refine Section ===== */
.refine-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.refine-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}

.refine-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.refine-chip {
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: #fff;
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.refine-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.refine-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.refine-custom {
  display: flex;
  gap: 8px;
}

.refine-custom input {
  flex: 1;
}

.btn-refine {
  width: auto;
  padding: 10px 20px;
  flex-shrink: 0;
  font-size: 0.9rem;
}

/* ===== Desktop tweaks ===== */
@media (min-width: 640px) {
  .modal {
    border-radius: 16px;
    margin: auto;
    max-height: 70dvh;
  }

  .modal-overlay {
    align-items: center;
  }
}