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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f6fa;
  color: #1a1a2e;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  padding: 18px 32px 14px;
  border-bottom: 1px solid #e0e3ef;
  background: #fff;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 700;
  color: #1a1a2e;
}
.subtitle {
  font-size: 13px;
  color: #9099b0;
  margin-top: 3px;
}

/* ── Layout ── */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 66px);
}

/* ── Sidebar ── */
.sidebar {
  width: 300px;
  border-right: 1px solid #e0e3ef;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar-header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid #eef0f7;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fafbfe;
}

.search-wrap { position: relative; }
.search-box {
  width: 100%;
  background: #fff;
  border: 1px solid #d8dcea;
  border-radius: 8px;
  padding: 9px 12px 9px 36px;
  color: #1a1a2e;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box:focus {
  border-color: #4f6ef7;
  box-shadow: 0 0 0 3px rgba(79,110,247,0.1);
}
.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #aab;
}

.add-wrap { display: flex; gap: 6px; }
.add-input {
  flex: 1;
  background: #fff;
  border: 1px solid #d8dcea;
  border-radius: 7px;
  padding: 7px 10px;
  color: #1a1a2e;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 0;
}
.add-input:focus {
  border-color: #4f6ef7;
  box-shadow: 0 0 0 3px rgba(79,110,247,0.1);
}
.add-input::placeholder { color: #bdc5d8; }
.add-btn {
  background: #eef1fd;
  border: 1px solid #c5cef7;
  color: #4f6ef7;
  padding: 7px 13px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.add-btn:hover { background: #dce3fb; border-color: #4f6ef7; }

.kw-count { font-size: 11px; color: #aab0c8; padding: 0 2px; }

.keyword-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.keyword-list::-webkit-scrollbar { width: 4px; }
.keyword-list::-webkit-scrollbar-track { background: transparent; }
.keyword-list::-webkit-scrollbar-thumb { background: #dde0ee; border-radius: 2px; }

.keyword-item {
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #4a5270;
  transition: all 0.12s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.keyword-item:hover { background: #f0f2fc; color: #1a1a2e; }
.keyword-item.selected { background: #eef1fd; color: #3557e8; font-weight: 500; }
.keyword-item.selected .kw-check { display: inline; }
.kw-check { display: none; color: #4f6ef7; font-size: 12px; }
.keyword-item.disabled { opacity: 0.35; cursor: not-allowed; }
.keyword-item.disabled:hover { background: transparent; color: #4a5270; }

/* ── Content ── */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: #f5f6fa;
}

.selected-area {
  padding: 18px 28px 14px;
  border-bottom: 1px solid #e0e3ef;
  background: #fff;
  flex-shrink: 0;
}
.section-label {
  font-size: 11px;
  font-weight: 600;
  color: #9099b0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}
.selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 34px;
  align-items: flex-start;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #eef1fd;
  border: 1px solid #c5cef7;
  color: #3557e8;
  padding: 5px 11px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  animation: tagIn 0.18s ease;
}
@keyframes tagIn {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}
.tag-remove {
  cursor: pointer;
  color: #8ea4f0;
  font-size: 16px;
  line-height: 1;
  transition: color 0.12s;
  padding: 0 1px;
}
.tag-remove:hover { color: #3557e8; }
.empty-hint { color: #c0c8dc; font-size: 13px; font-style: italic; padding-top: 4px; }

.counter-bar { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.counter { font-size: 12px; color: #9099b0; }
.counter span { color: #4f6ef7; font-weight: 600; }
.limit-warning { font-size: 12px; color: #e55; font-weight: 500; }

/* ── Action Area ── */
.action-area {
  padding: 20px 28px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}

.url-preview {
  background: #fff;
  border: 1px solid #e0e3ef;
  border-radius: 10px;
  padding: 14px 16px;
}
.url-text {
  font-size: 12px;
  color: #4f6ef7;
  word-break: break-all;
  line-height: 1.7;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.url-text.empty { color: #c0c8dc; font-style: italic; font-family: inherit; font-size: 13px; }

.buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 22px;
  border-radius: 9px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
}
.btn-primary {
  background: linear-gradient(135deg, #4f6ef7, #7c5cfc);
  color: #fff;
  box-shadow: 0 3px 12px rgba(79,110,247,0.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 5px 18px rgba(79,110,247,0.35); }
.btn-primary:active { transform: none; }
.btn-primary:disabled {
  background: #e8eaf2;
  color: #bdc5d8;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}
.btn-secondary {
  background: #fff;
  border: 1px solid #d8dcea;
  color: #6b7599;
}
.btn-secondary:hover { background: #f5f6fa; color: #1a1a2e; border-color: #bdc5d8; }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }
.divider-v { width: 1px; height: 20px; background: #e0e3ef; }

/* ── Presets ── */
.quick-presets h3 {
  font-size: 11px;
  color: #9099b0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.preset-list { display: flex; flex-wrap: wrap; gap: 7px; }
.preset-btn {
  background: #fff;
  border: 1px solid #e0e3ef;
  color: #6b7599;
  padding: 5px 13px;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.14s;
}
.preset-btn:hover { background: #eef1fd; border-color: #c5cef7; color: #4f6ef7; }

/* ── Random Groups ── */
.random-groups-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rg-header h3 {
  font-size: 11px;
  color: #9099b0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.rg-total {
  font-size: 11px;
  color: #bdc5d8;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 6px;
}
.btn-reshuffle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #fff;
  border: 1px solid #d8dcea;
  color: #6b7599;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-reshuffle:hover { background: #f0f2fc; border-color: #bdc5d8; color: #3557e8; }
.btn-reshuffle svg { transition: transform 0.4s; }
.btn-reshuffle:hover svg { transform: rotate(180deg); }

.rg-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rg-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid #e0e3ef;
  border-radius: 9px;
  padding: 9px 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.rg-item:hover {
  border-color: #c5cef7;
  background: #f5f7ff;
  box-shadow: 0 2px 8px rgba(79,110,247,0.1);
}
.rg-num {
  font-size: 11px;
  font-weight: 700;
  color: #c5cef7;
  min-width: 22px;
}
.rg-keywords {
  flex: 1;
  font-size: 12px;
  color: #4a5270;
  line-height: 1.5;
}
.rg-keywords span {
  display: inline-block;
  background: #f0f2fc;
  border-radius: 4px;
  padding: 1px 6px;
  margin: 2px 2px;
  color: #5570aa;
}
.rg-open-icon {
  color: #c5cef7;
  flex-shrink: 0;
  transition: color 0.15s;
}
.rg-item:hover .rg-open-icon { color: #4f6ef7; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #fff;
  border: 1px solid #c5cef7;
  color: #3557e8;
  padding: 11px 18px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(79,110,247,0.15);
  transform: translateY(70px);
  opacity: 0;
  transition: all 0.28s ease;
  z-index: 999;
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: #fff5f5; border-color: #ffc5c5; color: #d63030; box-shadow: 0 6px 20px rgba(214,48,48,0.1); }

.custom-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  background: #e8f0fe;
  color: #4f6ef7;
  border-radius: 3px;
  padding: 0 3px;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 14px;
}

.kw-delete {
  display: none;
  margin-left: auto;
  margin-right: 4px;
  font-size: 14px;
  color: #aaa;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.kw-delete:hover { color: #d63030; }
.keyword-item:hover .kw-delete { display: inline; }

/* ── Intro ── */
.intro {
  background: #f5f7ff;
  border-bottom: 1px solid #e5e9ff;
  padding: 14px 24px;
}
.intro-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}
.intro-block {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 220px;
}
.intro-icon {
  font-size: 20px;
  line-height: 1.4;
  flex-shrink: 0;
}
.intro-block strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #2c3e6b;
  margin-bottom: 3px;
}
.intro-block p {
  margin: 0;
  font-size: 12px;
  color: #555;
  line-height: 1.6;
}
.intro-block a {
  color: #4f6ef7;
  text-decoration: none;
}
.intro-block a:hover { text-decoration: underline; }
.intro-block code {
  background: #e8ecff;
  color: #4f6ef7;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
}
.intro-block em { color: #444; font-style: italic; }

/* ── Tag ahrefs link ── */
.tag-ahrefs {
  font-size: 10px;
  color: #f0670a;
  text-decoration: none;
  font-weight: 600;
  opacity: 0.8;
  margin-left: 5px;
}
.tag-ahrefs:hover { opacity: 1; text-decoration: underline; }

.intro-block kbd {
  background: #eef0f8;
  border: 1px solid #d0d5e8;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: inherit;
  color: #333;
}
