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

:root {
  --bg:       #0f0f0f;
  --surface:  #1a1a1a;
  --surface2: #242424;
  --border:   #2e2e2e;
  --accent:   #ff0000;
  --accent2:  #7c4dff;
  --text:     #e8e8e8;
  --muted:    #888;
  --radius:   10px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
}

.card h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-header h2 { margin-bottom: 0; }

/* ── Inputs ───────────────────────────────────────────────────────────────── */
input[type="text"], select, textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
  resize: vertical;
}

input[type="text"]:focus, select:focus, textarea:focus {
  border-color: var(--accent2);
}

textarea { font-family: inherit; }

.row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.options-row {
  align-items: center;
  flex-wrap: wrap;
}

.options-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.options-row select { width: auto; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
button {
  cursor: pointer;
  border: none;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}

button:hover  { opacity: .85; }
button:active { transform: scale(.97); }

.btn-primary  { background: var(--accent);  color: #fff; }
.btn-secondary{ background: var(--accent2); color: #fff; }
.btn-copy {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 14px;
  font-size: 13px;
}
.btn-copy:hover { border-color: var(--accent2); color: var(--text); }

/* ── Status bar ───────────────────────────────────────────────────────────── */
#status-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.status-pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
}
.status-ok  { background: #1a3a1a; color: #4caf50; border: 1px solid #2e6b2e; }
.status-err { background: #3a1a1a; color: #f44336; border: 1px solid #6b2e2e; }

/* ── Preview ──────────────────────────────────────────────────────────────── */
.preview {
  margin-top: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 14px;
  font-size: 13px;
  color: var(--muted);
  max-height: 160px;
  overflow-y: auto;
  line-height: 1.7;
}

/* ── Tags ─────────────────────────────────────────────────────────────────── */
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.tag:hover       { border-color: var(--accent2); background: #1e1e2e; }
.tag.selected    { background: var(--accent2); border-color: var(--accent2); color: #fff; }

/* ── Hashtags ─────────────────────────────────────────────────────────────── */
.hashtags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.hashtag {
  font-size: 13px;
  color: #7c4dff;
  background: #1e1a2e;
  border-radius: 5px;
  padding: 2px 8px;
}

/* ── KW list ──────────────────────────────────────────────────────────────── */
.kw-list {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}
.kw-list strong { color: var(--text); margin-right: 6px; }

/* ── Shorts ───────────────────────────────────────────────────────────────── */
.short-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.short-card .short-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.short-card .short-title { font-weight: 700; color: #fff; }
.short-time {
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
  background: #2a1a1a;
  padding: 3px 10px;
  border-radius: 5px;
}
.short-hook { font-size: 13px; color: var(--muted); }
.ffmpeg-cmd {
  margin-top: 8px;
  background: #111;
  border-radius: 5px;
  padding: 8px 12px;
  font-family: 'Consolas', monospace;
  font-size: 12px;
  color: #a5d6a7;
  overflow-x: auto;
  white-space: nowrap;
}

/* ── Mind mapa ────────────────────────────────────────────────────────────── */
.mindmap-container {
  overflow-x: auto;
  padding: 10px 0;
}
.mm-center {
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  margin-bottom: 20px;
  background: var(--accent2);
  display: inline-block;
  padding: 8px 22px;
  border-radius: 30px;
  width: 100%;
}
.mm-branches {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}
.mm-branch {
  background: var(--surface2);
  border: 1px solid var(--accent2);
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 160px;
  max-width: 220px;
}
.mm-branch-label {
  font-weight: 700;
  color: #b39ddb;
  margin-bottom: 8px;
  font-size: 14px;
}
.mm-child {
  font-size: 13px;
  color: var(--muted);
  padding: 2px 0 2px 10px;
  border-left: 2px solid #3e2e6e;
}

/* ── Article ──────────────────────────────────────────────────────────────── */
.article-content {
  background: var(--surface2);
  border-radius: 7px;
  padding: 18px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
}

/* Sekcje bloku artykułu */
.article-block-section {
  margin-bottom: 4px;
}

.article-block-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.article-block-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.article-block-divider {
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Najmocniejszy tytuł */
.article-best-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

/* Streszczenie / meta description */
.article-excerpt {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #c8c8c8;
  line-height: 1.6;
  font-style: italic;
}

/* Treść artykułu */
.article-body {
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  color: var(--text);
}

/* Spis treści w artykule */
.article-toc {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.article-toc-row {
  display: flex;
  gap: 12px;
  font-size: 13px;
}

.article-toc-time {
  color: var(--accent2);
  font-weight: 600;
  white-space: nowrap;
  min-width: 44px;
}

.article-toc-title {
  color: var(--text);
}

/* ── Loading ──────────────────────────────────────────────────────────────── */
#loading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  color: var(--muted);
}
.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--accent2);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-loading {
  opacity: .65 !important;
  background: #555 !important;
  cursor: not-allowed !important;
  pointer-events: none;
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
}
.btn-loading::before {
  content: '';
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

/* ── Preset bar ───────────────────────────────────────────────────────────── */
.preset-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}

.preset-bar select { width: auto; flex: 1; min-width: 160px; }
.preset-bar input  { flex: 1; }

.prompt-label {
  display: block;
  font-size: 13px;
  color: #aaa;
  margin-bottom: 6px;
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

.error-msg {
  background: #3a1a1a;
  color: #f44336;
  border: 1px solid #6b2e2e;
  border-radius: 7px;
  padding: 12px 16px;
  margin-top: 12px;
  font-size: 14px;
}
