:root {
  --accent: #1F5D4C;
  --accent-dark: #123D31;
  --accent-bg: #EAF3EE;
  --gold: #C9A227;
  --gold-bg: #FBF3DD;
  --text: #22291F;
  --muted: #6B7568;
  --border: #E3E8DE;
  --bg: #FFFDF8;
  --card-bg: #ffffff;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

h1, h2, .logo, .generate-btn { font-family: "Poppins", "Inter", sans-serif; }

.topbar {
  background: var(--accent);
  color: white;
  padding: 18px 0;
}
.topbar-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.logo { font-size: 22px; font-weight: 700; }
.subtitle { font-size: 14px; opacity: 0.9; }

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(20, 40, 30, 0.05);
}

.intro h1 { margin-top: 0; font-size: 26px; color: var(--accent-dark); }
.intro p { color: var(--muted); }

h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  margin-top: 0;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 6px;
}

input[type="text"], input[type="file"], textarea, select {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #FEFEFC;
  color: var(--text);
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  background: white;
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
}

.tagcloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.tagcloud.small .tag { font-size: 12px; padding: 5px 10px; }
.tag {
  background: var(--accent-bg);
  color: var(--accent-dark);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.tag:hover { background: var(--gold); color: #4a3a08; border-color: var(--gold); }

.niche-meta {
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0 0;
}

.info-box, .help-text-box {
  background: var(--accent-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text);
  margin-top: 10px;
  line-height: 1.5;
}
.info-box b, .help-text-box b { color: var(--accent-dark); }

.help-text {
  font-size: 13px;
  color: var(--muted);
  margin-top: -6px;
  margin-bottom: 14px;
  line-height: 1.5;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}
.checkbox-line input { width: auto; }

.source-box {
  background: var(--gold-bg);
  border: 1px solid #EEDDA6;
  border-radius: 10px;
  padding: 16px;
}

.char-count {
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 0;
}

.mode-toggle {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.mode-btn {
  flex: 1;
  min-width: 220px;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}
.mode-btn.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent-dark);
}
.mode-hint { font-size: 13px; color: var(--muted); margin-top: 10px; margin-bottom: 0; }

.action-card { text-align: center; }
.generate-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 16px 28px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  width: 100%;
}
.generate-btn:hover { background: var(--accent-dark); }
.error-text { color: #A5352A; font-size: 13px; margin-top: 10px; }

.output-card textarea {
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.5;
}
.copy-btn {
  margin-top: 12px;
  margin-right: 10px;
  background: var(--gold);
  color: #3d2f06;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.copy-btn:hover { opacity: 0.88; }

.hidden { display: none !important; }

.loading {
  text-align: center;
  padding: 30px 0;
  color: var(--muted);
}
.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.output-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  background: #FEFEFC;
}
.output-block:last-child { margin-bottom: 0; }
.output-block-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-dark);
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.output-block textarea {
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.5;
}

.article-preview {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  max-height: 600px;
  overflow-y: auto;
  background: #fff;
  line-height: 1.6;
}
.article-preview h1 { font-size: 24px; color: var(--accent-dark); }
.article-preview h2 { font-size: 19px; text-transform: none; letter-spacing: normal; color: var(--text); margin-top: 24px; }
.article-preview h3 { font-size: 16px; color: var(--text); }
.article-preview img { max-width: 100%; border-radius: 10px; }

.image-upload-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.image-upload-preview .thumb {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid var(--border);
}
.image-upload-preview .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.image-upload-preview .thumb .remove-thumb {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(34, 41, 31, 0.75);
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  padding: 0;
}

.footer {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 24px 0 40px;
}
.footer p { margin: 4px 0; }
.footer-brand { font-weight: 600; color: var(--accent-dark); }
.footer a { color: var(--muted); text-decoration: underline; }
.footer a:hover { color: var(--accent-dark); }
.footer-links span { margin: 0 6px; }
