:root {
  color-scheme: light dark;
  --bg: #0f172a;
  --panel: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --danger: #f87171;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  padding: 2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

header h1 { margin: 0 0 0.25rem; }
header p { margin: 0; color: var(--muted); }

main {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  max-width: 1100px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border-radius: 12px;
  padding: 1.5rem;
}

.panel h2 { margin-top: 0; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

select, textarea, input[type="text"] {
  background: #0f172a;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: var(--text);
  padding: 0.6rem;
  font-family: inherit;
  font-size: 0.95rem;
  width: 100%;
}

button {
  background: var(--accent);
  color: #0f172a;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover { opacity: 0.9; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.status { color: var(--muted); min-height: 1.2rem; }

.drafts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.draft-card {
  background: #0f172a;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
}

.draft-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #111827;
}

.draft-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.draft-product {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.draft-hook { font-weight: 600; }

.draft-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.draft-actions .btn-delete { background: var(--danger); }

.draft-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
}

.history-scroll {
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
}

.history-row:last-child { border-bottom: none; }
.history-row:hover { background: rgba(255,255,255,0.04); }

.history-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #111827;
}

.history-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.history-hook {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.status-badge.draft { background: rgba(148,163,184,0.2); color: var(--muted); }
.status-badge.scheduled { background: rgba(56,189,248,0.2); color: var(--accent); }
.status-badge.published { background: rgba(74,222,128,0.2); color: #4ade80; }
.status-badge.failed { background: rgba(248,113,113,0.2); color: var(--danger); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 50;
}

.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--panel);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.25rem 0.6rem;
}

.modal-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.modal-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.modal-caption {
  white-space: pre-wrap;
  font-size: 0.9rem;
  color: var(--text);
}

.modal-hashtags {
  color: var(--accent);
  font-size: 0.85rem;
}

.modal-dates {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  font-size: 0.8rem;
  margin-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 0.75rem;
}

.modal-dates dt { color: var(--muted); }
.modal-dates dd { margin: 0; }
