@font-face { font-family: "Fredoka"; src: url("/fonts/Fredoka.ttf"); font-weight: 300 700; }
@font-face { font-family: "Nunito"; src: url("/fonts/Nunito.ttf"); font-weight: 200 1000; }
@font-face { font-family: "Noto Sans Malayalam"; src: url("/fonts/NotoSansMalayalam.ttf"); font-weight: 100 900; }

:root {
  --bg: #fff8ef; --card: #ffffff; --ink: #3b2416; --muted: #8a6f5c; --line: #f0e2d2;
  --orange: #ffb85a; --coral: #ff6068; --brown: #4a2c1a; --ok: #059669; --warn: #b45309; --bad: #dc2626; --blue: #2563eb;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1d1410; --card: #2a1e18; --ink: #f6e9de; --muted: #c4a894; --line: #3d2c22; --brown: #f6e9de; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 "Nunito", "Noto Sans Malayalam", system-ui, sans-serif; }
h2, h3, .brand { font-family: "Fredoka", sans-serif; margin: 0; }
h3 { margin: 24px 0 10px; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 999px; padding: 8px 16px; font-weight: 800; background: linear-gradient(135deg, var(--orange), var(--coral)); color: #fff; }
button.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
button.danger { background: var(--card); color: var(--bad); border: 1px solid var(--bad); }
button:disabled { opacity: .45; cursor: not-allowed; }
select, input, textarea { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 7px 10px; }
textarea { width: 100%; min-height: 110px; resize: vertical; }
code { background: var(--line); border-radius: 6px; padding: 1px 6px; font-size: 13px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-size: 22px; }
.brand .star { color: var(--orange); }
#tabs { display: flex; gap: 6px; flex-wrap: wrap; }
#tabs button { background: transparent; color: var(--muted); }
#tabs button.on { background: var(--bg); color: var(--ink); }
.pill { margin-left: auto; font-size: 13px; font-weight: 800; padding: 4px 12px; border-radius: 999px; background: var(--bg); color: var(--muted); }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.view { display: none; } .view.on { display: block; }
.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.grow { flex: 1; }
.hint { color: var(--muted); font-size: 13px; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 900px) { .week { grid-template-columns: 1fr; } }
.day { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 10px; min-height: 220px; }
.day.today { border-color: var(--orange); box-shadow: 0 0 0 2px var(--orange) inset; }
.day h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 8px; margin-bottom: 8px; cursor: pointer; }
.card:hover { border-color: var(--orange); }
.card img, .card video { width: 100%; aspect-ratio: 4/5; object-fit: cover; border-radius: 10px; display: block; background: #0001; }
.card .t { font-weight: 800; font-size: 13px; margin-top: 6px; }
.card .meta { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; align-items: center; font-size: 12px; }
.ph { width: 100%; aspect-ratio: 4/5; border-radius: 10px; display: grid; place-items: center; background: repeating-linear-gradient(45deg, var(--line) 0 8px, transparent 8px 16px); color: var(--muted); font-weight: 800; font-size: 12px; text-align: center; padding: 8px; }

.st { font-size: 11px; font-weight: 900; text-transform: uppercase; border-radius: 999px; padding: 2px 8px; background: var(--line); color: var(--muted); }
.st.draft { background: #fef3c7; color: #92400e; } .st.approved { background: #dbeafe; color: #1e40af; }
.st.posted { background: #d1fae5; color: #065f46; } .st.failed, .st.partly_posted { background: #fee2e2; color: #991b1b; }
.st.publishing { background: #ede9fe; color: #5b21b6; } .st.rejected { text-decoration: line-through; }

.list { display: grid; gap: 8px; }
.row { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; cursor: pointer; }
.row img { width: 64px; height: 80px; object-fit: cover; border-radius: 8px; }
.row .grow { min-width: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px; cursor: pointer; }
.tile { position: relative; }
.tile img, .tile video { width: 100%; aspect-ratio: 3/4; object-fit: contain; border-radius: 10px; display: block; background: repeating-conic-gradient(#0000000d 0 25%, #0000 0 50%) 0 0/14px 14px; }
.tile:hover img, .tile:hover video { outline: 2px solid var(--orange); }
.tile .copy { position: absolute; right: 10px; top: 10px; padding: 4px 9px; font-size: 12px; opacity: 0; transition: opacity .15s; }
.tile:hover .copy { opacity: 1; }
.tile .play { position: absolute; left: 50%; top: 38%; transform: translate(-50%,-50%); font-size: 34px; pointer-events: none; text-shadow: 0 2px 8px #0008; }
.tile .t { font-size: 12px; font-weight: 800; margin-top: 4px; overflow-wrap: anywhere; }
.tile .s { font-size: 11px; color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.conn { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.conn .ok { color: var(--ok); font-weight: 900; } .conn .no { color: var(--warn); font-weight: 900; }

.drawer { position: fixed; inset: 0; background: #0006; z-index: 20; display: flex; justify-content: flex-end; }
.drawer[hidden] { display: none; }
.drawer-inner { position: relative; width: min(980px, 100%); height: 100%; overflow: auto; background: var(--bg); padding: 22px; }
.x { position: absolute; right: 16px; top: 14px; background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.assets { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.assets figure { margin: 0; flex: none; }
.assets img, .assets video { height: 300px; border-radius: 12px; display: block; background: #0001; }
.assets figcaption { font-size: 11px; color: var(--muted); text-align: center; margin-top: 3px; }
.pa { display: flex; flex-direction: column; gap: 6px; width: min-content; }
.pa-media { position: relative; cursor: zoom-in; }
.pa-media:hover img, .pa-media:hover video { outline: 3px solid var(--orange); }
.pa-media .play { position: absolute; left: 50%; top: 45%; transform: translate(-50%,-50%); font-size: 40px; color: #fff; pointer-events: none; text-shadow: 0 2px 8px #0008; }
.pa figcaption { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; align-items: center; }
.pa figcaption select { padding: 2px 6px; font-size: 12px; border-radius: 8px; }
.pa-tools { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.pa-tools button { padding: 4px 9px; font-size: 12px; }
.pa-add { width: 180px; height: 300px; border: 2px dashed var(--line); border-radius: 12px; display: grid; place-content: center; text-align: center; gap: 6px; cursor: pointer; color: var(--muted); flex: none; }
.pa-add:hover { border-color: var(--orange); color: var(--ink); }
.pa-add span { font-size: 34px; }
.pa-add small { font-size: 11px; }
.fixer { border: 0; border-radius: 20px; padding: 20px; width: min(900px, 94vw); background: var(--bg); color: var(--ink); box-shadow: 0 30px 80px #0006; }
.fixer::backdrop { background: #0008; }
.fixer h3 { margin: 0 0 12px; }
.fixer-body { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
@media (max-width: 700px) { .fixer-body { grid-template-columns: 1fr; } }
.fx-preview img, .fx-preview video { width: 100%; max-height: 60vh; object-fit: contain; border-radius: 12px; background: #0001; display: block; }
.radio { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin: 6px 0; text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 400; }
.radio input:disabled + span { opacity: .45; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 800px) { .two { grid-template-columns: 1fr; } }
.field { display: grid; gap: 4px; margin: 10px 0; }
.field > span { font-size: 12px; font-weight: 900; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.checks div { padding: 6px 10px; border-radius: 10px; margin: 4px 0; font-size: 13px; }
.checks .e { background: #fee2e2; color: #991b1b; } .checks .w { background: #fef3c7; color: #92400e; } .checks .g { background: #d1fae5; color: #065f46; }
.preview { white-space: pre-wrap; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-size: 13px; max-height: 260px; overflow: auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); }
.platforms label { margin-right: 12px; font-weight: 800; white-space: nowrap; }
.results a { color: var(--blue); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--brown); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 800; z-index: 40; max-width: 90vw; }
.log { white-space: pre-wrap; font: 12px/1.4 ui-monospace, monospace; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; max-height: 220px; overflow: auto; }

/* Library viewer */
.viewer { position: fixed; inset: 0; z-index: 30; background: #120c09f2; display: grid; grid-template-rows: auto 1fr auto; color: #f6e9de; }
.viewer[hidden] { display: none; }
.viewer-top { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 18px; }
.viewer-title { display: grid; min-width: 0; }
.viewer-title b { font-family: "Fredoka", sans-serif; font-size: 18px; overflow-wrap: anywhere; }
.viewer-title .hint { color: #c4a894; }
.viewer-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.viewer-actions .ghost { background: #2a1e18; color: #f6e9de; border-color: #3d2c22; }
.x-inline { background: #2a1e18; color: #f6e9de; border: 1px solid #3d2c22; }
.viewer-stage { display: flex; align-items: center; justify-content: center; padding: 6px 64px; min-height: 0; overflow: auto; }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; border-radius: 10px; box-shadow: 0 20px 60px #0008; background: repeating-conic-gradient(#ffffff10 0 25%, #0000 0 50%) 0 0/16px 16px; }
.viewer-stage img.zoomed { max-width: none; max-height: none; cursor: zoom-out; }
.viewer-stage img { cursor: zoom-in; }
.viewer-stage audio { width: min(520px, 90vw); }
.viewer-nav { position: fixed; top: 50%; transform: translateY(-50%); background: #2a1e18cc; color: #fff; font-size: 34px; width: 48px; height: 64px; padding: 0; border-radius: 14px; }
.viewer-nav.left { left: 10px; } .viewer-nav.right { right: 10px; }
.viewer-count { text-align: center; padding: 8px; font-size: 13px; color: #c4a894; }
@media (max-width: 700px) { .viewer-stage { padding: 6px 8px; } .viewer-nav { top: auto; bottom: 8px; transform: none; } }
button.busy { opacity: .7; cursor: progress; }
