/* ============================================
   FAKEBOOK v1.0(3.1) - v11.7
   ============================================ */

/* === CSS Variables === */
:root {
  /* Colors - Light */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1a1b1e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --border-light: #f0f1f3;
  --accent: #1a1b1e;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --danger-light: #fee2e2;

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Typography */
  --font-sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

body.dark {
  --bg: #0c0d0e;
  --surface: #141516;
  --text: #f3f4f6;
  --text-secondary: #9ca3af;
  --border: #262729;
  --border-light: #1f2022;
  --accent: #f3f4f6;
  --accent-text: #0c0d0e;
  --danger: #ef4444;
  --danger-light: #7f1d1d;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

body.dark ::-webkit-scrollbar-track {
  background: var(--bg);
}

body.dark ::-webkit-scrollbar-thumb {
  background: var(--border);
}

body.dark ::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

body.exporting {
  overflow: visible;
  height: auto;
}

/* === Topbar === */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-sans);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.logo {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tag {
  font-size: 12px;
  color: var(--text-secondary);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-right: 4px;
}

.tool-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 6px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-width: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tool-btn:hover {
  background: var(--bg);
}

.tool-btn.text {
  padding: 0 12px;
}

.tool-btn.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.tool-btn.danger:hover {
  background: var(--danger-light);
}

.tool-icon {
  font-size: 14px;
}

.file-label {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.file-label input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-label:hover,
.file-label:focus-within {
  background: var(--bg);
}

/* === Main Layout === */
.main-layout {
  display: flex;
  gap: 0;
  padding: 16px;
  height: calc(100vh - 56px);
}

.preview-panel {
  flex: 1;
  min-width: 0;
  overflow: auto;
}

.editor-panel {
  width: 420px;
  min-width: 280px;
  max-width: 600px;
  flex-shrink: 0;
}

/* Panel Resizer */
.panel-resizer {
  width: 8px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  flex-shrink: 0;
  margin: 0 4px;
}

.panel-resizer::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 40px;
  background: var(--border);
  border-radius: 2px;
  transition: background 0.15s;
}

.panel-resizer:hover::before,
.panel-resizer.dragging::before {
  background: var(--accent);
}

body.resizing {
  cursor: col-resize;
  user-select: none;
}

body.resizing * {
  pointer-events: none;
}

body.resizing .panel-resizer {
  pointer-events: auto;
}

@media (max-width: 1100px) {
  .main-layout {
    flex-direction: column;
    height: auto;
  }

  .preview-panel,
  .editor-panel {
    width: 100% !important;
    min-width: unset;
    max-width: unset;
  }

  .panel-resizer {
    display: none;
  }

  body {
    overflow: auto;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}

/* === Preview Panel === */
.preview-panel {
  overflow: auto;
}

body.exporting .preview-panel {
  overflow: visible;
}

.preview-content {
  padding: 24px;
}

/* Product Header */
.product-header {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 720px) {
  .product-header {
    grid-template-columns: 1fr;
  }
}

/* Cover */
.cover-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cover-frame {
  position: relative;
  width: 200px;
  aspect-ratio: 2/3;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--border-light);
}

.cover-frame.noimg {
  background: linear-gradient(135deg, var(--border) 0%, var(--border-light) 100%);
}

.cover-frame.cleared {
  background: transparent;
}

.cover-frame.cleared::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image:
    linear-gradient(45deg, rgba(128,128,128,0.1) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(128,128,128,0.1) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(128,128,128,0.1) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(128,128,128,0.1) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

body.exporting .cover-frame.cleared::before {
  display: none;
}

.cover-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.cover-frame.hasImage .cover-image {
  display: block;
}

/* Age Badge */
.age-badge {
  position: absolute;
  display: none;
  user-select: none;
  pointer-events: none;
}

/* Age Badge - Basic (19세미만 구독불가) */
.age-badge.basic {
  display: flex;
  padding: 5px 10px;
  background: #b71c1c;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  font-family: inherit;
  letter-spacing: -0.05em;
}

/* Age Badge - Circle (19) */
.age-badge.circle {
  display: flex;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #ff0047;
  color: #1a1a1a;
  font-weight: 900;
  font-size: 15px;
  align-items: center;
  justify-content: center;
}

body.dark .age-badge.circle {
  background: #fafafa;
}

/* Age Badge Positions */
.age-badge.pos-tl { top: 0; left: 0; border-radius: 0 0 var(--radius-md) 0; }
.age-badge.pos-tr { top: 0; right: 0; border-radius: 0 0 0 var(--radius-md); }
.age-badge.pos-bl { bottom: 0; left: 0; border-radius: 0 var(--radius-md) 0 0; }
.age-badge.pos-br { bottom: 0; right: 0; border-radius: var(--radius-md) 0 0 0; }

.age-badge.circle.pos-tl { top: 8px; left: 8px; border-radius: 50%; }
.age-badge.circle.pos-tr { top: 8px; right: 8px; border-radius: 50%; }
.age-badge.circle.pos-bl { bottom: 8px; left: 8px; border-radius: 50%; }
.age-badge.circle.pos-br { bottom: 8px; right: 8px; border-radius: 50%; }

/* Age Badge Sizes */
.age-badge.size-sm.basic { padding: 3px 7px; font-size: 11px; }
.age-badge.size-md.basic { padding: 5px 10px; font-size: 14px; }
.age-badge.size-lg.basic { padding: 7px 14px; font-size: 17px; }

.age-badge.size-sm.circle { width: 24px; height: 24px; font-size: 12px; border-width: 2px; }
.age-badge.size-md.circle { width: 30px; height: 30px; font-size: 15px; border-width: 3px; }
.age-badge.size-lg.circle { width: 38px; height: 38px; font-size: 18px; border-width: 4px; }

/* Age Badge Shadow */
.age-badge.with-shadow { box-shadow: 0 3px 10px rgba(0,0,0,0.3); }

/* Product Info */
.product-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
}

.breadcrumb-label {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.breadcrumb-path {
  font-weight: 700;
  /*white-space: nowrap;*/
  /*overflow: hidden;*/
  /*text-overflow: ellipsis;*/
  flex: 1;
  min-width: 0;
}

.product-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.3;
  word-break: keep-all;
}

.rating-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stars {
  display: flex;
  gap: 1px;
}

.star {
  font-size: 14px;
  color: var(--text);
}

.star.muted {
  color: var(--border);
}

.star.half {
  background: linear-gradient(90deg, var(--text) 50%, transparent 50%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
}

.star.half::after {
  content: "★";
  position: absolute;
  left: 0;
  opacity: 0.2;
  -webkit-text-fill-color: var(--text);
}

body.exporting-png .star.half {
  background: none;
  -webkit-text-fill-color: initial;
  position: relative;
  color: rgba(0, 0, 0, 0.25);
}

body.dark.exporting-png .star.half {
  color: rgba(255, 255, 255, 0.35);
}

body.exporting-png .star.half::after {
  content: "\2605";
  position: absolute;
  left: 0;
  top: 0;
  width: 50%;
  overflow: hidden;
  color: var(--text);
  -webkit-text-fill-color: var(--text);

  opacity: 0.2;
}

.rating-score {
  font-weight: 800;
  font-size: 15px;
}

.rating-count {
  color: var(--text-secondary);
  font-size: 13px;
}

/* Meta List */
.meta-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
}

.meta-list.layout-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 20px;
}

.meta-item {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-self: flex-start;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  font-size: 13px;
  font-weight: 700;
}

/* Product Info Row */
.product-info-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  min-width: 0;
}

.product-info-main {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* Purchase Box */
.purchase-box {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.purchase-box.purchase-long {
  margin-top: 8px;
}


.price-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 10px;
}

.price-table th,
.price-table td {
  padding: 3px 6px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.price-table th {
  color: var(--text-secondary);
  font-weight: 700;
}

.price-table .label {
  color: var(--text-secondary);
}

.price-table .price {
  text-align: right;
  font-weight: 700;
  white-space: normal;
  overflow-wrap:anywhere;
}

.price-table .highlight {
  color: var(--danger);
}

.btn-buy {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: opacity 0.15s ease;
  white-space: nowrap;
}

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

/* 모바일에서 구매영역 대응 */
@media (max-width: 720px) {
  .product-info-row {
    flex-direction: column;
    min-height: unset;
  }
}

/* Disclaimer */
.disclaimer-note {
  margin-top: 8px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* Details Section */
.details-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 24px;
  margin-bottom: 8px;
}

.section-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 12px;
}

.keyword-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.keyword-tag::before {
  content: "#";
  margin-right: 1px;
}

.keyword-tag {
  display: inline-flex;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 13px;
  font-weight: 600;
}

.intro-content {
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text);
}

/* Reviews */
.reviews-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.reviews-header h2 {
  font-size: 16px;
  font-weight: 800;
}

.review-count-badge {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  font-size: 12px;
  font-weight: 700;
}

.reviews-toolbar {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.btn-outline {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-outline:hover {
  background: var(--bg);
}

.reviews-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

/* Review Card */
.review-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.review-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.review-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.review-nick {
  font-weight: 700;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.review-badge {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  font-size: 11px;
  font-weight: 700;
}

.review-date {
  font-size: 12px;
  color: var(--text-secondary);
}

.review-title {
  margin: 10px 0 6px;
  font-size: 14px;
  font-weight: 700;
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* Review Body Wrap */
.review-body-wrap {
  position: relative;
}

.review-body {
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* collapsed 클래스는 JS 수동 truncate에서 사용 (CSS -webkit-line-clamp 대신) */
.review-body.collapsed {
  display: block;
  overflow: hidden;
}

/* [버그3+4 수정] 더보기/접기 버튼: "… " 바로 뒤에 인라인으로 배치 (JS가 텍스트를 잘라 "… "을 붙이고 그 옆에 more-btn이 오도록 함) */
.review-body-wrap .more-btn {
  display: inline;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-left: 2px;
}

.review-body-wrap .more-btn:hover {
  color: var(--text);
}

.review-bottom {
  margin-top: 12px;
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.icon-text {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.icon-text i {
  font-size: 13px;
}

/* Spoiler */
.spoiler-box {
  margin-top: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.spoiler-title {
  font-weight: 700;
  font-size: 13px;
}

.spoiler-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* [버그5 수정] 스포일러 보기/닫기 버튼 CSS 통일 */
.spoiler-btn,
.spoiler-hide-btn {
  margin-top: 10px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.spoiler-btn:hover,
.spoiler-hide-btn:hover {
  background: var(--bg);
}

/* Replies */
.replies {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reply-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.reply-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.reply-body {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Empty State */
.empty-state {
  margin-top: 20px;
  padding: 32px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  text-align: center;
}

.empty-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.empty-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

/* === Editor Panel === */
.editor-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.editor-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.editor-header h2 {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 2px;
}

.editor-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Tabs */
.tab-nav {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
}

/* Editor Body */
.editor-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  min-height: 0;
}

.tab-content {
  display: block;
}

.tab-content.hidden {
  display: none;
}

/* Form Stack */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Fieldset */
.form-fieldset {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 0;
}

.form-fieldset legend {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

/* Form Fields */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.form-field:first-of-type {
  margin-top: 8px;
}

.form-field > label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  border-color: var(--accent);
}

.form-field textarea {
  resize: vertical;
  min-height: 80px;
}

/* [버그4 수정] 다크모드 select/dropdown 배경색 & 글씨색 */
body.dark .form-field select,
body.dark select {
  background-color: var(--surface);
  color: var(--text);
}

body.dark .form-field select option,
body.dark select option {
  background-color: var(--surface);
  color: var(--text);
}

.form-hint {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* Form Row 2 Columns */
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.form-row-2 .form-field {
  margin-top: 0;
}

@media (max-width: 500px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

/* Radio Group */
.radio-group {
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.radio-item:hover {
  background: var(--bg);
}

.radio-item input {
  margin: 0;
  accent-color: var(--accent);
}

/* Toggle Items */
.toggle-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

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

.toggle-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.toggle-item:hover {
  background: var(--bg);
}

.toggle-item input {
  margin: 0;
  accent-color: var(--accent);
}

.toggle-item.standalone {
  margin-top: 8px;
}

.toggle-item.compact {
  padding: 4px 8px;
  border: none;
  font-size: 12px;
}

/* Category Sections */
.cat-preset,
.cat-custom {
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

.cat-preset .form-row-2,
.cat-custom .form-field {
  margin-top: 0;
}

/* Cover Actions */
.cover-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-file {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
}

.btn-file input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.btn-ghost {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost:hover {
  background: var(--bg);
}

.btn-ghost.small {
  padding: 4px 10px;
  font-size: 11px;
}

/* Fold (Collapsible) */
.fold {
  margin-top: 12px;
}

/* Review Options Row */
.review-options-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
  flex-wrap: nowrap;
}

.review-options-row .toggle-item.compact {
  white-space: nowrap;
}

/* Field Footer */
.field-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.char-counter {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* Replies Inputs */
.replies-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reply-input {
  width: 100%;
  min-height: 70px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn-primary {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

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

.btn-danger {
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--danger);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

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

.btn-danger:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Manage List */
.manage-list {
  display: flex
  ;
  max-height: min(320px, 40vh);
  overflow: auto;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.manage-item {
  width: 100%;
  min-width: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.manage-item:hover {
  background: var(--bg);
}

.manage-item.selected {
  border-color: var(--accent);
  background: var(--bg);
}

.manage-left {
  flex: 1;
  min-width: 0;
}

.manage-title {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.manage-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.manage-right {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--bg);
}

.icon-btn.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.icon-btn.danger:hover {
  background: var(--danger-light);
}

/* Editor Footer */
.editor-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

/* Help button in editor footer */
.editor-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.help-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.help-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.help-tooltip {
  display: none;
  position: absolute;
  bottom: 24px;
  right: -10px;
  width: 280px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 11px;
  font-weight: 400;
  color: var(--text);
  text-align: left;
  line-height: 1.5;
  z-index: 100;
}


.help-btn:hover .help-tooltip,
.help-btn:focus .help-tooltip,
.help-btn:focus-within .help-tooltip {
  display: block;
}


/* === Modal === */
.modal {
  border: none;
  border-radius: var(--radius-lg);
  width: min(900px, 90vw);
  max-height: 85vh;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.modal::backdrop {
  background: rgba(0,0,0,0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 700;
}

.btn-close {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  max-height: calc(85vh - 60px);
  overflow: auto;
}

/* === Toast === */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease;
}

.toast.out {
  animation: toastOut 0.2s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-10px); }
}

/* === Utilities === */
.hidden {
  display: none !important;
}

/* === Export Mode === */
body.exporting .topbar,
body.exporting .editor-panel {
  display: none;
}

body.exporting .main-layout {
  display: block;
  height: auto;
  padding: 0;
}

body.exporting .preview-panel {
  border: none;
  border-radius: 0;
  box-shadow: none;
}


body.exporting-png #captureRoot {
  width: 700px;
}

body.exporting-png .cover-frame.cleared {
  background: transparent;
  border-color: transparent;
}

body.exporting-png .cover-frame.export-empty {
  background: transparent;
  border-color: transparent;
}

body.exporting-png .cover-frame.export-empty::before {
  display: none;
}

body.exporting-png .cover-frame.export-empty .cover-image {
  display: none;
}



/* Export snapshot (fixed width, consistent layout) */
.export-wrapper {
  position: fixed;
  left: -99999px;
  top: 0;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
}

.export-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.export-content {
  padding: 24px;
}
@media (max-width: 760px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    padding: 10px 12px;
    gap: 10px;
  }
  .brand {
    flex-wrap: wrap;
    gap: 6px;
  }
  .logo { font-size: 15px; }
  .tag { font-size: 11px; }
  .toolbar {
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 6px;
  }
  .tool-divider { display: none; }
  .tool-label { display: none; }
  .tool-btn { height: 30px; }
}
.topbar, .topbar * {
  font-family: var(--font-sans);
}

/* Export: force desktop layout regardless of viewport */
body.exporting-png .export-panel.export-desktop .product-header {
  grid-template-columns: 200px 1fr !important;
}
body.exporting-png .export-panel.export-desktop .cover-area {
  align-items: flex-start !important;
}
body.exporting-png .export-panel.export-desktop .product-info {
  width: auto !important;
}
