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

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --primary: #f97316;
  --primary-hover: #ea6c0a;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #ef4444;
  --radius: 12px;
}

[data-theme="dark"] {
  --bg: #111111;
  --surface: #1e1e1e;
  --border: #2e2e2e;
  --text: #e5e5e5;
  --muted: #9ca3af;
}

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

header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 2rem; display: flex; align-items: center; justify-content: space-between; height: 64px; position: sticky; top: 0; z-index: 10; }
header h1 { font-size: 1.25rem; font-weight: 700; }
header h1 span { color: var(--primary); }
nav { display: flex; gap: 1rem; align-items: center; }

.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 1.2rem; border-radius: 8px; border: none; cursor: pointer; font-size: 0.9rem; font-weight: 600; text-decoration: none; transition: background 0.15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 0.3rem 0.8rem; font-size: 0.8rem; }

main { max-width: 1100px; margin: 0 auto; padding: 2rem; }

.hero { text-align: center; padding: 3rem 0 2rem; }
.hero h2 { font-size: 2rem; margin-bottom: 0.5rem; }
.hero p { color: var(--muted); margin-bottom: 1.5rem; }

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

.card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; transition: box-shadow 0.15s; }
.card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
.card-media { width: 100%; height: 200px; object-fit: cover; display: block; background: var(--bg); }
.card-media.video { height: 200px; }
.card-body { padding: 1.25rem; }
.card-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.4rem; }
.card-desc { color: var(--muted); font-size: 0.9rem; line-height: 1.5; margin-bottom: 1rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.card-url { font-size: 0.85rem; color: var(--primary); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-url:hover { text-decoration: underline; }
.card-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.media-placeholder { width: 100%; height: 200px; background: var(--bg); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 2.5rem; }

.empty { text-align: center; padding: 4rem; color: var(--muted); }
.empty p { margin-top: 0.5rem; }

/* Login page */
.auth-wrap { min-height: calc(100vh - 64px); display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 2.5rem; width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.auth-card .subtitle { color: var(--muted); font-size: 0.9rem; margin-bottom: 2rem; }

/* Form */
.form-group { margin-bottom: 1.25rem; }
label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.4rem; }
input[type=text], input[type=url], input[type=password], textarea {
  width: 100%; padding: 0.6rem 0.9rem; border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.95rem; background: var(--surface); color: var(--text); transition: border-color 0.15s;
}
input:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: 0.8rem; color: var(--muted); margin-top: 0.3rem; }

.upload-area { border: 2px dashed var(--border); border-radius: 8px; padding: 2rem; text-align: center; cursor: pointer; transition: border-color 0.15s; }
.upload-area:hover, .upload-area.dragover { border-color: var(--primary); }
.upload-area p { color: var(--muted); font-size: 0.9rem; margin-top: 0.5rem; }
.upload-area input { display: none; }
#preview-wrap { margin-top: 1rem; }
#preview-wrap img, #preview-wrap video { max-width: 100%; max-height: 240px; border-radius: 8px; }

.alert { padding: 0.75rem 1rem; border-radius: 8px; font-size: 0.9rem; margin-bottom: 1.25rem; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; }
.page-header h2 { font-size: 1.5rem; }

.submit-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: start; }
.form-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 2rem; }
.form-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.5rem; }

.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.4); border-top-color: white; border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; margin-right: 0.3rem; }
@keyframes spin { to { transform: rotate(360deg); } }

#auth-actions .hidden { display: none; }
