:root {
  color-scheme: dark;
  --bg: #0b0f17;
  --surface: #141c29;
  --surface-subtle: #182334;
  --line: #283445;
  --muted: #a1afc4;
  --text: #eef4ff;
  --accent: #63ebce;
  --accent-glow: rgba(99, 235, 206, 0.25);
  --heart: #ff3b69;
  --heart-bg: rgba(255, 59, 105, 0.12);
  --heart-border: rgba(255, 59, 105, 0.45);
  --heart-glow: rgba(255, 59, 105, 0.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Noto Sans KR", sans-serif;
  line-height: 1.65;
}

button, input, select { font: inherit; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #1b2738;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
}

button:hover, .button:hover { border-color: var(--accent); }
button:active, .button:active { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

a { color: var(--accent); }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.primary {
  background: var(--accent);
  color: #092b25;
  font-weight: 750;
  border-color: var(--accent);
}

.danger {
  color: #ffb9b9;
  border-color: #7b454e;
  background: #341f29;
}

.community-shell {
  width: min(100% - 32px, 1040px);
  margin: auto;
  padding: env(safe-area-inset-top) 0 max(24px, env(safe-area-inset-bottom));
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0;
}

.brand { font-weight: 800; letter-spacing: -0.5px; }
.back { text-decoration: none; }

.hero { padding: 24px 0 16px; }
.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent);
}

h1 {
  font-size: clamp(28px, 5vw, 48px);
  letter-spacing: -1.5px;
  line-height: 1.2;
  margin: 8px 0 12px;
}

h2 { font-size: 20px; letter-spacing: -0.5px; }
h3 { font-size: 15px; margin: 0; }

.hero > p:last-child, .muted, small, footer { color: var(--muted); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  max-width: 750px;
  margin: 0 auto;
}

input:not([type=checkbox]), select {
  background: #0c131f;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 40px;
  padding: 8px 12px;
  max-width: 100%;
  width: 100%;
}

label:not(.check):not(.exercise-check-label) {
  display: block;
  margin: 12px 0 6px;
  font-weight: 650;
}

small { display: block; margin-top: 6px; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0;
}

input[type=checkbox] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}

.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin: 16px 0 6px;
}

/* ==========================================================================
   1. 상단 프로필 바: 닉네임, 헬스 초보, 내설정 한 줄 레이아웃
   ========================================================================== */
.sharing-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  background: #112922;
  border: 1px solid #234f40;
  border-radius: 12px;
  flex-wrap: nowrap;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}

.profile-avatar {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.profile-nickname {
  font-size: 14.5px;
  font-weight: 750;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
}

.profile-level {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 2px 7px;
  border: 1px solid #36546d;
  border-radius: 999px;
  background: #172638;
  color: #bcd8ef;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.auto-badge {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
}

.auto-badge.on {
  color: #63ebce;
  background: rgba(99, 235, 206, 0.12);
  border: 1px solid rgba(99, 235, 206, 0.25);
}

.settings-btn {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 12.5px;
  padding: 5px 12px;
  min-height: 32px;
  border-radius: 8px;
}

.today-status {
  color: var(--muted);
  font-size: 13px;
  margin: 10px 0 4px;
}

/* ==========================================================================
   커뮤니티 탭
   ========================================================================== */
.community-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  overflow: auto;
}

.community-tabs button {
  white-space: nowrap;
  flex: 1;
  background: transparent;
  border-color: transparent;
  font-weight: 700;
  min-height: 38px;
  padding: 6px 10px;
}

.community-tabs button[aria-pressed=true] {
  color: var(--accent);
  background: #16332c;
  border-color: #2a5348;
}

.tab-heart {
  display: inline-block;
  font-size: 13px;
  margin-right: 2px;
}

/* ==========================================================================
   피드 및 카드
   ========================================================================== */
.list-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 18px 0 10px;
}

.list-heading span {
  font-size: 12px;
  color: var(--muted);
}

.feed {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.workout-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-wrap: anywhere;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.workout-card:hover {
  border-color: #3b4d66;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.card-head time {
  color: var(--muted);
  font-size: 12.5px;
}

.card-summary {
  font-size: 20px;
  font-weight: 750;
}

.card-summary small {
  display: inline;
  font-size: 12.5px;
  font-weight: 400;
}

.exercise-names {
  color: var(--muted);
  margin: 0;
  flex: 1;
  font-size: 13px;
  line-height: 1.5;
}

.tags {
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
}

.card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.card-actions button {
  font-size: 12px;
  padding: 5px 10px;
  min-height: 34px;
  white-space: nowrap;
  border-radius: 8px;
}

/* ==========================================================================
   하트 아이콘 & 활성화 애니메이션
   ========================================================================== */
.like-button, #detailLike {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}

.heart-svg {
  display: inline-block;
  vertical-align: middle;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), fill 0.2s ease;
  flex-shrink: 0;
}

.heart-svg.heart-filled {
  color: var(--heart);
}

.like-button[aria-pressed="true"], #detailLike[aria-pressed="true"] {
  color: #ff5e84;
  background: var(--heart-bg);
  border-color: var(--heart-border);
  box-shadow: 0 2px 8px var(--heart-glow);
}

.like-button[aria-pressed="true"] .heart-filled, #detailLike[aria-pressed="true"] .heart-filled {
  color: var(--heart);
  filter: drop-shadow(0 0 5px rgba(255, 59, 105, 0.7));
  animation: heartPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes heartPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.35); }
  75% { transform: scale(0.94); }
  100% { transform: scale(1); }
}

.like-count {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 12.5px;
}

/* ==========================================================================
   운동 상세 모달 & 운동 총 볼륨 성장 그래프
   ========================================================================== */
/* ==========================================================================
   운동 상세 모달 & 운동 총 볼륨 성장 그래프
   ========================================================================== */
dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: min(720px, calc(100% - 16px));
  max-height: 94dvh;
  padding: 14px 16px;
  overflow-y: auto;
}

dialog::backdrop {
  background: #020812cc;
  backdrop-filter: blur(5px);
}

/* 모바일 화면에서 상세 팝업을 화면 꽉 차게 (Full-bleed) */
@media (max-width: 640px) {
  #detailDialog {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    padding: max(10px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom)) !important;
  }
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.dialog-head h2 { margin: 0; font-size: 16px; }

.dialog-head button[data-close] {
  min-height: 28px;
  height: 28px;
  width: 28px;
  padding: 0;
  font-size: 14px;
  border-radius: 6px;
  flex-shrink: 0;
}

.detail-meta {
  color: var(--muted);
  font-size: 12px;
  margin: 2px 0 6px;
}

/* 모달 상단 버튼 3개 (하트, 코드 복사, 인스타 공유) - 타이트한 높이 & 한 줄 */
.detail-actions {
  display: flex;
  gap: 5px;
  margin: 4px 0 6px;
  flex-wrap: nowrap;
}

.detail-actions button {
  flex: 1;
  min-width: 0;
  min-height: 30px;
  padding: 4px 6px;
  font-size: 11.5px;
  white-space: nowrap;
  border-radius: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 차트 컨테이너 - 여백 축소 */
.detail-chart-box {
  background: #0c1421;
  border: 1px solid #1f2f45;
  border-radius: 10px;
  padding: 8px 10px;
  margin: 6px 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.detail-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.detail-chart-title {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 750;
  color: #e4eeff;
  white-space: nowrap;
}

.detail-chart-title .chart-icon {
  font-size: 14px;
}

.chart-total-badge {
  font-size: 11px;
  font-weight: 750;
  color: var(--accent);
  background: rgba(99, 235, 206, 0.1);
  border: 1px solid rgba(99, 235, 206, 0.25);
  padding: 2px 6px;
  border-radius: 12px;
  white-space: nowrap;
}

.detail-canvas-container {
  width: 100%;
  height: 125px;
  position: relative;
  touch-action: pan-y;
}

#detailVolumeCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.detail-chart-hint {
  font-size: 10.5px;
  color: var(--muted);
  margin: 3px 0 0;
  text-align: center;
  min-height: 15px;
  transition: color 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-chart-hint.highlighted {
  color: var(--accent);
  font-weight: 600;
}

/* 운동 항목 요약 리스트 (헤더 한 줄 유지 & 마진 축소) */
.exercise-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin: 6px 0 4px;
}

.exercise-list-head h3 {
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
  margin: 0;
}

.exercise-list-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.detail-exercise-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.exercise-row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  transition: border-color 0.15s ease;
}

.exercise-row-card:hover {
  border-color: #3f5573;
}

.exercise-check-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  min-width: 0;
  flex: 1;
}

.exercise-name-text {
  font-weight: 700;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exercise-info-badges {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  white-space: nowrap;
}

.category-pill {
  font-size: 10px;
  color: #92a4bc;
  background: #111a28;
  border: 1px solid #23344a;
  padding: 1px 5px;
  border-radius: 4px;
}

.sets-pill {
  font-size: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 1px 5px;
  border-radius: 4px;
}

.volume-pill {
  font-size: 11.5px;
  font-weight: 750;
  color: var(--accent);
  padding-left: 2px;
}

.import-section {
  background: #101724;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  margin: 6px 0;
}

.import-section label {
  margin: 0 0 2px;
  font-size: 11.5px;
}

.import-section input {
  min-height: 30px;
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 6px;
}

.import-section p {
  margin: 2px 0 0;
  font-size: 10px;
  line-height: 1.35;
}

/* 하단 가져오기 / 삭제 / 신고 버튼 - 타이트한 높이 */
.detail-footer-actions {
  display: flex;
  gap: 5px;
  margin: 6px 0 0;
}

.detail-footer-actions button {
  min-height: 34px;
  padding: 4px 10px;
  font-size: 12px;
  white-space: nowrap;
  border-radius: 6px;
}

.detail-footer-actions button.primary {
  flex: 2;
  font-weight: 750;
}

.detail-footer-actions button:not(.primary) {
  flex: 1;
}

/* ==========================================================================
   랭킹 및 기타 요소
   ========================================================================== */
#periodSelect {
  width: auto;
  min-width: 110px;
}

.my-rank {
  padding: 12px 16px;
  background: #12362b;
  border: 1px solid #315d4c;
  border-radius: 10px;
  color: var(--accent);
  font-size: 13.5px;
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.rank-row.is-me {
  border-color: var(--accent);
  background: #132422;
}

.rank-number {
  font-size: 18px;
  min-width: 26px;
}

.rank-avatar {
  font-size: 24px;
}

.rank-row > div {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.rank-row small {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.rank-score {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  white-space: nowrap;
  font-size: 20px;
  color: var(--accent);
}

.rank-score small {
  font-size: 12px;
}

.level-badge {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 2px 6px;
  border: 1px solid #36546d;
  border-radius: 999px;
  background: #172638;
  color: #bcd8ef;
  font-size: 10.5px;
  font-weight: 700;
}

.volume {
  font-variant-numeric: tabular-nums;
  color: #82ead5;
}

.post-photo {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #0b111b;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.workout-card .post-photo {
  margin: 4px 0;
}

.detail-photo {
  margin: 0 0 12px;
}

.photo-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.photo-upload {
  cursor: pointer;
}

.photo-upload.disabled {
  opacity: 0.45;
  pointer-events: none;
}

#fitnessLevel { width: 100%; }

#copyCodeText {
  width: 100%;
  background: #0c131f;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  resize: vertical;
}

#saveNicknameBtn { margin-top: 10px; }

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

.nickname-row input {
  min-width: 0;
  flex: 1;
}

.nickname-row button {
  flex-shrink: 0;
  white-space: nowrap;
}

.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
}

.more {
  display: flex;
  margin: 20px auto;
}

footer {
  font-size: 11.5px;
  text-align: center;
  padding: 32px 0 16px;
}

#message:empty { display: none; }
#message {
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  background: #152332;
  margin: 10px 0;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

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

[hidden] { display: none !important; }

/* ==========================================================================
   미디어 쿼리 (모바일 최적화)
   ========================================================================== */
@media (max-width: 640px) {
  .feed { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .brand { display: none; }
  .hero { padding-top: 16px; }
  .list-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }
  .list-heading h2 { margin-bottom: 0; font-size: 18px; }
  dialog { padding: 16px; }
}

@media (max-width: 480px) {
  .community-shell { width: min(100% - 20px, 1040px); }
  .sharing-bar {
    padding: 7px 10px;
    gap: 6px;
  }
  .profile-row { gap: 5px; }
  .profile-avatar { font-size: 17px; }
  .profile-nickname { font-size: 13.5px; }
  .profile-level { font-size: 10px; padding: 2px 5px; }
  .auto-badge { display: none; }
  .settings-btn {
    font-size: 11.5px;
    padding: 4px 8px;
    min-height: 28px;
  }
  .detail-actions button {
    font-size: 11.5px;
    padding: 4px 6px;
    min-height: 32px;
  }
  .exercise-row-card {
    padding: 6px 10px;
  }
  .exercise-name-text {
    font-size: 13px;
  }
  .volume-pill {
    font-size: 11.5px;
  }
}
