:root {
  --panel-bg: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(255, 255, 255, 0.10);
  --panel-border-strong: rgba(255, 255, 255, 0.16);
  --text-main: #f8fbff;
  --text-soft: #b5c0d8;
  --text-dim: #8f9bb3;
  --field-bg: rgba(8, 15, 31, 0.55);
  --field-border: rgba(255, 255, 255, 0.10);
  --field-border-focus: rgba(124, 156, 255, 0.75);
  --chip-bg: rgba(255, 255, 255, 0.06);
  --accent: #7c9cff;
  --accent-2: #4ecdc4;
  --danger: #ff7b8c;
  --success: #64e5b3;
  --shadow-lg: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

.tool-page {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 60px;
}

.tool-shell {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.tool-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tool-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 999px;
  color: var(--text-main);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(14px);
  transition: 0.2s ease;
}

.tool-back:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.09);
}

.tool-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tool-chip {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: #dce6ff;
  background: var(--chip-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(14px);
}

.tool-chip-active {
  background: rgba(124, 156, 255, 0.16);
  border-color: rgba(124, 156, 255, 0.36);
  color: #fff;
}

.tool-hero {
  padding: 28px 30px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
}

.tool-hero-badge {
  display: inline-flex;
  padding: 9px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d7e0ff;
  background: rgba(124, 156, 255, 0.14);
  border: 1px solid rgba(124, 156, 255, 0.24);
}

.tool-hero h1 {
  margin: 0 0 12px;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.02;
  letter-spacing: -0.04em;
  color: #fff;
}

.tool-hero p {
  margin: 0;
  max-width: 860px;
  color: var(--text-soft);
  font-size: 16px;
  line-height: 1.75;
}

.texts-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(380px, 0.8fr);
  gap: 24px;
  align-items: start;
}

.panel {
  border-radius: 28px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
}

.panel-main {
  padding: 24px;
}

.panel-preview {
  position: sticky;
  top: 20px;
  padding: 24px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-head-result {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-kicker {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.panel-head h2 {
  margin: 0;
  color: #fff;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.generate-status {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
}

.generate-status.is-loading {
  color: #ffd36b;
}

.generate-status.is-success {
  color: var(--success);
}

.generate-status.is-error {
  color: var(--danger);
}

.cb-section {
  margin-bottom: 22px;
}

.cb-section-title {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 14px;
}

.cb-soft-block {
  margin-bottom: 18px;
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cb-block-title {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 14px;
}

.cb-grid {
  display: grid;
  gap: 14px;
}

.cb-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cb-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cb-field {
  margin-bottom: 14px;
}

.cb-field-no-margin {
  margin-bottom: 0;
}

.cb-field label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #d7dff3;
}

.cb-field input[type="text"],
.cb-field input[type="number"],
.cb-field input[type="file"],
.cb-field select,
.cb-field textarea {
  width: 100%;
  border: 1px solid var(--field-border);
  border-radius: 16px;
  padding: 14px 15px;
  background: var(--field-bg);
  color: var(--text-main);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: 0.2s ease;
}

.cb-field input::placeholder,
.cb-field textarea::placeholder {
  color: #7f8aa4;
}

.cb-field input:focus,
.cb-field select:focus,
.cb-field textarea:focus {
  border-color: var(--field-border-focus);
  box-shadow: 0 0 0 4px rgba(124, 156, 255, 0.12);
}

.cb-field textarea {
  min-height: 150px;
  resize: vertical;
}

.cb-preview-textarea {
  min-height: 380px;
  resize: vertical;
  font-family: Consolas, "SFMono-Regular", monospace;
  line-height: 1.6;
}

.cb-result-textarea {
  min-height: 320px;
  resize: vertical;
  line-height: 1.7;
}

.cb-note {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-dim);
}

.cb-check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.cb-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: #e7efff;
  cursor: pointer;
  user-select: none;
}

.cb-check input {
  margin: 0;
  accent-color: var(--accent);
}

.cb-hidden {
  display: none !important;
}

.cb-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.cb-btn {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: 0.2s ease;
}

.cb-btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #6e8cff 0%, #4ecdc4 100%);
  box-shadow: 0 18px 40px rgba(78, 205, 196, 0.18);
}

.cb-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 48px rgba(78, 205, 196, 0.24);
}

.cb-btn-secondary {
  color: #ecf3ff;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-border);
}

.cb-btn-secondary:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.10);
}

.cb-btn-generate {
  color: #fff;
  background: linear-gradient(135deg, #8b5cf6 0%, #7c9cff 100%);
  box-shadow: 0 18px 40px rgba(124, 156, 255, 0.18);
}

.cb-btn-generate:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 48px rgba(124, 156, 255, 0.24);
}

.cb-btn[disabled] {
  opacity: 0.6;
  cursor: wait;
  transform: none !important;
}

.cb-keyword-item {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.cb-keyword-item > div:first-child {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  border-radius: 14px;
  color: #fff;
  font-weight: 800;
  background: rgba(124, 156, 255, 0.15);
  border: 1px solid rgba(124, 156, 255, 0.25);
}

.cb-image-list {
  border: 1px solid var(--field-border);
  border-radius: 18px;
  background: rgba(8, 15, 31, 0.45);
  padding: 10px 14px;
  min-height: 48px;
}

.cb-image-list.cb-empty {
  color: var(--text-dim);
}

.cb-image-file {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 14px;
}

.cb-image-file:last-child {
  border-bottom: 0;
}

.cb-image-file-name {
  color: #eaf0ff;
  word-break: break-word;
}

.cb-image-file-meta {
  color: var(--text-dim);
  white-space: nowrap;
}

.cb-file-remove {
  border: 0;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: rgba(255, 123, 140, 0.16);
  border: 1px solid rgba(255, 123, 140, 0.26);
  cursor: pointer;
  transition: 0.2s ease;
}

.cb-file-remove:hover {
  background: rgba(255, 123, 140, 0.22);
}

.cb-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 12px;
  border: 1px solid var(--field-border);
  border-radius: 20px;
  background: rgba(8, 15, 31, 0.45);
  padding: 12px;
  min-height: 132px;
}

.cb-preview-grid.cb-empty {
  display: block;
}

.cb-preview-empty {
  color: var(--text-dim);
  font-size: 14px;
}

.cb-preview-card {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cb-preview-thumb-wrap {
  aspect-ratio: 1 / 1;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.cb-preview-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cb-preview-info {
  padding: 10px;
}

.cb-preview-name {
  color: #eef3ff;
  font-size: 12px;
  line-height: 1.35;
  min-height: 32px;
  overflow: hidden;
  word-break: break-word;
}

.cb-preview-meta {
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-dim);
}

.cb-preview-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(7, 13, 28, 0.82);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.10);
}

.cb-preview-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 0;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: rgba(127, 29, 29, 0.90);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: 0.2s ease;
}

.cb-preview-remove:hover {
  background: rgba(153, 27, 27, 1);
}

@media (max-width: 1180px) {
  .texts-layout {
    grid-template-columns: 1fr;
  }

  .panel-preview {
    position: static;
  }

  .cb-preview-textarea {
    min-height: 320px;
  }

  .cb-result-textarea {
    min-height: 260px;
  }
}

@media (max-width: 760px) {
  .tool-page {
    width: min(100%, calc(100% - 20px));
    padding: 18px 0 40px;
  }

  .tool-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .tool-topbar-right {
    justify-content: flex-start;
  }

  .tool-hero,
  .panel-main,
  .panel-preview {
    padding: 18px;
    border-radius: 22px;
  }

  .cb-grid-2,
  .cb-grid-3 {
    grid-template-columns: 1fr;
  }

  .panel-head h2 {
    font-size: 24px;
  }

  .tool-hero h1 {
    font-size: 32px;
  }
}