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

:root {
  --bg:        #f0f2f5;
  --surface:   #ffffff;
  --border:    #dde1e7;
  --text:      #1a1a2e;
  --muted:     #6b7280;
  --primary:   #4f46e5;
  --primary-h: #4338ca;
  --success:   #16a34a;
  --error:     #dc2626;
  --warn:      #d97706;
  --radius:    14px;
  --shadow:    0 4px 24px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

header svg { flex-shrink: 0; }
header h1  { font-size: 18px; font-weight: 700; }

.container {
  max-width: 900px;
  margin: 32px auto;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 720px) {
  .container { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

/* ── Composer ─────────────────────────────────────────────────────────────── */

#text {
  width: 100%;
  min-height: 140px;
  padding: 16px 20px;
  font-size: 16px;
  line-height: 1.6;
  border: none;
  resize: vertical;
  outline: none;
  font-family: inherit;
  color: var(--text);
}

.char-bar {
  display: flex;
  justify-content: flex-end;
  padding: 4px 16px 8px;
  font-size: 12px;
  color: var(--muted);
}

.char-bar.warn  { color: var(--warn); }
.char-bar.error { color: var(--error); }

/* ── Media drop ───────────────────────────────────────────────────────────── */

.drop-zone {
  margin: 0 16px 16px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: #f5f3ff;
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-zone .drop-icon { font-size: 28px; margin-bottom: 6px; }
.drop-zone p          { font-size: 13px; color: var(--muted); }
.drop-zone strong     { color: var(--primary); }

#preview-wrap {
  margin: 0 16px 16px;
  position: relative;
  display: none;
}

#preview-wrap img,
#preview-wrap video {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 10px;
}

#remove-media {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,.55);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 16px;
  cursor: pointer;
  line-height: 28px;
  text-align: center;
}

/* ── Submit button ────────────────────────────────────────────────────────── */

.btn-post {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 32px);
  margin: 0 16px 16px;
  padding: 13px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background .2s, transform .1s;
}

.btn-post:hover   { background: var(--primary-h); }
.btn-post:active  { transform: scale(.98); }
.btn-post:disabled { opacity: .6; cursor: not-allowed; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Platform cards ───────────────────────────────────────────────────────── */

.platforms { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; }

.platform-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  user-select: none;
}

.platform-item input[type="checkbox"] { display: none; }

.platform-item.selected {
  border-color: var(--primary);
  background: #f5f3ff;
}

.platform-item.disabled {
  opacity: .45;
  cursor: not-allowed;
}

.platform-logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.platform-info { flex: 1; }
.platform-info strong { font-size: 14px; display: block; }
.platform-info span   { font-size: 12px; color: var(--muted); }

.platform-check {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, border-color .2s;
  flex-shrink: 0;
}

.platform-item.selected .platform-check {
  background: var(--primary);
  border-color: var(--primary);
}

.platform-item.selected .platform-check::after {
  content: '';
  display: block;
  width: 5px; height: 9px;
  border: 2px solid #fff;
  border-top: none; border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* Platform brand colors */
.logo-instagram { background: linear-gradient(45deg,#f09433,#e6683c,#dc2743,#cc2366,#bc1888); }
.logo-facebook  { background: #1877f2; }
.logo-twitter   { background: #000; }
.logo-linkedin  { background: #0a66c2; }

/* ── Results ─────────────────────────────────────────────────────────────── */

#results {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  grid-column: 1 / -1;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.result-item.ok   { border-left: 4px solid var(--success); }
.result-item.fail { border-left: 4px solid var(--error); }

.result-icon { font-size: 20px; flex-shrink: 0; }
.result-text { flex: 1; }
.result-text strong { display: block; margin-bottom: 2px; }
.result-text small  { color: var(--muted); }
