*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f0f0f0;
  --sidebar-bg: #f7f7f5;
  --border: #e0ddd6;
  --text: #111;
  --text-secondary: #666;
  --radius: 8px;
  --radius-sm: 6px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* APP HEADER */
.app-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 52px;
  flex-shrink: 0;
}
.app-header-inner {
  max-width: 1600px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-title { font-size: 15px; font-weight: 600; color: #111; }
.app-actions { display: flex; gap: 8px; }

/* GEN WRAP */
.gen-wrap {
  display: flex;
  flex: 1;
  overflow: hidden;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  height: calc(100vh - 52px);
}

/* SIDEBAR */
.sidebar {
  width: 340px;
  min-width: 340px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.section { border-bottom: 1px solid var(--border); }

.section-title {
  padding: 11px 16px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.section-title:hover { background: #eeece8; }
.section-title.hl-seo   { color: #1a3a6a; background: #eef4ff; }
.section-title.hl-aff   { color: #7a5800; background: #fff8e6; }
.section-title.hl-domain{ color: #1a4a1a; background: #f0faf0; }

.section-body { padding: 10px 16px; display: flex; flex-direction: column; gap: 8px; }
.section-body.collapsed { display: none; }

.sidebar-footer {
  padding: 14px 16px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
  background: var(--sidebar-bg);
}

/* FIELDS */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--text-secondary); }
.field input,
.field select,
.field textarea {
  font-size: 13px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  width: 100%;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: #aaa; }
.field textarea { resize: vertical; min-height: 56px; line-height: 1.5; }
.field input.link-input   { border-color: #d4b060; background: #fffdf5; }
.field input.domain-input { border-color: #90c890; background: #f6fff6; }
.mt6 { margin-top: 6px; }
.mt4 { margin-top: 4px; }

.hint-label  { font-size: 11px; color: var(--text-secondary); line-height: 1.4; }
.sub-label   { font-size: 12px; font-weight: 600; color: #333; margin-bottom: 6px; }
.info-text   { font-size: 11px; color: var(--text-secondary); padding: 5px 9px; background: #f5f5f3; border: 1px solid var(--border); border-radius: var(--radius-sm); }

.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=color] { width: 36px; height: 28px; padding: 2px; border-radius: var(--radius-sm); border: 1px solid var(--border); cursor: pointer; }
.color-row span { font-size: 12px; color: var(--text-secondary); }

.divider { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; display: flex; flex-direction: column; gap: 6px; }

/* INFO BLOCK */
.info-block { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 5px; }
.info-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.info-row.small { font-size: 11px; color: var(--text-secondary); }
.info-row .dot { width: 7px; height: 7px; border-radius: 50%; background: #2ecc71; flex-shrink: 0; }
.info-row .lbl { color: var(--text-secondary); min-width: 70px; }
.info-row code { font-family: 'SF Mono', monospace; font-size: 11px; background: #f0f0ee; padding: 2px 6px; border-radius: 4px; }

.dl-btns { display: flex; gap: 6px; }
.dl-btn {
  flex: 1; font-size: 12px; padding: 7px 8px;
  border: 1px solid #90c890; border-radius: var(--radius-sm);
  background: #f0faf0; color: #1a4a1a; cursor: pointer; text-align: center;
  font-family: inherit;
}
.dl-btn:hover { background: #e0f5e0; }

/* BUTTONS */
.tbtn {
  font-size: 12.5px; padding: 6px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; color: var(--text); cursor: pointer; font-family: inherit;
  white-space: nowrap;
}
.tbtn:hover { background: #f5f5f3; }
.tbtn.primary { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }
.tbtn.primary:hover { background: #333; }
.tbtn.green { background: #1a4a1a; color: #fff; border-color: #1a4a1a; }
.tbtn.green:hover { background: #235a23; }
.tbtn.full { width: 100%; font-size: 13px; padding: 9px; }

.btn-add {
  font-size: 12px; padding: 6px 10px;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  background: #fff; color: var(--text-secondary); cursor: pointer; width: 100%; margin-top: 4px;
  font-family: inherit;
}
.btn-add:hover { background: #f5f5f3; border-color: #aaa; }

.row-between { display: flex; align-items: center; justify-content: space-between; }
.row-gap8 { display: flex; gap: 8px; }
.flex1 { flex: 1; }

.badge-dofollow {
  font-size: 11px; background: #e8f5e9; color: #2e7d32;
  border-radius: 20px; padding: 2px 8px; font-weight: 500;
}

/* IMAGE UPLOAD */
.img-upload-box {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 14px; text-align: center; cursor: pointer; position: relative;
  transition: border-color .15s;
}
.img-upload-box:hover { border-color: #999; }
.img-upload-box input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.img-upload-box .upload-label { font-size: 12px; color: var(--text-secondary); pointer-events: none; }
.img-upload-box .upload-label span { display: block; font-size: 22px; margin-bottom: 4px; }
.img-preview-wrap { position: relative; display: inline-block; }
.img-preview { max-width: 100%; max-height: 100px; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; margin: 0 auto; }
.img-remove {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #e03030; color: #fff; border: none; cursor: pointer;
  font-size: 11px; display: flex; align-items: center; justify-content: center;
}
.img-name { font-size: 11px; color: var(--text-secondary); margin-top: 4px; text-align: center; }

/* HREFLANG ROWS */
.hreflang-row { display: flex; gap: 4px; align-items: center; margin-bottom: 4px; }
.hreflang-row input { font-size: 12px; padding: 5px 7px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; color: var(--text); font-family: inherit; }
.hreflang-row input:first-child { width: 62px; min-width: 62px; }
.hreflang-row input:nth-child(2) { flex: 1; }
.hreflang-row button { padding: 5px 9px; font-size: 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #f5f5f3; color: var(--text-secondary); cursor: pointer; flex-shrink: 0; font-family: inherit; }

/* GAME CARD EDITOR */
.games-list { display: flex; flex-direction: column; gap: 8px; max-height: 560px; overflow-y: auto; }
.game-card-editor {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 6px;
}
.game-card-header { display: flex; justify-content: space-between; align-items: center; }
.game-card-header span { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.game-card-header button { padding: 2px 8px; font-size: 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); cursor: pointer; font-family: inherit; }
.game-field { display: flex; flex-direction: column; gap: 3px; }
.game-field label { font-size: 11px; color: var(--text-secondary); }
.game-field input { font-size: 12px; padding: 5px 7px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #f9f9f9; color: var(--text); width: 100%; font-family: inherit; }
.game-img-upload {
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: 7px 10px; text-align: center; cursor: pointer; position: relative;
  font-size: 11px; color: var(--text-secondary); transition: border-color .15s;
}
.game-img-upload:hover { border-color: #999; }
.game-img-upload input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.game-img-thumb { width: 100%; height: 60px; object-fit: cover; border-radius: 4px; display: block; }
.game-img-row { position: relative; }
.game-img-row .img-remove { top: -5px; right: -5px; width: 18px; height: 18px; font-size: 10px; }

/* BONUS LIST */
#bonus-list { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; }
.bonus-row { display: flex; gap: 4px; align-items: center; }
.bonus-row input { flex: 1; font-size: 12px; padding: 5px 7px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #f9f9f9; color: var(--text); font-family: inherit; }
.bonus-row button { padding: 5px 9px; font-size: 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #f5f5f3; color: var(--text-secondary); cursor: pointer; font-family: inherit; }

/* HEADINGS */
.heading-blocks-list { display: flex; flex-direction: column; gap: 6px; max-height: 400px; overflow-y: auto; }
.heading-block { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.heading-block-top { display: flex; align-items: center; gap: 6px; }
.heading-block-top select,
.heading-block-top input {
  font-size: 12px; padding: 4px 7px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #f9f9f9; color: var(--text); font-family: inherit;
}
.heading-block-top select { width: auto; }
.heading-block-top input { flex: 1; }
.heading-block-top button { padding: 4px 8px; font-size: 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); cursor: pointer; font-family: inherit; }
.heading-block textarea { font-size: 12px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #f9f9f9; color: var(--text); width: 100%; font-family: inherit; resize: vertical; min-height: 52px; line-height: 1.5; }
.move-btns { display: flex; flex-direction: column; gap: 2px; }
.move-btns button { padding: 1px 5px; font-size: 10px; border: 1px solid var(--border); border-radius: 3px; background: transparent; color: var(--text-secondary); cursor: pointer; font-family: inherit; line-height: 1.5; }

/* RG LINKS */
#rg-list { display: flex; flex-direction: column; gap: 6px; }
.rg-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 10px; display: flex; flex-direction: column; gap: 6px; }
.rg-card-header { display: flex; justify-content: space-between; align-items: center; }
.rg-card-header span { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.rg-card-header button { padding: 2px 8px; font-size: 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); cursor: pointer; font-family: inherit; }
.rg-field { display: flex; flex-direction: column; gap: 3px; }
.rg-field label { font-size: 11px; color: var(--text-secondary); }
.rg-field input { font-size: 12px; padding: 5px 7px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #f9f9f9; color: var(--text); width: 100%; font-family: inherit; }

/* PREVIEW */
.preview-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #fff; }
.preview-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: #fafafa; gap: 8px; flex-wrap: wrap; flex-shrink: 0;
}
.ptl-left { display: flex; align-items: center; gap: 10px; }
.ptl-title { font-size: 13px; font-weight: 600; color: var(--text); }
.tab-btns { display: flex; gap: 4px; }
.tab-btn {
  font-size: 12px; padding: 4px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary); cursor: pointer; font-family: inherit;
}
.tab-btn.active { background: #fff; color: var(--text); border-color: #aaa; font-weight: 500; }
.toolbar-btns { display: flex; gap: 6px; }
.preview-iframe-wrap { flex: 1; overflow: hidden; display: none; }
.preview-iframe-wrap.active { display: block; }
.preview-iframe-wrap iframe { width: 100%; height: 100%; border: none; }
.code-view {
  flex: 1; overflow: auto; display: none;
  background: #1a1a1a; color: #e0e0e0;
  font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px;
  line-height: 1.6; padding: 16px; white-space: pre; margin: 0;
}
.code-view.active { display: block; }
