/* ============================================
   장한가족 — Instagram-style Design System
   ============================================ */

/* ── Design Tokens ─────────────────────────── */
:root {
  --bg: #fafafa;
  --card: #ffffff;
  --border: #dbdbdb;
  --text-primary: #262626;
  --text-secondary: #8e8e8e;
  --text-link: #00376b;
  --accent: #0095f6;
  --accent-dark: #0074cc;
  --accent-gradient: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  --danger: #ed4956;
  --success: #58b368;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --nav-height: 54px;
}

/* ── Reset / Base ───────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font); }
input, textarea { font-family: var(--font); }

/* ── Navigation Bar ─────────────────────────── */
.ig-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  height: var(--nav-height);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.ig-nav__logo {
  font-size: 22px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
  text-decoration: none;
}
.ig-nav__actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.ig-nav__link {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.ig-nav__link--muted {
  color: var(--text-secondary);
  font-weight: 400;
}
.ig-nav__icon-btn {
  background: none;
  border: none;
  padding: 4px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  font-size: 22px;
  line-height: 1;
}

/* ── App Shell ──────────────────────────────── */
.ig-body {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.ig-container {
  width: 100%;
  max-width: 470px;
  padding: 0 0 80px 0;
}

/* ── Cards ──────────────────────────────────── */
.ig-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}
.ig-card--flat {
  border-radius: 0;
  border-left: none;
  border-right: none;
}

/* ── Post Feed ──────────────────────────────── */
.post-feed {
  display: flex;
  gap: 50px;
  flex-direction: column;
  align-items: center;
}

/* ── Post Card ──────────────────────────────── */
.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 95%;
  margin: 12px auto;
  overflow: hidden;
}
.post-card--secret {
  background: #f5f5f5;
  border-color: #c8c8c8;
}
.post-card__header {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  gap: 10px;
}
.post-card__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.post-card__meta {
  flex: 1;
  min-width: 0;
}
.post-card__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 5px;
}
.post-card__date {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}
.post-card__image {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  display: block;
  cursor: pointer;
}
.post-card__image--landscape {
  aspect-ratio: 4/3;
}
.post-card__actions {
  display: flex;
  align-items: center;
  padding: 8px 12px 0;
  gap: 14px;
}
.post-card__action-btn {
  all: unset;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}
.post-card__action-btn svg {
  width: 22px;
  height: 22px;
}
.post-card__action-btn--liked svg { fill: var(--danger); stroke: var(--danger); }
.post-card__caption {
  padding: 8px 12px 10px;
  font-size: 14px;
  color: var(--text-secondary);
  white-space: pre-line;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}
.post-card__footer {
  padding: 4px 12px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.post-card__days {
  font-size: 11px;
  color: var(--text-secondary);
}
.post-card__stats {
  font-size: 11px;
  color: var(--text-secondary);
}
.lock-badge {
  display: inline-flex;
  align-items: center;
  background: #fff3cd;
  border: 1px solid #f0c040;
  border-radius: var(--radius-pill);
  padding: 1px 6px;
  font-size: 10px;
  color: #856404;
  font-weight: 600;
  gap: 2px;
}

/* ── Search Bar ─────────────────────────────── */
.ig-search-wrap {
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--nav-height);
  z-index: 90;
}
.ig-search {
  all: unset;
  box-sizing: border-box;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-primary);
}
.ig-search::placeholder {
  color: var(--text-secondary);
}

/* ── Quick Actions ──────────────────────────── */
.ig-quick-actions {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.ig-quick-actions::-webkit-scrollbar { display: none; }
.ig-action-chip {
  all: unset;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.ig-action-chip__ring {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  padding: 3px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ig-action-chip__ring--blue {
  background: linear-gradient(45deg, #43b0f1, #0074cc, #2563eb);
}
.ig-action-chip__inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.ig-action-chip__label {
  font-size: 11px;
  color: var(--text-primary);
  text-align: center;
  font-weight: 500;
}

/* ── Pagination ─────────────────────────────── */
.ig-pagination {
  all: unset;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 16px;
  list-style: none;
}
.ig-page-btn {
  all: unset;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  border: 1px solid transparent;
}
.ig-page-btn:hover { background: var(--border); }
.ig-page-btn--active {
  background: var(--accent);
  color: white;
  font-weight: 700;
}
.ig-page-btn--nav {
  background: var(--bg);
  border-color: var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  width: auto;
  padding: 0 10px;
  border-radius: var(--radius-pill);
}

/* ── Create Post Form ───────────────────────── */
.ig-create-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}
.ig-create-card__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.ig-input {
  all: unset;
  box-sizing: border-box;
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  margin-bottom: 8px;
}
.ig-input:focus { border-color: #a8a8a8; }
.ig-input::placeholder { color: var(--text-secondary); }
.ig-textarea {
  all: unset;
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-height: 72px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  margin-bottom: 8px;
  resize: vertical;
}
.ig-textarea:focus { border-color: #a8a8a8; }
.ig-btn {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  text-align: center;
  transition: opacity .15s;
}
.ig-btn:hover { opacity: .85; }
.ig-btn--primary { background: var(--accent); color: white; }
.ig-btn--secondary { background: var(--bg); color: var(--text-primary); border: 1px solid var(--border); }
.ig-btn--danger { color: var(--danger); border: 1px solid var(--danger); }
.ig-btn--success { background: var(--success); color: white; }
.ig-btn--full { width: 100%; display: flex; }
.ig-btn--lg { padding: 10px 20px; font-size: 15px; }
.ig-btn--sm { padding: 5px 10px; font-size: 12px; }

/* ── Detail Page ────────────────────────────── */
.ig-detail__header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.ig-detail__back {
  all: unset;
  cursor: pointer;
  display: flex;
  align-items: center;
  color: var(--text-primary);
  margin-right: 4px;
  font-size: 22px;
}
.ig-detail__title {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
}
.ig-detail__date {
  font-size: 12px;
  color: var(--text-secondary);
}
.ig-detail__notice {
  margin: 12px 16px;
  padding: 10px 14px;
  background: #fff8e1;
  border: 1px solid #f0c040;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: #856404;
  font-weight: 500;
}
.shuffle_img_wrap {
  position: relative;
  width: 100%;
}
.shuffle_img_img {
  display: block;
  width: 100%;
  height: auto;
}
.shuffle_img_date {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 8px 8px;
}

.img-toolbar {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.img-item {
  position: relative;
  display: block;
}
.img-dl-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,.45);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  opacity: 0;
  transition: opacity .2s;
}
/* 마우스 hover 지원 기기 */
.img-item:hover .img-dl-btn { opacity: 1; }
/* 터치 기기(모바일): 항상 표시 */
@media (hover: none) {
  .img-dl-btn { opacity: 1; }
}

.ig-detail__media-section {
  background: var(--card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-top: 8px;
  overflow: hidden;
  max-width: 100%;
}
.ig-detail__content-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 12px 16px;
  padding: 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}
.ig-detail__more-pages {
  padding: 8px 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ig-detail__more-btn {
  all: unset;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 600;
}
.ig-detail__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
}
/* ── Comments ───────────────────────────────── */
.ig-comments {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 12px 16px;
  overflow: hidden;
}
.ig-comments__header {
  padding: 12px 14px 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}
.ig-comment-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ig-comment-item:last-of-type { border-bottom: none; }
.ig-comment-item__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ig-comment-item__user {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}
.ig-comment-item__date {
  font-size: 11px;
  color: var(--text-secondary);
}
.ig-comment-item__del {
  all: unset;
  cursor: pointer;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.ig-comment-item__text {
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-word;
}
.ig-comment-form {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ig-comment-form__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}
.ig-comment-input {
  all: unset;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  min-height: 64px;
  color: var(--text-primary);
  resize: none;
  background: var(--bg);
}
.ig-comment-input:focus { border-color: #a8a8a8; }
.ig-comment-form__row {
  display: flex;
  justify-content: flex-end;
}

/* ── Edit Form ──────────────────────────────── */
.ig-edit-wrap {
  padding: 16px;
  max-width: 470px;
  margin: 0 auto;
}
.ig-edit-field {
  margin-bottom: 16px;
}
.ig-edit-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.ig-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
}
.ig-checkbox-row input[type=checkbox] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}
.ig-checkbox-row label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  margin: 0;
}
.ig-edit-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ── Login / Auth ───────────────────────────── */
.ig-login-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ig-login-card {
  width: 100%;
  max-width: 350px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 36px 32px;
}
.ig-login-logo {
  text-align: center;
  font-size: 36px;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 28px;
  letter-spacing: -1px;
  line-height: 1;
}
.ig-login-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 20px;
  line-height: 1.4;
}
.ig-login-input {
  all: unset;
  box-sizing: border-box;
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text-primary);
  margin-bottom: 6px;
}
.ig-login-input:focus { border-color: #a8a8a8; }
.ig-login-input::placeholder { color: var(--text-secondary); font-size: 12px; }
.ig-login-btn {
  all: unset;
  box-sizing: border-box;
  display: block;
  width: 100%;
  text-align: center;
  cursor: pointer;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-sm);
  padding: 9px;
  font-size: 14px;
  font-weight: 700;
  margin-top: 10px;
  transition: opacity .15s;
}
.ig-login-btn:hover { opacity: .85; }
.ig-login-btn--disabled {
  background: #b2dffc;
  cursor: not-allowed;
}
.ig-login-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 18px 0;
}
.ig-login-divider__line {
  flex: 1;
  height: 1px;
  background: var(--border);
}
.ig-login-divider__text {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}
.ig-login-signup-box {
  width: 100%;
  max-width: 350px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  margin-top: 10px;
  font-size: 14px;
  color: var(--text-primary);
}
.ig-login-signup-box a {
  color: var(--accent);
  font-weight: 700;
  margin-left: 4px;
}
.ig-alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 8px;
}
.ig-alert--error {
  background: #ffeaea;
  color: var(--danger);
  border: 1px solid #fac8cb;
}
.ig-alert--info {
  background: #e8f4fd;
  color: #0c6aa6;
  border: 1px solid #b8d9f5;
}

/* ── Loading Bar ────────────────────────────── */
.ig-loading {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.ig-loading--hidden { display: none; }
.ig-loading__spinner {
  width: 60px;
  height: 60px;
  background: rgba(255,255,255,.15);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ig-loading__gif {
  width: 44px;
  height: 44px;
}
.ig-loading__text {
  color: white;
  font-size: 13px;
  font-weight: 600;
}
.ig-loading__progress {
  color: rgba(255,255,255,.75);
  font-size: 12px;
}

/* ── Utility ────────────────────────────────── */
.u-muted { color: var(--text-secondary); }
.u-truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
