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

:root {
  --bg: #f5f5f5;
  --card: #ffffff;
  --border: #e0e0e0;
  --text: #333333;
  --text-light: #666666;
  --text-muted: #999999;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --kakao: #fee500;
}

body {
  font-family: 'Noto Sans KR', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 1.5rem;
  line-height: 1.5;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

header {
  text-align: center;
  margin-bottom: 1.5rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

/* 3컬럼 에디터 섹션 */
.editor-section {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.editor-column {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.center-column {
  min-width: 240px;
  max-width: 280px;
}

.column-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.column-header span {
  font-size: 1.25rem;
}

.column-header h2 {
  font-size: 1rem;
  font-weight: 700;
}

.column-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* Textarea */
.editor-column textarea {
  flex: 1;
  min-height: 280px;
  padding: 0.75rem;
  font-size: 0.8rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: none;
  line-height: 1.6;
}

.editor-column textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.editor-column textarea[readonly] {
  background: #fafafa;
  cursor: default;
}

/* 액션 버튼 */
.action-btn {
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
  margin-top: 0.75rem;
}

.primary-btn {
  background: var(--accent);
  color: white;
}

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

.add-btn {
  background: var(--accent);
  color: white;
  width: 100%;
}

.add-btn:hover {
  background: var(--accent-hover);
}

.kakao-btn {
  background: var(--kakao);
  color: #000;
  flex: 1;
}

.kakao-btn:hover {
  opacity: 0.9;
}

.copy-btn {
  background: var(--text);
  color: white;
  flex: 1;
}

.copy-btn:hover {
  opacity: 0.9;
}

.share-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* 입력 폼 */
.input-form {
  flex: 1;
}

.form-group {
  margin-bottom: 0.75rem;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}

select {
  width: 100%;
  padding: 0.5rem;
  font-size: 0.85rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
}

select:focus {
  outline: none;
  border-color: var(--accent);
}

.distance-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

input[type='number'] {
  width: 100%;
  padding: 0.5rem;
  padding-right: 2.5rem;
  font-size: 0.85rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
}

input[type='number']:focus {
  outline: none;
  border-color: var(--accent);
}

.unit {
  position: absolute;
  right: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.radio-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.radio-label input[type='radio'] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.feedback {
  margin-top: 0.5rem;
  padding: 0.5rem;
  font-size: 0.75rem;
  border-radius: 4px;
  text-align: center;
  display: none;
}

.feedback.success {
  display: block;
  background: #f0fdf4;
  color: #16a34a;
}

.feedback.error {
  display: block;
  background: #fef2f2;
  color: #dc2626;
}

.parse-error {
  margin-top: 0.5rem;
  padding: 0.5rem;
  font-size: 0.75rem;
  border-radius: 4px;
  display: none;
}

.parse-error.show {
  display: block;
  background: #fef2f2;
  color: #dc2626;
}

.parse-error.success {
  display: block;
  background: #f0fdf4;
  color: #16a34a;
}

.saved-member {
  padding-top: 0.75rem;
  margin-top: auto;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  display: flex;
  gap: 0.25rem;
}

.saved-label {
  color: var(--text-muted);
}

.saved-name {
  font-weight: 600;
}

/* 마일리지 현황 섹션 */
.status-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  max-width: 400px;
  margin: 1rem auto;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.section-header span:first-child {
  font-size: 1.25rem;
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 700;
}

.section-header .note {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.teams-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 400px;
}

.team-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.team-card.leading-team {
  border: 2px solid #f59e0b;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
  transform: scale(1.02);
}

.team-card.leading-team .team-header {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-bottom-color: #fcd34d;
}

.team-card.leading-team .team-name {
  color: #b45309;
}

.team-card.leading-team .progress-fill {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.team-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.team-name {
  font-size: 0.9rem;
  font-weight: 700;
}

.team-stats {
  font-size: 0.8rem;
  color: var(--text-light);
}

.stat-current {
  font-weight: 600;
  color: var(--accent);
}

.stat-percent {
  color: var(--text-muted);
  margin-left: 0.25rem;
}

.team-members {
  padding: 0.4rem;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.25rem;
}

.member {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0.4rem;
  background: var(--bg);
  border-radius: 4px;
  font-size: 0.7rem;
}

.member-name .mileage {
  color: var(--text-muted);
  font-size: 0.65rem;
}

.member-distance {
  font-weight: 600;
}

.member-distance.empty {
  color: var(--text-muted);
  font-weight: normal;
}

.team-progress {
  padding: 0 0.75rem 0.5rem;
}

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

/* 링크 섹션 */
.link-section {
  text-align: center;
}

.link-btn {
  padding: 0.5rem 1.5rem;
  font-size: 0.8rem;
  font-family: inherit;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.15s ease;
}

.link-btn:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}

/* 토스트 */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 반응형 */
@media (max-width: 900px) {
  .editor-section {
    grid-template-columns: 1fr;
  }

  .center-column {
    max-width: none;
  }

  .editor-column textarea {
    min-height: 150px;
  }

  body {
    padding: 1rem;
  }
}

@media (max-width: 500px) {
  .teams-container {
    grid-template-columns: 1fr;
  }

  .share-buttons {
    flex-direction: column;
  }
}
