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

:root {
  --bg:        #0d0d17;
  --surface:   #13131f;
  --surface2:  #1b1b2d;
  --border:    #26263a;
  --border2:   #33334d;
  --accent:    #7c6ef5;
  --accent-h:  #6b5de8;
  --accent-glow: rgba(124, 110, 245, 0.25);
  --text:      #e0e0f0;
  --text2:     #8888a8;
  --text3:     #55556a;
  --success:   #34d399;
  --error:     #f87171;
  --warning:   #fbbf24;
  --font:      'Inter', 'Segoe UI', system-ui, sans-serif;
  --mono:      'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --radius:    10px;
  --radius-lg: 16px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.app { max-width: 1000px; margin: 0 auto; padding: 0 20px 60px; }

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.logo h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.logo p { font-size: 12px; color: var(--text2); }
.header-actions { display: flex; gap: 8px; }
.btn-sm {
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-sm:hover { border-color: var(--accent); color: var(--text); }

/* ── Section Labels ──────────────────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text3);
  margin-bottom: 12px;
}

/* ── Article Meta ────────────────────────────────────────────────────────── */
.article-meta { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 16px; }
.meta-row { display: flex; flex-direction: column; gap: 4px; }
.meta-row label { font-size: 11px; color: var(--text2); font-weight: 500; }

input[type=text] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
input[type=text]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
::placeholder { color: var(--text3); }

#title-input { font-size: 18px; font-weight: 600; letter-spacing: -0.3px; padding: 12px 16px; }

.word-count {
  font-size: 11px; color: var(--text3);
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 90px;
  text-align: center;
  white-space: nowrap;
}

.tags-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 24px;
}
.tags-row label { font-size: 12px; color: var(--text2); white-space: nowrap; font-weight: 500; }
#tags-input { flex: 1; }

/* ── Editor Pane ─────────────────────────────────────────────────────────── */
.editor-area { margin-bottom: 24px; }

.pane {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  height: 460px;
}
.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  flex-shrink: 0;
}
.pane-header-actions { display: flex; gap: 6px; }
.pane-btn {
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text3);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.pane-btn:hover { color: var(--text); border-color: var(--border2); background: var(--surface); }

/* ── Quill Wrapper ───────────────────────────────────────────────────────── */
#quill-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ── Quill Dark Theme Overrides ──────────────────────────────────────────── */
.ql-toolbar.ql-snow {
  background: var(--surface2) !important;
  border: none !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 8px 12px !important;
  flex-shrink: 0;
}
.ql-container.ql-snow {
  background: var(--surface) !important;
  border: none !important;
  flex: 1;
  overflow-y: auto;
  font-family: var(--font) !important;
  font-size: 14px !important;
}
.ql-editor {
  color: var(--text) !important;
  line-height: 1.8 !important;
  padding: 16px 20px !important;
  min-height: 100%;
}
.ql-editor.ql-blank::before {
  color: var(--text3) !important;
  font-style: italic !important;
}

/* Toolbar icons */
.ql-toolbar .ql-stroke { stroke: var(--text2) !important; }
.ql-toolbar .ql-fill   { fill:   var(--text2) !important; }
.ql-toolbar .ql-picker  { color:  var(--text2) !important; }
.ql-toolbar button:hover .ql-stroke,
.ql-toolbar .ql-active  .ql-stroke { stroke: var(--accent) !important; }
.ql-toolbar button:hover .ql-fill,
.ql-toolbar .ql-active  .ql-fill   { fill:   var(--accent) !important; }
.ql-toolbar button:hover,
.ql-toolbar .ql-active             { color:  var(--accent) !important; }

/* Heading picker dropdown */
.ql-snow .ql-picker-options {
  background: var(--surface2) !important;
  border-color: var(--border2) !important;
  border-radius: var(--radius) !important;
}
.ql-snow .ql-picker-item:hover { color: var(--accent) !important; }
.ql-snow .ql-picker-label      { color: var(--text2) !important; }
.ql-snow .ql-picker-label::before { color: var(--text2) !important; }

/* Content typography inside editor */
.ql-editor h1 { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.ql-editor h2 { font-size: 19px; font-weight: 700; margin-bottom: 6px; color: var(--accent); }
.ql-editor h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.ql-editor p  { margin-bottom: 8px; }
.ql-editor ul, .ql-editor ol { margin-left: 20px; margin-bottom: 8px; }
.ql-editor blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  color: var(--text2);
  font-style: italic;
  margin-bottom: 8px;
}
.ql-editor pre.ql-syntax {
  background: var(--surface2) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  color: var(--text) !important;
  font-family: var(--mono) !important;
  font-size: 12px !important;
  padding: 12px !important;
}
.ql-editor code {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12px;
  padding: 1px 5px;
}
.ql-editor a { color: var(--accent); }

/* Quill tooltip / link popup */
.ql-snow .ql-tooltip {
  background: var(--surface2) !important;
  border-color: var(--border2) !important;
  border-radius: var(--radius) !important;
  color: var(--text) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5) !important;
}
.ql-snow .ql-tooltip input[type=text] {
  border-color: var(--border2) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  border-radius: 6px !important;
}
.ql-snow .ql-tooltip a.ql-action { color: var(--accent) !important; }
.ql-snow .ql-tooltip a.ql-remove { color: var(--error) !important; }

/* ── Platform Grid ───────────────────────────────────────────────────────── */
.platforms-section { margin-bottom: 20px; }
.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.platform-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  transition: all 0.18s;
  background: var(--surface);
  user-select: none;
}
.platform-card:hover { border-color: var(--border2); background: var(--surface2); }
.platform-card.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  box-shadow: 0 0 0 1px var(--accent);
}
.platform-card-top {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.platform-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.toggle {
  width: 32px; height: 18px; background: var(--border2);
  border-radius: 999px; position: relative; transition: background 0.18s; flex-shrink: 0;
}
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; background: var(--text3);
  border-radius: 50%; transition: transform 0.18s, background 0.18s;
}
.platform-card.active .toggle { background: var(--accent); }
.platform-card.active .toggle::after { transform: translateX(14px); background: #fff; }
.platform-name { font-size: 13px; font-weight: 600; }
.platform-desc { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ── Credentials Accordion ───────────────────────────────────────────────── */
.credentials-section { margin-bottom: 24px; }
.cred-accordion { display: flex; flex-direction: column; gap: 8px; }
.cred-card { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.cred-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; cursor: pointer; background: var(--surface2); transition: background 0.15s;
}
.cred-card-header:hover { background: var(--border); }
.cred-card-title { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; }
.cred-chevron { font-size: 10px; color: var(--text2); transition: transform 0.2s; }
.cred-card.open .cred-chevron { transform: rotate(90deg); }
.cred-card-body { display: none; padding: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.cred-card.open .cred-card-body { display: grid; }
.cred-field { display: flex; flex-direction: column; gap: 5px; }
.cred-field label { font-size: 11px; color: var(--text2); font-weight: 500; }
.cred-field input {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-family: var(--font); font-size: 13px; padding: 8px 12px;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s; width: 100%;
}
.cred-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.cred-note {
  grid-column: 1/-1; font-size: 11px; color: var(--text3);
  padding: 6px 10px; background: var(--surface2); border-radius: 6px;
  border-left: 2px solid var(--accent);
}
.cred-note a { color: var(--accent); }
.cred-save-badge {
  font-size: 10px; color: var(--success); padding: 2px 8px;
  background: color-mix(in srgb, var(--success) 12%, transparent);
  border-radius: 999px; border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
  transition: opacity 0.3s;
}

/* ── Publish Button ──────────────────────────────────────────────────────── */
.publish-row { display: flex; align-items: center; justify-content: center; margin-bottom: 28px; }
#publish-btn {
  padding: 14px 48px; border-radius: var(--radius-lg); border: none;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: all 0.18s; box-shadow: 0 4px 20px var(--accent-glow);
  display: flex; align-items: center; gap: 10px;
}
#publish-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 28px var(--accent-glow); }
#publish-btn:active { transform: translateY(0); }
#publish-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── Results ─────────────────────────────────────────────────────────────── */
.results-section { margin-top: 8px; }
.results-grid { display: flex; flex-direction: column; gap: 8px; }
.result-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--surface);
  animation: slideIn 0.2s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.result-card.success { border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.result-card.error   { border-color: color-mix(in srgb, var(--error)   40%, transparent); }
.result-status {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
}
.result-status.success { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.result-status.error   { background: color-mix(in srgb, var(--error)   15%, transparent); color: var(--error); }
.result-status.loading { background: var(--surface2); }
.result-info { flex: 1; min-width: 0; }
.result-platform { font-size: 13px; font-weight: 600; }
.result-url { font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.result-url a { color: var(--accent); text-decoration: none; }
.result-url a:hover { text-decoration: underline; }
.result-error { font-size: 12px; color: var(--error); }
.result-actions { display: flex; gap: 6px; flex-shrink: 0; }
.result-btn {
  padding: 5px 12px; border-radius: 8px; border: 1px solid var(--border2);
  background: var(--surface2); color: var(--text2); font-size: 11px;
  cursor: pointer; transition: all 0.15s; text-decoration: none;
  display: flex; align-items: center; gap: 4px;
}
.result-btn:hover { border-color: var(--accent); color: var(--text); }
.result-btn.copied { color: var(--success); border-color: var(--success); }
.results-summary {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-radius: var(--radius-lg);
  background: var(--surface2); border: 1px solid var(--border);
  margin-bottom: 12px; font-size: 13px;
}
.results-summary .ok   { color: var(--success); font-weight: 600; }
.results-summary .fail { color: var(--error);   font-weight: 600; }

/* Spinner */
.spinner {
  width: 14px; height: 14px; border: 2px solid var(--border2);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.upload-zone {
  border: 1.5px dashed var(--border2); border-radius: var(--radius);
  padding: 6px 14px; cursor: pointer; color: var(--text3); font-size: 12px;
  transition: all 0.15s; display: flex; align-items: center; gap: 6px;
}
.upload-zone:hover { border-color: var(--accent); color: var(--text2); }

@media (max-width: 600px) {
  .platform-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .pane { height: 360px; }
}
