:root{
  --olive:#5A6350; --olive-d:#454c3d; --olive-l:#e9ebe3; --gold:#BC9459; --gold-l:#f3eadb;
  --ivory:#F7F4EE; --paper:#fffdf9; --ink:#2F332B; --muted:#7c7a70; --line:#e6e0d4;
  --red:#b4543f; --red-l:#f6e3de; --green:#5c7f4f; --green-l:#e5efdf; --blue:#4f6f8f; --blue-l:#e2eaf2;
  --radius:14px; --shadow:0 1px 2px rgba(47,51,43,.06),0 4px 16px rgba(47,51,43,.06);
  --sidebar:248px; --topbar:60px; --bottom:64px;
  --font:'Tajawal',system-ui,-apple-system,'Segoe UI',sans-serif;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{font-family:var(--font);background:var(--ivory);color:var(--ink);font-size:15px;line-height:1.55;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent}
a{color:inherit;text-decoration:none}
button,input,select,textarea{font:inherit;color:inherit}
img,video{max-width:100%}
.ic{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;flex:none;vertical-align:middle}
.hidden{display:none!important}

/* ---------- layout ---------- */
.app{display:grid;grid-template-columns:var(--sidebar) 1fr;min-height:100dvh}
.sidebar{background:var(--paper);border-inline-end:1px solid var(--line);position:sticky;top:0;height:100dvh;display:flex;flex-direction:column;padding:18px 14px}
.brand{display:flex;align-items:center;gap:10px;padding:4px 8px 18px}
.brand img{height:42px}
.brand small{display:block;color:var(--muted);font-size:12px;letter-spacing:.04em}
.nav{display:flex;flex-direction:column;gap:2px}
.nav a{display:flex;align-items:center;gap:12px;padding:10px 12px;border-radius:10px;color:#4c5046;font-weight:500;position:relative}
.nav a svg{width:20px;height:20px;flex:none;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.nav a:hover{background:var(--ivory)}
.nav a.active{background:var(--olive);color:#fff}
.nav .badge{margin-inline-start:auto}
.side-foot{margin-top:auto;padding:12px 8px 0;border-top:1px solid var(--line);display:flex;align-items:center;gap:10px}
.main{min-width:0;display:flex;flex-direction:column}
.topbar{height:var(--topbar);display:flex;align-items:center;gap:12px;padding:0 24px;background:rgba(247,244,238,.92);backdrop-filter:blur(8px);position:sticky;top:0;z-index:20;border-bottom:1px solid var(--line)}
.topbar h1{font-size:19px;margin:0;font-weight:700;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.topbar .mlogo{display:none;height:30px}
.content{padding:24px;max-width:1280px;width:100%;margin:0 auto;flex:1}
.bottomnav{display:none}

/* ---------- components ---------- */
.badge{min-width:20px;height:20px;padding:0 6px;border-radius:10px;background:var(--red);color:#fff;font-size:11px;font-weight:700;display:inline-flex;align-items:center;justify-content:center}
.icon-btn{width:40px;height:40px;border-radius:12px;border:1px solid var(--line);background:var(--paper);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;position:relative}
.icon-btn svg{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.icon-btn .badge{position:absolute;top:-6px;inset-inline-end:-6px}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;height:40px;padding:0 16px;border-radius:11px;border:1px solid transparent;background:var(--olive);color:#fff;font-weight:600;cursor:pointer;white-space:nowrap}
.btn:hover{background:var(--olive-d)}
.btn.gold{background:var(--gold)}
.btn.ghost{background:var(--paper);color:var(--ink);border-color:var(--line)}
.btn.ghost:hover{background:var(--ivory)}
.btn.danger{background:var(--red)}
.btn.sm{height:32px;padding:0 12px;font-size:13px;border-radius:9px}
.btn:disabled{opacity:.55;cursor:not-allowed}
.btn svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.card{background:var(--paper);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow)}
.card.pad{padding:18px}
.section-title{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 0 12px}
.section-title h2{font-size:16px;margin:0}
.muted{color:var(--muted)}
.small{font-size:13px}
.row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.spacer{flex:1}
.grid{display:grid;gap:16px}
.g2{grid-template-columns:repeat(2,minmax(0,1fr))}
.g3{grid-template-columns:repeat(3,minmax(0,1fr))}
.g4{grid-template-columns:repeat(4,minmax(0,1fr))}
.avatar{width:34px;height:34px;border-radius:50%;background:var(--gold-l);color:#8a6a3b;display:inline-flex;align-items:center;justify-content:center;font-weight:700;font-size:14px;flex:none}
.avatar.sm{width:26px;height:26px;font-size:11px}
.pill{display:inline-flex;align-items:center;gap:6px;height:24px;padding:0 10px;border-radius:12px;font-size:12px;font-weight:600;background:var(--olive-l);color:var(--olive-d);white-space:nowrap}
.pill.dot::before{content:"";width:7px;height:7px;border-radius:50%;background:currentColor}
.st-idea{background:#eeeae2;color:#6d675b}
.st-confirmed{background:var(--blue-l);color:var(--blue)}
.st-content{background:#efe6f3;color:#7a5a8a}
.st-shoot{background:var(--gold-l);color:#93703c}
.st-shot{background:#e3eef0;color:#3f7480}
.st-approved{background:var(--green-l);color:var(--green)}
.st-published{background:var(--olive);color:#fff}
.m-pending{background:var(--gold-l);color:#93703c}
.m-approved{background:var(--green-l);color:var(--green)}
.m-changes{background:var(--blue-l);color:var(--blue)}
.m-rejected{background:var(--red-l);color:var(--red)}
.empty{padding:36px 16px;text-align:center;color:var(--muted)}
.empty svg{width:42px;height:42px;stroke:var(--gold);fill:none;stroke-width:1.5;margin-bottom:6px}

/* forms */
.field{display:flex;flex-direction:column;gap:6px;margin-bottom:14px}
.field label{font-size:13px;font-weight:600;color:#55594d}
.input,.select,.textarea{width:100%;border:1px solid var(--line);background:#fff;border-radius:10px;padding:10px 12px;outline:none;transition:border-color .15s,box-shadow .15s}
.input:focus,.select:focus,.textarea:focus{border-color:var(--gold);box-shadow:0 0 0 3px rgba(188,148,89,.18)}
.textarea{min-height:110px;resize:vertical;line-height:1.7}
.search{position:relative;flex:1;min-width:180px;max-width:360px}
.search input{padding-inline-start:38px}
.search svg{position:absolute;inset-inline-start:12px;top:50%;transform:translateY(-50%);width:18px;height:18px;stroke:var(--muted);fill:none;stroke-width:2}
.seg{display:inline-flex;background:var(--paper);border:1px solid var(--line);border-radius:11px;padding:3px}
.seg button{border:0;background:transparent;height:32px;padding:0 12px;border-radius:8px;cursor:pointer;font-weight:600;color:var(--muted);font-size:13px}
.seg button.on{background:var(--olive);color:#fff}

/* stats */
.stat{padding:16px;display:flex;flex-direction:column;gap:4px}
.stat b{font-size:28px;line-height:1;font-weight:800}
.stat span{color:var(--muted);font-size:13px}
.pipeline{display:flex;gap:6px;overflow-x:auto;padding-bottom:4px}
.pipeline a{flex:1;min-width:96px;padding:12px;border-radius:12px;text-align:center}
.pipeline a b{display:block;font-size:22px}
.pipeline a span{font-size:12px;font-weight:600}

/* list items */
.list{display:flex;flex-direction:column}
.item{display:flex;align-items:center;gap:12px;padding:12px 16px;border-bottom:1px solid var(--line)}
.item:last-child{border-bottom:0}
.item:hover{background:#fcfaf5}
.item .t{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.item .grow{flex:1;min-width:0}
.meta{display:flex;gap:10px;flex-wrap:wrap;color:var(--muted);font-size:12px;align-items:center}
.meta svg{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:2;vertical-align:-2px}

/* board */
.board{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(250px,1fr);gap:12px;overflow-x:auto;padding-bottom:10px;align-items:start}
.col{background:#efebe2;border-radius:var(--radius);padding:10px;min-height:120px}
.col h3{font-size:13px;margin:2px 4px 10px;display:flex;align-items:center;gap:8px}
.col h3 .n{color:var(--muted);font-weight:500}
.rcard{background:var(--paper);border:1px solid var(--line);border-radius:12px;padding:12px;margin-bottom:8px;display:block;box-shadow:0 1px 2px rgba(0,0,0,.03);transition:transform .1s,box-shadow .1s}
.rcard:hover{transform:translateY(-1px);box-shadow:var(--shadow)}
.rcard .t{font-weight:700;margin-bottom:6px}
.rcard .cat{font-size:12px;color:var(--gold);font-weight:600}

/* calendar */
.cal{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:1px;background:var(--line);border:1px solid var(--line);border-radius:var(--radius);overflow:hidden}
.cal .h{background:var(--olive-l);padding:8px;font-size:12px;font-weight:700;text-align:center}
.cal .d{background:var(--paper);min-height:104px;padding:6px;font-size:12px;overflow:hidden}
.cal .d.out{background:#f8f6f1;color:#b9b4a8}
.cal .d.today .num{background:var(--gold);color:#fff;border-radius:50%;width:22px;height:22px;display:inline-flex;align-items:center;justify-content:center}
.cal .ev{display:block;margin-top:4px;padding:3px 6px;border-radius:6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:600;font-size:11px}
.cal .ev.shoot{background:var(--gold-l);color:#7d5f33}
.cal .ev.pub{background:var(--green-l);color:var(--green)}

/* recipe detail */
.detail-head{display:flex;gap:14px;align-items:flex-start;flex-wrap:wrap;margin-bottom:16px}
.detail-head h2{margin:0 0 6px;font-size:24px}
.stepper{display:flex;gap:4px;overflow-x:auto;margin:6px 0 18px;padding-bottom:4px}
.stepper button{flex:1;min-width:92px;border:1px solid var(--line);background:var(--paper);border-radius:10px;padding:8px 6px;font-size:12px;font-weight:600;color:var(--muted);cursor:pointer}
.stepper button.done{background:var(--olive-l);color:var(--olive-d);border-color:transparent}
.stepper button.cur{background:var(--olive);color:#fff;border-color:var(--olive)}
.stepper button:disabled{cursor:default}
.tabs{display:flex;gap:4px;border-bottom:1px solid var(--line);margin-bottom:16px;overflow-x:auto}
.tabs button{border:0;background:transparent;padding:10px 14px;font-weight:600;color:var(--muted);cursor:pointer;border-bottom:2px solid transparent;white-space:nowrap}
.tabs button.on{color:var(--olive-d);border-color:var(--gold)}
.kv{display:grid;grid-template-columns:140px 1fr;gap:10px 16px;font-size:14px}
.kv dt{color:var(--muted)}
.kv dd{margin:0;white-space:pre-wrap}
.prose{white-space:pre-wrap;line-height:1.85}

/* media */
.mgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:14px}
.mcard{overflow:hidden;display:flex;flex-direction:column}
.thumb{aspect-ratio:4/3;background:#2f332b;display:flex;align-items:center;justify-content:center;position:relative;cursor:pointer;overflow:hidden}
.thumb img,.thumb video{width:100%;height:100%;object-fit:cover}
.thumb .play{position:absolute;width:46px;height:46px;border-radius:50%;background:rgba(255,255,255,.9);display:flex;align-items:center;justify-content:center}
.thumb .play svg{width:20px;height:20px;fill:var(--olive);margin-inline-start:-3px}
.thumb .file{color:#cfc9bb;font-size:13px;text-align:center;padding:10px}
.mcard .body{padding:10px 12px;display:flex;flex-direction:column;gap:6px;flex:1}
.mcard .fname{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.dropzone{display:block;border:2px dashed #d6ccb8;border-radius:var(--radius);padding:26px;text-align:center;background:#fffcf6;cursor:pointer;transition:background .15s,border-color .15s}
.dropzone.over{background:var(--gold-l);border-color:var(--gold)}
.dropzone svg{width:36px;height:36px;display:block;margin:0 auto 6px;stroke:var(--gold);fill:none;stroke-width:1.6}
.uploads{display:flex;flex-direction:column;gap:8px;margin-top:12px}
.up{display:flex;align-items:center;gap:10px;font-size:13px}
.bar{flex:1;height:8px;background:#ece6da;border-radius:4px;overflow:hidden}
.bar i{display:block;height:100%;background:var(--gold);width:0;transition:width .2s}

/* chat */
.chat{display:grid;grid-template-columns:280px 1fr;height:calc(100dvh - var(--topbar) - 48px);min-height:420px;overflow:hidden}
.chlist{border-inline-end:1px solid var(--line);overflow-y:auto;background:var(--paper)}
.chlist a{display:flex;gap:10px;align-items:center;padding:12px 14px;border-bottom:1px solid var(--line)}
.chlist a.on{background:var(--olive-l)}
.chlist .chav{width:40px;height:40px;border-radius:12px;background:var(--olive);color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700;flex:none}
.chpane{display:flex;flex-direction:column;min-width:0;background:#f3efe6 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='%23bc9459' fill-opacity='.06'%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Ccircle cx='50' cy='40' r='2'/%3E%3Ccircle cx='25' cy='65' r='1.5'/%3E%3C/g%3E%3C/svg%3E")}
.chhead{display:flex;align-items:center;gap:10px;padding:10px 14px;background:var(--paper);border-bottom:1px solid var(--line)}
.msgs{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:6px}
.msg{max-width:min(76%,560px);padding:8px 12px 6px;border-radius:14px;background:#fff;box-shadow:0 1px 1px rgba(0,0,0,.05);align-self:flex-start;word-wrap:break-word;white-space:pre-wrap}
.msg.me{align-self:flex-end;background:#e4ead9}
.msg .who{font-size:12px;font-weight:700;color:var(--gold);margin-bottom:2px}
.msg .time{font-size:10.5px;color:var(--muted);text-align:end;margin-top:2px}
.msg img,.msg video{border-radius:10px;margin-top:4px;max-height:260px}
.daysep{align-self:center;background:rgba(255,255,255,.85);font-size:12px;color:var(--muted);padding:3px 10px;border-radius:8px;margin:6px 0}
.composer{display:flex;gap:8px;padding:10px;background:var(--paper);border-top:1px solid var(--line);align-items:flex-end}
.composer textarea{flex:1;min-height:42px;max-height:140px;resize:none;border-radius:21px;padding:10px 16px}
.composer .icon-btn{border-radius:50%;flex:none}
.composer .send{background:var(--olive);color:#fff;border-color:var(--olive)}

/* notifications */
.notif{display:flex;gap:12px;padding:12px 16px;border-bottom:1px solid var(--line);cursor:pointer}
.notif.unread{background:#fdf8ee}
.notif.unread .dot{width:8px;height:8px;border-radius:50%;background:var(--gold);margin-top:8px;flex:none}

/* modal & toast */
.modal-bg{position:fixed;inset:0;background:rgba(47,51,43,.45);z-index:50;display:flex;align-items:center;justify-content:center;padding:16px;animation:fade .15s}
.modal{background:var(--paper);border-radius:18px;width:min(640px,100%);max-height:90dvh;overflow:auto;box-shadow:0 20px 50px rgba(0,0,0,.2)}
.modal.wide{width:min(980px,100%)}
.modal-h{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--line);position:sticky;top:0;background:var(--paper);z-index:1}
.modal-h h3{margin:0;font-size:17px}
.modal-b{padding:18px 20px}
.modal-f{display:flex;gap:8px;justify-content:flex-end;padding:14px 20px;border-top:1px solid var(--line);position:sticky;bottom:0;background:var(--paper)}
.viewer{background:#111;border-radius:12px;overflow:hidden;display:flex;align-items:center;justify-content:center;max-height:62dvh}
.viewer img,.viewer video{max-height:62dvh;width:auto;max-width:100%}
.toast{position:fixed;bottom:24px;inset-inline-start:50%;transform:translateX(50%);background:var(--ink);color:#fff;padding:10px 18px;border-radius:12px;z-index:60;box-shadow:var(--shadow);font-weight:500;animation:fade .2s;max-width:90vw}
[dir=ltr] .toast{transform:translateX(-50%)}
@keyframes fade{from{opacity:0}to{opacity:1}}
.loader{width:28px;height:28px;border:3px solid var(--line);border-top-color:var(--gold);border-radius:50%;animation:spin .8s linear infinite;margin:40px auto}
@keyframes spin{to{transform:rotate(360deg)}}
.fullscreen-msg{min-height:100dvh;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:24px;gap:10px}
.fullscreen-msg img{height:90px;margin-bottom:10px}

/* ---------- responsive ---------- */
@media (max-width:1100px){
  .g4{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (max-width:860px){
  .app{grid-template-columns:1fr}
  .sidebar{display:none}
  .topbar{padding:0 14px;padding-top:env(safe-area-inset-top);height:calc(var(--topbar) + env(safe-area-inset-top))}
  .topbar .mlogo{display:block}
  .content{padding:14px 14px calc(var(--bottom) + 24px + env(safe-area-inset-bottom))}
  .bottomnav{display:grid;grid-template-columns:repeat(5,1fr);position:fixed;bottom:0;left:0;right:0;height:calc(var(--bottom) + env(safe-area-inset-bottom));padding-bottom:env(safe-area-inset-bottom);background:var(--paper);border-top:1px solid var(--line);z-index:30}
  .bottomnav a{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;font-size:11px;color:var(--muted);font-weight:600;position:relative}
  .bottomnav a svg{width:22px;height:22px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
  .bottomnav a.active{color:var(--olive)}
  .bottomnav .badge{position:absolute;top:6px;inset-inline-start:calc(50% + 4px);height:17px;min-width:17px;font-size:10px}
  .g2,.g3{grid-template-columns:1fr}
  .kv{grid-template-columns:1fr;gap:2px}
  .kv dd{margin-bottom:10px}
  .chat{grid-template-columns:1fr;height:calc(100dvh - var(--topbar) - var(--bottom) - env(safe-area-inset-top) - env(safe-area-inset-bottom));margin:-14px;border-radius:0;border:0}
  .chat.has-ch .chlist{display:none}
  .chat:not(.has-ch) .chpane{display:none}
  .msg{max-width:86%}
  .detail-head h2{font-size:20px}
  .modal-bg{align-items:flex-end;padding:0}
  .modal{border-radius:18px 18px 0 0;max-height:94dvh}
  .board{grid-auto-columns:82%}
  .cal .d{min-height:64px;padding:3px}
  .cal .ev{font-size:10px;padding:2px 4px}
  .hide-m{display:none!important}
  .toast{bottom:calc(var(--bottom) + 16px)}
}
@media (max-width:420px){
  .g4{grid-template-columns:repeat(2,minmax(0,1fr))}
  .stat b{font-size:24px}
  .mgrid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
}
@media (min-width:861px){ .hide-d{display:none!important} }
