:root {
  --bg-1: #d9ecff;
  --bg-2: #8ec5ff;
  --phone: #f8fbff;
  --text: #172238;
  --muted: #6b7890;
  --line: #e4edf8;
  --card: #ffffff;
  --accent: #2f7df6;
  --accent-dark: #165ed0;
  --danger: #e05252;
  --shadow: 0 16px 40px rgba(31, 91, 155, 0.22);
  --card-shadow: 0 8px 24px rgba(40, 76, 112, 0.10);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Noto Sans KR", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(255,255,255,.7), transparent 34%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.page-shell {
  width: 100%;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 24px 12px;
}

.phone-frame {
  width: min(100%, 430px);
  min-height: calc(100vh - 48px);
  background: var(--phone);
  border-radius: 34px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.7);
}

.profile-header {
  padding: 28px 22px 18px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255,255,255,.95), rgba(255,255,255,.72)),
    linear-gradient(135deg, #dff0ff, #ffffff);
}

.top-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  margin-bottom: 14px;
  border-radius: 999px;
  background: #eef6ff;
  color: #3271c7;
  font-size: 12px;
  font-weight: 700;
}

.avatar {
  width: 82px;
  height: 82px;
  margin: 0 auto 12px;
  border-radius: 28px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 42px;
  font-weight: 800;
  background: linear-gradient(135deg, #58a6ff, #1f65db);
  box-shadow: 0 12px 30px rgba(47, 125, 246, 0.28);
}

.profile-header h1, .admin-header h1 {
  margin: 0;
  letter-spacing: -0.03em;
}

.profile-copy {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.associate-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(47, 125, 246, 0.08);
  color: #345a8a;
  font-size: 11px;
  line-height: 1.5;
}

.controls { padding: 16px 18px 8px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0 14px;
  box-shadow: 0 6px 16px rgba(31, 91, 155, 0.06);
}

.search-box span { color: var(--muted); font-weight: 700; }
.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  padding: 14px 0;
  background: transparent;
  color: var(--text);
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

select, input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
}

select { padding: 12px 10px; }
input { padding: 13px 12px; }
textarea { padding: 12px; resize: vertical; }

.status {
  margin: 10px 18px;
  padding: 12px;
  border-radius: 16px;
  background: #eef6ff;
  color: #43627d;
  font-size: 13px;
  line-height: 1.5;
}

.status.error { background: #fff0f0; color: #b33838; }
.status.success { background: #ecfff4; color: #227141; }
.status:empty { display: none; }

.product-list { padding: 8px 18px 20px; }

.product-card {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  align-items: center;
  padding: 12px;
  margin-bottom: 12px;
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--card-shadow);
  text-decoration: none;
  border: 1px solid rgba(227,237,248,.8);
  transition: transform .14s ease, box-shadow .14s ease;
}

.product-card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(40, 76, 112, 0.15); }
.product-card:active { transform: scale(.99); }

.product-thumb {
  width: 88px;
  height: 88px;
  border-radius: 18px;
  object-fit: cover;
  background: linear-gradient(135deg, #eef6ff, #ffffff);
  border: 1px solid var(--line);
}

.product-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  font-weight: 800;
}

.product-desc {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.category-chip {
  display: inline-flex;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: #3370be;
  background: #eef6ff;
}

.site-footer {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  border-top: 1px solid var(--line);
}

.fine-print { color: #7b8799; }
.admin-link { display: inline-block; margin-top: 8px; color: #2f7df6; text-decoration: none; font-weight: 700; }

.admin-frame { background: #f6f9ff; }
.admin-header {
  padding: 24px 20px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.admin-header p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.back-link { display: inline-block; margin-bottom: 12px; color: #2f7df6; text-decoration: none; font-weight: 700; font-size: 13px; }

.admin-card {
  margin: 16px 18px;
  padding: 16px;
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--line);
}

.admin-card label, .product-form label {
  display: block;
  margin: 12px 0 6px;
  color: #324157;
  font-size: 12px;
  font-weight: 800;
}

.primary-button, .secondary-button, .ghost-button, .danger-button {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 800;
}
.primary-button { background: var(--accent); color: #fff; box-shadow: 0 8px 20px rgba(47,125,246,.22); }
.primary-button:hover { background: var(--accent-dark); }
.secondary-button { background: #edf5ff; color: #2f6fc4; }
.ghost-button { background: #f3f6fa; color: #516073; }
.danger-button { background: #fff0f0; color: var(--danger); }

#loginButton { width: 100%; margin-top: 12px; }

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.admin-toolbar, .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.inline-action {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
.inline-action .secondary-button { white-space: nowrap; }

.form-grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
}
.checkbox-label input { width: auto; }

.image-preview-wrap {
  margin-top: 8px;
  width: 96px;
  height: 96px;
  border-radius: 18px;
  border: 1px dashed #c7d8ee;
  background: #f8fbff;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.image-preview-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.admin-list {
  padding: 0 18px 22px;
}

.admin-item {
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--line);
}
.admin-item-main {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  align-items: center;
}
.admin-item img {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  object-fit: cover;
  background: #eef6ff;
  border: 1px solid var(--line);
}
.admin-item h3 { margin: 0; font-size: 14px; line-height: 1.4; }
.admin-meta { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 520px) {
  body { background: var(--phone); }
  .page-shell { padding: 0; }
  .phone-frame {
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
    box-shadow: none;
    border: 0;
  }
  .inline-action { grid-template-columns: 1fr; }
}

.image-candidates {
  margin-top: 10px;
}

.image-candidates.hidden {
  display: none;
}

.candidate-title {
  margin: 0 0 8px;
  color: #52627a;
  font-size: 12px;
  font-weight: 800;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.candidate-image {
  border: 1px solid #dce6f5;
  background: #fff;
  border-radius: 14px;
  padding: 4px;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
}

.candidate-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.candidate-image:hover {
  border-color: #2f80ff;
  box-shadow: 0 6px 16px rgba(47,128,255,.16);
}

/* v3: horizontal category scroller + clickable hashtags */
.category-scroller {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 18px 2px;
  margin-top: -2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.category-scroller::-webkit-scrollbar { display: none; }

.category-scroll-chip {
  flex: 0 0 auto;
  border: 1px solid #dbe8f8;
  background: #fff;
  color: #516073;
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(40, 76, 112, 0.06);
}
.category-scroll-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.product-card {
  cursor: pointer;
  align-items: start;
}

.product-info { min-width: 0; }

.product-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.hashtag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.hashtag-chip {
  display: inline-flex;
  align-items: center;
  border: 0;
  border-radius: 999px;
  padding: 4px 8px;
  color: #3370be;
  background: #eef6ff;
  font-size: 11px;
  font-weight: 700;
}

.hashtag-chip:hover {
  background: #dbeeff;
  color: #1f5fb6;
}
