* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #ebedf0;
  color: #222;
  display: flex;
  justify-content: center;
}

/* App Layout */
.app {
  display: flex;
  width: 100%;
  max-width: 1200px;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 72px;
  min-width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 24px;
  gap: 8px;
  background: transparent;
}
.sidebar-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #666;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: background 0.2s;
}
.sidebar-btn:hover { background: #f5f5f5; }
.sidebar-btn.add-page { border: 2px dashed #bbb; background: transparent; box-shadow: none; }
.sidebar-label { font-size: 11px; color: #888; margin-top: -2px; }

/* Phone Preview */
.phone-preview-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  min-width: 300px;
}
.phone-frame {
  width: 280px;
  min-height: 520px;
  background: linear-gradient(180deg, #e8e8e8 0%, #f8f8f8 30%, #fff 100%);
  border-radius: 32px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}
.phone-top-bar {
  display: flex;
  justify-content: space-between;
  padding: 16px 20px 8px;
}
.phone-icon-btn {
  background: none; border: none; cursor: pointer;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.phone-icon-btn:hover { background: rgba(0,0,0,0.05); }
.phone-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}
.phone-profile { text-align: center; margin-bottom: 16px; }
.phone-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: #d0d0d0;
  margin: 0 auto 8px;
  display: flex; align-items: center; justify-content: center;
}
.phone-username {
  font-size: 15px; font-weight: 700; margin-bottom: 4px;
}
.phone-bio {
  font-size: 12px; color: #888;
}
.phone-links {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.phone-link-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: #000;
  color: #fff;
  text-align: center;
  border-radius: 8px;
  font-size: 13px;
  text-decoration: none;
  transition: transform 0.2s;
}
.phone-link-btn:hover { transform: scale(1.02); }

/* Placeholder blocks */
.phone-block-placeholder {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}
.placeholder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 2px dashed #e0d0c0;
  border-radius: 10px;
  background: rgba(255,250,240,0.6);
}
.placeholder-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.placeholder-icon.single { background: #4ade80; }
.placeholder-icon.group { background: #4ade80; }
.placeholder-title { font-size: 12px; font-weight: 600; }
.placeholder-warn { font-size: 10px; color: #e74c3c; }

.phone-footer {
  text-align: center;
  padding: 16px;
  font-size: 11px;
  color: #888;
}
.phone-logo { cursor: pointer; }
.phone-remove-logo {
  margin-top: 8px;
  font-size: 11px;
  color: #999;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}

/* URL Bar */
.url-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-top: 16px;
  width: 280px;
  font-size: 13px;
}
.url-bar span { color: #888; }
.url-bar a { color: #3b82f6; text-decoration: none; }
.url-share {
  margin-left: auto;
  background: none; border: none; cursor: pointer;
}

/* Main Panel */
.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Tabs */
.tabs {
  display: flex;
  background: #fff;
  border-radius: 16px;
  margin: 20px 20px 0;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  gap: 2px;
}
.tab {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: transparent;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #666;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  transition: all 0.2s;
  white-space: nowrap;
}
.tab:hover { background: #f5f5f5; }
.tab.active { background: #111; color: #fff; }
.tab.active svg { stroke: #fff; }

/* Tab Content */
.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 40px;
}
.tab-content.active { display: block; }

/* Sections */
.section {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-header h3 { font-size: 15px; font-weight: 700; }
.section-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.section-icon.single { background: #4ade80; }
.section-icon.group { background: #4ade80; }
.section-label { font-size: 16px; font-weight: 700; margin-bottom: 16px; }

/* Toggle Switch */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #ccc;
  border-radius: 24px;
  cursor: pointer;
  transition: 0.3s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle input:checked + .toggle-slider { background: #4ade80; }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Collapse */
.collapse-btn {
  background: none; border: none; cursor: pointer; color: #888;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
}
.collapse-btn:hover { background: #f0f0f0; }
.section-body.collapsed { display: none; }
.section-header.clickable { cursor: pointer; margin-bottom: 0; }

/* Fields */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 600; color: #555;
  margin-bottom: 8px;
}
.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.input:focus { border-color: #888; }
.input::placeholder { color: #bbb; }

/* Layout Options */
.layout-options {
  display: flex; gap: 8px;
}
.layout-opt {
  width: 100px; height: 72px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: #f5f5f5;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.2s;
}
.layout-opt.active { border-color: #111; background: #e8e8e8; }
.layout-thumb {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.lt-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #bbb;
}
.lt-avatar.small { width: 18px; height: 18px; }
.lt-line { width: 36px; height: 3px; background: #bbb; border-radius: 2px; }
.lt-line.short { width: 24px; }
.left-layout { align-items: flex-start; }
.right-layout { align-items: flex-end; }
.wide-layout {
  flex-direction: row; gap: 8px;
}
.lt-lines { display: flex; flex-direction: column; gap: 4px; }

/* Image Upload */
.image-upload { display: flex; justify-content: center; }
.avatar-preview {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: #e8e8e8;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.camera-btn {
  position: absolute;
  bottom: 0; right: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #111;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* Size Options */
.size-options {
  display: flex; gap: 0;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}
.size-opt {
  flex: 1;
  padding: 12px;
  border: none;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}
.size-opt.active { background: #111; color: #fff; }
.size-opt:not(:last-child) { border-right: 1px solid #e0e0e0; }

/* Link form */
.link-item-form { padding: 16px 0; }
.btn-add-link {
  width: 100%;
  padding: 10px;
  background: #4ade80;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.btn-add-link:hover { background: #22c55e; }
.link-added-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #f8f8f8;
  border-radius: 8px;
  margin-top: 8px;
  font-size: 13px;
}
.link-remove-btn {
  background: none; border: none; cursor: pointer; color: #e74c3c; font-size: 18px;
}

/* Block Add */
.btn-block-add {
  width: 100%;
  padding: 14px;
  background: #111;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-block-add:hover { background: #333; }

/* ======= Design Tab ======= */
.color-grid {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.color-swatch, .btn-color-swatch {
  width: 52px; height: 52px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.color-swatch.active, .btn-color-swatch.active { border-color: #111; }
.custom-color, .photo-upload, .custom-btn-color {
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: #666;
  background: #f0f0f0;
}
.custom-color span, .photo-upload span, .custom-btn-color span {
  text-align: center; line-height: 1.2;
}

.radio-group {
  display: flex; gap: 16px; margin-top: 8px;
  font-size: 13px; color: #555;
}
.radio-group label {
  display: flex; align-items: center; gap: 4px; cursor: pointer;
}

/* Shape Options */
.shape-options {
  display: flex; gap: 8px;
}
.shape-opt {
  flex: 1;
  padding: 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.shape-opt.active { border-color: #111; }
.shape-thumb {
  width: 80px; height: 28px;
  background: #111;
}
.shape-thumb.square { border-radius: 4px; }
.shape-thumb.rounded { border-radius: 14px; background: #ccc; }
.shape-thumb.pill { border-radius: 14px; background: #ccc; }

/* Action Options */
.action-options {
  display: flex; gap: 8px;
}
.action-opt {
  width: 52px; height: 52px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #888;
}
.action-opt.active { border-color: #111; color: #111; }

/* Font Grid */
.font-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.font-opt {
  padding: 10px 8px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  text-align: center;
  transition: all 0.2s;
}
.font-opt.active { background: #111; color: #fff; border-color: #111; }

/* ======= Analytics Tab ======= */
.analytics-toolbar {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.select-period {
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  outline: none;
}
.btn-download {
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 13px;
  background: #f5f5f5;
  color: #aaa;
  display: flex; align-items: center; gap: 4px;
}

.chart-legend {
  display: flex; gap: 16px; margin-bottom: 12px;
}
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.legend-dot {
  width: 12px; height: 4px; border-radius: 2px;
}
.legend-dot.blue { background: #3b82f6; }
.legend-dot.red { background: #ef4444; }

.chart-area { margin-bottom: 16px; }
.chart-placeholder {
  display: flex;
  height: 120px;
  border-bottom: 1px solid #e0e0e0;
}
.chart-y {
  display: flex; flex-direction: column;
  justify-content: space-between;
  font-size: 11px; color: #aaa;
  padding-right: 8px;
  width: 24px;
}
.chart-grid { flex: 1; border-left: 1px solid #e0e0e0; }

/* Stats Row */
.stats-row {
  display: flex; gap: 0;
  background: #111;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}
.stat-card {
  flex: 1;
  padding: 16px;
  text-align: center;
  color: #fff;
}
.stat-card:not(:last-child) { border-right: 1px solid #333; }
.stat-icon { margin-bottom: 4px; }
.stat-icon svg { stroke: #fff; }
.stat-label { font-size: 12px; color: #aaa; margin-bottom: 4px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.stat-value { font-size: 18px; font-weight: 700; }

/* Donut Chart */
.donut-chart {
  display: flex; justify-content: center;
  padding: 20px 0;
}

.chart-legend-list {
  display: flex; flex-direction: column; gap: 8px;
  padding-top: 8px;
}
.legend-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: #888;
}
.legend-bar {
  width: 40px; height: 6px;
  background: #ddd;
  border-radius: 3px;
}
.badge {
  font-size: 11px;
  background: #f0f0f0;
  color: #888;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

/* ======= Manage Tab ======= */
.dark-section {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.dark-section-header {
  background: #111;
  color: #fff;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
}
.dark-section.green .dark-section-header { background: #166534; }
.dark-section.yellow .dark-section-header { background: #854d0e; }
.detail-link { color: #fff; font-size: 12px; text-decoration: none; }
.manage-list { padding: 4px 0; }
.manage-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 14px;
  border-bottom: 1px solid #f0f0f0;
}
.manage-item:last-child { border-bottom: none; }
.manage-icon { font-size: 16px; }
.manage-count { margin-left: auto; color: #888; font-size: 13px; }

/* ======= Marketing Tab ======= */
.marketing-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
}
.marketing-card.disabled { opacity: 0.6; }
.marketing-icon {
  width: 56px; height: 56px;
  border-radius: 12px;
  background: #f0f0ff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.marketing-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.marketing-desc { font-size: 13px; color: #888; }

/* Scrollbar */
.tab-content::-webkit-scrollbar { width: 6px; }
.tab-content::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* Responsive */
@media (max-width: 900px) {
  .app { flex-direction: column; height: auto; }
  .sidebar { flex-direction: row; width: 100%; min-width: auto; padding: 12px; justify-content: center; }
  .sidebar-label { display: none; }
  .phone-preview-area { display: none; }
  .main-panel { width: 100%; }
  .tabs { margin: 12px 12px 0; }
  .tab-content { padding: 12px; }
}
